From 6a06a56256b28d939e78a361796fdad845682e77 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sat, 20 May 2023 14:15:06 +0200 Subject: [PATCH] Debugger: fix width of alert for short messages Don't force a larger min size if the message is short enough. To do this: - Get the TextRect without word wrapping - If that is small enough, nothing to do - If that is too wide, set a minimal size that will be used for the word wrapping so the alert doesn't get too large and also doesn't get too narrow Fixes #18404 Change-Id: Iee2704377180510edf7bdf930583b8a7cc47ef2e Reviewed-on: https://review.haiku-os.org/c/haiku/+/6461 Reviewed-by: waddlesplash --- .../user_interface/gui/util/AlertWithCheckbox.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp b/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp index 64d0b37965..48682b205f 100644 --- a/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp +++ b/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp @@ -58,11 +58,15 @@ AlertWithCheckbox::AlertWithCheckbox(const char* title, const char* messageText, message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); message->MakeEditable(false); message->MakeSelectable(false); - message->SetWordWrap(true); message->SetText(messageText); + BRect textRect = message->TextRect(); + textRect.PrintToStream(); + message->SetWordWrap(true); message->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNSET)); float width = message->StringWidth("W") * 40; - message->SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); + if (width < textRect.Width()) { + message->SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); + } fDontAskAgain = new BCheckBox("checkbox", checkboxLabel, NULL);