From d7b2b94cec5b0f9d5bfff3e6da7f52c24262a383 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 31 Dec 2024 17:04:32 +0100 Subject: [PATCH] impr: Reduce jittering when changing the number of hex columns --- plugins/ui/source/ui/hex_editor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index ede6b7ade..847fca567 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -504,8 +504,8 @@ namespace hex::ui { } const auto bytesPerCell = m_currDataVisualizer->getBytesPerCell(); - const u16 columnCount = m_bytesPerRow / bytesPerCell; - auto byteColumnCount = 2 + columnCount + getByteColumnSeparatorCount(columnCount) + 2 + 2; + const auto columnCount = m_bytesPerRow / bytesPerCell; + auto byteColumnCount = 2 + columnCount + getByteColumnSeparatorCount(columnCount) + 2 + 2; if (byteColumnCount >= IMGUI_TABLE_MAX_COLUMNS) { m_bytesPerRow = 64; @@ -523,6 +523,8 @@ namespace hex::ui { m_mode = Mode::Overwrite; Region hoveredCell = Region::Invalid(); + ImGui::PushID(m_bytesPerRow); + ON_SCOPE_EXIT { ImGui::PopID(); }; if (ImGui::BeginChild("Hex View", size, ImGuiChildFlags_None, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) { this->drawScrollbar(CharacterSize); @@ -532,7 +534,7 @@ namespace hex::ui { ImGui::TableSetupScrollFreeze(0, 2); // Row address column - ImGui::TableSetupColumn("hex.ui.common.address"_lang); + ImGui::TableSetupColumn("hex.ui.common.address"_lang, ImGuiTableColumnFlags_WidthFixed, CharacterSize.x * fmt::formatted_size("{:08X}: ", (m_scrollPosition + m_visibleRowCount) * m_bytesPerRow + m_provider->getBaseAddress() + m_provider->getCurrentPageAddress())); ImGui::TableSetupColumn(""); // Byte columns