1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 19:05:07 +00:00

GScrollBar: highlight the scrubber while it's in use.

Originally, it would stop being highlighted if the mouse was moved away from
it, even while in use. Now it will stay highlighted for the duration of
usage.
This commit is contained in:
Ignas S 2019-08-11 12:53:02 +03:00 committed by Andreas Kling
parent b07a315736
commit feabe6ed31
2 changed files with 4 additions and 1 deletions

View file

@ -208,7 +208,7 @@ void GScrollBar::paint_event(GPaintEvent& event)
} }
if (has_scrubber()) if (has_scrubber())
StylePainter::paint_button(painter, scrubber_rect(), ButtonStyle::Normal, false, m_hovered_component == Component::Scrubber); StylePainter::paint_button(painter, scrubber_rect(), ButtonStyle::Normal, false, m_hovered_component == Component::Scrubber || m_scrubber_in_use);
} }
void GScrollBar::on_automatic_scrolling_timer_fired() void GScrollBar::on_automatic_scrolling_timer_fired()
@ -238,6 +238,7 @@ void GScrollBar::mousedown_event(GMouseEvent& event)
return; return;
} }
if (has_scrubber() && scrubber_rect().contains(event.position())) { if (has_scrubber() && scrubber_rect().contains(event.position())) {
m_scrubber_in_use = true;
m_scrubbing = true; m_scrubbing = true;
m_scrub_start_value = value(); m_scrub_start_value = value();
m_scrub_origin = event.position(); m_scrub_origin = event.position();
@ -270,6 +271,7 @@ void GScrollBar::mouseup_event(GMouseEvent& event)
{ {
if (event.button() != GMouseButton::Left) if (event.button() != GMouseButton::Left)
return; return;
m_scrubber_in_use = false;
m_automatic_scrolling_direction = AutomaticScrollingDirection::None; m_automatic_scrolling_direction = AutomaticScrollingDirection::None;
set_automatic_scrolling_active(false); set_automatic_scrolling_active(false);
if (!m_scrubbing) if (!m_scrubbing)

View file

@ -70,6 +70,7 @@ private:
Orientation m_orientation { Orientation::Vertical }; Orientation m_orientation { Orientation::Vertical };
Component m_hovered_component { Component::Invalid }; Component m_hovered_component { Component::Invalid };
bool m_scrubber_in_use { false };
enum class AutomaticScrollingDirection { enum class AutomaticScrollingDirection {
None = 0, None = 0,