diff --git a/plugins/builtin/romfs/themes/dark.json b/plugins/builtin/romfs/themes/dark.json index bb1cfd0de..637670fa2 100644 --- a/plugins/builtin/romfs/themes/dark.json +++ b/plugins/builtin/romfs/themes/dark.json @@ -90,7 +90,7 @@ "advanced-encoding-multi": "#F1C40FFF", "advanced-encoding-unknown": "#E74C3CFF", "patches": "#E74C3CFF", - "pattern-selected": "#06539BFF" + "pattern-selected": "#3683CBFF" }, "imnodes": { "box-selector": "#3D85E01E", diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index d57d38bfe..252f7cc89 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -44,7 +44,7 @@ namespace hex::ui { using namespace ::std::literals::string_literals; - bool isPatternSelected(u64 address, u64 size) { + bool isPatternOverlapSelected(u64 address, u64 size) { auto currSelection = ImHexApi::HexEditor::getSelection(); if (!currSelection.has_value()) return false; @@ -52,26 +52,38 @@ namespace hex::ui { return Region{ address, size }.overlaps(*currSelection); } + bool isPatternFullySelected(u64 address, u64 size) { + auto currSelection = ImHexApi::HexEditor::getSelection(); + if (!currSelection.has_value()) + return false; + + return currSelection->address == address && currSelection->size == size; + } + template auto highlightWhenSelected(u64 address, u64 size, const T &callback) { constexpr static bool HasReturn = !requires(T t) { { t() } -> std::same_as; }; - auto selected = isPatternSelected(address, size); + const auto overlapSelected = isPatternOverlapSelected(address, size); + const auto fullySelected = isPatternFullySelected(address, size); - if (selected) - ImGui::PushStyleColor(ImGuiCol_Text, ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_PatternSelected)); + const u32 selectionColor = ImColor(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_PatternSelected)); + if (overlapSelected) + ImGui::PushStyleColor(ImGuiCol_Text, selectionColor); + if (fullySelected) + ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, (selectionColor & 0x00'FF'FF'FF) | 0x30'00'00'00); if constexpr (HasReturn) { auto result = callback(); - if (selected) + if (overlapSelected) ImGui::PopStyleColor(); return result; } else { callback(); - if (selected) + if (overlapSelected) ImGui::PopStyleColor(); } }