From 754eb89f04cf7223d85bae2e69db6bfbc4fde606 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 20 Feb 2022 23:54:31 +0100 Subject: [PATCH] patterns: Fixed jumping to and displaying tooltips of static array entries --- .../include/hex/pattern_language/pattern_data.hpp | 13 +++++++++++-- .../source/content/views/view_pattern_editor.cpp | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/libimhex/include/hex/pattern_language/pattern_data.hpp b/lib/libimhex/include/hex/pattern_language/pattern_data.hpp index c03df1fe5..470c459ca 100644 --- a/lib/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/lib/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -267,9 +267,15 @@ namespace hex::pl { ImGui::TableNextRow(); ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap); ImGui::TableNextColumn(); - if (ImGui::Selectable(("##PatternDataLine"s + std::to_string(u64(this))).c_str(), false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) { + + ImGui::PushID(this->getOffset()); + ImGui::PushID(this->getVariableName().c_str()); + if (ImGui::Selectable("##PatternDataLine", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) { ImHexApi::HexEditor::setSelection(this->getOffset(), this->getSize()); } + ImGui::PopID(); + ImGui::PopID(); + this->drawCommentTooltip(); ImGui::SameLine(); ImGui::TextUnformatted(this->getDisplayName().c_str()); @@ -1019,7 +1025,6 @@ namespace hex::pl { void setColor(u32 color) override { PatternData::setColor(color); this->m_template->setColor(color); - this->m_highlightTemplate->setColor(color); } [[nodiscard]] std::string getFormattedName() const override { @@ -1058,6 +1063,10 @@ namespace hex::pl { [[nodiscard]] const PatternData *getPattern(u64 offset) const override { if (this->isHidden()) return nullptr; + this->m_highlightTemplate->setColor(this->getColor()); + this->m_highlightTemplate->setVariableName(this->getVariableName()); + this->m_highlightTemplate->setDisplayName(this->getDisplayName()); + if (offset >= this->getOffset() && offset < (this->getOffset() + this->getSize())) { this->m_highlightTemplate->setOffset((offset / this->m_highlightTemplate->getSize()) * this->m_highlightTemplate->getSize()); return this->m_highlightTemplate->getPattern(offset); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 02cbb3c53..bf5dfc36d 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -229,7 +229,7 @@ namespace hex::plugin::builtin { for (const auto &pattern : patterns) { auto child = pattern->getPattern(address); if (child != nullptr) { - return ImHexApi::HexEditor::Highlighting(Region { address, 1 }, child->getColor(), child->getVariableName()); + return ImHexApi::HexEditor::Highlighting(Region { address, 1 }, child->getColor(), child->getDisplayName()); } } @@ -672,7 +672,7 @@ namespace hex::plugin::builtin { } if (result) { - EventManager::post(); + ImHexApi::HexEditor::invalidateHighlight(); } this->m_runningEvaluators--;