FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
docking: craft-libs' one docking model; Tools and Audio Meters are ordinary panels
aiongg365557844457
diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex e1a30cb84..034fe602f 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -1,5 +1,5 @@-//! FilmCraft's panels and workspaces. craft-ui's docking (Frame profile) owns the frame tree,-//! the tab strips, floating windows and gestures (`dock_ui.rs` draws it); this module names the+//! FilmCraft's panels and workspaces. craft-ui's docking owns the frame tree, the tab strips,+//! floating windows and gestures (`dock_ui.rs` draws it); this module names the//! panels, builds the built-in workspaces and draws the Timeline's sequence tabs.use egui::{Align2, Rect, Sense, Stroke, StrokeKind, pos2, vec2};@@ -11,11 +11,6 @@ use craft_ui::layout::{SplitAxis, SplitSize};use crate::icons::{self, Icon};use crate::theme::Tokens;-/// Width of the Tools panel in the factory layouts.-pub const TOOLS_WIDTH: f32 = 64.0;-/// Width of the Audio Meters in the factory layouts.-pub const METERS_WIDTH: f32 = 116.0;-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]pub enum PanelKind {Project,@@ -133,18 +128,6 @@ impl PanelKind {_ => None,}}- /// Narrow chrome-less panels (no tab strip; a slim grip instead).- pub fn compact(self) -> bool {- matches!(self, PanelKind::Tools | PanelKind::AudioMeters)- }- /// The widest the panel may be: Tools and the Audio Meters stay at their factory widths.- pub fn max_width(self) -> Option<f32> {- match self {- PanelKind::Tools => Some(TOOLS_WIDTH),- PanelKind::AudioMeters => Some(METERS_WIDTH),- _ => None,- }- }}/// A FilmCraft panel arrangement: craft-ui's frame tree and floating windows.@@ -381,8 +364,10 @@ pub fn workspace(name: &str) -> Layout {fn workspace_root(name: &str) -> Node<PanelKind> {use PanelKind::*;- use SplitSize::{FixedFirst as FixedA, FixedSecond as FixedB, Ratio};- let bottom_editing = || hsplit(FixedA(TOOLS_WIDTH), tabs(&[Tools], 0), hsplit(FixedB(METERS_WIDTH), tabs(&[Timeline], 0), tabs(&[AudioMeters], 0)));+ use SplitSize::Ratio;+ // Tools | Timeline | Audio Meters. The ratios start Tools about 64 pt and the meters about+ // 116 pt wide in a 1600 pt window; all three resize like any other group.+ let bottom_editing = |tools: f32, timeline: f32| hsplit(Ratio(tools), tabs(&[Tools], 0), hsplit(Ratio(timeline), tabs(&[Timeline], 0), tabs(&[AudioMeters], 0)));match name {"Assembly" => vsplit(Ratio(0.52),@@ -391,41 +376,41 @@ fn workspace_root(name: &str) -> Node<PanelKind> {tabs(&[Project, MediaBrowser, Libraries, Info, Effects, Markers, History], 0),hsplit(Ratio(0.5), tabs(&[Source, EffectControls, AudioClipMixer, Metadata], 0), tabs(&[Program], 0)),),- bottom_editing(),+ bottom_editing(0.04, 0.92),),"Color" => hsplit(- FixedB(340.0),+ Ratio(0.79),vsplit(Ratio(0.58),hsplit(Ratio(0.42), tabs(&[LumetriScopes, Source, EffectControls], 0), tabs(&[Program], 0)),- hsplit(Ratio(0.3), tabs(&[Project, Info, Markers, History], 0), bottom_editing()),+ hsplit(Ratio(0.3), tabs(&[Project, Info, Markers, History], 0), bottom_editing(0.07, 0.86)),),tabs(&[LumetriColor, Effects], 0),),"Effects" => hsplit(- FixedB(320.0),+ Ratio(0.8),vsplit(Ratio(0.5),hsplit(Ratio(0.5), tabs(&[Source, EffectControls, AudioClipMixer], 1), tabs(&[Program], 0)),- hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Info, Markers, History], 0), bottom_editing()),+ hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Info, Markers, History], 0), bottom_editing(0.07, 0.86)),),vsplit(Ratio(0.5), tabs(&[Effects], 0), tabs(&[EssentialGraphics], 0)),),"Audio" => hsplit(- FixedB(320.0),+ Ratio(0.8),vsplit(Ratio(0.5),hsplit(Ratio(0.5), tabs(&[AudioTrackMixer, Source, AudioClipMixer, EffectControls], 0), tabs(&[Program], 0)),- hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Effects, Markers, History], 0), bottom_editing()),+ hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Effects, Markers, History], 0), bottom_editing(0.07, 0.86)),),tabs(&[EssentialSound, TextToSpeech], 0),),"Captions and Graphics" => hsplit(- FixedB(330.0),+ Ratio(0.79),vsplit(Ratio(0.5),hsplit(Ratio(0.4), tabs(&[Text, Source, EffectControls], 0), tabs(&[Program], 0)),- hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Libraries], 0), bottom_editing()),+ hsplit(Ratio(0.3), tabs(&[Project, MediaBrowser, Libraries], 0), bottom_editing(0.07, 0.86)),),tabs(&[EssentialGraphics, Properties], 0),),@@ -436,21 +421,21 @@ fn workspace_root(name: &str) -> Node<PanelKind> {tabs(&[Source, EffectControls, AudioClipMixer, Metadata, LumetriScopes, Text], 0),hsplit(Ratio(0.6), tabs(&[Program], 0), tabs(&[LumetriColor, EssentialGraphics, EssentialSound, TextToSpeech, Properties, AudioTrackMixer], 0)),),- hsplit(Ratio(0.26), tabs(&[Project, MediaBrowser, Libraries, Info, Effects, Markers, History], 0), bottom_editing()),+ hsplit(Ratio(0.26), tabs(&[Project, MediaBrowser, Libraries, Info, Effects, Markers, History], 0), bottom_editing(0.055, 0.9)),),// Editing (default), Learning, Review — Premiere 26 factory layout:// top: Source group | Program | Properties; bottom: Project group | Tools | Timeline | Meters._ => vsplit(Ratio(0.57),hsplit(- FixedB(450.0),+ Ratio(0.72),hsplit(Ratio(0.5), tabs(&[Source, EffectControls, AudioClipMixer, Metadata], 0), tabs(&[Program], 0)),tabs(&[Properties, EssentialGraphics, Text], 0),),hsplit(Ratio(0.29),tabs(&[Project, MediaBrowser, Libraries, Info, Effects, Markers, History], 0),- hsplit(FixedA(TOOLS_WIDTH), tabs(&[Tools], 0), hsplit(FixedB(METERS_WIDTH), tabs(&[Timeline], 0), tabs(&[AudioMeters], 0))),+ bottom_editing(0.06, 0.89),),),}@@ -495,7 +480,9 @@ impl LayoutExt for Layout {if let Some(root) = &self.root {walk(root, &mut out);}- out.extend(self.floating.iter().flat_map(|window| window.groups.iter().filter_map(|group| group.panels.get(group.active).copied())));+ for window in &self.floating {+ walk(&window.root, &mut out);+ }out}@@ -507,7 +494,7 @@ impl LayoutExt for Layout {match n {Node::Split { first, second, .. } => beside_meters(first) || beside_meters(second),Node::Tabs { panels, .. } if panels.as_slice() == [PanelKind::AudioMeters] => {- *n = hsplit(SplitSize::FixedSecond(METERS_WIDTH), tabs(&[PanelKind::Timeline], 0), tabs(&[PanelKind::AudioMeters], 0));+ *n = hsplit(SplitSize::Ratio(0.85), tabs(&[PanelKind::Timeline], 0), tabs(&[PanelKind::AudioMeters], 0));true}_ => false,@@ -763,6 +750,22 @@ mod tests {}}+ fn fixed_splits(node: &Node<PanelKind>) -> usize {+ match node {+ Node::Split { size, first, second, .. } => usize::from(!matches!(size, SplitSize::Ratio(_))) + fixed_splits(first) + fixed_splits(second),+ _ => 0,+ }+ }++ /// Every group of a built-in workspace resizes with the window: no split keeps a fixed size.+ #[test]+ fn workspaces_use_ratio_splits() {+ for w in WORKSPACES {+ let layout = workspace(w);+ assert_eq!(layout.root.as_ref().map_or(0, fixed_splits), 0, "{w}");+ }+ }+/// #284: with Project and Program closed (or every panel closed) a panel still opens.#[test]fn open_near_falls_back_to_the_first_group() {diff --git a/crates/ui-egui/src/dock_ui.rs b/crates/ui-egui/src/dock_ui.rsindex a9cdaff1b..d397499f2 100644--- a/crates/ui-egui/src/dock_ui.rs+++ b/crates/ui-egui/src/dock_ui.rs@@ -1,12 +1,10 @@-//! FilmCraft's panels in craft-ui's shared docking, Frame profile. craft-ui draws the frames, tab-//! strips, floating windows and drag previews and owns the gestures; FilmCraft draws the panel+//! FilmCraft's panels in craft-ui's shared docking. craft-ui draws the frames, tab strips,+//! floating windows and drag previews and owns the gestures; FilmCraft draws the panel//! bodies, the ≡ panel menu, the panel items of each tab's context menu and the Timeline's//! sequence tabs, and maps its control commands onto//! craft-ui's `DockCommand`.-use craft_ui::docking::{- Action, Divider, DockArea, DockCommand, DockContent, DockEvent, DockStyle, FloatSpace, Hit, Layout, PanelLimits, Profile, ResizeEdge, Workspace,-};+use craft_ui::docking::{Action, Divider, DockArea, DockCommand, DockContent, DockEvent, DockStyle, FloatSpace, Hit, Layout, ResizeEdge, Workspace};use egui::{Rect, Sense, Stroke, StrokeKind, vec2};use serde_json::{Value, json};@@ -25,8 +23,6 @@ fn bodies_id() -> egui::Id {area_id().with("bodies")}-/// Height of the move grip above a panel without a tab strip.-const GRIP_H: f32 = 8.0;/// Width of the ≡ panel menu button at the end of each tab strip.const MENU_W: f32 = 26.0;@@ -318,9 +314,11 @@ 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`,- /// `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.+ /// `dock.gutter.<path>` (`a`/`b` per split level), `dock.corner.<outer path>.<inner path>`+ /// where two dividers meet, the same inside floating window `n` as `panel.float.<n>.gutter.…`+ /// and `panel.float.<n>.corner.…`, 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();@@ -338,12 +336,19 @@ impl FilmcraftApp {Some(index) => (format!("panel.float.{index}.resize.{edge:?}"), "Resize floating panel"),None => continue,},- Hit::Divider(Divider::Split(path)) => {- (format!("dock.gutter.{}", path.iter().map(|second| if *second { 'b' } else { 'a' }).collect::<String>()), "gutter")- }+ Hit::Divider(Divider::Split(path)) => (format!("dock.gutter.{}", path_id(path)), "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"),+ Hit::Divider(Divider::Intersection(outer, inner)) => (format!("dock.corner.{}.{}", path_id(outer), path_id(inner)), "gutter corner"),+ Hit::Divider(Divider::WindowSplit(panel, path)) => match window(panel) {+ Some(index) => (format!("panel.float.{index}.gutter.{}", path_id(path)), "gutter"),+ None => continue,+ },+ Hit::Divider(Divider::WindowIntersection(panel, outer, inner)) => match window(panel) {+ Some(index) => (format!("panel.float.{index}.corner.{}.{}", path_id(outer), path_id(inner)), "gutter corner"),+ None => continue,+ },_ => continue,};found.push((entry, *rect, DockArea::hit_id(area_id(), hit)));@@ -360,9 +365,28 @@ impl FilmcraftApp {}}+/// A split path as `a`/`b` per level (first/second child).+fn path_id(path: &[bool]) -> String {+ path.iter().map(|second| if *second { 'b' } else { 'a' }).collect()+}++/// FilmCraft's window is all groups: drops on all four window edges, Ctrl/Cmd-drag undocks, a+/// release over no target cancels, and a floating window's title bar only moves it.fn dock_style(ui: &egui::Ui, t: &Tokens) -> DockStyle {let mut style = DockStyle::from_ui(ui);- style.profile = Profile::Frame;+ style.side_edge_zones = true;+ style.new_dock_zones = false;+ style.maximize_item = true;+ style.close_others_item = true;+ style.command_press_floats = true;+ style.float_on_empty_drop = false;+ style.title_bar_docks = false;+ style.float_hint = true;+ style.wheel_selects_tabs = true;+ style.middle_click_closes_tabs = true;+ style.float_label = "Undock Panel".into();+ style.float_group_label = "Undock Panel Group".into();+ style.close_group_label = "Close Panel Group".into();style.tab_height = t.tab_h;style.gap = t.gap;style.background = t.panel_bg;@@ -395,20 +419,7 @@ impl DockContent<PanelKind> for FilmContent<'_> {fn body(&mut self, ui: &mut egui::Ui, panel: &PanelKind) {let t = self.tokens;let frame = ui.max_rect();- let mut rect = frame;- // Tools and the audio meters have no tab strip: a slim grip on top moves them.- if panel.compact() {- let grip = Rect::from_min_size(rect.min, vec2(rect.width(), GRIP_H.min(rect.height())));- let response = ui.interact(grip, egui::Id::new(("panel-grip", panel.id())), Sense::drag()).on_hover_cursor(egui::CursorIcon::Grab);- self.app.auto.add_response(&format!("panel.drag.{}", panel.id()), &response, "Move panel");- for dx in [-4.0, 0.0, 4.0] {- ui.painter().circle_filled(grip.center() + vec2(dx, 0.0), 1.0, if response.hovered() { t.tab_text_active } else { t.text_faint });- }- if response.drag_started() {- craft_ui::docking::begin_drag(ui.ctx(), area_id(), *panel, frame);- }- rect.min.y = grip.max.y;- }+ let rect = frame;self.bodies.push((*panel, rect, ui.layer_id()));self.app.auto.add(&format!("panel.{}", panel.id()), rect, panel.title());let mut child = ui.new_child(egui::UiBuilder::new().max_rect(rect).id_salt(("panel", panel.id())));@@ -422,14 +433,6 @@ impl DockContent<PanelKind> for FilmContent<'_> {}}- fn limits(&self, panel: &PanelKind) -> PanelLimits {- let mut limits = PanelLimits::default();- if let Some(width) = panel.max_width() {- limits.max.x = width;- }- limits- }-fn logical_label(&self, panel: &PanelKind) -> String {crate::i18n::t(panel.title()).to_string()}@@ -467,11 +470,6 @@ impl DockContent<PanelKind> for FilmContent<'_> {}}- /// Tools and the audio meters are narrow strips without a tab strip.- fn bare(&self, panel: &PanelKind) -> bool {- panel.compact()- }-/// The ≡ menu, and the Timeline's sequence tabs before it while the Timeline is shown./// The sequence tabs take at most two thirds of the strip, so the group's own tabs keep room;/// past that they scroll into their » list.diff --git a/crates/ui-egui/src/panels/keyboard.rs b/crates/ui-egui/src/panels/keyboard.rsindex 403e0a838..bfbea5306 100644--- a/crates/ui-egui/src/panels/keyboard.rs+++ b/crates/ui-egui/src/panels/keyboard.rs@@ -258,7 +258,7 @@ fn panel_under_pointer(app: &FilmcraftApp, ctx: &egui::Context) -> Option<PanelK/// Visible panels in layout order (the active tab of each frame).fn visible_panels(app: &FilmcraftApp) -> Vec<PanelKind> {use crate::dock::LayoutExt as _;- app.ui.dock.visible_panels().into_iter().filter(|p| !p.compact()).collect()+ app.ui.dock.visible_panels()}fn cycle_panel(app: &mut FilmcraftApp, next: bool) -> Value {diff --git a/crates/ui-egui/tests/meters_ui.rs b/crates/ui-egui/tests/meters_ui.rsindex cbd24fd7e..9b3363344 100644--- a/crates/ui-egui/tests/meters_ui.rs+++ b/crates/ui-egui/tests/meters_ui.rs@@ -89,8 +89,7 @@ impl Driver {fn label(&mut self, id: &str) -> String {self.element(id).and_then(|e| e["label"].as_str().map(str::to_string)).unwrap_or_default()}- /// Give the Audio Meters panel `width` points (it sits in a fixed-width split beside the- /// Timeline).+ /// Give the Audio Meters panel `width` points (it sits in a split beside the Timeline).fn meters_width(&mut self, width: f32) {fn set(n: &mut Node<PanelKind>, width: f32) -> bool {match n {diff --git a/crates/ui-egui/tests/shared_docking_ui.rs b/crates/ui-egui/tests/shared_docking_ui.rsindex 5f6904e5d..5a7359266 100644--- a/crates/ui-egui/tests/shared_docking_ui.rs+++ b/crates/ui-egui/tests/shared_docking_ui.rs@@ -39,7 +39,7 @@ impl Docked for Layout {fn layout() -> Layout {root(split(false,- SplitSize::FixedFirst(400.0),+ SplitSize::Ratio(0.3),tabs(&[PanelKind::Project, PanelKind::Info, PanelKind::History], 1),tabs(&[PanelKind::Source, PanelKind::Program], 1),))@@ -334,11 +334,30 @@ fn dropping_on_the_window_edge_docks_beside_the_whole_workspace() {false,SplitSize::Ratio(0.25),tabs(&[PanelKind::Info], 0),- split(false, SplitSize::FixedFirst(400.0), tabs(&[PanelKind::Project, PanelKind::History], 1), tabs(&[PanelKind::Source, PanelKind::Program], 1)),+ split(false, SplitSize::Ratio(0.3), tabs(&[PanelKind::Project, PanelKind::History], 1), tabs(&[PanelKind::Source, PanelKind::Program], 1)),)));}+/// A release over no drop target (the menu bar, the gap between two groups) cancels the drag:+/// nothing floats and nothing moves. Only Ctrl/Cmd or leaving the window floats.+#[test]+fn a_release_over_no_target_cancels_the_drag() {+ let mut app = FilmcraftApp::new(Session::default());+ app.ui.dock = layout();+ let mut h = Harness::builder().with_size(vec2(1200.0, 760.0)).build_eframe(move |_| app);+ for _ in 0..4 {+ step(&mut h);+ }+ let before = h.state().ui.dock.clone();+ let info = rect(&h, "panel.Info");+ for to in [pos2(600.0, 10.0), pos2(info.right() + 2.0, info.center().y)] {+ let from = rect(&h, "panel.tab.Info").center();+ drag(&mut h, from, to, Modifiers::NONE);+ assert_eq!(h.state().ui.dock, before, "release at {to:?}");+ }+}+#[test]fn dock_panel_without_anchor_docks_along_a_workspace_edge() {let mut app = FilmcraftApp::new(Session::default());@@ -709,13 +728,12 @@ fn the_last_docked_group_cannot_float_away() {assert!(app.ui.dock.docked(PanelKind::Project) && !app.ui.dock.docked(PanelKind::Info));}-/// Tools and the audio meters have no tab strip; the grip above each one moves it.+/// Tools and the audio meters are ordinary groups with a tab strip: the meters show their tab,+/// narrow Tools at least its drag bar, and either one joins another group.#[test]-fn tools_and_meters_move_by_their_grips() {+fn tools_and_meters_move_like_any_group() {let mut h = demo_harness();- for panel in [PanelKind::Tools, PanelKind::AudioMeters] {- assert!(h.state().auto.find(&format!("panel.drag.{}", panel.id())).is_some(), "{panel:?} has no grip");- }+ assert!(h.state().auto.find("panel.tab.AudioMeters").is_some(), "the meters have no tab");let from = rect(&h, "panel.drag.Tools").center();let to = rect(&h, "panel.Program").center();drag(&mut h, from, to, Modifiers::NONE);diff --git a/crates/ui-egui/tests/ui_control_input.rs b/crates/ui-egui/tests/ui_control_input.rsindex 15550468f..847882638 100644--- a/crates/ui-egui/tests/ui_control_input.rs+++ b/crates/ui-egui/tests/ui_control_input.rs@@ -115,10 +115,9 @@ fn background_divider(isolated: bool) {d.frames(2, true);d.h.input_mut().events.push(Event::WindowFocused(false));d.ok("ui.key", json!({"key":"ArrowRight"}), false);- assert!(- matches!(d.h.state().ui.dock.root, Some(craft_ui::docking::Node::Split { size: craft_ui::layout::SplitSize::FixedFirst(408.0), .. })),- "control input must work without native activation"- );+ d.frames(2, false);+ let width = d.h.state().auto.find("panel.Project").unwrap().rect[2];+ assert!((width - 408.0).abs() < 0.5, "control input must work without native activation: Project is {width} wide");assert_eq!(d.h.state().session.state.playheads, before_playheads);assert!(Arc::ptr_eq(&d.h.state().session.project, &before_project));assert!(!d.h.state().playback.playing);diff --git a/crates/ui-egui/tests/ui_dock_resize.rs b/crates/ui-egui/tests/ui_dock_resize.rsindex d08657e99..ce4a7bc32 100644--- a/crates/ui-egui/tests/ui_dock_resize.rs+++ b/crates/ui-egui/tests/ui_dock_resize.rs@@ -33,11 +33,15 @@ fn snapshots(h: &mut Harness<'_, FilmcraftApp>, directory: Option<&std::path::Paframes(h, 3);}-fn first_size(h: &Harness<'_, FilmcraftApp>) -> f32 {- match h.state().ui.dock.root {- Some(craft_ui::docking::Node::Split { size: craft_ui::layout::SplitSize::FixedFirst(value), .. }) => value,- ref other => panic!("fixed-size mode changed: {other:?}"),- }+/// The drawn width of the Project panel, the first child of the tests' split, after the layout+/// change has been drawn.+fn first_size(h: &mut Harness<'_, FilmcraftApp>) -> f32 {+ frames(h, 2);+ h.state().auto.find("panel.Project").unwrap().rect[2]+}++fn assert_near(value: f32, expected: f32) {+ assert!((value - expected).abs() < 0.5, "{value} is not {expected}");}#[test]@@ -79,7 +83,7 @@ fn focused_dock_resize_owns_arrows_and_keeps_pointer_dragging() {step(&mut h);h.event(Event::Key { key: Key::ArrowRight, physical_key: None, pressed: false, repeat: false, modifiers: Modifiers::NONE });step(&mut h);- assert_eq!(first_size(&h), 408.0);+ assert_near(first_size(&mut h), 408.0);assert_eq!(h.state().session.state.playheads, before_playheads, "the Timeline shortcut must not seek");assert!(std::sync::Arc::ptr_eq(&h.state().session.project, &before_project));@@ -96,7 +100,7 @@ fn focused_dock_resize_owns_arrows_and_keeps_pointer_dragging() {}h.event(Event::PointerButton { pos: from + vec2(20.0, 0.0), button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });step(&mut h);- assert_eq!(first_size(&h), 428.0);+ assert_near(first_size(&mut h), 428.0);assert_eq!(h.state().session.state.playheads, before_playheads);}@@ -138,7 +142,7 @@ fn space_plays_after_a_pane_is_resized_with_the_pointer() {}h.event(Event::PointerButton { pos: from + vec2(20.0, 0.0), button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });frames(&mut h, 3);- assert_eq!(first_size(&h), 420.0);+ assert_near(first_size(&mut h), 420.0);// A pointer drag leaves no keyboard focus on the divider, so the editor keeps its shortcuts.assert_ne!(h.ctx.memory(|memory| memory.focused()),@@ -178,7 +182,7 @@ fn space_plays_while_any_floating_resize_edge_has_focus() {}}-/// The divider between groups stacked in a floating window has an automation id, and Space plays+/// The divider between groups split 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() {@@ -193,10 +197,10 @@ fn space_plays_while_a_floating_group_divider_has_focus() {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 hit = Hit::Divider(Divider::WindowSplit(PanelKind::Info, vec![]));+ assert!(DockArea::<PanelKind>::hit_rects(&h.ctx, area).iter().any(|(drawn, _)| *drawn == hit), "no window 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");+ let element = h.state().auto.find("panel.float.0.gutter.").expect("the window 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);@@ -207,35 +211,42 @@ fn space_plays_while_a_floating_group_divider_has_focus() {assert!(!h.state().playback.playing);}-/// Tools keeps its factory width: dragging the divider beside it does not widen it.+/// Tools is an ordinary group: the divider beside it widens and narrows it.#[test]-fn the_divider_beside_tools_cannot_widen_it() {+fn the_divider_beside_tools_moves_both_ways() {let app = FilmcraftApp::new(Session::default());let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).build_eframe(move |_| app);frames(&mut h, 4);h.state_mut().ui.dock = craft_ui::docking::Layout {root: Some(craft_ui::docking::Node::Split {axis: craft_ui::layout::SplitAxis::Horizontal,- size: craft_ui::layout::SplitSize::FixedFirst(filmcraft_ui_egui::dock::TOOLS_WIDTH),+ size: craft_ui::layout::SplitSize::Ratio(0.06),first: Box::new(craft_ui::docking::Node::Tabs { panels: vec![PanelKind::Tools], active: 0 }),second: Box::new(craft_ui::docking::Node::Tabs { panels: vec![PanelKind::Timeline], active: 0 }),}),floating: vec![],};frames(&mut h, 3);- let element = h.state().auto.find("dock.gutter.").unwrap();- let from = Rect::from_min_size(pos2(element.rect[0], element.rect[1]), vec2(element.rect[2], element.rect[3])).center();- h.event(Event::PointerMoved(from));- step(&mut h);- h.event(Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });- step(&mut h);- for offset in [10.0, 20.0, 30.0, 40.0] {- h.event(Event::PointerMoved(from + vec2(offset, 0.0)));- step(&mut h);- }- h.event(Event::PointerButton { pos: from + vec2(40.0, 0.0), button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });- frames(&mut h, 3);- assert!(first_size(&h) <= filmcraft_ui_egui::dock::TOOLS_WIDTH, "Tools widened to {}", first_size(&h));- let tools = h.state().auto.find("panel.Tools").unwrap();- assert!(tools.rect[2] <= filmcraft_ui_egui::dock::TOOLS_WIDTH, "Tools drawn {} wide", tools.rect[2]);+ let width = |h: &Harness<'_, FilmcraftApp>| h.state().auto.find("panel.Tools").unwrap().rect[2];+ let before = width(&h);+ let drag = |h: &mut Harness<'_, FilmcraftApp>, dx: f32| {+ let element = h.state().auto.find("dock.gutter.").unwrap();+ let from = Rect::from_min_size(pos2(element.rect[0], element.rect[1]), vec2(element.rect[2], element.rect[3])).center();+ h.event(Event::PointerMoved(from));+ step(h);+ h.event(Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });+ step(h);+ for step_index in 1..=4 {+ h.event(Event::PointerMoved(from + vec2(dx * step_index as f32 / 4.0, 0.0)));+ step(h);+ }+ h.event(Event::PointerButton { pos: from + vec2(dx, 0.0), button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });+ frames(h, 3);+ };+ drag(&mut h, 200.0);+ let wider = width(&h);+ assert!(wider >= before + 150.0, "Tools widened only from {before} to {wider}");+ drag(&mut h, -150.0);+ let narrower = width(&h);+ assert!(narrower <= wider - 100.0, "Tools narrowed only from {wider} to {narrower}");}