summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/slider.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-08-01 08:18:52 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-08-01 08:18:52 +0200
commit9ba4cfd23f4620bab93df9616617643604db2c79 (patch)
treefda380f2fda871d0c3f736fb180d3eb4581758a7 /graphics/src/widget/slider.rs
parent72cfe85f7f2d3cc1221b788b7d86b99057bb58eb (diff)
downloadiced-9ba4cfd23f4620bab93df9616617643604db2c79.tar.gz
iced-9ba4cfd23f4620bab93df9616617643604db2c79.tar.bz2
iced-9ba4cfd23f4620bab93df9616617643604db2c79.zip
Add `height` method to `Slider`
Diffstat (limited to 'graphics/src/widget/slider.rs')
-rw-r--r--graphics/src/widget/slider.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/graphics/src/widget/slider.rs b/graphics/src/widget/slider.rs
index da8b5a86..99f0a098 100644
--- a/graphics/src/widget/slider.rs
+++ b/graphics/src/widget/slider.rs
@@ -19,17 +19,13 @@ pub use iced_style::slider::{Handle, HandleShape, Style, StyleSheet};
pub type Slider<'a, T, Message, Backend> =
iced_native::Slider<'a, T, Message, Renderer<Backend>>;
-const HANDLE_HEIGHT: f32 = 22.0;
-
impl<B> slider::Renderer for Renderer<B>
where
B: Backend,
{
type Style = Box<dyn StyleSheet>;
- fn height(&self) -> u32 {
- 30
- }
+ const DEFAULT_HEIGHT: u16 = 22;
fn draw(
&mut self,
@@ -81,16 +77,18 @@ where
let (range_start, range_end) = range.into_inner();
- let (handle_width, handle_height, handle_border_radius) =
- match style.handle.shape {
- HandleShape::Circle { radius } => {
- (f32::from(radius * 2), f32::from(radius * 2), radius)
- }
- HandleShape::Rectangle {
- width,
- border_radius,
- } => (f32::from(width), HANDLE_HEIGHT, border_radius),
- };
+ let (handle_width, handle_height, handle_border_radius) = match style
+ .handle
+ .shape
+ {
+ HandleShape::Circle { radius } => {
+ (f32::from(radius * 2), f32::from(radius * 2), radius)
+ }
+ HandleShape::Rectangle {
+ width,
+ border_radius,
+ } => (f32::from(width), f32::from(bounds.height), border_radius),
+ };
let handle_offset = (bounds.width - handle_width)
* ((value - range_start) / (range_end - range_start).max(1.0));