diff options
Diffstat (limited to 'Userland/Libraries/LibGUI/Scrollbar.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.cpp | 22 |
1 files changed, 17 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 } }; +} + } |