GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Integrate bevel rendering capability natively into Backplate container widget
src/backend/window_runner.rs | 4 ++++
src/widget/container/backplate.rs | 18 ++++++++++++++++++
src/widget/mod.rs | 1 +
3 files changed, 23 insertions(+)
diff --git a/src/backend/window_runner.rs b/src/backend/window_runner.rs
index e15590c..6f3aa38 100644
--- a/src/backend/window_runner.rs
+++ b/src/backend/window_runner.rs
@@ -797,6 +797,10 @@ pub fn push_widget_vertices(w: &dyn crate::widget::Element, sw: f32, sh: f32, cl
push_plate_solid_border_vertices(x, y, ww, h, radii, thickness, sw, sh, color, clip_circle, out);
}
+ if let Some(thickness) = w.plate_bevel() {
+ push_plate_bevel_vertices(x, y, ww, h, radii.top_left, thickness, sw, sh, clip_circle, out);
+ }
+
for (cx, cy, r, t, start, end, qc) in w.extra_arcs() {
push_arc_background_vertices(cx, cy, r, t, start, end, sw, sh, qc, 16, clip_circle, out);
}
diff --git a/src/widget/container/backplate.rs b/src/widget/container/backplate.rs
index bf8eda2..e844a99 100644
--- a/src/widget/container/backplate.rs
+++ b/src/widget/container/backplate.rs
@@ -13,6 +13,8 @@ pub struct Backplate {
pub background_color: Option<[f32; 4]>,
pub visible: bool,
pub movable: bool,
+ pub bevel: bool,
+ pub bevel_thickness: f32,
}
impl Backplate {
@@ -27,6 +29,8 @@ impl Backplate {
background_color: None,
visible: true,
movable: true,
+ bevel: false,
+ bevel_thickness: 1.5,
}
}
@@ -50,6 +54,12 @@ impl Backplate {
self.radius = radius;
self
}
+
+ pub fn with_bevel(mut self, bevel: bool, thickness: f32) -> Self {
+ self.bevel = bevel;
+ self.bevel_thickness = thickness;
+ self
+ }
}
impl Element for Backplate {
@@ -147,6 +157,14 @@ impl Element for Backplate {
self.border_color.map(|c| (c, self.border_thickness))
}
+ fn plate_bevel(&self) -> Option<f32> {
+ if self.bevel {
+ Some(self.bevel_thickness)
+ } else {
+ None
+ }
+ }
+
fn corner_radius(&self) -> f32 {
if self.radius < 0.0 {
crate::color::backplate_corner_radius()
diff --git a/src/widget/mod.rs b/src/widget/mod.rs
index 5097b11..8ff3950 100644
--- a/src/widget/mod.rs
+++ b/src/widget/mod.rs
@@ -420,6 +420,7 @@ pub trait Element {
fn color(&self) -> [f32; 4];
fn solid_border(&self) -> Option<([f32; 4], f32)> { None }
+ fn plate_bevel(&self) -> Option<f32> { None }
fn is_dragging(&self) -> bool { false }
fn drag_update(&mut self, _px: f32, _py: f32) -> bool { false }