From d079b8c3bb03474a0859f19563be526866718249 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 28 Jul 2023 10:31:44 +0200 Subject: [PATCH] impr: Hide column headers when hiding ASCII or custom encoding column --- plugins/builtin/source/ui/hex_editor.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/builtin/source/ui/hex_editor.cpp b/plugins/builtin/source/ui/hex_editor.cpp index d62f1bfcc..047ee2315 100644 --- a/plugins/builtin/source/ui/hex_editor.cpp +++ b/plugins/builtin/source/ui/hex_editor.cpp @@ -128,7 +128,7 @@ namespace hex::plugin::builtin::ui { provider->read(address, buffer.data(), size); const auto [decoded, advance] = encodingFile.getEncodingFor(buffer); - const ImColor color = [&decoded = decoded, &advance = advance]{ + const ImColor color = [&]{ if (decoded.length() == 1 && std::isalnum(decoded[0])) return ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarBlue); else if (decoded.length() == 1 && advance == 1) @@ -295,15 +295,20 @@ namespace hex::plugin::builtin::ui { // ASCII column ImGui::TableSetupColumn(""); - ImGui::TableSetupColumn("hex.builtin.common.encoding.ascii"_lang, ImGuiTableColumnFlags_WidthFixed, this->m_showAscii ? (CharacterSize.x + this->m_characterCellPadding * 1_scaled) * this->m_bytesPerRow : 0); - // Custom encoding column + if (this->m_showAscii) { + ImGui::TableSetupColumn("hex.builtin.common.encoding.ascii"_lang, ImGuiTableColumnFlags_WidthFixed, (CharacterSize.x + this->m_characterCellPadding * 1_scaled) * this->m_bytesPerRow); + } + else + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 0); + ImGui::TableSetupColumn(""); + // Custom encoding column { - if (this->m_currCustomEncoding.has_value()) { + if (this->m_currCustomEncoding.has_value() && this->m_showCustomEncoding) { ImGui::TableSetupColumn(this->m_currCustomEncoding->getName().c_str(), ImGuiTableColumnFlags_WidthStretch); } else { - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 0); } }