diff options
author | 2020-08-13 12:54:34 -0500 | |
---|---|---|
committer | 2020-08-22 21:23:27 +0200 | |
commit | 8d68c8584ea99d3974571cd92edcb31999ebb8fa (patch) | |
tree | 9aae5f2667bc60a8fe6c54440a9212ae1e63687b /examples/styling | |
parent | 00d66da0cee1dc7faeccc5b3f0794a0393a38da7 (diff) | |
download | iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.tar.gz iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.tar.bz2 iced-8d68c8584ea99d3974571cd92edcb31999ebb8fa.zip |
widget Rule added
Diffstat (limited to 'examples/styling')
-rw-r--r-- | examples/styling/src/main.rs | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 63ab9d62..c969526c 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -1,7 +1,7 @@ use iced::{ button, scrollable, slider, text_input, Align, Button, Checkbox, Column, - Container, Element, Length, ProgressBar, Radio, Row, Sandbox, Scrollable, - Settings, Slider, Space, Text, TextInput, + Container, Element, Length, ProgressBar, Radio, Row, Rule, Sandbox, + Scrollable, Settings, Slider, Space, Text, TextInput, }; pub fn main() { @@ -113,14 +113,17 @@ impl Sandbox for Styling { .padding(20) .max_width(600) .push(choose_theme) + .push(Rule::horizontal(38).style(self.theme)) .push(Row::new().spacing(10).push(text_input).push(button)) .push(slider) .push(progress_bar) .push( Row::new() .spacing(10) + .height(Length::Units(100)) .align_items(Align::Center) .push(scrollable) + .push(Rule::vertical(38).style(self.theme)) .push(checkbox), ); @@ -136,8 +139,8 @@ impl Sandbox for Styling { mod style { use iced::{ - button, checkbox, container, progress_bar, radio, scrollable, slider, - text_input, + button, checkbox, container, progress_bar, radio, rule, scrollable, + slider, text_input, }; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -228,6 +231,15 @@ mod style { } } + impl From<Theme> for Box<dyn rule::StyleSheet> { + fn from(theme: Theme) -> Self { + match theme { + Theme::Light => Default::default(), + Theme::Dark => dark::Rule.into(), + } + } + } + mod light { use iced::{button, Background, Color, Vector}; @@ -258,7 +270,7 @@ mod style { mod dark { use iced::{ - button, checkbox, container, progress_bar, radio, scrollable, + button, checkbox, container, progress_bar, radio, rule, scrollable, slider, text_input, Background, Color, }; @@ -516,5 +528,18 @@ mod style { } } } + + pub struct Rule; + + impl rule::StyleSheet for Rule { + fn style(&self) -> rule::Style { + rule::Style { + color: SURFACE, + width: 2, + radius: 1, + fill_percent: 90, + } + } + } } } |