From 768fcf230f871cc3dcf0f027fdce0e14ea9aca66 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 22 Nov 2026 23:25:22 +0100 Subject: [PATCH 1/2] WIP: toolbar docks only in dock columns (#16467) Co-Authored-By: Claude Opus 5.5 From 6ae2b47a18610f39e259174c5a77a2311cef4f4d Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 22 Nov 2026 23:38:44 +0100 Subject: [PATCH 2/2] Toolbar docks only in dock columns (#16467) Dragging the toolbar over the canvas offered a box drop area beside it, and a release there docked the toolbar in a frame of the docked tree, with a panel header like a window. The toolbar now sets the dock permission docks_outside_columns(false) (craft-libs#2099, in the pin): the model refuses every frame placement, so no box shows, and a workspace saved with the toolbar in a frame loads with it in a dock column. Tests: the_toolbar_never_docks_beside_the_canvas, a_saved_toolbar_below_the_canvas_loads_in_a_dock_column; both fail without the permission. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/registry.rs | 7 +-- .../src/panels/toolbar_docking_tests.rs | 47 +++++++++++++++++-- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/panels/registry.rs b/crates/ui-egui/src/panels/registry.rs index 00b1eed5d1..482e3a571b 100644 --- a/crates/ui-egui/src/panels/registry.rs +++ b/crates/ui-egui/src/panels/registry.rs @@ -276,12 +276,13 @@ pub(crate) fn registered(panel: &str) -> bool { } /// What may happen to `panel`: the canvas stays docked and open and takes no tabs, but panels open beside it; the -/// toolbar never collapses to icons and never shares its column or tab group; every other panel moves, floats and -/// closes. A locked workspace narrows these itself. +/// toolbar never collapses to icons, never shares its column or tab group and docks only in dock columns, so it is +/// always a vertical strip, never one across the window (#12517); every other panel moves, floats and closes. A +/// locked workspace narrows these itself. pub(crate) fn permissions(panel: &str) -> Permissions { match panel { CANVAS => Permissions::PROTECTED.accepts_splits(true), - TOOLBAR => Permissions::ALL.collapses(false).shares_column(false), + TOOLBAR => Permissions::ALL.collapses(false).shares_column(false).docks_outside_columns(false), _ => Permissions::ALL, } } diff --git a/crates/ui-egui/src/panels/toolbar_docking_tests.rs b/crates/ui-egui/src/panels/toolbar_docking_tests.rs index 0570b46ce5..e0c0823b71 100644 --- a/crates/ui-egui/src/panels/toolbar_docking_tests.rs +++ b/crates/ui-egui/src/panels/toolbar_docking_tests.rs @@ -1,9 +1,11 @@ -//! The toolbar as a dock panel (#12517): its tool flyouts open to the right of the button wherever it is docked, and -//! flip to the left only where they would leave the window. +//! The toolbar as a dock panel (#12517): it is always a vertical strip (it never docks above, below or beside the +//! canvas, only in dock columns), and its tool flyouts open to the right of the button wherever it is docked and flip +//! to the left only where they would leave the window. use super::*; -use crate::panels::registry::TOOLBAR; -use craft::behavior::dock::{Action, DockPlacement, Target}; +use crate::panels::registry::{CANVAS, TOOLBAR}; +use craft::behavior::DockSide; +use craft::behavior::dock::{Action, DockPlacement, PanelPlace, Permissions, Target}; use egui::{PointerButton, Pos2, Rect}; use egui_kittest::Harness; use egui_kittest::kittest::Queryable; @@ -87,3 +89,40 @@ fn flyouts_open_to_the_right_at_the_left_edge() { assert!(button.left() < 80.0, "the toolbar is at the left window edge: {button:?}"); assert!(row.left() >= button.right() - 0.5, "the flyout opens to the right of the button: row {row:?}, button {button:?}"); } + +/// Where the toolbar is: in a frame of the docked tree (`Node`), in a dock column or floating. +fn toolbar_place(app: &PhotocraftApp) -> Option { + app.ui.docking.layout().place(&TOOLBAR.to_owned()) +} + +/// The toolbar never docks across the window: a move beside the canvas on any side is refused and changes nothing, +/// while docking it at either edge still works. +#[test] +fn the_toolbar_never_docks_beside_the_canvas() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + let ctx = app.ctx().clone(); + let before = serde_json::to_value(&app.ui.docking).unwrap(); + for zone in ["top", "bottom", "left", "right"] { + let params = json!({"panel": "toolbar", "anchor": "canvas", "zone": zone}); + assert!(crate::menus::invoke(&mut app, &ctx, "window.panel.move", params).is_err(), "the toolbar docks {zone} of the canvas"); + assert_eq!(serde_json::to_value(&app.ui.docking).unwrap(), before, "{zone}"); + } + crate::menus::invoke(&mut app, &ctx, "window.panel.dock", json!({"panel": "toolbar", "column": true, "side": "end"})).unwrap(); + assert!(matches!(toolbar_place(&app), Some(PanelPlace::Dock { .. })), "{:?}", toolbar_place(&app)); +} + +/// A workspace saved while the toolbar could still dock below the canvas loads with it in a dock column of its own. +#[test] +fn a_saved_toolbar_below_the_canvas_loads_in_a_dock_column() { + let mut old = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + // Unrestricted permissions, as the release before this change let the toolbar dock there. + let below = Action::move_column(TOOLBAR.to_owned(), Target::at(CANVAS.to_owned(), DockPlacement::Split(DockSide::Bottom))); + std::sync::Arc::make_mut(&mut old.ui.docking).apply(below, false, |_: &String| Permissions::ALL).unwrap(); + assert!(matches!(toolbar_place(&old), Some(PanelPlace::Node(_)))); + let saved = crate::panel_docking::snapshot(&old); + + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + crate::panel_docking::load(&mut app, &saved); + assert!(matches!(toolbar_place(&app), Some(PanelPlace::Dock { .. })), "{:?}", toolbar_place(&app)); + assert!(app.ui.docking.layout().contains(&CANVAS.to_owned())); +}