From 03b34931383e701c39c653a7662a616fe21a0947 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:07:22 +0700 Subject: Remove trait-specific draw logic in `iced_native` --- graphics/src/widget/progress_bar.rs | 53 +------------------------------------ 1 file changed, 1 insertion(+), 52 deletions(-) (limited to 'graphics/src/widget/progress_bar.rs') 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; const DEFAULT_HEIGHT: u16 = 30; - - fn draw( - &self, - bounds: Rectangle, - range: std::ops::RangeInclusive, - 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(), - ) - } } -- cgit From e42e1e2f57ddb455ceff0017e215ddacca978d37 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 17:36:36 +0700 Subject: Implement `Widget::draw` for `ProgressBar` --- graphics/src/widget/progress_bar.rs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'graphics/src/widget/progress_bar.rs') diff --git a/graphics/src/widget/progress_bar.rs b/graphics/src/widget/progress_bar.rs index 3d21b7b9..df4f5ec6 100644 --- a/graphics/src/widget/progress_bar.rs +++ b/graphics/src/widget/progress_bar.rs @@ -2,22 +2,4 @@ //! //! A [`ProgressBar`] has a range of possible values and a current value, //! as well as a length, height and style. -use crate::{Backend, Renderer}; -use iced_native::progress_bar; - -pub use iced_style::progress_bar::{Style, StyleSheet}; - -/// A bar that displays progress. -/// -/// This is an alias of an `iced_native` progress bar with an -/// `iced_wgpu::Renderer`. -pub type ProgressBar = iced_native::ProgressBar>; - -impl progress_bar::Renderer for Renderer -where - B: Backend, -{ - type Style = Box; - - const DEFAULT_HEIGHT: u16 = 30; -} +pub use iced_native::progress_bar::*; -- cgit From 0aafcde0ef1533c9eeba0379de8c0082e30c7504 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 15:35:12 +0700 Subject: Remove `widget` module re-exports in `iced_native` --- graphics/src/widget/progress_bar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/widget/progress_bar.rs') diff --git a/graphics/src/widget/progress_bar.rs b/graphics/src/widget/progress_bar.rs index df4f5ec6..3666ecfd 100644 --- a/graphics/src/widget/progress_bar.rs +++ b/graphics/src/widget/progress_bar.rs @@ -2,4 +2,4 @@ //! //! A [`ProgressBar`] has a range of possible values and a current value, //! as well as a length, height and style. -pub use iced_native::progress_bar::*; +pub use iced_native::widget::progress_bar::*; -- cgit