reorginise

This commit is contained in:
2026-09-10 02:08:45 +01:00
parent 8696425590
commit bdec970b62
20 changed files with 593 additions and 548 deletions
+35
View File
@@ -0,0 +1,35 @@
use std::collections::BTreeMap;
use iced::window;
use common::{BarModule, Service};
/// Application state: module registry + popup bookkeeping.
pub(crate) struct Bar {
/// Module whose popup is open; None = closed.
pub(crate) active_popup: Option<String>,
/// Module registry keyed by stable module id.
pub(crate) modules: BTreeMap<&'static str, Box<dyn BarModule>>,
/// Surface id of the open popup.
pub(crate) popup_id: Option<window::Id>,
/// Fan-out routing table: module id -> services it wants.
pub(crate) routes: BTreeMap<&'static str, Vec<Service>>,
}
impl Bar {
pub(crate) fn new() -> Self {
// Registry owns construction: adding a module never edits this file.
let modules: BTreeMap<&'static str, Box<dyn BarModule>> =
modules::all().into_iter().map(|m| (m.id(), m)).collect();
let routes = modules
.iter()
.map(|(id, module)| (*id, module.services()))
.collect();
Self {
active_popup: None,
modules,
popup_id: None,
routes,
}
}
}