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