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

commit5b475d7339f52875fc0e2759b642973c1fd2676e
parente1d30ca126
authorLucas Galante <[email protected]>
date2026-06-25 14:46
Resolve window dragging issue on backplate click by introducing blocks_backplate_drag

 src/context.rs                    | 2 +-
 src/widget/container/container.rs | 1 +
 src/widget/container/layer.rs     | 1 +
 src/widget/container/page.rs      | 1 +
 src/widget/container/paginator.rs | 1 +
 src/widget/container/switcher.rs  | 1 +
 src/widget/display/label.rs       | 2 ++
 src/widget/display/separator.rs   | 1 +
 src/widget/display/status_dot.rs  | 1 +
 src/widget/mod.rs                 | 1 +
 10 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/context.rs b/src/context.rs
index a618bd0..54ec527 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -547,7 +547,7 @@ impl UiContext {
                             if w.is_movable_backplate() {
                                 hit_backplate = true;
                             }
-                        } else {
+                        } else if w.blocks_backplate_drag() {
                             return false;
                         }
                     }
diff --git a/src/widget/container/container.rs b/src/widget/container/container.rs
index 132cc08..7e56ecd 100644
--- a/src/widget/container/container.rs
+++ b/src/widget/container/container.rs
@@ -15,6 +15,7 @@ impl Container {
 
 impl Element for Container {
     fn base(&self) -> Option<&Widget> { Some(&self.base) }
+    fn blocks_backplate_drag(&self) -> bool { false }
     fn base_mut(&mut self) -> Option<&mut Widget> { Some(&mut self.base) }
     fn color(&self) -> [f32; 4] { [0.0, 0.0, 0.0, 0.0] }
     fn as_ptr(&self) -> *mut (dyn Element + 'static) {
diff --git a/src/widget/container/layer.rs b/src/widget/container/layer.rs
index 6afa901..48f7860 100644
--- a/src/widget/container/layer.rs
+++ b/src/widget/container/layer.rs
@@ -31,6 +31,7 @@ impl Layer {
 impl Element for Layer {
     fn base(&self) -> Option<&Widget> { Some(&self.base) }
     fn is_layer(&self) -> bool { true }
+    fn blocks_backplate_drag(&self) -> bool { false }
 
     fn base_mut(&mut self) -> Option<&mut Widget> { Some(&mut self.base) }
     fn as_any(&self) -> &dyn std::any::Any { self }
diff --git a/src/widget/container/page.rs b/src/widget/container/page.rs
index 158eae5..d57da3e 100644
--- a/src/widget/container/page.rs
+++ b/src/widget/container/page.rs
@@ -160,6 +160,7 @@ fn clip_quad(
 impl Element for Page {
     fn base(&self) -> Option<&Widget> { Some(&self.base.base) }
     fn is_page(&self) -> bool { true }
+    fn blocks_backplate_drag(&self) -> bool { false }
 
     fn base_mut(&mut self) -> Option<&mut Widget> { Some(&mut self.base.base) }
     fn as_any(&self) -> &dyn std::any::Any { self }
diff --git a/src/widget/container/paginator.rs b/src/widget/container/paginator.rs
index 47c784d..a39faeb 100644
--- a/src/widget/container/paginator.rs
+++ b/src/widget/container/paginator.rs
@@ -205,6 +205,7 @@ impl Element for Paginator {
     fn rect(&self) -> (f32, f32, f32, f32) {
         (self.x, self.y, self.w, self.h)
     }
+    fn blocks_backplate_drag(&self) -> bool { false }
 
     fn set_rect(&mut self, x: f32, y: f32, w: f32, h: f32) {
         self.x = x;
diff --git a/src/widget/container/switcher.rs b/src/widget/container/switcher.rs
index 9de8822..ea156f2 100644
--- a/src/widget/container/switcher.rs
+++ b/src/widget/container/switcher.rs
@@ -37,6 +37,7 @@ impl Switcher {
 
 impl Element for Switcher {
     crate::impl_widget_base!(Switcher);
+    fn blocks_backplate_drag(&self) -> bool { false }
 
     fn visible(&self) -> bool {
         self.visible
diff --git a/src/widget/display/label.rs b/src/widget/display/label.rs
index 1cb3afe..6843aff 100644
--- a/src/widget/display/label.rs
+++ b/src/widget/display/label.rs
@@ -40,6 +40,7 @@ impl Label {
 
 impl Element for Label {
     crate::impl_widget_base!(Label);
+    fn blocks_backplate_drag(&self) -> bool { false }
 
     fn color(&self) -> [f32; 4] { [0.0, 0.0, 0.0, 0.0] }
 
@@ -69,6 +70,7 @@ impl SectionHeader {
 
 impl Element for SectionHeader {
     crate::impl_widget_base!(SectionHeader);
+    fn blocks_backplate_drag(&self) -> bool { false }
     fn color(&self) -> [f32; 4] { [0.0, 0.0, 0.0, 0.0] }
     fn extra_quads(&self) -> Vec<(f32, f32, f32, f32, [f32; 4])> {
         vec![(self.base.x + 8.0, self.base.y + 22.0, self.base.w - 16.0, 1.0, [0.18, 0.18, 0.27, 1.0])]
diff --git a/src/widget/display/separator.rs b/src/widget/display/separator.rs
index 54ba050..92f7875 100644
--- a/src/widget/display/separator.rs
+++ b/src/widget/display/separator.rs
@@ -19,6 +19,7 @@ impl Element for Separator {
     fn rect(&self) -> (f32, f32, f32, f32) {
         (self.x, self.y, self.w, self.h)
     }
+    fn blocks_backplate_drag(&self) -> bool { false }
     fn as_ptr(&self) -> *mut (dyn Element + 'static) {
         self as *const Self as *mut Self as *mut (dyn Element + 'static)
     }
diff --git a/src/widget/display/status_dot.rs b/src/widget/display/status_dot.rs
index 7b0664a..cd92b50 100644
--- a/src/widget/display/status_dot.rs
+++ b/src/widget/display/status_dot.rs
@@ -29,6 +29,7 @@ impl StatusDot {
 
 impl Element for StatusDot {
     crate::impl_widget_base!(StatusDot);
+    fn blocks_backplate_drag(&self) -> bool { false }
     fn highlight_quad(&self, _ctx: &UiContext) -> Option<(f32, f32, f32, f32, [f32; 4])>{ None }
 
     fn color(&self) -> [f32; 4] {
diff --git a/src/widget/mod.rs b/src/widget/mod.rs
index b243546..cda76b9 100644
--- a/src/widget/mod.rs
+++ b/src/widget/mod.rs
@@ -518,6 +518,7 @@ pub trait Element {
     fn is_layer(&self) -> bool { false }
     fn is_backplate(&self) -> bool { false }
     fn is_movable_backplate(&self) -> bool { false }
+    fn blocks_backplate_drag(&self) -> bool { true }
     fn rounded_corners(&self) -> (bool, bool, bool, bool) { (false, false, false, false) }
 
     fn corner_radius(&self) -> f32 { 12.0 }