widget gallery and compositor test bench
fix: focus preset_dropdown inside Ramp on startup and fix key event duplication
src/main.rs | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index b91226c..2673528 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -739,6 +739,14 @@ cascades in cce."
state.widgets[46].set_parent(Some(statusbar_ptr), &mut state.ui_context);
let dropdown_ptr = state.widgets[46].as_ptr_mut();
state.widgets[2].add_child(dropdown_ptr, &mut state.ui_context);
+ } else {
+ state.focused_widget = Some(1);
+ let ramp = unsafe { &mut *(state.widgets[1].as_ptr_mut() as *mut Ramp) };
+ let preset_ptr = &mut ramp.preset_dropdown as *mut Dropdown as *mut (dyn Element + 'static);
+ state.ui_context.set_focused_ptr(preset_ptr);
+ unsafe {
+ (*preset_ptr).focus();
+ }
}
state.apply_layout();
@@ -914,6 +922,22 @@ cascades in cce."
quads.extend(w.all_quads(&self.ui_context));
}
}
+
+ let mut popover_pc = cce_ui::layout::PopoverCollector::new();
+ for (i, w) in self.widgets.iter().enumerate() {
+ if !self.is_widget_visible(i) {
+ continue;
+ }
+ if is_control_panel_child(i) {
+ continue;
+ }
+ if w.popover_rect().is_some() {
+ w.render_popover(&mut popover_pc);
+ }
+ }
+ for (qc, qx, qy, qw, qh) in popover_pc.rects {
+ quads.push((qx, qy, qw, qh, qc));
+ }
}
fn view_rounded_quads(&mut self, quads: &mut Vec<(f32, f32, f32, f32, f32, [f32; 4], (bool, bool, bool, bool))>, size: LogicalSize, _scale: f64) {
@@ -1652,18 +1676,6 @@ full screen background.",
}
}
};
- for (i, w) in self.widgets.iter_mut().enumerate() {
- if !is_visible(i) {
- continue;
- }
- if is_control_panel_child(i) {
- continue;
- }
- if w.keyboard_input(event, &mut self.ui_context) {
- changed = true;
- }
- }
-
let mut handled = false;
if let Some(focused) = self.focused_widget {
if self.widgets[focused].keyboard_input(event, &mut self.ui_context) {
@@ -1672,6 +1684,23 @@ full screen background.",
}
}
+ if !handled {
+ for (i, w) in self.widgets.iter_mut().enumerate() {
+ if Some(i) == self.focused_widget {
+ continue;
+ }
+ if !is_visible(i) {
+ continue;
+ }
+ if is_control_panel_child(i) {
+ continue;
+ }
+ if w.keyboard_input(event, &mut self.ui_context) {
+ changed = true;
+ }
+ }
+ }
+
if event.state == ElementState::Pressed {
let mut page_nav = false;
let mut selected = 0;