diff options
author | 2020-08-22 21:25:06 +0200 | |
---|---|---|
committer | 2020-08-22 21:25:06 +0200 | |
commit | 2ce5df084456a92ed1a228738816cf8398b2e918 (patch) | |
tree | 57eae346361880dc9dbbc15a42a56e001e20c5ff /examples | |
parent | bbc6e91429ff94c3792de9d874999818b2c84a9b (diff) | |
parent | fed30ef7753bbe33af026f1f46a09d8381682284 (diff) | |
download | iced-2ce5df084456a92ed1a228738816cf8398b2e918.tar.gz iced-2ce5df084456a92ed1a228738816cf8398b2e918.tar.bz2 iced-2ce5df084456a92ed1a228738816cf8398b2e918.zip |
Merge branch 'feature/rule-widget' into master
Diffstat (limited to '')
-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..0c2cfc57 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_mode: rule::FillMode::Padded(15), + } + } + } } } |