rlvgl_core/
theme.rs

1use crate::style::Style;
2use crate::widget::Color;
3
4/// Global theme that can modify widget styles.
5///
6/// Themes provide a simple hook to set initial colors and other stylistic
7/// properties for widgets. Applications can implement this trait to provide
8/// bespoke looks across the UI.
9pub trait Theme {
10    /// Apply the theme to the provided [`Style`].
11    fn apply(&self, style: &mut Style);
12}
13
14/// Simple light theme implementation.
15pub struct LightTheme;
16
17impl Theme for LightTheme {
18    fn apply(&self, style: &mut Style) {
19        style.bg_color = Color(255, 255, 255);
20        style.border_color = Color(0, 0, 0);
21    }
22}
23
24/// Simple dark theme implementation.
25pub struct DarkTheme;
26
27impl Theme for DarkTheme {
28    fn apply(&self, style: &mut Style) {
29        style.bg_color = Color(0, 0, 0);
30        style.border_color = Color(255, 255, 255);
31    }
32}