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

commit4797dcfbb1bcd37eaebd402f31cf60834813d3ca
parent71cb920c32
authorLucas Galante <[email protected]>
date2026-06-28 07:30
Implement all_rounded_quads recursively and skip flat background quads for rounded widgets

 src/widget/container/backplate.rs | 16 +++++++++++-----
 src/widget/container/plate.rs     | 16 +++++++++++-----
 src/widget/mod.rs                 | 22 ++++++++++++++++++++++
 3 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/widget/container/backplate.rs b/src/widget/container/backplate.rs
index c462dcd..ee8a6c8 100644
--- a/src/widget/container/backplate.rs
+++ b/src/widget/container/backplate.rs
@@ -170,16 +170,22 @@ impl Element for Backplate {
         let mut quads = Vec::new();
         let bg_color = self.color();
         let (wx, wy, ww, wh) = self.rect();
-        if bg_color[3] != 0.0 {
-            quads.push((wx, wy, ww, wh, bg_color));
+        let (r1, r2, r3, r4) = self.rounded_corners();
+        if !(r1 || r2 || r3 || r4) {
+            if bg_color[3] != 0.0 {
+                quads.push((wx, wy, ww, wh, bg_color));
+            }
         }
         for &child_ptr in &self.children {
             let widget = unsafe { &*child_ptr };
             let mut child_quads = Vec::new();
             let cc = widget.color();
-            if cc[3] > 0.0 {
-                let (cx, cy, cw, ch) = widget.rect();
-                child_quads.push((cx, cy, cw, ch, cc));
+            let (cr1, cr2, cr3, cr4) = widget.rounded_corners();
+            if !(cr1 || cr2 || cr3 || cr4) {
+                if cc[3] > 0.0 {
+                    let (cx, cy, cw, ch) = widget.rect();
+                    child_quads.push((cx, cy, cw, ch, cc));
+                }
             }
             child_quads.extend(widget.all_quads(ctx));
 
diff --git a/src/widget/container/plate.rs b/src/widget/container/plate.rs
index 3696d1c..2c9c129 100644
--- a/src/widget/container/plate.rs
+++ b/src/widget/container/plate.rs
@@ -365,14 +365,20 @@ impl Element for Plate {
         }
         let mut quads = Vec::new();
         let (px, py, pw, ph) = self.rect();
-        quads.push((px, py, pw, ph, self.color()));
+        let (r1, r2, r3, r4) = self.rounded_corners();
+        if !(r1 || r2 || r3 || r4) {
+            quads.push((px, py, pw, ph, self.color()));
+        }
 
         for &child_ptr in &self.base.children {
             let widget = unsafe { &*child_ptr };
-            let c = widget.color();
-            if c[3] > 0.0 {
-                let (wx, wy, ww, wh) = widget.rect();
-                quads.push((wx, wy, ww, wh, c));
+            let (cr1, cr2, cr3, cr4) = widget.rounded_corners();
+            if !(cr1 || cr2 || cr3 || cr4) {
+                let c = widget.color();
+                if c[3] > 0.0 {
+                    let (wx, wy, ww, wh) = widget.rect();
+                    quads.push((wx, wy, ww, wh, c));
+                }
             }
             quads.extend(widget.all_quads(ctx));
         }
diff --git a/src/widget/mod.rs b/src/widget/mod.rs
index cf6d21f..15b7db3 100644
--- a/src/widget/mod.rs
+++ b/src/widget/mod.rs
@@ -420,6 +420,10 @@ pub trait Element {
     fn extra_circles(&self) -> Vec<(f32, f32, f32, [f32; 4])> { Vec::new() }
     
     fn all_quads(&self, ctx: &UiContext) -> Vec<(f32, f32, f32, f32, [f32; 4])> {
+        let (r1, r2, r3, r4) = self.rounded_corners();
+        if r1 || r2 || r3 || r4 {
+            return Vec::new();
+        }
         let mut quads = self.extra_quads();
         if let Some(hq) = self.highlight_quad(ctx) {
             if hq.4 != colors::HIGHLIGHT_SECONDARY {
@@ -429,6 +433,24 @@ pub trait Element {
         quads
     }
 
+    fn all_rounded_quads(&self, ctx: &UiContext) -> Vec<(f32, f32, f32, f32, f32, [f32; 4], (bool, bool, bool, bool))> {
+        let mut quads = Vec::new();
+        let (r1, r2, r3, r4) = self.rounded_corners();
+        if r1 || r2 || r3 || r4 {
+            let (x, y, w, h) = self.rect();
+            let radius = self.corner_radius();
+            let c = self.color();
+            if c[3] > 0.0 {
+                quads.push((x, y, w, h, radius, c, (r1, r2, r3, r4)));
+            }
+        }
+        for &child_ptr in &self.children(ctx) {
+            let widget = unsafe { &*child_ptr };
+            quads.extend(widget.all_rounded_quads(ctx));
+        }
+        quads
+    }
+
     fn paint(&mut self, ctx: &mut UiContext) {
         if let Some(hq) = self.highlight_quad(ctx) {
             if hq.4 == colors::HIGHLIGHT_SECONDARY {