FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
UI.9: register every dock divider; any focused divider keeps shortcuts live
aiongg08816eac8fc3
diff --git a/crates/ui-egui/src/dock_ui.rs b/crates/ui-egui/src/dock_ui.rsindex a95e85f8d..dea65515f 100644--- a/crates/ui-egui/src/dock_ui.rs+++ b/crates/ui-egui/src/dock_ui.rs@@ -305,7 +305,9 @@ impl FilmcraftApp {/// Automation ids for craft-ui's gesture sources: `panel.tab.<Panel>`, `panel.drag.<Panel>`/// (the group's drag bar), `panel.tabs.more.<Panel>`, `panel.float.<n>.move` and `.resize`,- /// and `dock.gutter.<path>` (`a`/`b` per split level).+ /// `dock.gutter.<path>` (`a`/`b` per split level), and `dock.gutter.group.<Panel>`,+ /// `.stack.<Panel>` and `.column.<Panel>` for the dividers below a group or accordion entry and+ /// beside a column, named by the panel they hold first.fn register_dock_hits(&mut self, hits: &[(Hit<PanelKind>, Rect)]) {let window = |panel: &PanelKind| self.ui.dock.floating.iter().position(|window| window.contains(panel));let mut found = Vec::new();@@ -326,6 +328,9 @@ impl FilmcraftApp {Hit::Divider(Divider::Split(path)) => {(format!("dock.gutter.{}", path.iter().map(|second| if *second { 'b' } else { 'a' }).collect::<String>()), "gutter")}+ Hit::Divider(Divider::Group(panel)) => (format!("dock.gutter.group.{}", panel.id()), "gutter"),+ Hit::Divider(Divider::Stack(panel)) => (format!("dock.gutter.stack.{}", panel.id()), "gutter"),+ Hit::Divider(Divider::Column(panel)) => (format!("dock.gutter.column.{}", panel.id()), "gutter"),_ => continue,};found.push((entry, *rect, DockArea::hit_id(area_id(), hit)));diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex fdb145296..c093d0965 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1508,13 +1508,14 @@ impl FilmcraftApp {self.menu_sent = items;}- /// Whether keyboard focus is on a dock divider or a floating panel's resize grip, as drawn last pass.+ /// Whether keyboard focus is on any dock divider or floating-window resize grip, as drawn last pass.fn divider_focused(&self, ctx: &egui::Context) -> bool {+ use craft_ui::docking::{DockArea, Hit};let Some(focused) = ctx.memory(|m| m.focused()) else { return false };- self.auto- .previous+ let area = dock_ui::area_id();+ DockArea::<PanelKind>::hit_rects(ctx, area).iter()- .any(|e| e.response_id == Some(focused) && (e.id.starts_with("dock.gutter.") || (e.id.starts_with("panel.float.") && e.id.contains(".resize"))))+ .any(|(hit, _)| matches!(hit, Hit::Divider(_) | Hit::Resize(..)) && DockArea::hit_id(area, hit) == focused)}fn handle_shortcuts(&mut self, ctx: &egui::Context) {@@ -1524,8 +1525,8 @@ impl FilmcraftApp {self.bindings = menus::bindings(self);self.bindings_rev = self.session.shortcuts.revision;}- // A pane divider or floating-panel grip keeps focus after a pointer drag so arrows can- // nudge it, but it takes no other key: Space and the other shortcuts keep working (#1482).+ // A focused dock divider or floating-window grip takes the arrow keys to nudge it, but no+ // other key: Space and the other shortcuts keep working (#1482).let divider_focused = self.divider_focused(ctx);if (ctx.egui_wants_keyboard_input() && !divider_focused) || self.dialog == Some(Dialog::Shortcuts) {return;diff --git a/crates/ui-egui/tests/ui_dock_resize.rs b/crates/ui-egui/tests/ui_dock_resize.rsindex 50bcc0998..5c7d83249 100644--- a/crates/ui-egui/tests/ui_dock_resize.rs+++ b/crates/ui-egui/tests/ui_dock_resize.rs@@ -177,3 +177,32 @@ fn space_plays_while_any_floating_resize_edge_has_focus() {assert!(!h.state().playback.playing);}}++/// The divider between groups stacked in a floating window has an automation id, and Space plays+/// while it has keyboard focus (#1482).+#[test]+fn space_plays_while_a_floating_group_divider_has_focus() {+ let mut session = Session::default();+ session.execute("file.openDemoProject", json!({})).unwrap();+ let app = FilmcraftApp::new(session);+ let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).build_eframe(move |_| app);+ frames(&mut h, 4);+ let ctx = h.ctx.clone();+ filmcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "window.floatPanel", json!({"panel": "Info", "rect": [300, 200, 400, 400]})).unwrap();+ filmcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "window.dockPanel", json!({"panel": "Project", "anchor": "Info", "zone": "bottom"})).unwrap();+ frames(&mut h, 3);+ use craft_ui::docking::{Divider, DockArea, Hit};+ let area = filmcraft_ui_egui::dock_area_id();+ let hit = Hit::Divider(Divider::Group(PanelKind::Info));+ assert!(DockArea::<PanelKind>::hit_rects(&h.ctx, area).iter().any(|(drawn, _)| *drawn == hit), "no group divider drawn");+ let divider = DockArea::<PanelKind>::hit_id(area, &hit);+ let element = h.state().auto.find("dock.gutter.group.Info").expect("the group divider has no automation id");+ assert_eq!(element.widget_id, Some(format!("{:016x}", divider.value())));+ h.ctx.memory_mut(|memory| memory.request_focus(divider));+ frames(&mut h, 2);+ assert_eq!(h.ctx.memory(|memory| memory.focused()), Some(divider));+ press(&mut h, Key::Space);+ assert!(h.state().playback.playing, "Space must play with the group divider focused");+ press(&mut h, Key::Space);+ assert!(!h.state().playback.playing);+}diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 49d5228e8..328d220a5 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -184,8 +184,10 @@ Time is in ticks (254 016 000 000 per second); commands also accept `seconds`, `Invalid source/target identities and non-finite or out-of-range geometry return an error withthe layout unchanged. `ui.inspect.ui.dock.floating` reports floating windows and theirlogical-point rectangles. `panel.drag.<Panel>` locates the drag bar of each panel's group;-`panel.float.<index>.move` and `.resize` locate floating geometry handles; `ui.docking` lists-every docking gesture source. Named workspace saves include floating windows.+`panel.float.<index>.move` and `.resize` locate floating geometry handles; `dock.gutter.<path>`+locates a split divider (`a`/`b` per split level), and `dock.gutter.group.<Panel>`,+`.stack.<Panel>` and `.column.<Panel>` the dividers below a group or accordion entry and beside a+column, named by the panel they hold first; `ui.docking` lists every docking gesture source. Named workspace saves include floating windows.The panels use craft-ui's shared docking in its Frame profile. Its control commands(`window.panel.move`, `.float`, `.dock`, `.activate`, `.close`, `.closeGroup`, `.closeOthers`,