mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Tweak MessageBox layout slightly
This commit is contained in:
parent
14493645e0
commit
4cfef0cd95
Notes:
sideshowbarker
2024-07-19 00:13:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4cfef0cd95b
1 changed files with 8 additions and 5 deletions
|
@ -108,7 +108,7 @@ void MessageBox::build()
|
|||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget.layout()->set_spacing(8);
|
||||
widget.layout()->set_spacing(6);
|
||||
|
||||
auto& message_container = widget.add<Widget>();
|
||||
message_container.set_layout<HorizontalBoxLayout>();
|
||||
|
@ -132,13 +132,17 @@ void MessageBox::build()
|
|||
button_container.set_fixed_height(24);
|
||||
button_container.layout()->set_spacing(8);
|
||||
|
||||
constexpr int button_width = 80;
|
||||
int button_count = 0;
|
||||
|
||||
auto add_button = [&](String label, Dialog::ExecResult result) {
|
||||
auto& button = button_container.add<Button>();
|
||||
button.set_fixed_width(96);
|
||||
button.set_fixed_width(button_width);
|
||||
button.set_text(label);
|
||||
button.on_click = [this, label, result](auto) {
|
||||
done(result);
|
||||
};
|
||||
++button_count;
|
||||
};
|
||||
|
||||
button_container.layout()->add_spacer();
|
||||
|
@ -152,9 +156,8 @@ void MessageBox::build()
|
|||
add_button("Cancel", Dialog::ExecCancel);
|
||||
button_container.layout()->add_spacer();
|
||||
|
||||
int width = button_container.child_widgets().size() * 96 + 32;
|
||||
if (width < text_width + icon_width + 56)
|
||||
width = text_width + icon_width + 56;
|
||||
int width = (button_count * button_width) + ((button_count - 1) * button_container.layout()->spacing()) + 32;
|
||||
width = max(width, text_width + icon_width + 56);
|
||||
|
||||
set_rect(x(), y(), width, 96);
|
||||
set_resizable(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue