diff options
author | FrHun <28605587+frhun@users.noreply.github.com> | 2023-02-10 01:07:03 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-02-17 16:25:57 +0000 |
commit | b6d45f9c1feca10d80da65a1c14ba7488691f44e (patch) | |
tree | f82471588ada008be05a95efc6c0ba0997a5e512 /Userland | |
parent | e2691fcdf21cb0e4239dcf1ab4a5969f3bb2f234 (diff) | |
download | serenity-b6d45f9c1feca10d80da65a1c14ba7488691f44e.zip |
LibGUI: Use calculated_preferred_size in SeparatorWidget
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/SeparatorWidget.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/SeparatorWidget.h | 1 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGUI/SeparatorWidget.cpp b/Userland/Libraries/LibGUI/SeparatorWidget.cpp index 91bd6b137b..b60221de2f 100644 --- a/Userland/Libraries/LibGUI/SeparatorWidget.cpp +++ b/Userland/Libraries/LibGUI/SeparatorWidget.cpp @@ -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 }; +} + } diff --git a/Userland/Libraries/LibGUI/SeparatorWidget.h b/Userland/Libraries/LibGUI/SeparatorWidget.h index 40fc9f62c5..64393d190b 100644 --- a/Userland/Libraries/LibGUI/SeparatorWidget.h +++ b/Userland/Libraries/LibGUI/SeparatorWidget.h @@ -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; }; |