mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +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
2 changed files with 14 additions and 1 deletions
|
@ -291,4 +291,14 @@ Optional<UISize> Button::calculated_min_size() const
|
||||||
return UISize(width, height);
|
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 = {})
|
explicit DialogButton(String text = {})
|
||||||
: Button(move(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…
Add table
Add a link
Reference in a new issue