Skip to content

Commit 44090aa

Browse files
committed
Light theme
1 parent 2ba5164 commit 44090aa

6 files changed

Lines changed: 134 additions & 5 deletions

File tree

appcui/src/system/theme.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod tests;
55
// stock themes
66
mod default;
77
mod dark_gray;
8+
mod light;
89

910

1011
pub use structures::Theme;

appcui/src/system/theme/light.rs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
use super::structures::*;
2+
use crate::{controlattr, graphics::*, ui::common::ControlCharAttributesState};
3+
use appcui_proc_macro::*;
4+
5+
pub(crate) fn new() -> Theme {
6+
Theme {
7+
accordion: AccordionTheme {
8+
text: controlattr!("black,white", "w,white", "black,silver", "gray,?", "black,aqua"),
9+
hotkey: controlattr!("y,white", "dr,white", "dr,silver", "gray,?", "dr,aqua"),
10+
},
11+
desktop: DesktopTheme {
12+
character: char!("Block50,white,black"),
13+
},
14+
text: TextTheme {
15+
normal: charattr!("black"),
16+
hot_key: charattr!("dr"),
17+
inactive: charattr!("gray"),
18+
error: charattr!("r"),
19+
warning: charattr!("olive"),
20+
hovered: charattr!("dg"),
21+
focused: charattr!("black"),
22+
highlighted: charattr!("db"),
23+
enphasized_1: charattr!("dr"),
24+
enphasized_2: charattr!("dg"),
25+
enphasized_3: charattr!("olive"),
26+
},
27+
symbol: SymbolTheme {
28+
inactive: charattr!("gray"),
29+
hovered: charattr!("black,yellow"),
30+
pressed: charattr!("black,silver"),
31+
checked: charattr!("dg"),
32+
unchecked: charattr!("dr"),
33+
unknown: charattr!("olive"),
34+
arrows: charattr!("db"),
35+
close: charattr!("dr"),
36+
maximized: charattr!("black"),
37+
resize: charattr!("db"),
38+
},
39+
tooltip: ToolTipTheme {
40+
text: charattr!("black,aqua"),
41+
arrow: charattr!("green,black"),
42+
},
43+
menu: MenuTheme {
44+
text: controlattr!("black,white", "black,white", "black,silver", "gray,white", "y,magenta"),
45+
hotkey: controlattr!("dr,white", "dr,white", "dr,silver", "gray,white", "w,magenta"),
46+
shortcut: controlattr!("dr,white", "dr,white", "dr,silver", "gray,white", "w,magenta"),
47+
symbol: controlattr!("dg,white", "dg,white", "magenta,silver", "gray,white", "w,magenta"),
48+
},
49+
parent_menu: MenuTheme {
50+
text: controlattr!("black,silver", "black,silver", "black,gray", "gray,silver", "y,gray"),
51+
hotkey: controlattr!("dr,silver", "dr,silver", "dr,gray", "gray,silver", "w,gray"),
52+
shortcut: controlattr!("dr,silver", "dr,silver", "dr,gray", "gray,silver", "w,gray"),
53+
symbol: controlattr!("dg,silver", "dg,silver", "magenta,gray", "gray,silver", "w,gray"),
54+
},
55+
window: WindowTheme {
56+
normal: charattr!("black,white"),
57+
inactive: charattr!("black,silver"),
58+
error: charattr!("black,dr"),
59+
warning: charattr!("black,olive"),
60+
info: charattr!("black,dg"),
61+
},
62+
border: controlattr!("black", "black", "black", "gray", "y,magenta"),
63+
lines: controlattr!("dg", "dg", "y", "gray", "y,magenta"),
64+
button: ButtonTheme {
65+
text: controlattr!("black,silver", "black,gray", "black,y", "gray,black", "black,olive"),
66+
hotkey: controlattr!("magenta,silver", "dr,gray", "magenta,y", "gray,black", "dr,olive"),
67+
shadow: charattr!("black"),
68+
},
69+
tab: TabTheme {
70+
text: controlattr!("black,white", "black,silver", "black,gray", "gray,?", "black,silver"),
71+
hotkey: controlattr!("dr,white", "dr,silver", "dr,gray", "gray,?", "dr,silver"),
72+
},
73+
scrollbar: ScrollBarTheme {
74+
arrow: controlattr!("w,silver", "w,gray", "y,gray", "gray", "w,black"),
75+
bar: controlattr!("w,silver", "w,gray", "y,gray", "gray", "w,black"),
76+
position: controlattr!("w,silver", "w,gray", "y,gray", "gray", "w,black"),
77+
},
78+
searchbar: SearchBarTheme {
79+
normal: charattr!("white,silver"),
80+
focused: charattr!("black,silver"),
81+
count: charattr!("gray,silver"),
82+
},
83+
editor: controlattr!("silver,black", "w,black", "y,black", "gray", "w,magenta"),
84+
list_current_item: ListCurentItemTheme {
85+
focus: charattr!("black,silver"),
86+
over_inactive: charattr!("gray,w"),
87+
over_selection: charattr!("red,w"),
88+
normal: charattr!("y"),
89+
selected: charattr!("?,gray"),
90+
icon: charattr!("gray"),
91+
},
92+
header: HeaderTheme {
93+
text: controlattr!("silver,magenta", "w,magenta", "dr,silver", "gray", "w,pink"),
94+
hotkey: controlattr!("y,magenta", "y,magenta", "r,silver", "gray", "y,pink"),
95+
symbol: controlattr!("silver,magenta", "w,magenta", "r,silver", "gray", "y,pink"),
96+
},
97+
toggle_button: ToggleButtonTheme {
98+
selected: controlattr!("aqua", "dr,w", "dr,y", "gray", "w,black"),
99+
unselected: controlattr!("silver", "black,w", "black,y", "gray", "w,black"),
100+
},
101+
markdown: MarkdownTheme {
102+
text: charattr!("black"),
103+
bold: charattr!("red, flags: Bold"),
104+
italic: charattr!("magenta, flags: Italic"),
105+
link: charattr!("aqua, flags: Underiline"),
106+
code: charattr!("silver, black"),
107+
h1: charattr!("white"),
108+
h2: charattr!("y"),
109+
h3: charattr!("g"),
110+
code_block: charattr!("silver, black"),
111+
ordered_list: charattr!("black"),
112+
unordered_list: charattr!("black"),
113+
table: charattr!("black"),
114+
table_header: charattr!("black, flags: Bold"),
115+
},
116+
progressbar: ProgressBarTheme {
117+
background: Color::Black,
118+
progress: Color::Gray,
119+
text: Color::White,
120+
},
121+
}
122+
}

appcui/src/system/theme/structures.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{graphics::*, ui::common::ControlCharAttributesState};
33
pub enum Themes {
44
Default,
55
DarkGray,
6+
Light,
67
}
78

89
#[derive(Default)]
@@ -161,7 +162,8 @@ impl Theme {
161162
pub fn new(theme: Themes) -> Self {
162163
match theme {
163164
Themes::Default => super::default::new(),
164-
Themes::DarkGray => super::dark_gray::new(),
165+
Themes::DarkGray => super::dark_gray::new(),
166+
Themes::Light => super::light::new(),
165167
}
166168
}
167169
}

docs/chapter-6/img/light_theme.png

136 KB
Loading

examples/demo_app/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const LOGO: [&str; 15] = [
2424

2525
#[Desktop(events = [CommandBarEvents,MenuEvents,DesktopEvents],
2626
overwrite = OnPaint,
27-
commands = [Lists, BaseControls, Images, Animation, Exit, NoArrange, Cascade, Vertical, Horizontal, Grid, DefaultTheme, DarkGrayTheme])]
27+
commands = [Lists, BaseControls, Images, Animation, Exit, NoArrange, Cascade, Vertical, Horizontal, Grid, DefaultTheme, DarkGrayTheme, LightTheme])]
2828
struct MyDesktop {
2929
arrange_method: Option<desktop::ArrangeWindowsMethod>,
3030
menu_arrange: Handle<Menu>,
@@ -84,7 +84,8 @@ impl DesktopEvents for MyDesktop {
8484
self.menu_theme = self.register_menu(menu!("
8585
&Theme,class: MyDesktop, items:[
8686
{&Default,cmd: DefaultTheme, select: true},
87-
{'Dark &Gray',cmd: DarkGrayTheme, select: false}
87+
{'Dark &Gray',cmd: DarkGrayTheme, select: false},
88+
{'&Light',cmd: LightTheme, select: false}
8889
]
8990
"));
9091
}
@@ -112,6 +113,7 @@ impl MenuEvents for MyDesktop {
112113
mydesktop::Commands::Grid => self.arrange_method = Some(desktop::ArrangeWindowsMethod::Grid),
113114
mydesktop::Commands::DefaultTheme => App::set_theme(Theme::new(Themes::Default)),
114115
mydesktop::Commands::DarkGrayTheme => App::set_theme(Theme::new(Themes::DarkGray)),
116+
mydesktop::Commands::LightTheme => App::set_theme(Theme::new(Themes::Light)),
115117
_ => {}
116118
}
117119
let m = self.arrange_method;

examples/theme_switcher/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct FileInformation {
1111
created: NaiveDate,
1212
}
1313

14-
#[Window(events : MenuEvents, commands : New+Save+Open+Exit+DefaultTheme+DarkGrayTheme)]
14+
#[Window(events : MenuEvents, commands : New+Save+Open+Exit+DefaultTheme+DarkGrayTheme+LightTheme)]
1515
struct MyWindow {
1616
h_file: Handle<Menu>,
1717
h_theme: Handle<Menu>,
@@ -37,6 +37,7 @@ impl MyWindow {
3737
"&Theme,class: MyWindow, items=[
3838
{&Default,cmd:DefaultTheme,selected: true},
3939
{'Dark Gray',cmd:DarkGrayTheme, selected: false},
40+
{'&Light',cmd:LightTheme, selected: false}
4041
]"
4142
));
4243

@@ -123,11 +124,12 @@ impl MenuEvents for MyWindow {
123124
let stock_theme = match cmd {
124125
mywindow::Commands::DefaultTheme => Some(Themes::Default),
125126
mywindow::Commands::DarkGrayTheme => Some(Themes::DarkGray),
127+
mywindow::Commands::LightTheme => Some(Themes::Light),
126128
_ => None,
127129
};
128130
if let Some(theme) = stock_theme {
129131
App::set_theme(Theme::new(theme));
130-
}
132+
}
131133
}
132134

133135
fn on_update_menubar(&self, menubar: &mut MenuBar) {

0 commit comments

Comments
 (0)