system settings
git clone https://git.lucas.co/cce-system-interface.git
Expose Border Radius configuration under Spinbox section
src/main.rs | 26 +++++++++++++++++++++++++
src/pages/interface.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/src/main.rs b/src/main.rs
index 045e601..a4a2a8e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -690,6 +690,8 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
self.app.interface.grid_min_col_width_spinbox.set_parent(None, &mut self.ui_context);
self.app.interface.spinbox_height_spinbox.clear_children(&mut self.ui_context);
self.app.interface.spinbox_height_spinbox.set_parent(None, &mut self.ui_context);
+ self.app.interface.spinbox_corner_radius_spinbox.clear_children(&mut self.ui_context);
+ self.app.interface.spinbox_corner_radius_spinbox.set_parent(None, &mut self.ui_context);
self.app.interface.toggle_height_spinbox.clear_children(&mut self.ui_context);
self.app.interface.toggle_height_spinbox.set_parent(None, &mut self.ui_context);
self.app.interface.color_selector_height_spinbox.clear_children(&mut self.ui_context);
@@ -957,6 +959,7 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
// (Spinbox child widgets)
link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.spinbox_height_spinbox, &mut self.ui_context);
+ link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.spinbox_corner_radius_spinbox, &mut self.ui_context);
// (ColorSelector child widgets)
link_parent_child(&mut self.page_sec_containers[2], &mut self.app.interface.color_selector_height_spinbox, &mut self.ui_context);
@@ -1909,6 +1912,9 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
if self.app.interface.spinbox_height_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
changed = true;
}
+ if self.app.interface.spinbox_corner_radius_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
+ changed = true;
+ }
if self.app.interface.toggle_height_spinbox.cursor_moved(lx, ly, &mut self.ui_context) {
changed = true;
}
@@ -2414,6 +2420,7 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
if self.app.interface.page_margin_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
if self.app.interface.grid_min_col_width_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
if self.app.interface.spinbox_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
+ if self.app.interface.spinbox_corner_radius_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
if self.app.interface.toggle_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
if self.app.interface.color_selector_height_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
if self.app.interface.color_selector_preview_corner_radius_spinbox.hit_test(lx, ly, &self.ui_context) { clicked_any_focusable = true; }
@@ -2803,6 +2810,12 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
if sb.mouse_input(button, state, lx, ly, &mut self.ui_context) && sb.value != old {
actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetSpinboxHeight(sb.value as u16)));
}
+ let sb = &mut self.app.interface.spinbox_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::SetSpinboxCornerRadius(sb.value as u16)));
+ }
let sb = &mut self.app.interface.toggle_height_spinbox;
if !sb.hit_test(lx, ly, &self.ui_context) { sb.unfocus(); }
let old = sb.value;
@@ -3627,6 +3640,9 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
if self.app.interface.spinbox_height_spinbox.take_change() {
actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetSpinboxHeight(self.app.interface.spinbox_height_spinbox.value as u16)));
}
+ if self.app.interface.spinbox_corner_radius_spinbox.take_change() {
+ actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetSpinboxCornerRadius(self.app.interface.spinbox_corner_radius_spinbox.value as u16)));
+ }
if self.app.interface.toggle_height_spinbox.take_change() {
actions.push(AppAction::Interface(pages::interface::InterfaceMessage::SetToggleHeight(self.app.interface.toggle_height_spinbox.value as u16)));
}
@@ -4437,6 +4453,16 @@ fn collect_popover_rects(w: &dyn clear_ui::widget::Element, popovers: &mut Vec<(
self.needs_rebuild = true;
return true;
}
+ let sb = &mut self.app.interface.spinbox_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::SetSpinboxCornerRadius(new_val as u16)));
+ }
+ self.needs_rebuild = true;
+ return true;
+ }
let sb = &mut self.app.interface.toggle_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 a3196ad..ef5dcf5 100644
--- a/src/pages/interface.rs
+++ b/src/pages/interface.rs
@@ -58,6 +58,8 @@ pub struct InterfaceState {
pub grid_min_col_width_spinbox: Spinbox,
pub spinbox_height: u16,
pub spinbox_height_spinbox: Spinbox,
+ pub spinbox_corner_radius: u16,
+ pub spinbox_corner_radius_spinbox: Spinbox,
pub toggle_height: u16,
pub toggle_height_spinbox: Spinbox,
pub color_selector_height: u16,
@@ -190,6 +192,8 @@ impl Default for InterfaceState {
grid_min_col_width_spinbox: Spinbox::new(260, 100, 1000, 10).with_label("Minimum Width").with_unit("px"),
spinbox_height: 26,
spinbox_height_spinbox: Spinbox::new(26, 10, 100, 1).with_label("Height").with_unit("px"),
+ spinbox_corner_radius: 4,
+ spinbox_corner_radius_spinbox: Spinbox::new(4, 0, 50, 1).with_label("Border Radius").with_unit("px"),
toggle_height: 44,
toggle_height_spinbox: Spinbox::new(44, 10, 100, 1).with_label("Height").with_unit("px"),
color_selector_height: 22,
@@ -302,6 +306,7 @@ pub enum InterfaceMessage {
SetPageMargin(u16),
SetGridMinColWidth(u16),
SetSpinboxHeight(u16),
+ SetSpinboxCornerRadius(u16),
SetToggleHeight(u16),
SetColorSelectorHeight(u16),
SetColorSelectorPreviewCornerRadius(u16),
@@ -420,6 +425,7 @@ pub fn read_interface_config() -> InterfaceState {
let page_margin = parse_u16_from(&content, "page_margin", 20);
let grid_min_col_width = parse_u16_from(&content, "grid_min_col_width", 260);
let spinbox_height = parse_u16_from(&content, "spinbox_height", 26);
+ let spinbox_corner_radius = parse_u16_from(&content, "spinbox_corner_radius", 4);
let toggle_height = parse_u16_from(&content, "toggle_height", 44);
let color_selector_height = parse_u16_from(&content, "color_selector_height", 22);
let color_selector_preview_corner_radius = parse_u16_from(&content, "color_selector_preview_corner_radius", 4);
@@ -503,6 +509,8 @@ pub fn read_interface_config() -> InterfaceState {
grid_min_col_width_spinbox: Spinbox::new(grid_min_col_width as i32, 100, 1000, 10).with_label("Minimum Width").with_unit("px"),
spinbox_height,
spinbox_height_spinbox: Spinbox::new(spinbox_height as i32, 10, 100, 1).with_label("Height").with_unit("px"),
+ spinbox_corner_radius,
+ spinbox_corner_radius_spinbox: Spinbox::new(spinbox_corner_radius as i32, 0, 50, 1).with_label("Border Radius").with_unit("px"),
toggle_height,
toggle_height_spinbox: Spinbox::new(toggle_height as i32, 10, 100, 1).with_label("Height").with_unit("px"),
color_selector_height,
@@ -893,6 +901,11 @@ fn apply_spinbox_height(height: u16) {
clear_ui::layout::set_spinbox_height(height as f32);
}
+fn apply_spinbox_corner_radius(radius: u16) {
+ write_config_value("spinbox_corner_radius", &radius.to_string());
+ clear_ui::layout::set_spinbox_corner_radius(radius as f32);
+}
+
fn apply_toggle_height(height: u16) {
write_config_value("toggle_height", &height.to_string());
clear_ui::layout::set_toggle_height(height as f32);
@@ -1579,6 +1592,10 @@ pub fn view(state: &mut InterfaceState, cx: f32, cy: f32, cw: f32, ch: f32, sec_
state.spinbox_height_spinbox.value = state.spinbox_height as i32;
subsec.widget_full(&mut state.spinbox_height_spinbox, 44.0, ctx);
subsec.spacing(8.0);
+
+ state.spinbox_corner_radius_spinbox.value = state.spinbox_corner_radius as i32;
+ subsec.widget_full(&mut state.spinbox_corner_radius_spinbox, 44.0, ctx);
+ subsec.spacing(8.0);
});
sec.spacing(12.0);
@@ -1885,6 +1902,10 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
state.spinbox_height = height;
apply_spinbox_height(height);
}
+ InterfaceMessage::SetSpinboxCornerRadius(radius) => {
+ state.spinbox_corner_radius = radius;
+ apply_spinbox_corner_radius(radius);
+ }
InterfaceMessage::SetToggleHeight(height) => {
state.toggle_height = height;
apply_toggle_height(height);
@@ -2013,6 +2034,7 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
let was_pm_hovered = state.page_margin_spinbox.hovered();
let was_gm_hovered = state.grid_min_col_width_spinbox.hovered();
let was_sh_hovered = state.spinbox_height_spinbox.hovered();
+ let was_scr_hovered = state.spinbox_corner_radius_spinbox.hovered();
let was_th_hovered = state.toggle_height_spinbox.hovered();
let was_gsg_hovered = state.graph_show_grid_toggle.hovered();
let was_gse_hovered = state.graph_snap_enabled_toggle.hovered();
@@ -2065,6 +2087,7 @@ pub fn update(state: &mut InterfaceState, msg: InterfaceMessage) {
state.page_margin_spinbox.set_hovered(was_pm_hovered);
state.grid_min_col_width_spinbox.set_hovered(was_gm_hovered);
state.spinbox_height_spinbox.set_hovered(was_sh_hovered);
+ state.spinbox_corner_radius_spinbox.set_hovered(was_scr_hovered);
state.toggle_height_spinbox.set_hovered(was_th_hovered);
state.graph_show_grid_toggle.set_hovered(was_gsg_hovered);
state.graph_snap_enabled_toggle.set_hovered(was_gse_hovered);
@@ -2797,6 +2820,34 @@ mod tests {
let _ = fs::remove_file(path_str);
}
+ #[test]
+ fn test_read_write_spinbox_corner_radius() {
+ let dir = std::env::temp_dir();
+ let path = dir.join("test_spinbox_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 spinbox_corner_radius when missing (should return default 4)
+ let content = fs::read_to_string(path_str).unwrap();
+ let val = parse_u16_from(&content, "spinbox_corner_radius", 4);
+ assert_eq!(val, 4);
+
+ // 3. Write spinbox_corner_radius config
+ assert!(write_config_value_path(path_str, "spinbox_corner_radius", "8"));
+ let updated = fs::read_to_string(path_str).unwrap();
+ assert!(updated.contains("spinbox_corner_radius = 8"));
+
+ // 4. Parse spinbox_corner_radius when present (should return written value 8)
+ let val2 = parse_u16_from(&updated, "spinbox_corner_radius", 4);
+ assert_eq!(val2, 8);
+
+ // Clean up
+ let _ = fs::remove_file(path_str);
+ }
+
#[test]
fn test_read_write_spinbox_height() {
let dir = std::env::temp_dir();