diff options
author | DragonAlex98 <alessandro.antinori@studenti.unicam.it> | 2022-12-05 00:03:42 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-10 14:03:27 +0100 |
commit | b8706729ba9f824e9696ea188259119cb35568fd (patch) | |
tree | e63f297947b587a02b67091901079ca01e61ec30 /Userland/Libraries | |
parent | 4b12def5d8cd1c201a6a44cb4ffbb76c256af520 (diff) | |
download | serenity-b8706729ba9f824e9696ea188259119cb35568fd.zip |
LibGUI: Disable corresponding Scrollbar button when reaching min or max
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp index 195f9bff03..c38065522b 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.cpp +++ b/Userland/Libraries/LibGUI/Scrollbar.cpp @@ -199,11 +199,11 @@ void Scrollbar::paint_event(PaintEvent& event) painter.fill_rect_with_dither_pattern(rect_to_fill, palette().button(), palette().button().lightened(0.77f)); } - bool decrement_pressed = (m_pressed_component == Component::DecrementButton) && (m_pressed_component == m_hovered_component); - bool increment_pressed = (m_pressed_component == Component::IncrementButton) && (m_pressed_component == m_hovered_component); + bool decrement_pressed = (m_pressed_component == Component::DecrementButton) && (m_pressed_component == m_hovered_component) && !is_min(); + bool increment_pressed = (m_pressed_component == Component::IncrementButton) && (m_pressed_component == m_hovered_component) && !is_max(); - Gfx::StylePainter::paint_button(painter, decrement_button_rect(), palette(), Gfx::ButtonStyle::ThickCap, decrement_pressed, hovered_component_for_painting == Component::DecrementButton); - Gfx::StylePainter::paint_button(painter, increment_button_rect(), palette(), Gfx::ButtonStyle::ThickCap, increment_pressed, hovered_component_for_painting == Component::IncrementButton); + Gfx::StylePainter::paint_button(painter, decrement_button_rect(), palette(), Gfx::ButtonStyle::ThickCap, decrement_pressed, hovered_component_for_painting == Component::DecrementButton && !is_min()); + Gfx::StylePainter::paint_button(painter, increment_button_rect(), palette(), Gfx::ButtonStyle::ThickCap, increment_pressed, hovered_component_for_painting == Component::IncrementButton && !is_max()); if (length(orientation()) >= default_button_size() * 2) { auto decrement_location = decrement_button_rect().location().translated(3, 3); @@ -211,14 +211,14 @@ void Scrollbar::paint_event(PaintEvent& event) decrement_location.translate_by(1, 1); if (!has_scrubber() || !is_enabled()) painter.draw_triangle(decrement_location + Gfx::IntPoint { 1, 1 }, orientation() == Orientation::Vertical ? s_up_arrow_coords : s_left_arrow_coords, palette().threed_highlight()); - painter.draw_triangle(decrement_location, orientation() == Orientation::Vertical ? s_up_arrow_coords : s_left_arrow_coords, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); + painter.draw_triangle(decrement_location, orientation() == Orientation::Vertical ? s_up_arrow_coords : s_left_arrow_coords, (has_scrubber() && is_enabled() && !is_min()) ? palette().button_text() : palette().threed_shadow1()); auto increment_location = increment_button_rect().location().translated(3, 3); if (increment_pressed) increment_location.translate_by(1, 1); if (!has_scrubber() || !is_enabled()) painter.draw_triangle(increment_location + Gfx::IntPoint { 1, 1 }, orientation() == Orientation::Vertical ? s_down_arrow_coords : s_right_arrow_coords, palette().threed_highlight()); - painter.draw_triangle(increment_location, orientation() == Orientation::Vertical ? s_down_arrow_coords : s_right_arrow_coords, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); + painter.draw_triangle(increment_location, orientation() == Orientation::Vertical ? s_down_arrow_coords : s_right_arrow_coords, (has_scrubber() && is_enabled() && !is_max()) ? palette().button_text() : palette().threed_shadow1()); } if (has_scrubber() && !scrubber_rect().is_null()) @@ -263,11 +263,15 @@ void Scrollbar::mousedown_event(MouseEvent& event) m_pressed_component = component_at_position(m_last_mouse_position); if (m_pressed_component == Component::DecrementButton) { + if (is_min()) + return; set_automatic_scrolling_active(true, Component::DecrementButton); update(); return; } if (m_pressed_component == Component::IncrementButton) { + if (is_max()) + return; set_automatic_scrolling_active(true, Component::IncrementButton); update(); return; |