diff options
author | 2020-08-13 12:54:34 -0500 | |
---|---|---|
committer | 2020-08-22 21:23:27 +0200 | |
commit | 8d68c8584ea99d3974571cd92edcb31999ebb8fa (patch) | |
tree | 9aae5f2667bc60a8fe6c54440a9212ae1e63687b /style | |
parent | 00d66da0cee1dc7faeccc5b3f0794a0393a38da7 (diff) | |
download | iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.tar.gz iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.tar.bz2 iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.zip |
widget Rule added
Diffstat (limited to 'style')
-rw-r--r-- | style/src/lib.rs | 1 | ||||
-rw-r--r-- | style/src/rule.rs | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs index 8e402bb1..3d23d990 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -11,6 +11,7 @@ pub mod menu; pub mod pick_list; pub mod progress_bar; pub mod radio; +pub mod rule; pub mod scrollable; pub mod slider; pub mod text_input; diff --git a/style/src/rule.rs b/style/src/rule.rs new file mode 100644 index 00000000..dbd72d41 --- /dev/null +++ b/style/src/rule.rs @@ -0,0 +1,51 @@ +//! Display a horizontal or vertical rule for dividing content. + +use iced_core::Color; + +/// The appearance of a rule. +#[derive(Debug, Clone, Copy)] +pub struct Style { + /// The color of the rule. + pub color: Color, + /// The width (thickness) of the rule line. + pub width: u16, + /// The radius of the rectangle corners. + pub radius: u16, + /// The percent from [0, 100] of the filled space the rule + /// will be drawn. + pub fill_percent: u16, +} + +/// A set of rules that dictate the style of a rule. +pub trait StyleSheet { + /// Produces the style of a rule. + fn style(&self) -> Style; +} + +struct Default; + +impl StyleSheet for Default { + fn style(&self) -> Style { + Style { + color: [0.6, 0.6, 0.6, 0.49].into(), + width: 1, + radius: 0, + fill_percent: 90, + } + } +} + +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) + } +} |