From e78c452dafe1416d688d813aeeb900a754f0d572 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 10 Oct 2022 20:33:34 +0200 Subject: [PATCH] fix: Hex editor selection not showing rendering properly --- .../source/content/views/view_hex_editor.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 9a9bee453..ed4c8e93a 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -523,9 +523,6 @@ namespace hex::plugin::builtin { } std::optional ViewHexEditor::applySelectionColor(u64 byteAddress, std::optional color) { - if (!color.has_value()) - return std::nullopt; - if (this->isSelectionValid()) { auto selection = this->getSelection(); @@ -873,12 +870,14 @@ namespace hex::plugin::builtin { if (y == u64(clipper.DisplayStart)) cellSize.y -= (ImGui::GetStyle().CellPadding.y + 1); + backgroundColor = applySelectionColor(byteAddress, backgroundColor); + // Draw highlights and selection if (backgroundColor.has_value()) { auto drawList = ImGui::GetWindowDrawList(); // Draw background color - drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, applySelectionColor(byteAddress, backgroundColor).value()); + drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, backgroundColor.value()); // Draw frame around mouse selection this->drawSelectionFrame(x, y, byteAddress, bytesPerCell, cellStartPos, cellSize); @@ -935,12 +934,14 @@ namespace hex::plugin::builtin { auto [foregroundColor, backgroundColor] = cellColors[x / bytesPerCell]; + backgroundColor = applySelectionColor(byteAddress, backgroundColor); + // Draw highlights and selection if (backgroundColor.has_value()) { auto drawList = ImGui::GetWindowDrawList(); // Draw background color - drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, applySelectionColor(byteAddress, backgroundColor).value()); + drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, backgroundColor.value()); this->drawSelectionFrame(x, y, byteAddress, 1, cellStartPos, cellSize); } @@ -993,12 +994,14 @@ namespace hex::plugin::builtin { if (x < validBytes && isCurrRegionValid(address)) { auto [foregroundColor, backgroundColor] = cellColors[x / bytesPerCell]; + backgroundColor = applySelectionColor(address, backgroundColor); + // Draw highlights and selection if (backgroundColor.has_value()) { auto drawList = ImGui::GetWindowDrawList(); // Draw background color - drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, applySelectionColor(address, backgroundColor).value()); + drawList->AddRectFilled(cellStartPos, cellStartPos + cellSize, backgroundColor.value()); this->drawSelectionFrame(x, y, address, 1, cellStartPos, cellSize); }