From c943ab823d74040f026454e329824cbe4223ec8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Oppeb=C3=B8en?= Date: Wed, 1 Mar 2023 21:33:28 +0100 Subject: [PATCH] LibGUI: Paint slider track shorter to ensure the knob covers it A 1px drop shadow from the track was peeking out behind the knob when at rightmost or lowest position. That made it look like it was possible to drag the knob even further right or down. Painting the track 1px shorter seems like a good compromise to avoid the problem. --- Userland/Libraries/LibGUI/Slider.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp index 45e165d899..3ff67bee33 100644 --- a/Userland/Libraries/LibGUI/Slider.cpp +++ b/Userland/Libraries/LibGUI/Slider.cpp @@ -35,14 +35,16 @@ void Slider::paint_event(PaintEvent& event) Gfx::IntRect track_rect; + // To avoid drop shadow peeking out behind the slider knob, we paint the track slightly shorter + int shadow_thickness = 1; if (orientation() == Orientation::Horizontal) { - track_rect = { inner_rect().x(), 0, inner_rect().width(), track_size() }; + track_rect = { inner_rect().x(), 0, inner_rect().width() - shadow_thickness, track_size() }; track_rect.center_vertically_within(inner_rect()); } else { - track_rect = { 0, inner_rect().y(), track_size(), inner_rect().height() }; + track_rect = { 0, inner_rect().y(), track_size(), inner_rect().height() - shadow_thickness }; track_rect.center_horizontally_within(inner_rect()); } - Gfx::StylePainter::paint_frame(painter, track_rect, palette(), Gfx::FrameShape::Panel, Gfx::FrameShadow::Sunken, 1); + Gfx::StylePainter::paint_frame(painter, track_rect, palette(), Gfx::FrameShape::Panel, Gfx::FrameShadow::Sunken, shadow_thickness); if (is_enabled()) Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered); else