From 490eaef5c1cc9bb99e10013534ebc66f49380abc Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 31 Dec 2021 11:01:22 +0100 Subject: [PATCH] patterns: Fixed color attribute not working correctly for arrays and structs Fixes #388 --- .../hex/pattern_language/pattern_data.hpp | 36 ++++++++++++++++++- source/window/window.cpp | 3 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp index 3539b3553..dddd02cb1 100644 --- a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -115,7 +115,7 @@ namespace hex::pl { void setTypeName(std::string name) { this->m_typeName = std::move(name); } [[nodiscard]] u32 getColor() const { return this->m_color; } - void setColor(u32 color) { this->m_color = color; } + virtual void setColor(u32 color) { this->m_color = color; } [[nodiscard]] std::endian getEndian() const { return this->m_endian; } void setEndian(std::endian endian) { this->m_endian = endian; } @@ -429,6 +429,11 @@ namespace hex::pl { return this->m_pointedAt; } + void setColor(u32 color) override { + PatternData::setColor(color); + this->m_pointedAt->setColor(color); + } + [[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual(other) && *static_cast(&other)->m_pointedAt == *this->m_pointedAt; @@ -756,6 +761,12 @@ namespace hex::pl { PatternData::setOffset(offset); } + void setColor(u32 color) override { + PatternData::setColor(color); + for (auto &entry : this->m_entries) + entry->setColor(color); + } + void createEntry(prv::Provider* &provider) override { if (this->m_entries.empty()) return; @@ -956,6 +967,11 @@ namespace hex::pl { PatternData::clearHighlightedAddresses(); } + void setColor(u32 color) override { + PatternData::setColor(color); + this->m_template->setColor(color); + } + [[nodiscard]] std::string getFormattedName() const override { return this->m_template->getTypeName() + "[" + std::to_string(this->m_entryCount) + "]"; } @@ -1079,6 +1095,12 @@ namespace hex::pl { PatternData::clearHighlightedAddresses(); } + void setColor(u32 color) override { + PatternData::setColor(color); + for (auto &member : this->m_members) + member->setColor(color); + } + void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override { this->m_sortedMembers = this->m_members; @@ -1219,6 +1241,12 @@ namespace hex::pl { PatternData::clearHighlightedAddresses(); } + void setColor(u32 color) override { + PatternData::setColor(color); + for (auto &member : this->m_members) + member->setColor(color); + } + void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override { this->m_sortedMembers = this->m_members; @@ -1514,6 +1542,12 @@ namespace hex::pl { } } + void setColor(u32 color) override { + PatternData::setColor(color); + for (auto &field : this->m_fields) + field->setColor(color); + } + [[nodiscard]] bool operator==(const PatternData &other) const override { if (!areCommonPropertiesEqual(other)) return false; diff --git a/source/window/window.cpp b/source/window/window.cpp index 9c8393c07..6cfaddd57 100644 --- a/source/window/window.cpp +++ b/source/window/window.cpp @@ -522,6 +522,7 @@ namespace hex { if (hasWindow) { ImGui::Begin(View::toWindowName(view->getUnlocalizedName()).c_str()); + focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows); ImGui::End(); } @@ -636,7 +637,7 @@ namespace hex { ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 6); ImGui::TableNextColumn(); - ImGui::UnderlinedText("hex.welcome.header.help"_lang); + ImGui:: UnderlinedText("hex.welcome.header.help"_lang); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5 * SharedData::globalScale); { if (ImGui::IconHyperlink(ICON_VS_GITHUB, "hex.welcome.help.repo"_lang)) hex::openWebpage("hex.welcome.help.repo.link"_lang);