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

LibGUI: Extract ScrollBar::update_hovered_component() method

This commit is contained in:
Nico Weber 2020-08-25 10:39:13 -04:00 committed by Andreas Kling
parent bf0b5c3c5a
commit b96759930d
2 changed files with 7 additions and 1 deletions

View file

@ -377,7 +377,7 @@ ScrollBar::Component ScrollBar::component_at_position(const Gfx::IntPoint& posit
return Component::Invalid; return Component::Invalid;
} }
void ScrollBar::mousemove_event(MouseEvent& event) void ScrollBar::update_hovered_component(const Gfx::IntPoint& position)
{ {
auto old_hovered_component = m_hovered_component; auto old_hovered_component = m_hovered_component;
m_hovered_component = component_at_position(event.position()); m_hovered_component = component_at_position(event.position());
@ -389,6 +389,11 @@ void ScrollBar::mousemove_event(MouseEvent& event)
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, m_automatic_scrolling_kind); set_automatic_scrolling_active(m_hovered_component == Component::IncrementButton, m_automatic_scrolling_kind);
} }
}
void ScrollBar::mousemove_event(MouseEvent& event)
{
update_hovered_component(event.position());
if (!m_scrubbing) if (!m_scrubbing)
return; return;
float delta = orientation() == Orientation::Vertical ? (event.y() - m_scrub_origin.y()) : (event.x() - m_scrub_origin.x()); float delta = orientation() == Orientation::Vertical ? (event.y() - m_scrub_origin.y()) : (event.x() - m_scrub_origin.x());

View file

@ -103,6 +103,7 @@ private:
void scroll_by_page(const Gfx::IntPoint&); void scroll_by_page(const Gfx::IntPoint&);
Component component_at_position(const Gfx::IntPoint&); Component component_at_position(const Gfx::IntPoint&);
void update_hovered_component(const Gfx::IntPoint&);
int m_min { 0 }; int m_min { 0 };
int m_max { 0 }; int m_max { 0 };