mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +00:00
LibGUI: Implement new layout system for Scrollbar
This commit is contained in:
parent
19fac58e49
commit
3978960481
Notes:
sideshowbarker
2024-07-17 09:54:18 +09:00
Author: https://github.com/frhun
Commit: 3978960481
Pull-request: https://github.com/SerenityOS/serenity/pull/14261
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/MacDue
Reviewed-by: https://github.com/mjz19910
2 changed files with 20 additions and 5 deletions
|
@ -48,11 +48,7 @@ Scrollbar::Scrollbar(Orientation orientation)
|
||||||
{
|
{
|
||||||
m_automatic_scrolling_timer = add<Core::Timer>();
|
m_automatic_scrolling_timer = add<Core::Timer>();
|
||||||
|
|
||||||
if (orientation == Orientation::Vertical) {
|
set_preferred_size({ SpecialDimension::Fit });
|
||||||
set_fixed_width(16);
|
|
||||||
} else {
|
|
||||||
set_fixed_height(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_automatic_scrolling_timer->set_interval(100);
|
m_automatic_scrolling_timer->set_interval(100);
|
||||||
m_automatic_scrolling_timer->on_timeout = [this] {
|
m_automatic_scrolling_timer->on_timeout = [this] {
|
||||||
|
@ -421,4 +417,20 @@ void Scrollbar::update_animated_scroll()
|
||||||
AbstractSlider::set_value(new_value);
|
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 } };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
virtual void increase_slider_by_steps(int steps) override { set_target_value(m_target_value + step() * steps); }
|
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 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 {
|
enum Component {
|
||||||
None,
|
None,
|
||||||
DecrementButton,
|
DecrementButton,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue