diff options
author | 2020-08-16 10:10:32 -0500 | |
---|---|---|
committer | 2020-08-22 21:23:44 +0200 | |
commit | 32561bd85c6db0d7e6d9d12c87b87f4b50f1d43f (patch) | |
tree | 150327574c8f50cda3c90413edd8c6ebbb51c40d /style | |
parent | 8d68c8584ea99d3974571cd92edcb31999ebb8fa (diff) | |
download | iced-32561bd85c6db0d7e6d9d12c87b87f4b50f1d43f.tar.gz iced-32561bd85c6db0d7e6d9d12c87b87f4b50f1d43f.tar.bz2 iced-32561bd85c6db0d7e6d9d12c87b87f4b50f1d43f.zip |
added FillMode enum style for the Rule widget
Diffstat (limited to 'style')
-rw-r--r-- | style/src/rule.rs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/style/src/rule.rs b/style/src/rule.rs index dbd72d41..aa095d3b 100644 --- a/style/src/rule.rs +++ b/style/src/rule.rs @@ -2,6 +2,23 @@ use iced_core::Color; +/// The fill mode of a rule. +#[derive(Debug, Clone, Copy)] +pub enum FillMode { + /// Fill the whole length of the container. + Full, + /// Fill a percent of the length of the container. The rule + /// will be centered in that container. + /// + /// The range is `[0.0, 100.0]`. + Percent(f32), + /// Uniform offset from each end, length units. + Padded(u16), + /// Different offset on each end of the rule, length units. + /// First = top or left. + AsymmetricPadding(u16, u16), +} + /// The appearance of a rule. #[derive(Debug, Clone, Copy)] pub struct Style { @@ -11,9 +28,10 @@ pub struct Style { 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, + /// The [`FillMode`] of the rule. + /// + /// [`FillMode`]: enum.FillMode.html + pub fill_mode: FillMode, } /// A set of rules that dictate the style of a rule. @@ -27,10 +45,10 @@ struct Default; impl StyleSheet for Default { fn style(&self) -> Style { Style { - color: [0.6, 0.6, 0.6, 0.49].into(), + color: [0.6, 0.6, 0.6, 0.51].into(), width: 1, radius: 0, - fill_percent: 90, + fill_mode: FillMode::Percent(90.0), } } } |