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

commitb104a7af0cebef6366a2fe228b3e1d2d95301063
parentc9630ced11
authorLucas Galante <[email protected]>
date2026-06-15 22:04
Support dynamic breadcrumb background color and render its background box

 src/color.rs                       | 33 ++++++++++++++++++++++++++++++++-
 src/widget/container/breadcrumb.rs |  6 +++++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/color.rs b/src/color.rs
index 9b6e673..af24897 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -36,6 +36,7 @@ static OPACITY: RwLock<Option<f32>> = RwLock::new(None);
 static TOGGLE_ON_COLOR: RwLock<[f32; 4]> = RwLock::new(TOGGLE_ON);
 static TOGGLE_OFF_COLOR: RwLock<[f32; 4]> = RwLock::new(TOGGLE_OFF);
 static SCROLLINGLIST_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12, 0.3]);
+static BREADCRUMB_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12, 1.0]);
 
 
 pub fn node_color() -> [f32; 4] {
@@ -83,6 +84,8 @@ fn read_config() -> Option<String> {
 
 fn parse_and_set_colors(content: &str) {
     let mut in_transparency = false;
+    let mut parsed_scrollinglist_bg = None;
+    let mut parsed_breadcrumb_bg = None;
     for line in content.lines() {
         let trimmed = line.trim();
         if trimmed == "[transparency]" {
@@ -151,7 +154,24 @@ fn parse_and_set_colors(content: &str) {
             if let Ok(mut lock) = TOGGLE_OFF_COLOR.write() { *lock = c; }
         }
         if let Some(c) = parse_hex(trimmed, "scrollinglist_bg_color") {
-            if let Ok(mut lock) = SCROLLINGLIST_BG_COLOR.write() { *lock = [c[0], c[1], c[2], 0.3]; }
+            parsed_scrollinglist_bg = Some(c);
+        }
+        if let Some(c) = parse_hex(trimmed, "breadcrumb_bg_color") {
+            parsed_breadcrumb_bg = Some(c);
+        }
+    }
+    if let Some(c) = parsed_scrollinglist_bg {
+        if let Ok(mut lock) = SCROLLINGLIST_BG_COLOR.write() {
+            *lock = [c[0], c[1], c[2], 0.3];
+        }
+    }
+    if let Some(c) = parsed_breadcrumb_bg {
+        if let Ok(mut lock) = BREADCRUMB_BG_COLOR.write() {
+            *lock = [c[0], c[1], c[2], 1.0];
+        }
+    } else if let Some(c) = parsed_scrollinglist_bg {
+        if let Ok(mut lock) = BREADCRUMB_BG_COLOR.write() {
+            *lock = [c[0], c[1], c[2], 1.0];
         }
     }
 }
@@ -338,6 +358,17 @@ pub fn set_scrollinglist_bg_color(color: [f32; 4]) {
     }
 }
 
+pub fn breadcrumb_bg_color() -> [f32; 4] {
+    load_colors_once();
+    *BREADCRUMB_BG_COLOR.read().unwrap()
+}
+
+pub fn set_breadcrumb_bg_color(color: [f32; 4]) {
+    if let Ok(mut lock) = BREADCRUMB_BG_COLOR.write() {
+        *lock = [color[0], color[1], color[2], 1.0];
+    }
+}
+
 #[derive(Debug, Clone, Copy)]
 pub struct Theme {
     pub surface_bg: [f32; 4],
diff --git a/src/widget/container/breadcrumb.rs b/src/widget/container/breadcrumb.rs
index bedf43b..e00b5a5 100644
--- a/src/widget/container/breadcrumb.rs
+++ b/src/widget/container/breadcrumb.rs
@@ -56,7 +56,10 @@ impl Element for Breadcrumb {
     fn rect(&self) -> (f32, f32, f32, f32) { (self.x, self.y, self.w, self.h) }
     fn set_rect(&mut self, x: f32, y: f32, w: f32, h: f32) { self.x = x; self.y = y; self.w = w; self.h = h; }
 
-    fn color(&self) -> [f32; 4] { [0.10, 0.10, 0.14, self.network_opacity] }
+    fn color(&self) -> [f32; 4] {
+        let c = crate::color::breadcrumb_bg_color();
+        [c[0], c[1], c[2], self.network_opacity]
+    }
     fn set_hovered(&mut self, v: bool) { self.hovered = v; }
     fn hovered(&self) -> bool { self.hovered }
 
@@ -84,6 +87,7 @@ impl Element for Breadcrumb {
 
     fn extra_quads(&self) -> Vec<(f32, f32, f32, f32, [f32; 4])> {
         let mut quads = Vec::new();
+        quads.push((self.x, self.y, self.w, self.h, self.color()));
         if let Some(i) = self.hovered_seg {
             let mut cx = self.x + BREADCRUMB_PADDING;
             let segs = self.virtual_segs();