git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitfff435f08070f6958a346cd5cb9084373ddf7dbc
parent120741aa07
authorLucas Galante <[email protected]>
date2026-06-21 09:16
feat: support global window_corner_radius configuration

 src/color.rs                   | 18 ++++++++++++++++++
 src/widget/container/window.rs |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/color.rs b/src/color.rs
index 2bf0287..11f342c 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -43,6 +43,7 @@ static BREADCRUMB_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12, 1.
 static POPOVER_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12, 1.0]);
 static PAGE_COLOR: RwLock<[f32; 4]> = RwLock::new([0.0, 0.0, 0.0, 0.0]);
 static LAYER_COLOR: RwLock<[f32; 4]> = RwLock::new([0.0, 0.0, 0.0, 0.0]);
+static WINDOW_CORNER_RADIUS: RwLock<f32> = RwLock::new(12.0);
 
 
 
@@ -109,6 +110,12 @@ fn parse_and_set_colors(content: &str) {
         }
     }
 
+    if let Some(radius) = val.pointer("/surfaces/window_corner_radius").and_then(|v| v.as_f64()) {
+        if let Ok(mut lock) = WINDOW_CORNER_RADIUS.write() {
+            *lock = radius as f32;
+        }
+    }
+
     let parse_hex = |hex_str: &str| -> Option<[f32; 4]> {
         let hex = hex_str.trim_matches(|c| c == '"' || c == '\'' || c == ' ');
         let hex = hex.trim_start_matches('#');
@@ -472,6 +479,17 @@ pub fn set_popover_bg_color(color: [f32; 4]) {
     }
 }
 
+pub fn window_corner_radius() -> f32 {
+    load_colors_once();
+    *WINDOW_CORNER_RADIUS.read().unwrap()
+}
+
+pub fn set_window_corner_radius(radius: f32) {
+    if let Ok(mut lock) = WINDOW_CORNER_RADIUS.write() {
+        *lock = radius;
+    }
+}
+
 #[derive(Debug, Clone, Copy)]
 pub struct Theme {
     pub surface_bg: [f32; 4],
diff --git a/src/widget/container/window.rs b/src/widget/container/window.rs
index 8a4867f..1183f3d 100644
--- a/src/widget/container/window.rs
+++ b/src/widget/container/window.rs
@@ -22,7 +22,7 @@ impl Window {
             parent: None,
             border_color: None,
             border_thickness: 1.0,
-            radius: 12.0,
+            radius: crate::color::window_corner_radius(),
             background_color: None,
             visible: true,
         }