1
0
mirror of synced 2025-02-28 15:10:36 +01:00

fix: Item tooltips being sized incorrectly

This commit is contained in:
WerWolv 2024-06-26 19:11:59 +02:00
parent 95f71bcb10
commit 1eadb77722

View File

@ -575,16 +575,23 @@ namespace ImGuiExt {
if (!std::string_view(text).empty()) { if (!std::string_view(text).empty()) {
const auto textWidth = CalcTextSize(text).x; const auto textWidth = CalcTextSize(text).x;
auto width = 150 * hex::ImHexApi::System::getGlobalScale(); const auto maxWidth = 300 * hex::ImHexApi::System::getGlobalScale();
if (textWidth < width) const bool wrapping = textWidth > maxWidth;
width = textWidth;
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 (BeginTooltip()) {
if (isSeparator) if (isSeparator)
SeparatorText(text); SeparatorText(text);
else else {
TextFormattedWrapped("{}", text); if (wrapping)
TextFormattedWrapped("{}", text);
else
TextFormatted("{}", text);
}
EndTooltip(); EndTooltip();
} }