reorginise
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user