mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 18:58:56 +00:00
LibGUI: Use calculated_preferred_size in SeparatorWidget
This commit is contained in:
parent
e2691fcdf2
commit
b6d45f9c1f
Notes:
sideshowbarker
2024-07-17 01:11:48 +09:00
Author: https://github.com/frhun
Commit: b6d45f9c1f
Pull-request: https://github.com/SerenityOS/serenity/pull/17407
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 9 additions and 4 deletions
|
@ -17,10 +17,7 @@ namespace GUI {
|
|||
SeparatorWidget::SeparatorWidget(Gfx::Orientation orientation)
|
||||
: m_orientation(orientation)
|
||||
{
|
||||
if (m_orientation == Gfx::Orientation::Vertical)
|
||||
set_fixed_width(8);
|
||||
else
|
||||
set_fixed_height(8);
|
||||
set_preferred_size(SpecialDimension::Fit);
|
||||
}
|
||||
|
||||
void SeparatorWidget::paint_event(PaintEvent& event)
|
||||
|
@ -39,4 +36,11 @@ void SeparatorWidget::paint_event(PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Optional<UISize> SeparatorWidget::calculated_preferred_size() const
|
||||
{
|
||||
if (m_orientation == Gfx::Orientation::Vertical)
|
||||
return UISize { 8, SpecialDimension::OpportunisticGrow };
|
||||
return UISize { SpecialDimension::OpportunisticGrow, 8 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ protected:
|
|||
|
||||
private:
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual Optional<UISize> calculated_preferred_size() const override;
|
||||
|
||||
const Gfx::Orientation m_orientation;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue