GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Expose ParametersBg collections and scan them all in get_child_widget_for_quad to fix Toggle borders rendering in manual layouts
src/backend/window_runner.rs | 55 +++++++++++++++++++++++++++++++++++
src/widget/container/parameters_bg.rs | 4 +--
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/src/backend/window_runner.rs b/src/backend/window_runner.rs
index f9bc3cd..0dad421 100644
--- a/src/backend/window_runner.rs
+++ b/src/backend/window_runner.rs
@@ -614,6 +614,22 @@ fn get_child_widget_for_quad<'a>(
qx: f32, qy: f32, qw: f32, qh: f32,
) -> &'a dyn crate::widget::Element {
if let Some(pbg) = w.as_any().downcast_ref::<crate::widget::ParametersBg>() {
+ for s_opt in &pbg.sliders {
+ if let Some(s) = s_opt {
+ let (sx, sy, sww, shh) = s.rect();
+ if qx >= sx - 0.1 && qx + qw <= sx + sww + 0.1 && qy >= sy - 0.1 && qy + qh <= sy + shh + 0.1 {
+ return s;
+ }
+ }
+ }
+ for f_opt in &pbg.float3s {
+ if let Some(f) = f_opt {
+ let (fx, fy, fww, fhh) = f.rect();
+ if qx >= fx - 0.1 && qx + qw <= fx + fww + 0.1 && qy >= fy - 0.1 && qy + qh <= fy + fhh + 0.1 {
+ return f;
+ }
+ }
+ }
for sb_opt in &pbg.spinboxes {
if let Some(sb) = sb_opt {
let (sx, sy, sww, shh) = sb.rect();
@@ -630,6 +646,45 @@ fn get_child_widget_for_quad<'a>(
}
}
}
+ for ch_opt in &pbg.choices {
+ if let Some(ch) = ch_opt {
+ let (cx, cy, cww, chh) = ch.rect();
+ if qx >= cx - 0.1 && qx + qw <= cx + cww + 0.1 && qy >= cy - 0.1 && qy + qh <= cy + chh + 0.1 {
+ return ch;
+ }
+ }
+ }
+ for t_opt in &pbg.texts {
+ if let Some(t) = t_opt {
+ let (tx, ty, tww, thh) = t.rect();
+ if qx >= tx - 0.1 && qx + qw <= tx + tww + 0.1 && qy >= ty - 0.1 && qy + qh <= ty + thh + 0.1 {
+ return t;
+ }
+ }
+ }
+ for cb_opt in &pbg.checkboxes {
+ if let Some(cb) = cb_opt {
+ let (cx, cy, cww, chh) = cb.rect();
+ if qx >= cx - 0.1 && qx + qw <= cx + cww + 0.1 && qy >= cy - 0.1 && qy + qh <= cy + chh + 0.1 {
+ return cb;
+ }
+ }
+ }
+ for c_opt in &pbg.colors {
+ if let Some(c) = c_opt {
+ let (cx, cy, cww, chh) = c.rect();
+ if qx >= cx - 0.1 && qx + qw <= cx + cww + 0.1 && qy >= cy - 0.1 && qy + qh <= cy + chh + 0.1 {
+ return c;
+ }
+ }
+ }
+ for &child_ptr in &pbg.children {
+ let child = unsafe { &*child_ptr };
+ let (cx, cy, cww, chh) = child.rect();
+ if qx >= cx - 0.1 && qx + qw <= cx + cww + 0.1 && qy >= cy - 0.1 && qy + qh <= cy + chh + 0.1 {
+ return child;
+ }
+ }
}
if let Some(mc) = w.as_any().downcast_ref::<crate::widget::input::MultiControl>() {
let (bx, by, bw, bh) = mc.add_button.rect();
diff --git a/src/widget/container/parameters_bg.rs b/src/widget/container/parameters_bg.rs
index b14e755..265df53 100644
--- a/src/widget/container/parameters_bg.rs
+++ b/src/widget/container/parameters_bg.rs
@@ -10,8 +10,8 @@ pub struct ParametersBg {
pub focused_param: Option<usize>,
pub code_editor: Option<TextEditorState>,
mouse_pos: Option<(f32, f32)>,
- sliders: Vec<Option<Slider>>,
- float3s: Vec<Option<Float3>>,
+ pub sliders: Vec<Option<Slider>>,
+ pub float3s: Vec<Option<Float3>>,
pub spinboxes: Vec<Option<Spinbox>>,
pub buttons: Vec<Option<Button>>,
pub choices: Vec<Option<Dropdown>>,