diff options
author | 2020-01-07 01:53:26 +0100 | |
---|---|---|
committer | 2020-01-07 01:53:26 +0100 | |
commit | 48b3b78a3840778eef1035f4585d5ba9dd3d6291 (patch) | |
tree | 2df86a26f9961969b4f8da38c145b123162f0923 /style | |
parent | fce89d0ffe36111cdbf42480c28e67811afb42e6 (diff) | |
download | iced-48b3b78a3840778eef1035f4585d5ba9dd3d6291.tar.gz iced-48b3b78a3840778eef1035f4585d5ba9dd3d6291.tar.bz2 iced-48b3b78a3840778eef1035f4585d5ba9dd3d6291.zip |
Implement styling for `ProgressBar`
Diffstat (limited to 'style')
-rw-r--r-- | style/src/lib.rs | 1 | ||||
-rw-r--r-- | style/src/progress_bar.rs | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs index 4b8d339e..3f3dc0b0 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -1,5 +1,6 @@ pub mod button; pub mod container; +pub mod progress_bar; pub mod scrollable; pub mod slider; pub mod text_input; diff --git a/style/src/progress_bar.rs b/style/src/progress_bar.rs new file mode 100644 index 00000000..73503fa8 --- /dev/null +++ b/style/src/progress_bar.rs @@ -0,0 +1,42 @@ +//! Provide progress feedback to your users. +use iced_core::{Background, Color}; + +/// The appearance of a progress bar. +#[derive(Debug)] +pub struct Style { + pub background: Background, + pub bar: Background, + pub border_radius: u16, +} + +/// A set of rules that dictate the style of a progress bar. +pub trait StyleSheet { + fn style(&self) -> Style; +} + +struct Default; + +impl StyleSheet for Default { + fn style(&self) -> Style { + Style { + background: Background::Color(Color::from_rgb(0.6, 0.6, 0.6)), + bar: Background::Color(Color::from_rgb(0.3, 0.9, 0.3)), + border_radius: 5, + } + } +} + +impl std::default::Default for Box<dyn StyleSheet> { + fn default() -> Self { + Box::new(Default) + } +} + +impl<T> From<T> for Box<dyn StyleSheet> +where + T: 'static + StyleSheet, +{ + fn from(style: T) -> Self { + Box::new(style) + } +} |