1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::event::Event;
use crate::theme::Theme;
/// Centralized application state.
///
/// Single source of truth for UI-level flags, the active theme, and
/// built-in command definitions.
#[derive(Debug)]
pub struct AppState {
/// Whether the main event loop should keep running.
pub running: bool,
/// Whether the about screen is shown.
pub show_about: bool,
/// The currently active theme.
pub theme: Theme,
/// Whether the theme picker overlay is open.
pub theme_picker_open: bool,
/// Whether the plugin registry overlay is open.
pub registry_open: bool,
/// Built-in palette commands: `(id, category, label)`.
pub builtin_items: Vec<(super::BuiltinId, String, String)>,
}
impl AppState {
pub fn new(theme: Theme) -> Self {
let builtin_items = super::all_builtins()
.into_iter()
.map(|(id, cat, label)| (id, cat.to_string(), label.to_string()))
.collect();
AppState {
running: true,
show_about: false,
theme,
theme_picker_open: false,
registry_open: false,
builtin_items,
}
}
/// Process a batch of events from the EventBus.
/// Updates internal state in response to theme changes.
pub fn process_events(&mut self, events: &[Event]) {
for event in events {
if let Event::ThemeChanged(theme) = event {
self.theme = theme.clone();
}
}
}
}