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

commit87df378a39835b0677b4125430408dbfb7e0aab5
parentd86e4a727b
authorLucas Galante <[email protected]>
date2026-06-16 17:52
Add Border Radius spinbox to Textbox section of interface page

 src/main.rs            | 26 ++++++++++++++++++++++++++
 src/pages/interface.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index 65141de..12c2f6a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -701,6 +701,8 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
         self.app.interface.color_selector_preview_margin_spinbox.set_parent(None, &mut self.ui_context);
         self.app.interface.textbox_height_spinbox.clear_children(&mut self.ui_context);
         self.app.interface.textbox_height_spinbox.set_parent(None, &mut self.ui_context);
+        self.app.interface.textbox_corner_radius_spinbox.clear_children(&mut self.ui_context);
+        self.app.interface.textbox_corner_radius_spinbox.set_parent(None, &mut self.ui_context);
         self.app.interface.slider_height_spinbox.clear_children(&mut self.ui_context);
         self.app.interface.slider_height_spinbox.set_parent(None, &mut self.ui_context);
         self.app.interface.color_selector_font_selector.clear_children(&mut self.ui_context);
@@ -968,6 +970,7 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
                 
                 // (Textbox child widgets)
                 link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.textbox_height_spinbox, &mut self.ui_context);
+                link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.textbox_corner_radius_spinbox, &mut self.ui_context);
                 
                 // (FontSelector child widgets)
                 link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.font_selector_height_spinbox, &mut self.ui_context);
@@ -1953,6 +1956,9 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
             if self.app.interface.textbox_height_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
                 changed = true;
             }
+            if self.app.interface.textbox_corner_radius_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
+                changed = true;
+            }
             if self.app.interface.slider_height_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
                 changed = true;
             }
@@ -2442,6 +2448,7 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
                     if self.app.interface.section_label_font_selector.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
                     if self.app.interface.nested_section_label_font_selector.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
                     if self.app.interface.textbox_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
+                    if self.app.interface.textbox_corner_radius_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
                     if self.app.interface.slider_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
                     if self.app.interface.font_selector_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
                     if self.app.interface.dropdown_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
@@ -2862,6 +2869,12 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
             if sb.mouse_input(button, state, lx, ly, &mut self.ui_context) && sb.value != old {
                 actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetTextboxHeight(sb.value as u16)));
             }
+            let sb = &mut self.app.interface.textbox_corner_radius_spinbox;
+            if !sb.hit_test(lx, ly, &self.ui_context) { sb.unfocus(); }
+            let old = sb.value;
+            if sb.mouse_input(button, state, lx, ly, &mut self.ui_context) && sb.value != old {
+                actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetTextboxCornerRadius(sb.value as u16)));
+            }
             let sb = &mut self.app.interface.slider_height_spinbox;
             if !sb.hit_test(lx, ly, &self.ui_context) { sb.unfocus(); }
             let old = sb.value;
@@ -3671,6 +3684,9 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
                 if self.app.interface.textbox_height_spinbox.take_change() {
                     actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetTextboxHeight(self.app.interface.textbox_height_spinbox.value as u16)));
                 }
+                if self.app.interface.textbox_corner_radius_spinbox.take_change() {
+                    actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetTextboxCornerRadius(self.app.interface.textbox_corner_radius_spinbox.value as u16)));
+                }
                 if self.app.interface.slider_height_spinbox.take_change() {
                     actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetSliderHeight(self.app.interface.slider_height_spinbox.value as u16)));
                 }
@@ -4516,6 +4532,16 @@ fn collect_popover_rects(w: &dyn cce_ui::widget::Element, popovers: &mut Vec<(f3
                 self.needs_rebuild = true;
                 return true;
             }
+            let sb = &mut self.app.interface.textbox_corner_radius_spinbox;
+            let old = sb.value;
+            if sb.keyboard_input(event, &mut self.ui_context) {
+                let new_val = sb.value;
+                if new_val != old {
+                    self.handle_action(&AppAction::Interface(pages::interface::InterfaceMessage::SetTextboxCornerRadius(new_val as u16)));
+                }
+                self.needs_rebuild = true;
+                return true;
+            }
             let sb = &mut self.app.interface.slider_height_spinbox;
             let old = sb.value;
             if sb.keyboard_input(event, &mut self.ui_context) {
diff --git a/src/pages/interface.rs b/src/pages/interface.rs
index 1340f24..7d90c0e 100644
--- a/src/pages/interface.rs
+++ b/src/pages/interface.rs
@@ -70,6 +70,8 @@ pub struct InterfaceState {
     pub color_selector_preview_margin_spinbox: Spinbox,
     pub textbox_height: u16,
     pub textbox_height_spinbox: Spinbox,
+    pub textbox_corner_radius: u16,
+    pub textbox_corner_radius_spinbox: Spinbox,
     pub slider_height: u16,
     pub slider_height_spinbox: Spinbox,
     pub font_selector_height: u16,
@@ -204,6 +206,8 @@ impl Default for InterfaceState {
             color_selector_preview_margin_spinbox: Spinbox::new(0, 0, 20, 1).with_label("Preview Margin").with_unit("px"),
             textbox_height: 44,
             textbox_height_spinbox: Spinbox::new(44, 10, 100, 1).with_label("Height").with_unit("px"),
+            textbox_corner_radius: 4,
+            textbox_corner_radius_spinbox: Spinbox::new(4, 0, 50, 1).with_label("Border Radius").with_unit("px"),
             slider_height: 28,
             slider_height_spinbox: Spinbox::new(28, 10, 100, 1).with_label("Height").with_unit("px"),
             font_selector_height: 44,
@@ -311,6 +315,7 @@ pub enum InterfaceMessage {
     SetColorSelectorPreviewCornerRadius(u16),
     SetColorSelectorPreviewMargin(u16),
     SetTextboxHeight(u16),
+    SetTextboxCornerRadius(u16),
     SetSliderHeight(u16),
     SetFontSelectorHeight(u16),
     SetDropdownHeight(u16),
@@ -431,6 +436,7 @@ pub fn read_interface_config() -> InterfaceState {
     let color_selector_preview_corner_radius = parse_u16_from(&content, "color_selector_preview_corner_radius", 4);
     let color_selector_preview_margin = parse_u16_from(&content, "color_selector_preview_margin", 0);
     let textbox_height = parse_u16_from(&content, "textbox_height", 44);
+    let textbox_corner_radius = parse_u16_from(&content, "textbox_corner_radius", 4);
     let slider_height = parse_u16_from(&content, "slider_height", 28);
     let font_selector_height = parse_u16_from(&content, "font_selector_height", 44);
     let dropdown_height = parse_u16_from(&content, "dropdown_height", 44);
@@ -521,6 +527,8 @@ pub fn read_interface_config() -> InterfaceState {
         color_selector_preview_margin_spinbox: Spinbox::new(color_selector_preview_margin as i32, 0, 20, 1).with_label("Preview Margin").with_unit("px"),
         textbox_height,
         textbox_height_spinbox: Spinbox::new(textbox_height as i32, 10, 100, 1).with_label("Height").with_unit("px"),
+        textbox_corner_radius,
+        textbox_corner_radius_spinbox: Spinbox::new(textbox_corner_radius as i32, 0, 50, 1).with_label("Border Radius").with_unit("px"),
         slider_height,
         slider_height_spinbox: Spinbox::new(slider_height as i32, 10, 100, 1).with_label("Height").with_unit("px"),
         font_selector_height,
@@ -925,6 +933,11 @@ fn apply_textbox_height(height: u16) {
     cce_ui::layout::set_textbox_height(height as f32);
 }
 
+fn apply_textbox_corner_radius(radius: u16) {
+    write_config_value("textbox_corner_radius", &radius.to_string());
+    cce_ui::layout::set_textbox_corner_radius(radius as f32);
+}
+
 fn apply_slider_height(height: u16) {
     write_config_value("slider_height", &height.to_string());
     cce_ui::layout::set_slider_height(height as f32);
@@ -1614,6 +1627,9 @@ pub fn view(state: &mut InterfaceState, cx: f32, cy: f32, cw: f32, ch: f32, sec_
             state.textbox_height_spinbox.value = state.textbox_height as i32;
             subsec.widget_full(&mut state.textbox_height_spinbox, 44.0, ctx);
             subsec.spacing(8.0);
+            state.textbox_corner_radius_spinbox.value = state.textbox_corner_radius as i32;
+            subsec.widget_full(&mut state.textbox_corner_radius_spinbox, 44.0, ctx);
+            subsec.spacing(8.0);
         });
         sec.spacing(12.0);
 
@@ -1919,6 +1935,10 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
             state.textbox_height = height;
             apply_textbox_height(height);
         }
+        InterfaceMessage::SetTextboxCornerRadius(radius) => {
+            state.textbox_corner_radius = radius;
+            apply_textbox_corner_radius(radius);
+        }
         InterfaceMessage::SetSliderHeight(height) => {
             state.slider_height = height;
             apply_slider_height(height);
@@ -2036,6 +2056,7 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
             let was_ggw_hovered = state.graph_gap_width_spinbox.hovered();
             let was_csh_hovered = state.color_selector_height_spinbox.hovered();
             let was_tbh_hovered = state.textbox_height_spinbox.hovered();
+            let was_tcr_hovered = state.textbox_corner_radius_spinbox.hovered();
             let was_fsh_hovered = state.font_selector_height_spinbox.hovered();
             let was_lm_hovered = state.label_margin_spinbox.hovered();
             let was_mo_hovered = state.menubar_opacity_spinbox.hovered();
@@ -2088,6 +2109,7 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
             state.graph_gap_width_spinbox.set_hovered(was_ggw_hovered);
             state.color_selector_height_spinbox.set_hovered(was_csh_hovered);
             state.textbox_height_spinbox.set_hovered(was_tbh_hovered);
+            state.textbox_corner_radius_spinbox.set_hovered(was_tcr_hovered);
             state.font_selector_height_spinbox.set_hovered(was_fsh_hovered);
             state.label_margin_spinbox.set_hovered(was_lm_hovered);
             state.menubar_opacity_spinbox.set_hovered(was_mo_hovered);
@@ -2923,6 +2945,34 @@ mod tests {
         let _ = fs::remove_file(path_str);
     }
 
+    #[test]
+    fn test_read_write_textbox_corner_radius() {
+        let dir = std::env::temp_dir();
+        let path = dir.join("test_textbox_corner_radius_config.toml");
+        let path_str = path.to_str().unwrap();
+
+        // 1. Initial configuration
+        let initial_content = "[layout]\ngap = 18\nborder_color = \"#374673\"\n";
+        fs::write(path_str, initial_content).unwrap();
+
+        // 2. Parse textbox_corner_radius when missing (should return default 4)
+        let content = fs::read_to_string(path_str).unwrap();
+        let val = parse_u16_from(&content, "textbox_corner_radius", 4);
+        assert_eq!(val, 4);
+
+        // 3. Write textbox_corner_radius config
+        assert!(write_config_value_path(path_str, "textbox_corner_radius", "8"));
+        let updated = fs::read_to_string(path_str).unwrap();
+        assert!(updated.contains("textbox_corner_radius = 8"));
+
+        // 4. Parse textbox_corner_radius when present (should return written value 8)
+        let val2 = parse_u16_from(&updated, "textbox_corner_radius", 4);
+        assert_eq!(val2, 8);
+
+        // Clean up
+        let _ = fs::remove_file(path_str);
+    }
+
     #[test]
     fn test_read_write_textbox_height() {
         let dir = std::env::temp_dir();