From 34b8f481e12f2a0e9fa981a5fd6e694d4e0fe0d0 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 20 Nov 2020 11:56:37 +0100 Subject: [PATCH] Improved table rendering --- include/lang/pattern_data.hpp | 3 ++- source/views/view_strings.cpp | 37 ++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/lang/pattern_data.hpp b/include/lang/pattern_data.hpp index 81e60a826..2f43a9ad1 100644 --- a/include/lang/pattern_data.hpp +++ b/include/lang/pattern_data.hpp @@ -117,8 +117,9 @@ namespace hex::lang { protected: void createDefaultEntry(std::string value) { + static u64 id = 0; ImGui::TableNextRow(); - ImGui::TreeNodeEx(this->getName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth); + ImGui::TreeNodeEx(this->getName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth); ImGui::TableNextColumn(); ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip); ImGui::TableNextColumn(); diff --git a/source/views/view_strings.cpp b/source/views/view_strings.cpp index 65d0dffc7..b51a38d2a 100644 --- a/source/views/view_strings.cpp +++ b/source/views/view_strings.cpp @@ -106,30 +106,31 @@ namespace hex { } ImGui::TableHeadersRow(); - u32 rowCount = 0; ImGuiListClipper clipper; - clipper.Begin(this->m_foundStrings.size(), 14); - clipper.Step(); + clipper.Begin(this->m_foundStrings.size()); - for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { - auto &foundString = this->m_foundStrings[i]; + while (clipper.Step()) { + u32 rowCount = clipper.DisplayStart; + for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { + auto &foundString = this->m_foundStrings[i]; - if (strlen(this->m_filter) != 0 && foundString.string.find(this->m_filter) == std::string::npos) - continue; + if (strlen(this->m_filter) != 0 && + foundString.string.find(this->m_filter) == std::string::npos) + continue; - ImGui::TableNextRow(ImGuiTableRowFlags_Headers); - ImGui::TableNextColumn(); - ImGui::Text("0x%08lx : 0x%08lx", foundString.offset, foundString.offset + foundString.size); - ImGui::TableNextColumn(); - ImGui::Text("0x%04lx", foundString.size); - ImGui::TableNextColumn(); - ImGui::Text("%s", foundString.string.c_str()); - ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, - ((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030); - rowCount++; + ImGui::TableNextRow(ImGuiTableRowFlags_Headers); + ImGui::TableNextColumn(); + ImGui::Text("0x%08lx : 0x%08lx", foundString.offset, foundString.offset + foundString.size); + ImGui::TableNextColumn(); + ImGui::Text("0x%04lx", foundString.size); + ImGui::TableNextColumn(); + ImGui::Text("%s", foundString.string.c_str()); + ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, + ((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030); + rowCount++; + } } - clipper.Step(); clipper.End(); ImGui::EndTable();