iced_aw/style/
color_picker.rs1use super::{Status, StyleFn};
6use iced_core::{Background, Color, Theme};
7
8#[derive(Clone, Copy, Debug)]
10pub struct Style {
11 pub background: Background,
13
14 pub border_radius: f32,
16
17 pub border_width: f32,
19
20 pub border_color: Color,
22
23 pub bar_border_radius: f32,
25
26 pub bar_border_width: f32,
28
29 pub bar_border_color: Color,
31}
32
33pub trait Catalog {
35 type Class<'a>;
37
38 fn default<'a>() -> Self::Class<'a>;
40
41 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style;
43}
44
45impl Catalog for Theme {
46 type Class<'a> = StyleFn<'a, Self, Style>;
47
48 fn default<'a>() -> Self::Class<'a> {
49 Box::new(primary)
50 }
51
52 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
53 class(self, status)
54 }
55}
56
57#[must_use]
59pub fn primary(theme: &Theme, status: Status) -> Style {
60 let palette = theme.extended_palette();
61 let foreground = theme.palette();
62
63 let base = Style {
64 background: palette.background.base.color.into(),
65 border_radius: 15.0,
66 border_width: 1.0,
67 border_color: foreground.text,
68 bar_border_radius: 5.0,
69 bar_border_width: 1.0,
70 bar_border_color: foreground.text,
71 };
72
73 match status {
74 Status::Focused => Style {
75 border_color: palette.background.strong.color,
76 bar_border_color: palette.background.strong.color,
77 ..base
78 },
79 _ => base,
80 }
81}