Skip to main content

display_and_visibility/helpers/
theme.rs

1use bevy::{
2    color::palettes, feathers::theme::ThemeProps, platform::collections::HashMap, prelude::*,
3};
4
5/// Creates a basic example theme props for the radio buttons and number inputs.
6pub fn basic_example_theme(text_color: Color) -> ThemeProps {
7    let mut color = HashMap::new();
8
9    // Radio Button tokens
10    color.insert(bevy::feathers::tokens::RADIO_TEXT, text_color);
11    color.insert(bevy::feathers::tokens::RADIO_MARK, Color::BLACK);
12    color.insert(bevy::feathers::tokens::RADIO_MARK_HOVER, Color::BLACK);
13    color.insert(bevy::feathers::tokens::RADIO_MARK_PRESSED, Color::BLACK);
14
15    color.insert(bevy::feathers::tokens::RADIO_BG, Color::WHITE);
16    color.insert(
17        bevy::feathers::tokens::RADIO_BG_HOVER,
18        palettes::basic::GRAY.into(),
19    );
20    color.insert(
21        bevy::feathers::tokens::RADIO_BG_PRESSED,
22        palettes::basic::GRAY.into(),
23    );
24    color.insert(bevy::feathers::tokens::RADIO_BG_CHECKED, Color::WHITE);
25    color.insert(bevy::feathers::tokens::RADIO_BG_CHECKED_HOVER, Color::BLACK);
26    color.insert(
27        bevy::feathers::tokens::RADIO_BG_CHECKED_PRESSED,
28        Color::BLACK,
29    );
30
31    color.insert(bevy::feathers::tokens::RADIO_BORDER, Color::BLACK);
32    color.insert(
33        bevy::feathers::tokens::RADIO_BORDER_HOVER,
34        palettes::basic::GRAY.into(),
35    );
36    color.insert(
37        bevy::feathers::tokens::RADIO_BORDER_PRESSED,
38        palettes::basic::BLACK.into(),
39    );
40    color.insert(bevy::feathers::tokens::RADIO_BORDER_CHECKED, Color::BLACK);
41    color.insert(
42        bevy::feathers::tokens::RADIO_BORDER_CHECKED_HOVER,
43        Color::BLACK,
44    );
45    color.insert(
46        bevy::feathers::tokens::RADIO_BORDER_CHECKED_PRESSED,
47        Color::BLACK,
48    );
49
50    // Number Input tokens
51    color.insert(bevy::feathers::tokens::TEXT_INPUT_TEXT, text_color);
52    color.insert(bevy::feathers::tokens::TEXT_INPUT_BG, Color::BLACK);
53    color.insert(bevy::feathers::tokens::TEXT_INPUT_LABEL_BG, Color::BLACK);
54
55    color.insert(bevy::feathers::tokens::SLIDER_BAR, Color::WHITE);
56    color.insert(bevy::feathers::tokens::SLIDER_BAR_HOVER, Color::WHITE);
57    color.insert(bevy::feathers::tokens::SLIDER_BAR_PRESSED, Color::WHITE);
58    color.insert(bevy::feathers::tokens::SLIDER_BG, Color::BLACK);
59    color.insert(bevy::feathers::tokens::SLIDER_BG_HOVER, Color::BLACK);
60    color.insert(bevy::feathers::tokens::SLIDER_BG_PRESSED, Color::BLACK);
61
62    color.insert(
63        bevy::feathers::tokens::TEXT_INPUT_CURSOR,
64        bevy::feathers::palette::ACCENT.lighter(0.2),
65    );
66    color.insert(
67        bevy::feathers::tokens::TEXT_INPUT_SELECTION,
68        bevy::feathers::palette::ACCENT,
69    );
70    color.insert(
71        bevy::feathers::tokens::TEXT_INPUT_SELECTION_UNFOCUSED,
72        bevy::feathers::palette::TRANSPARENT,
73    );
74
75    // Checkbox tokens
76    color.insert(bevy::feathers::tokens::CHECKBOX_TEXT, text_color);
77    color.insert(bevy::feathers::tokens::CHECKBOX_BG, Color::BLACK);
78    color.insert(bevy::feathers::tokens::CHECKBOX_MARK, Color::WHITE);
79    color.insert(bevy::feathers::tokens::CHECKBOX_BORDER, Color::BLACK);
80    color.insert(
81        bevy::feathers::tokens::CHECKBOX_BORDER_HOVER,
82        bevy::feathers::palette::GRAY_2,
83    );
84    color.insert(
85        bevy::feathers::tokens::CHECKBOX_BORDER_CHECKED_HOVER,
86        bevy::feathers::palette::GRAY_0,
87    );
88    color.insert(
89        bevy::feathers::tokens::CHECKBOX_BORDER_PRESSED,
90        bevy::feathers::palette::GRAY_1,
91    );
92    color.insert(
93        bevy::feathers::tokens::CHECKBOX_BORDER_CHECKED_PRESSED,
94        bevy::feathers::palette::GRAY_1,
95    );
96    color.insert(
97        bevy::feathers::tokens::CHECKBOX_BORDER_CHECKED,
98        Color::BLACK,
99    );
100    color.insert(
101        bevy::feathers::tokens::CHECKBOX_BG_HOVER,
102        bevy::feathers::palette::GRAY_0,
103    );
104    color.insert(bevy::feathers::tokens::CHECKBOX_BG_CHECKED, Color::BLACK);
105    color.insert(
106        bevy::feathers::tokens::CHECKBOX_BG_CHECKED_HOVER,
107        Color::BLACK,
108    );
109    color.insert(
110        bevy::feathers::tokens::CHECKBOX_BG_CHECKED_PRESSED,
111        bevy::feathers::palette::GRAY_1,
112    );
113    color.insert(bevy::feathers::tokens::CHECKBOX_BG_PRESSED, Color::BLACK);
114    // Feathers Button / Select
115    color.insert(
116        bevy::feathers::tokens::BUTTON_BG,
117        bevy::feathers::palette::TRANSPARENT,
118    );
119    color.insert(
120        bevy::feathers::tokens::BUTTON_BG_HOVER,
121        bevy::feathers::palette::TRANSPARENT,
122    );
123    color.insert(
124        bevy::feathers::tokens::BUTTON_BG_PRESSED,
125        bevy::feathers::palette::TRANSPARENT,
126    );
127    color.insert(
128        bevy::feathers::tokens::MENU_BG,
129        bevy::feathers::palette::GRAY_0,
130    );
131    color.insert(
132        bevy::feathers::tokens::MENU_BORDER,
133        bevy::feathers::palette::GRAY_0,
134    );
135    color.insert(
136        bevy::feathers::tokens::MENUITEM_BG_HOVER,
137        bevy::feathers::palette::TRANSPARENT,
138    );
139    color.insert(
140        bevy::feathers::tokens::MENUITEM_BG_PRESSED,
141        bevy::feathers::palette::TRANSPARENT,
142    );
143    color.insert(
144        bevy::feathers::tokens::MENUITEM_BG_FOCUSED,
145        bevy::feathers::palette::TRANSPARENT,
146    );
147    color.insert(
148        bevy::feathers::tokens::LISTROW_BG,
149        bevy::feathers::palette::TRANSPARENT,
150    );
151    color.insert(
152        bevy::feathers::tokens::LISTROW_BG_HOVER,
153        bevy::feathers::palette::BLACK,
154    );
155    color.insert(
156        bevy::feathers::tokens::LISTROW_BG_SELECTED,
157        bevy::feathers::palette::BLACK,
158    );
159    color.insert(bevy::feathers::tokens::BUTTON_TEXT, text_color);
160    color.insert(bevy::feathers::tokens::LISTROW_TEXT, text_color);
161
162    // Slider tokens
163    color.insert(
164        bevy::feathers::tokens::SLIDER_BG,
165        bevy::feathers::palette::BLACK,
166    );
167    color.insert(
168        bevy::feathers::tokens::SLIDER_BG_HOVER,
169        bevy::feathers::palette::GRAY_0,
170    );
171    color.insert(
172        bevy::feathers::tokens::SLIDER_BG_PRESSED,
173        bevy::feathers::palette::GRAY_1,
174    );
175    color.insert(
176        bevy::feathers::tokens::SLIDER_BAR,
177        bevy::feathers::palette::ACCENT,
178    );
179    color.insert(
180        bevy::feathers::tokens::SLIDER_BAR_HOVER,
181        bevy::feathers::palette::ACCENT.lighter(0.05),
182    );
183    color.insert(
184        bevy::feathers::tokens::SLIDER_BAR_PRESSED,
185        bevy::feathers::palette::ACCENT.lighter(0.1),
186    );
187    color.insert(bevy::feathers::tokens::SLIDER_TEXT, text_color);
188
189    // Main text color
190    color.insert(bevy::feathers::tokens::TEXT_MAIN, text_color);
191    ThemeProps::new_non_contextual(color)
192}