From 3efb59dea3d206a9d627ce5a7a7a93c00d769ba8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 10 Mar 2022 17:01:57 +0700 Subject: Implement `pure` version of `ProgressBar` widget --- pure/src/widget.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pure/src/widget.rs') diff --git a/pure/src/widget.rs b/pure/src/widget.rs index bee21633..8f2cf920 100644 --- a/pure/src/widget.rs +++ b/pure/src/widget.rs @@ -1,4 +1,5 @@ pub mod image; +pub mod progress_bar; pub mod rule; pub mod tree; @@ -24,6 +25,7 @@ pub use container::Container; pub use element::Element; pub use image::Image; pub use pick_list::PickList; +pub use progress_bar::ProgressBar; pub use radio::Radio; pub use row::Row; pub use rule::Rule; @@ -43,6 +45,7 @@ use iced_native::renderer; use iced_native::{Clipboard, Length, Point, Rectangle, Shell}; use std::borrow::Cow; +use std::ops::RangeInclusive; pub trait Widget { fn width(&self) -> Length; @@ -246,3 +249,15 @@ pub fn horizontal_rule<'a>(height: u16) -> Rule<'a> { pub fn vertical_rule<'a>(width: u16) -> Rule<'a> { Rule::horizontal(width) } + +/// Creates a new [`ProgressBar`]. +/// +/// It expects: +/// * an inclusive range of possible values +/// * the current value of the [`ProgressBar`] +pub fn progress_bar<'a>( + range: RangeInclusive, + value: f32, +) -> ProgressBar<'a> { + ProgressBar::new(range, value) +} -- cgit