mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibGUI: Use new layout system for basic widgets
This commit is contained in:
parent
bfbaad9f41
commit
19fac58e49
17 changed files with 85 additions and 18 deletions
|
@ -23,8 +23,8 @@ namespace GUI {
|
|||
Button::Button(String text)
|
||||
: AbstractButton(move(text))
|
||||
{
|
||||
set_min_width(32);
|
||||
set_fixed_height(22);
|
||||
set_min_size({ 40, 22 });
|
||||
set_preferred_size({ SpecialDimension::OpportunisticGrow, 22 });
|
||||
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
||||
|
||||
on_focus_change = [this](bool has_focus, auto) {
|
||||
|
@ -257,4 +257,26 @@ void Button::timer_event(Core::TimerEvent&)
|
|||
}
|
||||
}
|
||||
|
||||
Optional<UISize> Button::calculated_min_size() const
|
||||
{
|
||||
int horizontal = 0, vertical = 0;
|
||||
|
||||
if (!text().is_empty()) {
|
||||
auto& font = this->font();
|
||||
horizontal = font.width(text()) + 2;
|
||||
vertical = font.glyph_height() + 4; // FIXME: Use actual maximum total height
|
||||
}
|
||||
|
||||
if (m_icon) {
|
||||
vertical = max(vertical, m_icon->height());
|
||||
|
||||
horizontal += m_icon->width() + icon_spacing();
|
||||
}
|
||||
|
||||
horizontal += 8;
|
||||
vertical += 4;
|
||||
|
||||
return UISize(horizontal, vertical);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue