From 0178ba014af8bc939b9e5bee43c71f2d0ed5e490 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 24 Aug 2025 16:29:36 +0200 Subject: [PATCH] fix: Region picker widget overflowing in many views --- plugins/ui/source/ui/widgets.cpp | 43 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/plugins/ui/source/ui/widgets.cpp b/plugins/ui/source/ui/widgets.cpp index cc01a77bf..17cd238ae 100644 --- a/plugins/ui/source/ui/widgets.cpp +++ b/plugins/ui/source/ui/widgets.cpp @@ -1,7 +1,9 @@ #include #include +#include #include +#include #include @@ -31,25 +33,36 @@ namespace hex::ui { ).getRegion(); break; case RegionType::Region: - ImGui::SameLine(); + ImGui::SameLine(0, 10_scaled); - const auto width = ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(" - ").x / 2; - u64 start = region->getStartAddress(), end = region->getEndAddress(); + if (ImGuiExt::DimmedIconButton(ICON_VS_TRIANGLE_RIGHT, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { + ImGui::OpenPopup("RegionSelectionPopup"); + } - if (end < start) - end = start; - - ImGui::PushItemWidth(width); - ImGuiExt::InputHexadecimal("##start", &start); - ImGui::PopItemWidth(); ImGui::SameLine(0, 0); - ImGui::TextUnformatted(" - "); - ImGui::SameLine(0, 0); - ImGui::PushItemWidth(width); - ImGuiExt::InputHexadecimal("##end", &end); - ImGui::PopItemWidth(); - *region = { start, (end - start) + 1 }; + ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos()); + if (ImGui::BeginPopup("RegionSelectionPopup")) { + const auto width = 150_scaled; + u64 start = region->getStartAddress(), end = region->getEndAddress(); + + if (end < start) + end = start; + + ImGui::PushItemWidth(width); + ImGuiExt::InputHexadecimal("##start", &start); + ImGui::PopItemWidth(); + ImGui::SameLine(0, 0); + ImGui::TextUnformatted(" - "); + ImGui::SameLine(0, 0); + ImGui::PushItemWidth(width); + ImGuiExt::InputHexadecimal("##end", &end); + ImGui::PopItemWidth(); + + *region = { start, (end - start) + 1 }; + + ImGui::EndPopup(); + } break; }