1
0
mirror of synced 2024-11-28 09:30:51 +01:00

patterns: Fixed color attribute not working correctly for arrays and structs

Fixes #388
This commit is contained in:
WerWolv 2021-12-31 11:01:22 +01:00
parent 077bc45b7d
commit 490eaef5c1
2 changed files with 37 additions and 2 deletions

View File

@ -115,7 +115,7 @@ namespace hex::pl {
void setTypeName(std::string name) { this->m_typeName = std::move(name); } void setTypeName(std::string name) { this->m_typeName = std::move(name); }
[[nodiscard]] u32 getColor() const { return this->m_color; } [[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; } [[nodiscard]] std::endian getEndian() const { return this->m_endian; }
void setEndian(std::endian endian) { this->m_endian = endian; } void setEndian(std::endian endian) { this->m_endian = endian; }
@ -429,6 +429,11 @@ namespace hex::pl {
return this->m_pointedAt; 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 { [[nodiscard]] bool operator==(const PatternData &other) const override {
return areCommonPropertiesEqual<decltype(*this)>(other) && return areCommonPropertiesEqual<decltype(*this)>(other) &&
*static_cast<const PatternDataPointer*>(&other)->m_pointedAt == *this->m_pointedAt; *static_cast<const PatternDataPointer*>(&other)->m_pointedAt == *this->m_pointedAt;
@ -756,6 +761,12 @@ namespace hex::pl {
PatternData::setOffset(offset); 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 { void createEntry(prv::Provider* &provider) override {
if (this->m_entries.empty()) if (this->m_entries.empty())
return; return;
@ -956,6 +967,11 @@ namespace hex::pl {
PatternData::clearHighlightedAddresses(); PatternData::clearHighlightedAddresses();
} }
void setColor(u32 color) override {
PatternData::setColor(color);
this->m_template->setColor(color);
}
[[nodiscard]] std::string getFormattedName() const override { [[nodiscard]] std::string getFormattedName() const override {
return this->m_template->getTypeName() + "[" + std::to_string(this->m_entryCount) + "]"; return this->m_template->getTypeName() + "[" + std::to_string(this->m_entryCount) + "]";
} }
@ -1079,6 +1095,12 @@ namespace hex::pl {
PatternData::clearHighlightedAddresses(); 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 { void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override {
this->m_sortedMembers = this->m_members; this->m_sortedMembers = this->m_members;
@ -1219,6 +1241,12 @@ namespace hex::pl {
PatternData::clearHighlightedAddresses(); 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 { void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override {
this->m_sortedMembers = this->m_members; 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 { [[nodiscard]] bool operator==(const PatternData &other) const override {
if (!areCommonPropertiesEqual<decltype(*this)>(other)) if (!areCommonPropertiesEqual<decltype(*this)>(other))
return false; return false;

View File

@ -522,6 +522,7 @@ namespace hex {
if (hasWindow) { if (hasWindow) {
ImGui::Begin(View::toWindowName(view->getUnlocalizedName()).c_str()); ImGui::Begin(View::toWindowName(view->getUnlocalizedName()).c_str());
focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows); focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows);
ImGui::End(); ImGui::End();
} }
@ -636,7 +637,7 @@ namespace hex {
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 6); ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 6);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::UnderlinedText("hex.welcome.header.help"_lang); ImGui:: UnderlinedText("hex.welcome.header.help"_lang);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5 * SharedData::globalScale); 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); if (ImGui::IconHyperlink(ICON_VS_GITHUB, "hex.welcome.help.repo"_lang)) hex::openWebpage("hex.welcome.help.repo.link"_lang);