mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGUI: Implement calculated_min_size() for DialogButton
Dialog buttons now scale based on presentation size to accomodate larger fonts while retaining uniform widths. Scaling by 8 is arbitrary but preserves the historical 80 pixel width with Katica 10. This needs improvement but works well for most fonts as a start.
This commit is contained in:
parent
5181fafce6
commit
479e67212a
|
@ -291,4 +291,14 @@ Optional<UISize> Button::calculated_min_size() const
|
|||
return UISize(width, height);
|
||||
}
|
||||
|
||||
Optional<UISize> DialogButton::calculated_min_size() const
|
||||
{
|
||||
int constexpr scale = 8;
|
||||
int constexpr padding = 6;
|
||||
int width = max(80, font().presentation_size() * scale);
|
||||
int height = max(22, font().pixel_size_rounded_up() + padding);
|
||||
|
||||
return UISize(width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,8 +95,11 @@ public:
|
|||
explicit DialogButton(String text = {})
|
||||
: Button(move(text))
|
||||
{
|
||||
set_fixed_width(80);
|
||||
set_min_size({ SpecialDimension::Shrink });
|
||||
set_preferred_size({ SpecialDimension::Shrink });
|
||||
}
|
||||
|
||||
virtual Optional<UISize> calculated_min_size() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue