mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:47:42 +00:00
LibGUI: Make AutomaticScrollingKind a paramter on set_automatic_scrolling_active
Most callers of set_automatic_scrolling_active() also change m_automatic_scrolling_kind, and it makes it possible to make timer behavior dependent on the autoscroll kind later.
This commit is contained in:
parent
129816e056
commit
ecf6cbbd02
2 changed files with 15 additions and 16 deletions
|
@ -279,14 +279,12 @@ void ScrollBar::mousedown_event(MouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (decrement_button_rect().contains(event.position())) {
|
if (decrement_button_rect().contains(event.position())) {
|
||||||
m_automatic_scrolling_kind = AutomaticScrollingKind::DecrementButton;
|
set_automatic_scrolling_active(true, AutomaticScrollingKind::DecrementButton);
|
||||||
set_automatic_scrolling_active(true);
|
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (increment_button_rect().contains(event.position())) {
|
if (increment_button_rect().contains(event.position())) {
|
||||||
m_automatic_scrolling_kind = AutomaticScrollingKind::IncrementButton;
|
set_automatic_scrolling_active(true, AutomaticScrollingKind::IncrementButton);
|
||||||
set_automatic_scrolling_active(true);
|
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -312,8 +310,7 @@ void ScrollBar::mouseup_event(MouseEvent& event)
|
||||||
if (event.button() != MouseButton::Left)
|
if (event.button() != MouseButton::Left)
|
||||||
return;
|
return;
|
||||||
m_scrubber_in_use = false;
|
m_scrubber_in_use = false;
|
||||||
m_automatic_scrolling_kind = AutomaticScrollingKind::None;
|
set_automatic_scrolling_active(false, AutomaticScrollingKind::None);
|
||||||
set_automatic_scrolling_active(false);
|
|
||||||
m_scrubbing = false;
|
m_scrubbing = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -326,8 +323,10 @@ void ScrollBar::mousewheel_event(MouseEvent& event)
|
||||||
Widget::mousewheel_event(event);
|
Widget::mousewheel_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollBar::set_automatic_scrolling_active(bool active)
|
void ScrollBar::set_automatic_scrolling_active(bool active, AutomaticScrollingKind kind)
|
||||||
{
|
{
|
||||||
|
m_automatic_scrolling_kind = kind;
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
on_automatic_scrolling_timer_fired();
|
on_automatic_scrolling_timer_fired();
|
||||||
m_automatic_scrolling_timer->start();
|
m_automatic_scrolling_timer->start();
|
||||||
|
@ -376,9 +375,9 @@ void ScrollBar::mousemove_event(MouseEvent& event)
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if (m_automatic_scrolling_kind == AutomaticScrollingKind::DecrementButton)
|
if (m_automatic_scrolling_kind == AutomaticScrollingKind::DecrementButton)
|
||||||
set_automatic_scrolling_active(m_hovered_component == Component::DecrementButton);
|
set_automatic_scrolling_active(m_hovered_component == Component::DecrementButton, m_automatic_scrolling_kind);
|
||||||
else if (m_automatic_scrolling_kind == AutomaticScrollingKind::IncrementButton)
|
else if (m_automatic_scrolling_kind == AutomaticScrollingKind::IncrementButton)
|
||||||
set_automatic_scrolling_active(m_hovered_component == Component::IncrementButton);
|
set_automatic_scrolling_active(m_hovered_component == Component::IncrementButton, m_automatic_scrolling_kind);
|
||||||
}
|
}
|
||||||
if (!m_scrubbing)
|
if (!m_scrubbing)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -78,6 +78,12 @@ private:
|
||||||
virtual void leave_event(Core::Event&) override;
|
virtual void leave_event(Core::Event&) override;
|
||||||
virtual void change_event(Event&) override;
|
virtual void change_event(Event&) override;
|
||||||
|
|
||||||
|
enum class AutomaticScrollingKind {
|
||||||
|
None = 0,
|
||||||
|
DecrementButton,
|
||||||
|
IncrementButton,
|
||||||
|
};
|
||||||
|
|
||||||
int default_button_size() const { return 16; }
|
int default_button_size() const { return 16; }
|
||||||
int button_size() const { return length(orientation()) <= (default_button_size() * 2) ? length(orientation()) / 2 : default_button_size(); }
|
int button_size() const { return length(orientation()) <= (default_button_size() * 2) ? length(orientation()) / 2 : default_button_size(); }
|
||||||
int button_width() const { return orientation() == Orientation::Vertical ? width() : button_size(); }
|
int button_width() const { return orientation() == Orientation::Vertical ? width() : button_size(); }
|
||||||
|
@ -91,7 +97,7 @@ private:
|
||||||
int visible_scrubber_size() const;
|
int visible_scrubber_size() const;
|
||||||
int scrubbable_range_in_pixels() const;
|
int scrubbable_range_in_pixels() const;
|
||||||
void on_automatic_scrolling_timer_fired();
|
void on_automatic_scrolling_timer_fired();
|
||||||
void set_automatic_scrolling_active(bool);
|
void set_automatic_scrolling_active(bool, AutomaticScrollingKind);
|
||||||
|
|
||||||
void scroll_to_position(const Gfx::IntPoint&);
|
void scroll_to_position(const Gfx::IntPoint&);
|
||||||
void scroll_by_page(const Gfx::IntPoint&);
|
void scroll_by_page(const Gfx::IntPoint&);
|
||||||
|
@ -111,12 +117,6 @@ private:
|
||||||
Component m_hovered_component { Component::Invalid };
|
Component m_hovered_component { Component::Invalid };
|
||||||
bool m_scrubber_in_use { false };
|
bool m_scrubber_in_use { false };
|
||||||
|
|
||||||
enum class AutomaticScrollingKind {
|
|
||||||
None = 0,
|
|
||||||
DecrementButton,
|
|
||||||
IncrementButton,
|
|
||||||
};
|
|
||||||
|
|
||||||
AutomaticScrollingKind m_automatic_scrolling_kind { AutomaticScrollingKind::None };
|
AutomaticScrollingKind m_automatic_scrolling_kind { AutomaticScrollingKind::None };
|
||||||
RefPtr<Core::Timer> m_automatic_scrolling_timer;
|
RefPtr<Core::Timer> m_automatic_scrolling_timer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue