From 1eadb7772260d5a815feb0ab3345d4824e5e1577 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 26 Jun 2024 19:11:59 +0200 Subject: [PATCH] fix: Item tooltips being sized incorrectly --- .../source/ui/imgui_imhex_extensions.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 3d4598561..eed2180af 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -575,16 +575,23 @@ namespace ImGuiExt { if (!std::string_view(text).empty()) { const auto textWidth = CalcTextSize(text).x; - auto width = 150 * hex::ImHexApi::System::getGlobalScale(); - if (textWidth < width) - width = textWidth; + const auto maxWidth = 300 * hex::ImHexApi::System::getGlobalScale(); + const bool wrapping = textWidth > maxWidth; + + if (wrapping) + ImGui::SetNextWindowSizeConstraints(ImVec2(maxWidth, 0), ImVec2(maxWidth, FLT_MAX)); + else + ImGui::SetNextWindowSize(ImVec2(textWidth + GetStyle().WindowPadding.x * 2, 0)); - ImGui::SetNextWindowSizeConstraints(ImVec2(width, 0), ImVec2(width * 2, FLT_MAX)); if (BeginTooltip()) { if (isSeparator) SeparatorText(text); - else - TextFormattedWrapped("{}", text); + else { + if (wrapping) + TextFormattedWrapped("{}", text); + else + TextFormatted("{}", text); + } EndTooltip(); }