git.lucas.co / cce-system-interface
system settings
git clone https://git.lucas.co/cce-system-interface.git

src/pages/mod.rs (4.8K)

  1 pub mod audio;
  2 pub mod bluetooth;
  3 pub mod browser;
  4 pub mod default_apps;
  5 pub mod network;
  6 pub mod storage;
  7 pub mod system_info;
  8 pub mod timers;
  9 pub mod processes;
 10 pub mod services;
 11 pub mod accounts;
 12 pub mod packages;
 13 pub mod notifications;
 14 pub mod power;
 15 
 16 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 17 pub enum Page {
 18     Accounts,
 19     Audio,
 20     Bluetooth,
 21     Browser,
 22     DefaultApps,
 23     Network,
 24     Notifications,
 25     Power,
 26     Storage,
 27     System,
 28     Timers,
 29     Processes,
 30     Services,
 31     Packages,
 32 }
 33 
 34 impl Page {
 35     pub const ALL: [Page; 14] = [
 36         Page::Accounts,
 37         Page::Audio,
 38         Page::Bluetooth,
 39         Page::Browser,
 40         Page::DefaultApps,
 41         Page::Network,
 42         Page::Notifications,
 43         Page::Packages,
 44         Page::Power,
 45         Page::Processes,
 46         Page::Services,
 47         Page::Storage,
 48         Page::System,
 49         Page::Timers,
 50     ];
 51 
 52     pub fn label(self) -> &'static str {
 53         match self {
 54             Page::Accounts => "Accounts",
 55             Page::Audio => "Audio",
 56             Page::Bluetooth => "Bluetooth",
 57             Page::Browser => "Browser",
 58             Page::DefaultApps => "Default Apps",
 59             Page::Network => "Network",
 60             Page::Notifications => "Notifications",
 61             Page::Power => "Power",
 62             Page::Storage => "Storage",
 63             Page::System => "System",
 64             Page::Timers => "Timers",
 65             Page::Processes => "Processes",
 66             Page::Services => "Services",
 67             Page::Packages => "Packages",
 68         }
 69     }
 70 
 71     pub fn icon(self) -> &'static str {
 72         ""
 73     }
 74 
 75     pub fn index(self) -> usize {
 76         Page::ALL.iter().position(|&p| p == self).unwrap()
 77     }
 78 }
 79 
 80 pub trait AppPage {
 81     /// Per-section event/nav widget groups (Phase 6w: SectionContainer dissolved). One
 82     /// inner Vec per section — same count and order as the old section containers (the
 83     /// outer length drives the `sec_focused` flags) — holding the widgets that used to
 84     /// hang under that section's container, in the old link order. The widgets dispatch
 85     /// directly as propagate roots and the groups drive the app-side ctrl-nav.
 86     fn section_widgets(&mut self) -> Vec<Vec<cce_ui::widget::WidgetId>>;
 87 
 88     fn view(
 89         &mut self,
 90         cx: f32,
 91         cy: f32,
 92         cw: f32,
 93         ch: f32,
 94         root_focused: bool,
 95         sec_focused: &[bool],
 96         layout: &mut dyn cce_ui::layout::LayoutStrategy,
 97         ctx: &mut cce_ui::context::UiContext,
 98     ) -> crate::app::PageContent;
 99 
100     fn propagate_widget_changes(&mut self, actions: &mut Vec<crate::app::AppAction>);
101 
102     fn handle_pointer_move(
103         &mut self,
104         _lx: f32,
105         _ly: f32,
106         _actions: &mut Vec<crate::app::AppAction>,
107         _ctx: &mut cce_ui::context::UiContext,
108     ) -> bool {
109         false
110     }
111 
112     fn handle_pointer_down(&mut self, _lx: f32, _ly: f32, _ctx: &mut cce_ui::context::UiContext) -> bool {
113         false
114     }
115 
116     fn handle_pointer_up(&mut self, _ctx: &mut cce_ui::context::UiContext) -> bool {
117         false
118     }
119 
120     /// Extra top-level event-dispatch roots beyond the section containers: the per-row
121     /// widgets that used to hang under a `List`'s ScrollBox (dissolved — the rows now
122     /// dispatch directly; `Adapted` hit-gates presses/wheel so misses fall through).
123     fn extra_dispatch_roots(&mut self) -> Vec<cce_ui::widget::WidgetId> {
124         Vec::new()
125     }
126 
127     /// Refresh the extra dispatch roots' registrations (id-rooted router: roots resolve
128     /// through the registry). The row Vecs are rebuilt on data refresh, so pages
129     /// re-register the current allocations right before each dispatch — the same
130     /// liveness contract the pointer-rooted dispatch had. Default no-op.
131     fn register_extra_dispatch_roots(&mut self, _ctx: &mut cce_ui::context::UiContext) {}
132 
133     /// The dissolved inner lists' wheel (`ScrollBox::mouse_wheel`, hit-scoped). Runs after
134     /// the widget dispatch and before the manual whole-page scroll fallback — the legacy
135     /// "inner ScrollBoxes take the wheel first" order.
136     fn handle_mouse_wheel(&mut self, _delta: &cce_ui::widget::MouseScrollDelta, _lx: f32, _ly: f32) -> bool {
137         false
138     }
139 
140     /// The dissolved inner lists' hover/focus-scoped keyboard scrolling
141     /// (`ScrollBox::keyboard_input`). Runs before the whole-page scroll-key fallback.
142     fn handle_key_input(&mut self, _event: &cce_ui::widget::KeyEvent) -> bool {
143         false
144     }
145 
146     /// Per-frame upkeep for the dissolved inner lists. A `ScrollRegion`'s
147     /// wheel only moves its target; its `tick` is what glides (wheel) or
148     /// coasts (trackpad flick) the drawn offset there — a page hosting one
149     /// must pump it here or the list freezes after the first notch. True =
150     /// the page's geometry changed (the host re-lays it out).
151     fn tick(&mut self, _dt: f32) -> bool {
152         false
153     }
154 }
155 
156