diff options
author | 2021-10-14 16:07:22 +0700 | |
---|---|---|
committer | 2021-10-14 16:07:22 +0700 | |
commit | 03b34931383e701c39c653a7662a616fe21a0947 (patch) | |
tree | 8c0773d50b615dbc62210db8919ecb97ca912bd9 /graphics/src/widget/progress_bar.rs | |
parent | 3aae45c1913e6a6f60b009f19d00d10add7ad11e (diff) | |
download | iced-03b34931383e701c39c653a7662a616fe21a0947.tar.gz iced-03b34931383e701c39c653a7662a616fe21a0947.tar.bz2 iced-03b34931383e701c39c653a7662a616fe21a0947.zip |
Remove trait-specific draw logic in `iced_native`
Diffstat (limited to 'graphics/src/widget/progress_bar.rs')
-rw-r--r-- | graphics/src/widget/progress_bar.rs | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/graphics/src/widget/progress_bar.rs b/graphics/src/widget/progress_bar.rs index 32ee42c6..3d21b7b9 100644 --- a/graphics/src/widget/progress_bar.rs +++ b/graphics/src/widget/progress_bar.rs @@ -2,10 +2,8 @@ //! //! A [`ProgressBar`] has a range of possible values and a current value, //! as well as a length, height and style. -use crate::{Backend, Primitive, Renderer}; -use iced_native::mouse; +use crate::{Backend, Renderer}; use iced_native::progress_bar; -use iced_native::{Color, Rectangle}; pub use iced_style::progress_bar::{Style, StyleSheet}; @@ -22,53 +20,4 @@ where type Style = Box<dyn StyleSheet>; const DEFAULT_HEIGHT: u16 = 30; - - fn draw( - &self, - bounds: Rectangle, - range: std::ops::RangeInclusive<f32>, - value: f32, - style_sheet: &Self::Style, - ) -> Self::Output { - let style = style_sheet.style(); - let (range_start, range_end) = range.into_inner(); - - let active_progress_width = if range_start >= range_end { - 0.0 - } else { - bounds.width * (value - range_start) / (range_end - range_start) - }; - - let background = Primitive::Group { - primitives: vec![Primitive::Quad { - bounds: Rectangle { ..bounds }, - background: style.background, - border_radius: style.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }], - }; - - ( - if active_progress_width > 0.0 { - let bar = Primitive::Quad { - bounds: Rectangle { - width: active_progress_width, - ..bounds - }, - background: style.bar, - border_radius: style.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }; - - Primitive::Group { - primitives: vec![background, bar], - } - } else { - background - }, - mouse::Interaction::default(), - ) - } } |