From 2e9129582a88ee0758c215847b0ec49baab79f11 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 20 Apr 2023 15:25:37 +0200 Subject: Fix sliders drawing out of their bounds --- native/src/widget/slider.rs | 4 ++-- native/src/widget/vertical_slider.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index ba467834..cfb0a8fe 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -391,7 +391,7 @@ pub fn draw( let offset = if range_start >= range_end { 0.0 } else { - (bounds.width - handle_width / 2.0) * (value - range_start) + (bounds.width - handle_width) * (value - range_start) / (range_end - range_start) }; @@ -417,7 +417,7 @@ pub fn draw( bounds: Rectangle { x: bounds.x + offset + handle_width / 2.0, y: rail_y - style.rail.width / 2.0, - width: bounds.width - offset, + width: bounds.width - offset - handle_width / 2.0, height: style.rail.width, }, border_radius: Default::default(), diff --git a/native/src/widget/vertical_slider.rs b/native/src/widget/vertical_slider.rs index 5af69676..cb2de480 100644 --- a/native/src/widget/vertical_slider.rs +++ b/native/src/widget/vertical_slider.rs @@ -384,7 +384,7 @@ pub fn draw( let offset = if range_start >= range_end { 0.0 } else { - (bounds.height - handle_width / 2.0) * (value - range_end) + (bounds.height - handle_width) * (value - range_end) / (range_start - range_end) }; @@ -411,7 +411,7 @@ pub fn draw( x: rail_x - style.rail.width / 2.0, y: bounds.y + offset + handle_width / 2.0, width: style.rail.width, - height: bounds.height - offset, + height: bounds.height - offset - handle_width / 2.0, }, border_radius: Default::default(), border_width: 0.0, -- cgit