From 382599dcf660cb68c63b80733e850c888fc3555e Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 23 Dec 2024 23:16:35 +0100 Subject: [PATCH] fix: Better icon text input width calculation --- lib/libimhex/source/ui/imgui_imhex_extensions.cpp | 4 +++- plugins/ui/source/ui/pattern_drawer.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 82d1557c6..b9f805c3b 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -981,7 +981,9 @@ namespace ImGuiExt { SetCursorPosX(GetCursorPosX() + frame_size.x); - bool value_changed = InputTextEx(label, nullptr, buffer.data(), buffer.size() + 1, ImVec2(CalcItemWidth() - icon_frame_size.x, label_size.y + style.FramePadding.y * 2.0F), ImGuiInputTextFlags_CallbackResize | flags, UpdateStringSizeCallback, &buffer); + float width_adjustment = window->DC.ItemWidth < 0 ? 0 : icon_frame_size.x; + + bool value_changed = InputTextEx(label, hint, buffer.data(), buffer.size() + 1, ImVec2(CalcItemWidth() - width_adjustment, label_size.y + style.FramePadding.y * 2.0F), ImGuiInputTextFlags_CallbackResize | flags, UpdateStringSizeCallback, &buffer); if (value_changed) MarkItemEdited(GImGui->LastItemData.ID); diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index 00c44e86a..cb8cef940 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -1242,7 +1242,7 @@ namespace hex::ui { this->resetEditing(); } - ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::GetTextLineHeightWithSpacing() * 9.4F)); + ImGui::PushItemWidth(-(ImGui::GetTextLineHeightWithSpacing() * 8)); if (ImGuiExt::InputTextIcon("##Search", ICON_VS_FILTER, m_filterText)) { m_filter = parseRValueFilter(m_filterText).value_or(Filter{ }); updateFilter();