From 217bbbf4239303e91a29fae5297f669da3f77553 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sat, 20 May 2023 14:16:56 +0200 Subject: [PATCH] Debugger: fix empty button on alerts with only 2 buttons When no debuginfo is available from packages, the alert has only two buttons. This was not handled correctly, leading to a small empty button being present. Change-Id: I44de1101f7cd539da5c582eaf34bb1476aa9ab20 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6462 Reviewed-by: waddlesplash --- .../gui/util/AlertWithCheckbox.cpp | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp b/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp index 48682b205f..786f01129b 100644 --- a/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp +++ b/src/apps/debugger/user_interface/gui/util/AlertWithCheckbox.cpp @@ -68,13 +68,28 @@ AlertWithCheckbox::AlertWithCheckbox(const char* title, const char* messageText, message->SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); } - fDontAskAgain = new BCheckBox("checkbox", - checkboxLabel, NULL); + fDontAskAgain = new BCheckBox("checkbox", checkboxLabel, NULL); - BButton* button1 = new BButton(label1, label1, new BMessage(kButton1Message)); - BButton* button2 = new BButton(label2, label2, new BMessage(kButton2Message)); - BButton* button3 = new BButton(label3, label3, new BMessage(kButton3Message)); - button1->MakeDefault(true); + BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL); + BLayoutBuilder::Group<> layoutBuilder(buttonGroup); + + layoutBuilder.AddGlue(); + + if (label1) { + BButton* button = new BButton(label1, label1, new BMessage(kButton1Message)); + button->MakeDefault(true); + layoutBuilder.Add(button); + } + + if (label2) { + BButton* button = new BButton(label2, label2, new BMessage(kButton2Message)); + layoutBuilder.Add(button); + } + + if (label3) { + BButton* button = new BButton(label3, label3, new BMessage(kButton3Message)); + layoutBuilder.Add(button); + } BLayoutBuilder::Group<>(this) .AddGroup(B_HORIZONTAL) @@ -86,12 +101,7 @@ AlertWithCheckbox::AlertWithCheckbox(const char* title, const char* messageText, .Add(fDontAskAgain) .AddGlue() .End() - .AddGroup(B_HORIZONTAL) - .AddGlue() - .Add(button1) - .Add(button2) - .Add(button3) - .End() + .Add(buttonGroup) .End() .End();