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

commit2d66881832c55dd36f360ebcb06c349e1610fcfe
parent675f549b2f
authorLucas Galante <[email protected]>
date2026-07-12 19:29
refactor: base() Option handling dropped (cce-ui flip part 1)

Element::base is guaranteed now — the map/map_or/if-let wrappers around a
base that always exists collapse to direct reads. Behavior-preserving.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018u7qTwzX95dd5ysAkaSCLk

 src/input_handler.rs  | 4 +---
 src/pages/accounts.rs | 2 +-
 src/renderer.rs       | 9 +++++----
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/input_handler.rs b/src/input_handler.rs
index 8a7ed45..c824ff3 100644
--- a/src/input_handler.rs
+++ b/src/input_handler.rs
@@ -244,9 +244,7 @@ impl SystemInterface {
                     }
                 }
                 for (btn, _) in &mut self.page_buttons[self.scrollable_buttons_start_idx..] {
-                    if let Some(base) = btn.base_mut() {
-                        base.y -= actual_dy;
-                    }
+                    btn.base_mut().y -= actual_dy;
                 }
                 self.last_scroll_y = self.scroll_y;
                 return true;
diff --git a/src/pages/accounts.rs b/src/pages/accounts.rs
index acf59aa..9b81042 100644
--- a/src/pages/accounts.rs
+++ b/src/pages/accounts.rs
@@ -894,7 +894,7 @@ mod tests {
         let pc = view(&mut state, 10.0, 20.0, 800.0, 600.0, &mut layout, &mut cce_ui::context::UiContext::new());
         println!("PC BUTTONS COUNT: {}", pc.buttons.len());
         for (i, (btn, _)) in pc.buttons.iter().enumerate() {
-            let base = btn.base().unwrap();
+            let base = btn.base();
             println!(
                 "Button {}: label={:?}, x={}, y={}, w={}, h={}, bg={:?}, hover_bg={:?}, label_color={:?}",
                 i, base.label, base.x, base.y, base.w, base.h, btn.bg, btn.hover_bg, btn.label_color
diff --git a/src/renderer.rs b/src/renderer.rs
index 16ac22a..a03a6a4 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -300,7 +300,7 @@ impl SystemInterface {
                     max_y = max_y.max(y + size);
                 }
                 for (btn, _) in &pc.buttons {
-                    let base = btn.base().unwrap();
+                    let base = btn.base();
                     max_y = max_y.max(base.y + base.h);
                 }
                 let local_max_scroll_y = (max_y - lch).max(0.0);
@@ -316,7 +316,7 @@ impl SystemInterface {
             max_y = max_y.max(y + size);
         }
         for (btn, _) in &pc.buttons {
-            let base = btn.base().unwrap();
+            let base = btn.base();
             max_y = max_y.max(base.y + base.h);
         }
         self.max_scroll_y = (max_y - lch).max(0.0);
@@ -452,7 +452,7 @@ impl SystemInterface {
             texts.push((t.clone(), *size, *x, *y - scroll_offset_y, text_color, font_opt.clone(), final_bounds));
         }
         for (btn, action) in &pc.buttons {
-            let base = btn.base().unwrap();
+            let base = btn.base();
             let bg = btn.bg.unwrap_or([0.16, 0.16, 0.24, 1.0]);
             let hover_bg = btn.hover_bg.unwrap_or([0.25, 0.30, 0.26, 1.0]);
             let wx = base.x * s;
@@ -537,7 +537,8 @@ impl SystemInterface {
                 button_bounds,
             ));
             let mut btn_clone = btn.clone();
-            if let Some(base_mut) = btn_clone.base_mut() {
+            {
+                let base_mut = btn_clone.base_mut();
                 base_mut.x *= s;
                 base_mut.y = (base_mut.y - scroll_offset_y) * s;
                 base_mut.w *= s;