mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibGUI: Only paint ScrollBar hover states if a component is pressed
While left-mouse is pressed on any component (arrows, gutter, scrubber), don't draw hover states for components other than the pressed component. For example, while clicking the arrow-down button and then dragging around, the arrow-up button and the scrubber now aren't highlighted. This also means that during a gutter drag session, the scrubber isn't highlighted while it's under the mouse cursor. That makes sense, since we get the gutter drag behavior, not the scrubber drag behavior, in this case. The highlight is supposed to indicate "clickability", but if the mouse is already down, they can't be clicked. Now that I check for it, this seems to match the scrollbar behavior on Windows.
This commit is contained in:
parent
23e2944aa4
commit
a9136d0f47
1 changed files with 7 additions and 3 deletions
|
@ -235,13 +235,17 @@ void ScrollBar::paint_event(PaintEvent& event)
|
|||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
Component hovered_component_for_painting = m_hovered_component;
|
||||
if (m_pressed_component != Component::None && m_hovered_component != m_pressed_component)
|
||||
hovered_component_for_painting = Component::None;
|
||||
|
||||
painter.fill_rect_with_dither_pattern(rect(), palette().button().lightened(1.3f), palette().button());
|
||||
|
||||
bool decrement_pressed = m_pressed_component == Component::DecrementButton;
|
||||
bool increment_pressed = m_pressed_component == Component::IncrementButton;
|
||||
|
||||
Gfx::StylePainter::paint_button(painter, decrement_button_rect(), palette(), Gfx::ButtonStyle::Normal, decrement_pressed, m_hovered_component == Component::DecrementButton);
|
||||
Gfx::StylePainter::paint_button(painter, increment_button_rect(), palette(), Gfx::ButtonStyle::Normal, increment_pressed, m_hovered_component == Component::IncrementButton);
|
||||
Gfx::StylePainter::paint_button(painter, decrement_button_rect(), palette(), Gfx::ButtonStyle::Normal, decrement_pressed, hovered_component_for_painting == Component::DecrementButton);
|
||||
Gfx::StylePainter::paint_button(painter, increment_button_rect(), palette(), Gfx::ButtonStyle::Normal, increment_pressed, hovered_component_for_painting == Component::IncrementButton);
|
||||
|
||||
if (length(orientation()) > default_button_size()) {
|
||||
auto decrement_location = decrement_button_rect().location().translated(3, 3);
|
||||
|
@ -256,7 +260,7 @@ void ScrollBar::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
if (has_scrubber())
|
||||
Gfx::StylePainter::paint_button(painter, scrubber_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_hovered_component == Component::Scrubber || m_pressed_component == Component::Scrubber);
|
||||
Gfx::StylePainter::paint_button(painter, scrubber_rect(), palette(), Gfx::ButtonStyle::Normal, false, hovered_component_for_painting == Component::Scrubber || m_pressed_component == Component::Scrubber);
|
||||
}
|
||||
|
||||
void ScrollBar::on_automatic_scrolling_timer_fired()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue