diff options
author | FrHun <28605587+frhun@users.noreply.github.com> | 2022-01-03 18:31:46 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-06-28 17:52:42 +0100 |
commit | 39789604812129498920457eadc1d4296c8ac1ba (patch) | |
tree | b6c27c5a3d8b5a1562e89c2bb7241886ecded5db /Userland/Libraries/LibGUI | |
parent | 19fac58e4981e50f7915a48eaf1741757b8dabf9 (diff) | |
download | serenity-39789604812129498920457eadc1d4296c8ac1ba.zip |
LibGUI: Implement new layout system for Scrollbar
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.cpp | 22 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.h | 3 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp index 74719febc4..cb4cc15908 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.cpp +++ b/Userland/Libraries/LibGUI/Scrollbar.cpp @@ -48,11 +48,7 @@ Scrollbar::Scrollbar(Orientation orientation) { m_automatic_scrolling_timer = add<Core::Timer>(); - if (orientation == Orientation::Vertical) { - set_fixed_width(16); - } else { - set_fixed_height(16); - } + set_preferred_size({ SpecialDimension::Fit }); m_automatic_scrolling_timer->set_interval(100); m_automatic_scrolling_timer->on_timeout = [this] { @@ -421,4 +417,20 @@ void Scrollbar::update_animated_scroll() AbstractSlider::set_value(new_value); } +Optional<UISize> Scrollbar::calculated_min_size() const +{ + if (orientation() == Gfx::Orientation::Vertical) + return { { default_button_size(), 2 * default_button_size() } }; + else + return { { 2 * default_button_size(), default_button_size() } }; +} + +Optional<UISize> Scrollbar::calculated_preferred_size() const +{ + if (orientation() == Gfx::Orientation::Vertical) + return { { SpecialDimension::Shrink, SpecialDimension::Grow } }; + else + return { { SpecialDimension::Grow, SpecialDimension::Shrink } }; +} + } diff --git a/Userland/Libraries/LibGUI/Scrollbar.h b/Userland/Libraries/LibGUI/Scrollbar.h index 51aa86aea2..841eab7117 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.h +++ b/Userland/Libraries/LibGUI/Scrollbar.h @@ -40,6 +40,9 @@ public: virtual void increase_slider_by_steps(int steps) override { set_target_value(m_target_value + step() * steps); } virtual void decrease_slider_by_steps(int steps) override { set_target_value(m_target_value - step() * steps); } + virtual Optional<UISize> calculated_min_size() const override; + virtual Optional<UISize> calculated_preferred_size() const override; + enum Component { None, DecrementButton, |