GScrollBar: Allow scrolling the scrollbar by mouse-wheeling over it

This commit is contained in:
Andreas Kling 2019-08-20 20:10:02 +02:00
parent 076827a05d
commit dc3c6be6f2
Notes: sideshowbarker 2024-07-19 12:35:20 +09:00
2 changed files with 11 additions and 0 deletions

View file

@ -281,6 +281,14 @@ void GScrollBar::mouseup_event(GMouseEvent& event)
update();
}
void GScrollBar::mousewheel_event(GMouseEvent& event)
{
if (!is_scrollable())
return;
set_value(value() + event.wheel_delta());
GWidget::mousewheel_event(event);
}
void GScrollBar::set_automatic_scrolling_active(bool active)
{
if (active) {

View file

@ -12,6 +12,8 @@ public:
Orientation orientation() const { return m_orientation; }
bool is_scrollable() const { return max() != min(); }
int value() const { return m_value; }
int min() const { return m_min; }
int max() const { return m_max; }
@ -41,6 +43,7 @@ private:
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mousewheel_event(GMouseEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void change_event(GEvent&) override;