iced_aw/style/
menu_bar.rs1use super::{Status, StyleFn};
3use iced_core::{Background, Border, Color, Shadow, Theme, Vector};
4
5#[derive(Debug, Clone, Copy)]
7pub struct Style {
8 pub bar_background: Background,
10 pub bar_border: Border,
12 pub bar_shadow: Shadow,
14
15 pub menu_background: Background,
17 pub menu_border: Border,
19 pub menu_shadow: Shadow,
21
22 pub path: Background,
24 pub path_border: Border,
26}
27
28impl std::default::Default for Style {
29 fn default() -> Self {
30 Self {
31 bar_background: Color::from([0.85; 3]).into(),
32 bar_border: Border {
33 radius: 8.0.into(),
34 ..Default::default()
35 },
36 bar_shadow: Shadow::default(),
37
38 menu_background: Color::from([0.85; 3]).into(),
39 menu_border: Border {
40 radius: 8.0.into(),
41 ..Default::default()
42 },
43 menu_shadow: Shadow {
44 color: Color::from([0.0, 0.0, 0.0, 0.5]),
45 offset: Vector::ZERO,
46 blur_radius: 10.0,
47 },
48 path: Color::from([0.3; 3]).into(),
49 path_border: Border {
50 radius: 6.0.into(),
51 ..Default::default()
52 },
53 }
54 }
55}
56
57pub trait Catalog {
59 type Class<'a>;
61
62 fn default<'a>() -> Self::Class<'a>;
64
65 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style;
67}
68
69impl Catalog for Theme {
70 type Class<'a> = StyleFn<'a, Self, Style>;
71
72 fn default<'a>() -> Self::Class<'a> {
73 Box::new(primary)
74 }
75
76 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
77 class(self, status)
78 }
79}
80
81#[must_use]
83pub fn primary(theme: &Theme, _status: Status) -> Style {
84 let palette = theme.extended_palette();
85
86 Style {
87 bar_background: palette.background.base.color.into(),
88 menu_background: palette.background.base.color.into(),
89 path: palette.primary.weak.color.into(),
90 ..Default::default()
91 }
92}