diff options
author | 2020-07-16 05:00:37 +0200 | |
---|---|---|
committer | 2020-07-16 05:00:37 +0200 | |
commit | da5da3958e3b7fe85e371846a795c4ae05cb2df7 (patch) | |
tree | cd9f353e005ebc9c49d987125ba168a87982c629 /examples/game_of_life/src/style.rs | |
parent | 62ec03a0afe8566a8f0b06675990a83fd65de1a9 (diff) | |
parent | 31c30fedd5e5ad74cc1f66162d7e5c0e5e3cf420 (diff) | |
download | iced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.tar.gz iced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.tar.bz2 iced-da5da3958e3b7fe85e371846a795c4ae05cb2df7.zip |
Merge pull request #444 from hecrj/feature/overlay
Overlay support and `PickList` widget
Diffstat (limited to 'examples/game_of_life/src/style.rs')
-rw-r--r-- | examples/game_of_life/src/style.rs | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/examples/game_of_life/src/style.rs b/examples/game_of_life/src/style.rs index d59569f2..308ce43c 100644 --- a/examples/game_of_life/src/style.rs +++ b/examples/game_of_life/src/style.rs @@ -1,4 +1,4 @@ -use iced::{button, container, slider, Background, Color}; +use iced::{button, container, pick_list, slider, Background, Color}; const ACTIVE: Color = Color::from_rgb( 0x72 as f32 / 255.0, @@ -18,6 +18,12 @@ const HOVERED: Color = Color::from_rgb( 0xC4 as f32 / 255.0, ); +const BACKGROUND: Color = Color::from_rgb( + 0x2F as f32 / 255.0, + 0x31 as f32 / 255.0, + 0x36 as f32 / 255.0, +); + pub struct Container; impl container::StyleSheet for Container { @@ -132,3 +138,51 @@ impl slider::StyleSheet for Slider { } } } + +pub struct PickList; + +impl pick_list::StyleSheet for PickList { + fn menu(&self) -> pick_list::Menu { + pick_list::Menu { + text_color: Color::WHITE, + background: BACKGROUND.into(), + border_width: 1, + border_color: Color { + a: 0.7, + ..Color::BLACK + }, + selected_background: Color { + a: 0.5, + ..Color::BLACK + } + .into(), + selected_text_color: Color::WHITE, + } + } + + fn active(&self) -> pick_list::Style { + pick_list::Style { + text_color: Color::WHITE, + background: BACKGROUND.into(), + border_width: 1, + border_color: Color { + a: 0.6, + ..Color::BLACK + }, + border_radius: 2, + icon_size: 0.5, + } + } + + fn hovered(&self) -> pick_list::Style { + let active = self.active(); + + pick_list::Style { + border_color: Color { + a: 0.9, + ..Color::BLACK + }, + ..active + } + } +} |