From 360ae718b9d70e90fd5f3cd344ae34e15e2968b8 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 22 Mar 2024 17:44:36 +0100 Subject: [PATCH] fix: Advanced data information not showing up correctly --- .../content/data_information_sections.cpp | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/plugins/yara_rules/source/content/data_information_sections.cpp b/plugins/yara_rules/source/content/data_information_sections.cpp index 07731e65b..feffa3e87 100644 --- a/plugins/yara_rules/source/content/data_information_sections.cpp +++ b/plugins/yara_rules/source/content/data_information_sections.cpp @@ -59,28 +59,39 @@ namespace hex::plugin::yara { } void drawContent() override { - if (ImGui::BeginTable("information", 2, ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_NoKeepColumnsVisible)) { - ImGui::TableSetupColumn("Left", ImGuiTableColumnFlags_WidthStretch, 0.5F); - ImGui::TableSetupColumn("Right", ImGuiTableColumnFlags_WidthStretch, 0.5F); + const auto empty = !std::ranges::any_of(m_categories, [](const auto &entry) { + const auto &[categoryName, category] = entry; + return !category.matchedRules.empty(); + }); - ImGui::TableNextRow(); + if (!empty) { + if (ImGui::BeginTable("information", 2, ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_NoKeepColumnsVisible)) { + ImGui::TableSetupColumn("Left", ImGuiTableColumnFlags_WidthStretch, 0.5F); + ImGui::TableSetupColumn("Right", ImGuiTableColumnFlags_WidthStretch, 0.5F); - for (auto &[categoryName, category] : m_categories) { - if (category.matchedRules.empty()) - continue; + ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGuiExt::BeginSubWindow(categoryName.c_str()); - { - for (const auto &match : category.matchedRules) { - const auto &ruleName = match.metadata.contains("name") ? match.metadata.at("name") : match.identifier; - ImGui::TextUnformatted(ruleName.c_str()); + for (auto &[categoryName, category] : m_categories) { + if (category.matchedRules.empty()) + continue; + + ImGui::TableNextColumn(); + ImGuiExt::BeginSubWindow(categoryName.c_str()); + { + for (const auto &match : category.matchedRules) { + const auto &ruleName = match.metadata.contains("name") ? match.metadata.at("name") : match.identifier; + ImGui::TextUnformatted(ruleName.c_str()); + } } + ImGuiExt::EndSubWindow(); } - ImGuiExt::EndSubWindow(); - } - ImGui::EndTable(); + ImGui::EndTable(); + } + } else { + ImGui::NewLine(); + ImGuiExt::TextFormattedCenteredHorizontal("{}", "hex.yara.information_section.advanced_data_info.no_information"_lang); + ImGui::NewLine(); } }