GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
fix: implement progressbar background and fill rendering as rounded quads
src/widget/display/progress_bar.rs | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/widget/display/progress_bar.rs b/src/widget/display/progress_bar.rs
index d6f1583..62331d5 100644
--- a/src/widget/display/progress_bar.rs
+++ b/src/widget/display/progress_bar.rs
@@ -34,10 +34,31 @@ impl Element for ProgressBar {
fn color(&self) -> [f32; 4] { colors::progress_bg() }
- fn extra_quads(&self) -> Vec<(f32, f32, f32, f32, [f32; 4])> {
+ fn corner_radius(&self) -> f32 {
+ crate::layout::slider_corner_radius()
+ }
+
+ fn rounded_corners(&self) -> (bool, bool, bool, bool) {
+ (true, true, true, true)
+ }
+
+ fn all_rounded_quads(&self, _ctx: &UiContext) -> Vec<(f32, f32, f32, f32, f32, [f32; 4], (bool, bool, bool, bool))> {
+ if !self.visible() {
+ return Vec::new();
+ }
+ let mut quads = Vec::new();
let top = self.base.label_offset();
let visual_h = self.base.h - top;
+ let radius = self.corner_radius();
+
+ // Progress bar background
+ quads.push((self.base.x, self.base.y + top, self.base.w, visual_h, radius, colors::progress_bg(), (true, true, true, true)));
+
+ // Progress fill
let fill_w = self.base.w * self._value.clamp(0.0, 1.0);
- vec![(self.base.x, self.base.y + top, fill_w, visual_h, colors::progress_fill())]
+ if fill_w > 0.0 {
+ quads.push((self.base.x, self.base.y + top, fill_w, visual_h, radius.min(visual_h / 2.0), colors::progress_fill(), (true, true, true, true)));
+ }
+ quads
}
}