From 474862b4af5bcf3a14c2d10e4c1a2ee9715331ac Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 26 Jun 2024 19:13:15 +0200 Subject: [PATCH] impr: Replace hardcoded pattern syntax highlighting colors style colors --- .../content/views/view_pattern_editor.cpp | 2 +- plugins/ui/source/ui/pattern_drawer.cpp | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index cfda35038..4200fd133 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -1457,7 +1457,7 @@ namespace hex::plugin::builtin { { ImGui::ColorButton(pattern->getVariableName().c_str(), ImColor(pattern->getColor())); ImGui::SameLine(0, 10); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "{} ", pattern->getFormattedName()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{} ", pattern->getFormattedName()); ImGui::SameLine(0, 5); ImGuiExt::TextFormatted("{}", pattern->getDisplayName()); ImGui::SameLine(); diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index dc6da6621..ea1e8f1c3 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -95,7 +96,7 @@ namespace hex::ui { void drawTypeNameColumn(const pl::ptrn::Pattern& pattern, const std::string& structureTypeName) { ImGui::TableNextColumn(); - ImGuiExt::TextFormattedColored(ImColor(0xFFD69C56), structureTypeName); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Keyword)], structureTypeName); ImGui::SameLine(); ImGui::TextUnformatted(pattern.getTypeName().c_str()); } @@ -478,7 +479,7 @@ namespace hex::ui { // Draw type column ImGui::TableNextColumn(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "{}", pattern.getFormattedName().empty() ? pattern.getTypeName() : pattern.getFormattedName()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{}", pattern.getFormattedName().empty() ? pattern.getTypeName() : pattern.getFormattedName()); } void PatternDrawer::closeTreeNode(bool inlined) const { @@ -503,21 +504,21 @@ namespace hex::ui { ImGui::TableNextColumn(); if (dynamic_cast(&pattern) != nullptr) { - ImGuiExt::TextFormattedColored(ImColor(0xFFD69C56), "signed"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Keyword)], "signed"); ImGui::SameLine(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), pattern.getBitSize() == 1 ? "bit" : "bits"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], pattern.getBitSize() == 1 ? "bit" : "bits"); } else if (dynamic_cast(&pattern) != nullptr) { - ImGuiExt::TextFormattedColored(ImColor(0xFFD69C56), "enum"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Keyword)], "enum"); ImGui::SameLine(); ImGui::TextUnformatted(pattern.getTypeName().c_str()); } else if (dynamic_cast(&pattern) != nullptr) { - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "bool"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "bool"); ImGui::SameLine(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "bit"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "bit"); } else { - ImGuiExt::TextFormattedColored(ImColor(0xFFD69C56), "unsigned"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Keyword)], "unsigned"); ImGui::SameLine(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), pattern.getBitSize() == 1 ? "bit" : "bits"); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], pattern.getBitSize() == 1 ? "bit" : "bits"); } if (!this->isEditingPattern(pattern)) { @@ -749,7 +750,7 @@ namespace hex::ui { drawOffsetColumns(pattern); drawSizeColumn(pattern); ImGui::TableNextColumn(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "{}", pattern.getFormattedName()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{}", pattern.getFormattedName()); drawValueColumn(pattern); drawCommentColumn(pattern); } @@ -978,12 +979,12 @@ namespace hex::ui { drawSizeColumn(pattern); ImGui::TableNextColumn(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", pattern.getTypeName()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{0}", pattern.getTypeName()); ImGui::SameLine(0, 0); ImGui::TextUnformatted("["); ImGui::SameLine(0, 0); - ImGuiExt::TextFormattedColored(ImColor(0xFF00FF00), "{0}", iterable.getEntryCount()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Number)], "{0}", iterable.getEntryCount()); ImGui::SameLine(0, 0); ImGui::TextUnformatted("]"); @@ -1036,12 +1037,12 @@ namespace hex::ui { ImGui::TableNextColumn(); ImGuiExt::TextFormatted("0x{0:04X}", chunkSize); ImGui::TableNextColumn(); - ImGuiExt::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", pattern.getTypeName()); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{0}", pattern.getTypeName()); ImGui::SameLine(0, 0); ImGui::TextUnformatted("["); ImGui::SameLine(0, 0); - ImGuiExt::TextFormattedColored(ImColor(0xFF00FF00), "{0}", endIndex - i); + ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::Number)], "{0}", endIndex - i); ImGui::SameLine(0, 0); ImGui::TextUnformatted("]");