Implement theme styling for PickList and Menu
This commit is contained in:
parent
97555e67af
commit
396735b682
14 changed files with 168 additions and 247 deletions
|
|
@ -1,7 +1,6 @@
|
|||
//! This example showcases an interactive version of the Game of Life, invented
|
||||
//! by John Conway. It leverages a `Canvas` together with other widgets.
|
||||
mod preset;
|
||||
mod style;
|
||||
|
||||
use grid::Grid;
|
||||
use iced::button::{self, Button};
|
||||
|
|
@ -877,8 +876,7 @@ impl Controls {
|
|||
Message::PresetPicked,
|
||||
)
|
||||
.padding(8)
|
||||
.text_size(16)
|
||||
.style(style::PickList),
|
||||
.text_size(16),
|
||||
)
|
||||
.push(
|
||||
Button::new(&mut self.clear_button, Text::new("Clear"))
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
use iced::{pick_list, Color};
|
||||
|
||||
const BACKGROUND: Color = Color::from_rgb(
|
||||
0x2F as f32 / 255.0,
|
||||
0x31 as f32 / 255.0,
|
||||
0x36 as f32 / 255.0,
|
||||
);
|
||||
|
||||
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.0,
|
||||
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.0,
|
||||
border_color: Color {
|
||||
a: 0.6,
|
||||
..Color::BLACK
|
||||
},
|
||||
border_radius: 2.0,
|
||||
icon_size: 0.5,
|
||||
..pick_list::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self) -> pick_list::Style {
|
||||
let active = self.active();
|
||||
|
||||
pick_list::Style {
|
||||
border_color: Color {
|
||||
a: 0.9,
|
||||
..Color::BLACK
|
||||
},
|
||||
..active
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
//! This example showcases an interactive version of the Game of Life, invented
|
||||
//! by John Conway. It leverages a `Canvas` together with other widgets.
|
||||
mod preset;
|
||||
mod style;
|
||||
|
||||
use grid::Grid;
|
||||
use iced::executor;
|
||||
|
|
@ -195,8 +194,7 @@ fn view_controls<'a>(
|
|||
.push(
|
||||
pick_list(preset::ALL, Some(preset), Message::PresetPicked)
|
||||
.padding(8)
|
||||
.text_size(16)
|
||||
.style(style::PickList),
|
||||
.text_size(16),
|
||||
)
|
||||
.push(
|
||||
button("Clear")
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
use iced::{pick_list, Color};
|
||||
|
||||
pub const BACKGROUND: Color = Color::from_rgb(
|
||||
0x2F as f32 / 255.0,
|
||||
0x31 as f32 / 255.0,
|
||||
0x36 as f32 / 255.0,
|
||||
);
|
||||
|
||||
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.0,
|
||||
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.0,
|
||||
border_color: Color {
|
||||
a: 0.6,
|
||||
..Color::BLACK
|
||||
},
|
||||
border_radius: 2.0,
|
||||
icon_size: 0.5,
|
||||
..pick_list::Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self) -> pick_list::Style {
|
||||
let active = self.active();
|
||||
|
||||
pick_list::Style {
|
||||
border_color: Color {
|
||||
a: 0.9,
|
||||
..Color::BLACK
|
||||
},
|
||||
..active
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue