From de9424cece8b880a34f80fe370315211331f5d18 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 06:56:36 -0800 Subject: [PATCH 1/2] Workspace: Tools dropped on the canvas's left edge docks there, and the setting follows A floating Tools panel dropped on the canvas's left edge, right of panels docked on the left, stayed floating unless Window > Toolbars > Keep Tools Beside the Canvas was on. The canvas's left edge is now always a target: a drop there docks Tools beside the canvas and turns the setting on, and a drop on the window's left edge docks it there and turns the setting off, so the menu item's check mark shows where Tools is. This changes one existing behavior: with the setting on and panels docked on the left, a drop on the window's left edge used to dock Tools beside the canvas and keep the setting on. It now docks Tools at the window's edge and turns the setting off. With no panels docked on the left, both edges put Tools in the same place (left of any toolbars made with New Toolbar docked there), so a drop on either docks it where the setting puts it and leaves the setting as it is. So does a drop in the column both edges share when left-side panels are collapsed to icons narrower than the window's edge strip. A release in the frame right after Tools floats out of its place at the window's edge skips the canvas-edge strip, which that frame laid out right of the docked panel. Part of #7837 --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/app.rs | 4 - crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/panel_docking.rs | 1 + crates/ui-egui/src/panel_docking/tests.rs | 174 ++++++++++++++++++---- crates/ui-egui/src/state.rs | 3 +- crates/ui-egui/src/toolbar.rs | 15 +- crates/ui-egui/src/tools_float.rs | 106 +++++++++---- docs/control-protocol.md | 3 +- docs/mcp.md | 13 +- docs/target-app-parity.md | 2 +- 11 files changed, 247 insertions(+), 78 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index b6da21331e..3707c3d96b 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -506,7 +506,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "window.toolsBesideCanvas", "Keep Tools Beside the Canvas", "", - "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", + "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge turns it on, and on the window's left edge turns it off. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", ), ( "window.floatTools", diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index e3d2a13d64..59efe943d0 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -602,10 +602,6 @@ impl VectorcraftApp { if self.ui.toolbar && self.ui.screen_mode < 3 { tools_float::set_window_dock_zone(&ctx, ui.available_rect_before_wrap()); } - if !self.ui.tools_beside_canvas { - // A canvas-edge target left from before the setting was turned off docks nothing. - tools_float::clear_canvas_dock_zone(&ctx); - } // Beside the canvas, docked Tools draws inside the canvas panel (`toolbar::show_beside_canvas`). // So does Tools docked on the right, left of the panels. if self.ui.toolbar && self.ui.screen_mode < 3 && ((!self.ui.tools_beside_canvas && !self.ui.toolbar_right) || self.ui.toolbar_pos.is_some()) { diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 677b804720..a7fc209e5e 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -507,7 +507,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "window.toolsBesideCanvas", "Keep Tools Beside the Canvas", "", - "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", + "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge turns it on, and on the window's left edge turns it off. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", ), ( "window.floatTools", diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 0a4f01879d..8f98ee50c0 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -1128,6 +1128,7 @@ fn known(action: &Action) -> bool { pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) { let area = area_id(); let ctx = ui.ctx().clone(); + crate::tools_float::set_dock_area_left(&ctx, ui.available_rect_before_wrap().left()); let changed_workspace = ctx.data_mut(|data| { let previous = data.get_temp::(area.with("generation")); data.insert_temp(area.with("generation"), app.ui.docking_generation); diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index 266f423838..2c05eb444f 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -833,57 +833,176 @@ fn keep_tools_beside_the_canvas_toggles_and_rejects_a_value_that_is_not_true_or_ assert!(!h.app.ui.tools_beside_canvas, "a bad value changes nothing"); } -/// Off, only the window's edge docks a floating Tools panel; on, the canvas's edge does too, and -/// both dock it beside the canvas. +/// Whichever way the setting is, the canvas's left edge, right of a left-side dock, docks a +/// floating Tools panel beside the canvas and turns the setting on, and the window's left edge +/// docks it outside the dock and turns the setting off; the menu item's check mark follows. #[test] -fn tools_redock_at_the_targets_of_the_chosen_placement() { +fn tools_dropped_on_a_left_edge_dock_there_and_the_setting_follows() { for beside in [false, true] { let mut h = Harness::new(); keep_tools_beside_canvas(&mut h, beside); h.app.run("window.panel.dock", json!({"panel": "layers", "side": "Start"})).unwrap(); - for at_window_edge in [false, true] { + for at_window_edge in [false, true, false] { h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); settle(&mut h); let canvas = h.app.canvas_rect.unwrap(); let canvas_edge = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())); - assert_eq!(canvas_edge.is_some(), beside, "a canvas-edge target only while kept beside the canvas"); - let canvas_edge = canvas_edge.map_or(pos2(canvas.left() + 12.0, canvas.center().y), |r| r.center()); - let target = if at_window_edge { pos2(12.0, canvas.center().y) } else { canvas_edge }; + let canvas_edge = canvas_edge.expect("the canvas's left edge is a target whichever way the setting is"); + assert!(canvas_edge.left() > 60.0, "right of the left-side dock: {canvas_edge:?}"); + let target = if at_window_edge { pos2(12.0, canvas.center().y) } else { canvas_edge.center() }; h.drag(pos2(620.0, 307.0), target); - if !beside && !at_window_edge { - assert!(h.app.ui.toolbar_pos.is_some(), "the canvas's edge does not dock Tools while the setting is off"); - continue; - } - assert_eq!(h.app.ui.toolbar_pos, None, "beside: {beside}, at the window edge: {at_window_edge}"); + let case = format!("set before: {beside}, at the window edge: {at_window_edge}"); + assert_eq!(h.app.ui.toolbar_pos, None, "{case}"); + assert_eq!(h.app.ui.tools_beside_canvas, !at_window_edge, "{case}"); + assert_eq!(crate::menus::checked(&h.app, "window.toolsBesideCanvas", &json!({})), Some(!at_window_edge), "{case}"); settle(&mut h); - assert_eq!(tools_place(&h), Some(beside), "beside: {beside}, at the window edge: {at_window_edge}"); + assert_eq!(tools_place(&h), Some(!at_window_edge), "{case}"); } } } -/// Turning the setting off while Tools floats forgets the canvas-edge target, and turning it on -/// leaves a floating Tools panel floating. +/// With no panels docked on the left, the canvas's left edge and the window's left edge overlap, +/// and a drop there docks Tools where the setting puts it, leaving the setting as it is. #[test] -fn toggling_while_tools_floats_keeps_it_floating_and_drops_the_canvas_target() { +fn tools_dropped_where_the_left_edges_overlap_keep_the_setting() { + for beside in [false, true] { + let mut h = Harness::new(); + keep_tools_beside_canvas(&mut h, beside); + h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); + settle(&mut h); + let canvas_edge = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target"); + assert!(canvas_edge.left() < 30.0, "no panels on the left: {canvas_edge:?}"); + h.drag(pos2(620.0, 307.0), pos2(canvas_edge.left() + 4.0, canvas_edge.center().y)); + assert_eq!(h.app.ui.toolbar_pos, None, "set before: {beside}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "the setting is unchanged"); + settle(&mut h); + let tools = docked_tools(&h); + assert!(tools.left() < 10.0, "docked at the left edge, set before: {beside}: {tools:?}"); + assert!(tools.right() <= h.app.canvas_rect.unwrap().left() + 1.0, "left of the canvas: {tools:?}"); + } +} + +/// A toolbar made with New Toolbar docked on the left, and no panels there: Tools docks left of the +/// toolbar's lane either way, so a drop on the canvas's edge, right of the lane, keeps the setting. +#[test] +fn tools_dropped_beside_a_left_toolbar_lane_keep_the_setting() { + for beside in [false, true] { + let mut h = Harness::new(); + keep_tools_beside_canvas(&mut h, beside); + h.app.run("window.toolbar.new", json!({"name": "Mine"})).unwrap(); + h.app.run("window.toolbar.dock", json!({"name": "Mine", "side": "left"})).unwrap(); + h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); + settle(&mut h); + let canvas_edge = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target"); + assert!(canvas_edge.left() > 30.0, "right of the toolbar lane: {canvas_edge:?}"); + h.drag(pos2(620.0, 307.0), pos2(canvas_edge.right() - 4.0, canvas_edge.center().y)); + assert_eq!(h.app.ui.toolbar_pos, None, "set before: {beside}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "the setting is unchanged"); + settle(&mut h); + assert!(docked_tools(&h).left() < 10.0, "left of the lane, set before: {beside}"); + } +} + +/// Dragged out of the panel docked at the window's edge and released in the next frame, right of +/// where the panel was, Tools stays floating and the setting stays off. +#[test] +fn tools_released_as_they_float_from_the_window_edge_keep_floating() { + let mut h = Harness::new(); + let docked = docked_tools(&h); + let title = docked.min + vec2(20.0, 12.0); + h.frame(vec![Event::PointerMoved(title), button(title, true)]); + h.frame(vec![Event::PointerMoved(title + vec2(0.0, 10.0))]); + let out = pos2(docked.right().max(crate::toolbar::WIDTH) + 8.0, title.y + 10.0); + h.frame(vec![Event::PointerMoved(out)]); + assert!(h.app.ui.toolbar_pos.is_some(), "dragged out of the docked panel, Tools floats"); + h.frame(vec![button(out, false)]); + settle(&mut h); + assert!(h.app.ui.toolbar_pos.is_some(), "the strip laid out right of the docked panel docks nothing"); + assert!(!h.app.ui.tools_beside_canvas); +} + +/// A drop on the right edge, or a click on the title bar of Tools floating over the canvas's left +/// edge, leaves the setting as it is. +#[test] +fn tools_docked_on_the_right_or_clicked_leave_the_setting() { + for beside in [false, true] { + let mut h = Harness::new(); + keep_tools_beside_canvas(&mut h, beside); + h.app.run("window.panel.dock", json!({"panel": "layers", "side": "Start"})).unwrap(); + h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); + settle(&mut h); + h.drag(pos2(620.0, 307.0), pos2(SCREEN.right() - 10.0, 500.0)); + assert_eq!((h.app.ui.toolbar_pos, h.app.ui.toolbar_right), (None, true), "set before: {beside}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "docked on the right, the setting is unchanged"); + let canvas_edge = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target"); + h.app.run("window.panel.float", json!({"panel": "tools", "x": canvas_edge.left(), "y": 300})).unwrap(); + settle(&mut h); + let [x, y] = h.app.ui.toolbar_pos.unwrap(); + let title = pos2(x + 12.0, y + 7.0); + assert!(canvas_edge.contains(title), "the title bar is over the canvas's edge: {title:?} {canvas_edge:?}"); + h.click(title); + assert!(h.app.ui.toolbar_pos.is_some(), "a click docks nothing, set before: {beside}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "a click leaves the setting"); + } +} + +/// A left-side dock collapsed to icons is narrower than the window's strip: only the column the +/// two strips share keeps the setting, and each strip's own part docks at its place. +#[test] +fn tools_dropped_beside_a_collapsed_left_dock_follow_the_strip_dropped_on() { + let mut h = Harness::new(); + h.app.run("window.panel.dock", json!({"panel": "layers", "side": "Start"})).unwrap(); + h.app.run("window.collapseDock", json!({"collapsed": true})).unwrap(); + let float = |h: &mut Harness| { + h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); + settle(h); + h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target") + }; + let zone = float(&mut h); + let window_strip = crate::toolbar::WIDTH; + assert!(zone.left() > 10.0 && zone.left() < window_strip - 4.0, "an icon column narrower than the window's strip: {zone:?}"); + let y = zone.center().y; + // Beside the canvas: right of the icon column; at the window's edge: left of it. + let placed_beside = |h: &mut Harness, icons: Rect| { + settle(h); + let tools = docked_tools(h); + if tools.left() >= icons.left() - 1.0 { + Some(true) + } else if tools.left() < 10.0 { + Some(false) + } else { + None + } + }; + // Right of the window's strip: beside the canvas. + h.drag(pos2(620.0, 307.0), pos2(window_strip + 4.0, y)); + assert_eq!((h.app.ui.toolbar_pos, h.app.ui.tools_beside_canvas), (None, true)); + assert_eq!(placed_beside(&mut h, zone), Some(true)); + // In the shared column: where the setting puts it, the setting unchanged. + let zone = float(&mut h); + h.drag(pos2(620.0, 307.0), pos2(zone.left() + 2.0, y)); + assert_eq!((h.app.ui.toolbar_pos, h.app.ui.tools_beside_canvas), (None, true)); + assert_eq!(placed_beside(&mut h, zone), Some(true)); + // Left of the icon column: at the window's edge. + let zone = float(&mut h); + h.drag(pos2(620.0, 307.0), pos2(zone.left() / 2.0, y)); + assert_eq!((h.app.ui.toolbar_pos, h.app.ui.tools_beside_canvas), (None, false)); + assert_eq!(placed_beside(&mut h, zone), Some(false)); +} + +/// Turning the setting on or off while Tools floats leaves it floating. +#[test] +fn toggling_while_tools_floats_keeps_it_floating() { let mut h = Harness::new(); h.app.run("window.panel.dock", json!({"panel": "layers", "side": "Start"})).unwrap(); keep_tools_beside_canvas(&mut h, true); h.app.run("window.panel.float", json!({"panel": "tools", "x": 600, "y": 300})).unwrap(); settle(&mut h); - let zone = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target"); - keep_tools_beside_canvas(&mut h, false); - assert!(h.app.ui.toolbar_pos.is_some(), "turning it off leaves Tools floating"); - assert!(h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).is_none(), "the canvas-edge target is gone"); - h.drag(pos2(620.0, 307.0), zone.center()); - assert!(h.app.ui.toolbar_pos.is_some(), "the old canvas-edge strip docks nothing"); let [x, y] = h.app.ui.toolbar_pos.unwrap(); + keep_tools_beside_canvas(&mut h, false); + assert_eq!(h.app.ui.toolbar_pos, Some([x, y]), "turning it off leaves Tools floating where it was"); keep_tools_beside_canvas(&mut h, true); assert_eq!(h.app.ui.toolbar_pos, Some([x, y]), "turning it on leaves Tools floating where it was"); - keep_tools_beside_canvas(&mut h, false); - h.drag(pos2(x + 20.0, y + 7.0), pos2(12.0, zone.center().y)); - assert_eq!(h.app.ui.toolbar_pos, None); - settle(&mut h); - assert_eq!(tools_place(&h), Some(false)); } /// The setting is kept with a workspace; state and workspaces saved without it keep Tools at the @@ -980,6 +1099,7 @@ fn tools_redock_at_window_edge_above_and_below_canvas() { assert!(panel.center().y < canvas.top() || panel.center().y > canvas.bottom()); h.drag(pos2(620.0, 307.0), pos2(12.0, panel.center().y)); assert_eq!(h.app.ui.toolbar_pos, None, "window-edge drop, beside: {beside}, above the canvas: {above}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "no panels on the left: the setting is unchanged"); settle(&mut h); let tools = docked_tools(&h); let panel = h.tab(if above { "layers" } else { "properties" }).unwrap(); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index ac241a5ebd..37edb59d6d 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -542,7 +542,8 @@ pub struct UiState { pub toolbar_pos: Option<[f32; 2]>, /// The docked Tools panel sits between the left-side panels and the canvas instead of at the /// window's left edge (Window › Toolbars › Keep Tools Beside the Canvas, - /// `window.toolsBesideCanvas`). Off by default, and off in state saved without it. + /// `window.toolsBesideCanvas`). Dropping Tools on the canvas's left edge turns it on, and on the + /// window's left edge turns it off. Off by default, and off in state saved without it. #[serde(default)] pub tools_beside_canvas: bool, /// The docked Tools panel stands on the right, between the canvas and the panels, instead of on diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 8afa8f571a..9a6ae8c55f 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -127,21 +127,20 @@ pub(crate) fn docked_width(ui: &crate::state::UiState) -> f32 { } } -/// With `UiState::tools_beside_canvas` on, the canvas-edge redocking target, registered even -/// while Tools floats, and the docked panel, which follows the canvas's left edge as dock columns -/// resize, collapse or hide. With it off, `app.rs` draws Tools before the docking layout. +/// The canvas-edge redocking targets, registered even while Tools floats, whichever way +/// `UiState::tools_beside_canvas` is (a drop on the left one turns it on), and, with it on, the +/// docked panel, which follows the canvas's left edge as dock columns resize, collapse or hide. +/// With it off, `app.rs` draws Tools before the docking layout. /// -/// The canvas's right edge, left of the panels, is a redocking target too, and Tools docked there -/// (`UiState::toolbar_right`) is drawn at it whichever way the setting is. +/// Tools docked on the canvas's right edge, left of the panels (`UiState::toolbar_right`), is +/// drawn there whichever way the setting is. pub(crate) fn show_beside_canvas(app: &mut VectorcraftApp, ui: &mut Ui) { if !app.ui.toolbar || app.ui.screen_mode >= 3 { return; } let canvas = ui.available_rect_before_wrap(); crate::tools_float::set_right_dock_zone(ui.ctx(), canvas, WIDTH); - if app.ui.tools_beside_canvas { - crate::tools_float::set_dock_zones(ui.ctx(), canvas, WIDTH); - } + crate::tools_float::set_dock_zones(ui.ctx(), canvas, WIDTH); if app.ui.toolbar_pos.is_none() && (app.ui.tools_beside_canvas || app.ui.toolbar_right) { show(app, ui); } diff --git a/crates/ui-egui/src/tools_float.rs b/crates/ui-egui/src/tools_float.rs index b5fb04d384..2dd62af1cb 100644 --- a/crates/ui-egui/src/tools_float.rs +++ b/crates/ui-egui/src/tools_float.rs @@ -1,10 +1,15 @@ //! The Tools panel floats by its title bar and docks again on the window's left edge //! ([`crate::toolbar`]). It stays outside the docking layout: dragging its title bar out of the //! docked panel floats it under the pointer, a floating panel's title bar moves it, and a release -//! over the strip along the window's left edge (lit up) docks it there. With Keep Tools Beside the -//! Canvas on (`UiState::tools_beside_canvas`), a release over the canvas's left edge docks it too, -//! and either release docks it beside the canvas. A release over the canvas's right edge (left of -//! the panels) or the window's right edge docks it on the right, between the canvas and the panels. +//! over the strip along the window's left edge (lit up) docks it there. A release over the strip +//! along the canvas's left edge, right of any panels docked on the left, docks it beside the +//! canvas. The release sets Keep Tools Beside the Canvas (`UiState::tools_beside_canvas`) to the +//! place it docked at. With no panels docked on the left, both strips put Tools in the same +//! place (left of any toolbars made with New Toolbar docked there), and a drop on either docks it +//! where the setting puts it and leaves the setting as it is; so does a drop in the column both +//! strips share when the panels are collapsed narrower than the window's strip. A release over +//! the canvas's right edge (left of the panels) or the window's right edge docks it on the right, +//! between the canvas and the panels. //! Escape or losing the window's focus puts it back where the drag began. //! //! `window.panel.float {panel: "tools"}` / `window.panel.dock {panel: "tools"}` do the same for @@ -32,6 +37,9 @@ struct Move { original: Option<[f32; 2]>, /// The side it was docked on before the drag. right: bool, + /// The frame that floated it from the window's left edge, whose canvas-edge strip was laid out + /// right of the docked panel and is not a target. + floated_from_edge: Option, } fn move_id() -> Id { @@ -53,8 +61,8 @@ pub(crate) fn mark_escape_cancelled(ctx: &egui::Context) { ctx.data_mut(|d| d.insert_temp(escape_cancel_id(), frame)); } -/// The strip along the canvas's left edge where the Tools panel docks while Keep Tools Beside the -/// Canvas is on, as last laid out. +/// The strip along the canvas's left edge where the Tools panel docks beside the canvas, as last +/// laid out. pub(crate) fn tools_zone_id() -> Id { Id::unique("tools-float-zone") } @@ -82,10 +90,14 @@ pub(crate) fn set_dock_zones(ctx: &egui::Context, canvas: Rect, width: f32) { }); } -/// Forget the canvas-edge target, so a strip laid out while Keep Tools Beside the Canvas was on -/// does not dock Tools after it is turned off. -pub(crate) fn clear_canvas_dock_zone(ctx: &egui::Context) { - ctx.data_mut(|d| d.remove::(tools_zone_id())); +fn dock_area_id() -> Id { + Id::unique("tools-float-dock-area-left") +} + +/// The left edge of the space the canvas and the panels share, as last laid out: right of the +/// lane of New Toolbar toolbars docked on the left, and of Tools docked at the window's edge. +pub(crate) fn set_dock_area_left(ctx: &egui::Context, left: f32) { + ctx.data_mut(|d| d.insert_temp(dock_area_id(), left)); } /// The legacy 48-point window-edge target spans the full layout below the bars, including @@ -113,9 +125,10 @@ pub(crate) fn cancel_move_on_escape(app: &mut VectorcraftApp, ctx: &egui::Contex } } -fn start(app: &VectorcraftApp, ctx: &egui::Context, grab: Vec2) { +fn start(app: &VectorcraftApp, ctx: &egui::Context, grab: Vec2, floated_from_edge: Option) { let Some(from) = ctx.input(|i| i.pointer.press_origin().or(i.pointer.interact_pos())) else { return }; - ctx.data_mut(|d| d.insert_temp(move_id(), Move { grab, from, original: app.ui.toolbar_pos, right: app.ui.toolbar_right })); + let m = Move { grab, from, original: app.ui.toolbar_pos, right: app.ui.toolbar_right, floated_from_edge }; + ctx.data_mut(|d| d.insert_temp(move_id(), m)); } /// The Tools panel's title bar was pressed (`title`, the panel's bounds `bounds`): docked, dragging @@ -126,11 +139,12 @@ pub(crate) fn drag_tools(app: &mut VectorcraftApp, ctx: &egui::Context, title: & } let Some(at) = ctx.input(|i| i.pointer.interact_pos()) else { return }; match floating { - Some(pos) if title.drag_started() => start(app, ctx, at - pos), + Some(pos) if title.drag_started() => start(app, ctx, at - pos, None), None if title.dragged() && !bounds.contains(at) => { // Held where the press grabbed the title bar. let grab = ctx.input(|i| i.pointer.press_origin()).map_or(vec2(10.0, 7.0), |p| p - bounds.min); - start(app, ctx, grab); + let at_edge = !app.ui.tools_beside_canvas && !app.ui.toolbar_right; + start(app, ctx, grab, at_edge.then(|| ctx.cumulative_frame_nr_for(ctx.viewport_id()))); let p = at - grab; app.ui.toolbar_pos = Some([p.x, p.y]); } @@ -138,23 +152,41 @@ pub(crate) fn drag_tools(app: &mut VectorcraftApp, ctx: &egui::Context, title: & } } -/// The docking strip under `at`, if any, and whether it docks the panel on the right: the window's -/// left edge, with `beside_canvas` the canvas's left edge as well, and on the right the canvas's -/// right edge or anywhere along the window's right edge (which lights up the strip left of the -/// panels, where it docks). -fn drop_zone(ctx: &egui::Context, at: Pos2, beside_canvas: bool) -> Option<(Rect, bool)> { - let (left, right) = ctx.data(|d| { - let canvas = d.get_temp::(tools_zone_id()).filter(|_| beside_canvas); - let left = [canvas, d.get_temp::(window_zone_id())].into_iter().flatten().find(|r| r.contains(at)); - (left, d.get_temp::(tools_zone_right_id())) +/// Where a release docks the Tools panel. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Dock { + /// On the left: beside the canvas (`Some(true)`), at the window's edge (`Some(false)`), or + /// where Keep Tools Beside the Canvas puts it (`None`, where the two strips share a column). + Left(Option), + /// On the right, between the canvas and the panels. + Right, +} + +/// The docking strip under `at`, if any, and where it docks the panel: the window's left edge, +/// the canvas's left edge, and on the right the canvas's right edge or anywhere along the +/// window's right edge (which lights up the strip left of the panels, where it docks). With no +/// panels docked on the left, both left strips put Tools in the same place, and a drop on either +/// docks it where `beside_canvas` puts it; with panels collapsed narrower than the window's strip, +/// so does a drop in the column the two strips share. The canvas's strip lights up where both are +/// under `at` and `beside_canvas` is on. Without `canvas_laid_out`, the canvas's strip is skipped. +fn drop_zone(ctx: &egui::Context, at: Pos2, beside_canvas: bool, canvas_laid_out: bool) -> Option<(Rect, Dock)> { + let (canvas, window, right, area_left) = ctx.data(|d| { + let canvas = d.get_temp::(tools_zone_id()).filter(|_| canvas_laid_out); + (canvas, d.get_temp::(window_zone_id()), d.get_temp::(tools_zone_right_id()), d.get_temp::(dock_area_id())) }); - if let Some(r) = left { - return Some((r, false)); + let panels_left = matches!((canvas, area_left), (Some(c), Some(left)) if c.left() > left + 0.5); + let shared = !panels_left || matches!((canvas, window), (Some(c), Some(w)) if c.x_range().contains(at.x) && w.x_range().contains(at.x)); + let follow = |beside: bool| Dock::Left((!shared).then_some(beside)); + match (canvas.filter(|r| r.contains(at)), window.filter(|r| r.contains(at))) { + (Some(c), Some(w)) => return Some((if beside_canvas { c } else { w }, follow(beside_canvas))), + (Some(c), None) => return Some((c, follow(true))), + (None, Some(w)) => return Some((w, follow(false))), + (None, None) => {} } let r = right?; // Read outside the data lock above: egui's context locks are not re-entrant. let at_edge = at.x >= ctx.content_rect().right() - crate::toolbar::WIDTH && r.y_range().contains(at.y); - (r.contains(at) || at_edge).then_some((r, true)) + (r.contains(at) || at_edge).then_some((r, Dock::Right)) } fn highlight(ctx: &egui::Context, zone: Rect) { @@ -179,7 +211,11 @@ pub fn track(app: &mut VectorcraftApp, ctx: &egui::Context) { return; } let at = ctx.input(|i| i.pointer.interact_pos()); - let zone = at.filter(|at| at.distance(m.from) > TRAVEL).and_then(|at| drop_zone(ctx, at, app.ui.tools_beside_canvas)); + // The frame after Tools floated from the window's edge reads the canvas-edge strip that frame + // laid out right of the docked panel. + let frame = ctx.cumulative_frame_nr_for(ctx.viewport_id()); + let canvas_laid_out = m.floated_from_edge.is_none_or(|f| frame > f + 1); + let zone = at.filter(|at| at.distance(m.from) > TRAVEL).and_then(|at| drop_zone(ctx, at, app.ui.tools_beside_canvas, canvas_laid_out)); if ctx.input(|i| i.pointer.primary_down()) { if let Some(p) = at.map(|at| at - m.grab) && p.x.is_finite() @@ -194,9 +230,19 @@ pub fn track(app: &mut VectorcraftApp, ctx: &egui::Context) { return; } ctx.data_mut(|d| d.remove::(move_id())); - if let Some((_, right)) = zone { - app.ui.toolbar_pos = None; - app.ui.toolbar_right = right; + match zone { + Some((_, Dock::Left(beside))) => { + app.ui.toolbar_pos = None; + app.ui.toolbar_right = false; + if let Some(beside) = beside { + app.ui.tools_beside_canvas = beside; + } + } + Some((_, Dock::Right)) => { + app.ui.toolbar_pos = None; + app.ui.toolbar_right = true; + } + None => {} } } diff --git a/docs/control-protocol.md b/docs/control-protocol.md index adac088a13..3ddc49aeaa 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -496,7 +496,8 @@ the desktop each floating window is an OS window of its own; on the web and on W window. `ui.toolbar_pos` in `ui.inspect` is the Tools panel's corner (null: docked); `window.panel.float` and `window.panel.dock` with `panel: "tools"` float it at `x`, `y` or dock it on the window's left edge. With `window.toolsBesideCanvas {on?}` (Window › Toolbars › Keep Tools Beside the Canvas, off by default; `ui.tools_beside_canvas`) -the docked Tools panel sits between left-side panels and the canvas, and `window.panel.dock` docks it there. +the docked Tools panel sits between left-side panels and the canvas, and `window.panel.dock` docks it there. Dropping +a floating Tools panel on the canvas's left edge turns the setting on, and on the window's left edge turns it off. Flatten Transparency: `ui.flattenTransparencyDialog` opens the `flattenTransparency` dialog for the selection (fields `preset`: a preset name, setting it loads that preset's options; the option keys of diff --git a/docs/mcp.md b/docs/mcp.md index a27f99feba..b42e5a34b8 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3210,10 +3210,15 @@ By default the docked Tools panel sits at the window's left edge, outside any pa `window.toolsBesideCanvas {on?}` (Window › Toolbars › Keep Tools Beside the Canvas, remote mode, `invoke_menu`) docks it between those panels and the canvas instead (`on: true`), back at the window's edge (`on: false`), or toggles it (`on` omitted or null), and answers the new state. Any other value of `on` is an error and changes -nothing. With the setting on, a floating Tools panel docks when it is dropped on the canvas's left edge as well as -on the window's left edge, and `window.panel.dock {panel: "tools"}` docks it beside the canvas. A floating Tools -panel stays floating when the setting changes. The setting is VectorCraft's own layout option, off by default; it is -kept with the workspace, and built-in workspaces and workspaces saved without it keep Tools at the window's edge. +nothing. A floating Tools panel dropped on the canvas's left edge, right of any panels docked on the left, docks +beside the canvas and turns the setting on; dropped on the window's left edge, it docks there and turns the setting +off. With no panels docked on the left, both edges put Tools in the same place (left of any toolbars made with +New Toolbar docked there), and a drop on either docks it where the setting puts it and leaves the setting as it +is; so does a drop in the column both edges share when left-side panels are collapsed to icons narrower than the +window's edge strip. With the setting on, `window.panel.dock {panel: "tools"}` docks it beside the canvas. A +floating Tools panel stays floating when the setting changes. The setting is VectorCraft's own layout option, off +by default; it is kept with the workspace, and built-in workspaces and workspaces saved without it keep Tools at +the window's edge. ```json {"name":"invoke_menu","arguments":{"command":"window.toolsBesideCanvas","params":{"on":true}}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index db61a96f73..d735501037 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -994,7 +994,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Window › Toolbars › Manage Toolbars… and Manage Toolbars… in the All Tools drawer's menu open a dialog that lists the toolbars made with New Toolbar: a new name typed for the selected toolbar renames it, + copies it with its tools (with none selected, + makes a blank toolbar), and the trash can deletes it. Each change shows under Window › Toolbars and stays in the workspace (; `window.toolbar.manage`, `window.toolbar.rename`, `window.toolbar.duplicate`, `window.toolbar.delete`; `manage_toolbars_renames_duplicates_and_deletes`). - A toolbar made with New Toolbar docks in a lane along the window's left or right edge when its title bar is dropped on that edge, or with Dock to Left and Dock to Right in the title bar's context menu. Toolbars docked at one edge stack from the top, each with its share of the lane's height, and the lane is as wide as its widest toolbar; a lane too short for its stack wraps it into more columns, up to half the window's width, and past that the toolbars show only their title bars, which the mouse wheel scrolls through when even they do not fit. Dragging the title bar out of the lane, or Float Toolbar, floats it again, and Escape during the drag puts it back. Hiding and renaming keep its place, and the workspace keeps it. New toolbars still start floating. The lanes and the stacking are VectorCraft's own rules (#1759; `window.toolbar.dock`, `window.toolbar.float`; `toolbars_dock_and_float_by_their_commands`, `docked_toolbars_stack_in_lanes_along_the_window_edges`, `a_title_bar_dropped_on_an_edge_docks_the_toolbar`). - The status bar shows the errors of the toolbars made with New Toolbar (a missing, empty, too long or taken name, the 64-toolbar limit, a `side` or `order` that `window.toolbar.dock` does not take, and New Toolbar's dialog and Manage Toolbars) in every language that translates every message, with the toolbar's name, the parameter key and the value given kept as they are; the error the command returns stays English (`custom_toolbar_command_errors_are_translated`). - - Window › Toolbars › Keep Tools Beside the Canvas, a VectorCraft layout option that is off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge; the canvas's left edge then also docks a floating Tools panel, and workspaces keep the setting. Scores are unchanged (`window.toolsBesideCanvas`; `docked_tools_keep_the_window_edge_unless_kept_beside_the_canvas`, `tools_redock_at_the_targets_of_the_chosen_placement`). + - Window › Toolbars › Keep Tools Beside the Canvas, a VectorCraft layout option that is off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and workspaces keep the setting. A floating Tools panel dropped on the canvas's left edge docks there and turns the setting on, and one dropped on the window's left edge docks there and turns it off (#7837). Scores are unchanged (`window.toolsBesideCanvas`; `docked_tools_keep_the_window_edge_unless_kept_beside_the_canvas`, `tools_dropped_on_a_left_edge_dock_there_and_the_setting_follows`, `tools_dropped_where_the_left_edges_overlap_keep_the_setting`, `tools_dropped_beside_a_collapsed_left_dock_follow_the_strip_dropped_on`). - Hindi (2026-11-06): Hindi (`hi`): 7,877-row machine-assisted catalog, zero/one singular plurals, desktop font fallback and optional Devanagari craft-fonts fallback; all 55 translation tests pass; native review and a web font remain; scores and estimates unchanged. [Terminology and limitations](localization-hi.md). - Gujarati (2026-11-14, #6613): `gu` has 4,673 catalog rows, zero/one singular plurals, installed desktop font fallback and support for optional `Gujr` craft-font faces. The original 4,286 rows remain unchanged; all 387 additions are contributor-reviewed and approved, with 11 wording corrections. Status/error messages remain partial; the pinned fonts and web startup list have no Gujarati face, so web selection remains unavailable until one is bundled. Current-head validation is recorded in the PR; scores and estimates unchanged. - Hindi wording (2026-11-13): rows outside the plug-in messages keep their English's meaning, quantities and clauses, and use the catalog's save, swatch, crop, resolution, path and type terms; a test checks those terms and the point unit in every row; native review remains; scores and estimates unchanged. From 4ab773494ea94e2e3c58303743b8f41248cd6f98 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 08:41:27 -0800 Subject: [PATCH 2/2] Workspace: the Tools drop strip lights up where Tools docks, and the docs name the exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With no panels docked on the left and a toolbar made with New Toolbar docked there, a drop on the canvas's left edge docks Tools at the window's edge, left of the toolbar's lane. The strip that lit up during the move was the canvas's edge, right of the lane. The window's edge now lights up instead. The window.toolsBesideCanvas params text, docs/control-protocol.md, docs/target-app-parity.md and the UiState doc comment now say that a drop with no panels docked on the left, or in the column both edges share beside panels collapsed to icons, leaves Window › Toolbars › Keep Tools Beside the Canvas as it is. ROADMAP's progress log gets a line for the changed drop rule. The test of a release where the move started now presses on the title bar, moves past the drag threshold so the move starts, and releases within the travel limit over the canvas's edge; it fails without that limit. --- ROADMAP.md | 1 + crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/panel_docking/tests.rs | 21 +++++++++++++++------ crates/ui-egui/src/state.rs | 5 +++-- crates/ui-egui/src/tools_float.rs | 15 ++++++++++++--- docs/control-protocol.md | 4 +++- docs/target-app-parity.md | 2 +- 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 4358817b60..3f266a3dd3 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -128,6 +128,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-14: Built-in Tech Circuit brush library: Circuit Trace (chamfered art with 45-degree elbows and terminal pads), Bus Lines (parallel conductor pattern) and Terminal Nodes (repeating solder pads, test points and leads), all original geometry generated in code. Ten built-in brush libraries; G5 remaining estimate 3–13 h (estimated), headline numbers unchanged. - 2026-11-05: Window › Toolbars › Keep Tools Beside the Canvas, off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and the canvas's left edge then also docks a floating Tools panel (`window.toolsBesideCanvas`, #5395). Workspaces keep the setting; workspaces saved without it keep Tools at the window's edge. An optional VectorCraft layout choice; headline numbers unchanged. +- 2026-11-17: The canvas's left edge docks a floating Tools panel whichever way Keep Tools Beside the Canvas is set: a drop there, right of panels docked on the left, turns the setting on, and a drop on the window's left edge turns it off (#7837). Headline numbers unchanged. - 2026-11-12: Stencil Bridges in the Cutting Tools add-on (Object › Plug-ins › Cutting Tools): strips of a set width are cut out of the selected art so that every island of a stencil cut from it (the inside of an O, a hole in a shape) stays attached to the sheet, by the shortest crossings first, vertical, horizontal or the shortest among 12 directions 15° apart, with up to 16 bridges per island; type is measured by its glyph outlines and stays type, and the original goes to a hidden layer or is replaced. One undo step (`addon.cutting.bridges`). A VectorCraft addition: headline numbers unchanged. - 2026-11-13: Banner Hems and Grommets in the Cutting Tools add-on (Object › Plug-ins › Cutting Tools): on the chosen sides of the selected art's bounds, or of each artboard, a hem line at a set depth inside the edge and grommet marks (a circle with a cross) at a set inset, one at each end of a side and the rest spread evenly at most a set spacing apart, stroked in a chosen swatch; a dialog with Preview, one undo step (`addon.cutting.banner`). A VectorCraft addition: headline numbers unchanged. - 2026-11-14: Nest Shapes in the Cutting Tools add-on (Object › Plug-ins › Cutting Tools): the selected objects move close together onto an artboard, a sheet of a set size or a roll of a set width, packed by their bounding boxes with a margin inside the edges and a spacing between them, optionally turning objects 90° to fit; objects that do not fit go in a column beside the sheet; a dialog with Preview, one undo step (`addon.cutting.nest`). A VectorCraft addition: headline numbers unchanged. diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 3707c3d96b..b53b9690fb 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -506,7 +506,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "window.toolsBesideCanvas", "Keep Tools Beside the Canvas", "", - "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge turns it on, and on the window's left edge turns it off. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", + "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge, right of panels docked on the left, turns it on, and on the window's left edge turns it off; with no panels docked on the left, or in the column both edges share beside panels collapsed to icons, a drop leaves it as it is. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", ), ( "window.floatTools", diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index a7fc209e5e..c0f5488c9c 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -507,7 +507,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "window.toolsBesideCanvas", "Keep Tools Beside the Canvas", "", - "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge turns it on, and on the window's left edge turns it off. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", + "{on?: bool} dock the Tools panel between the left-side panels and the canvas (true) or at the window's left edge (false, the default), or toggle (omitted or null; any other value is an error); a floating Tools panel stays floating and docks at the chosen place when it is docked again. Dropping a floating Tools panel on the canvas's left edge, right of panels docked on the left, turns it on, and on the window's left edge turns it off; with no panels docked on the left, or in the column both edges share beside panels collapsed to icons, a drop leaves it as it is. Kept with the workspace; a workspace saved without it docks Tools at the window's edge. Returns the new state", ), ( "window.floatTools", diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index 2c05eb444f..6699d63f90 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -895,7 +895,10 @@ fn tools_dropped_beside_a_left_toolbar_lane_keep_the_setting() { settle(&mut h); let canvas_edge = h.ctx.data(|d| d.get_temp::(crate::tools_float::tools_zone_id())).expect("the canvas-edge target"); assert!(canvas_edge.left() > 30.0, "right of the toolbar lane: {canvas_edge:?}"); - h.drag(pos2(620.0, 307.0), pos2(canvas_edge.right() - 4.0, canvas_edge.center().y)); + let at = pos2(canvas_edge.right() - 4.0, canvas_edge.center().y); + let lit = crate::tools_float::drop_highlight(&h.ctx, at, beside).expect("a strip lights up"); + assert!(lit.left() < 10.0, "the window's edge, where Tools docks, lights up: {lit:?}"); + h.drag(pos2(620.0, 307.0), at); assert_eq!(h.app.ui.toolbar_pos, None, "set before: {beside}"); assert_eq!(h.app.ui.tools_beside_canvas, beside, "the setting is unchanged"); settle(&mut h); @@ -921,8 +924,8 @@ fn tools_released_as_they_float_from_the_window_edge_keep_floating() { assert!(!h.app.ui.tools_beside_canvas); } -/// A drop on the right edge, or a click on the title bar of Tools floating over the canvas's left -/// edge, leaves the setting as it is. +/// A drop on the right edge leaves the setting as it is, and so does a move of Tools floating over +/// the canvas's left edge that ends within a few points of where it started. #[test] fn tools_docked_on_the_right_or_clicked_leave_the_setting() { for beside in [false, true] { @@ -940,9 +943,15 @@ fn tools_docked_on_the_right_or_clicked_leave_the_setting() { let [x, y] = h.app.ui.toolbar_pos.unwrap(); let title = pos2(x + 12.0, y + 7.0); assert!(canvas_edge.contains(title), "the title bar is over the canvas's edge: {title:?} {canvas_edge:?}"); - h.click(title); - assert!(h.app.ui.toolbar_pos.is_some(), "a click docks nothing, set before: {beside}"); - assert_eq!(h.app.ui.tools_beside_canvas, beside, "a click leaves the setting"); + h.press_and_move(title, title + vec2(30.0, 0.0)); + let moved = h.app.ui.toolbar_pos.map(|[px, _]| px - x); + assert!(moved.is_some_and(|dx| dx > 10.0), "the move started, set before: {beside}: {moved:?}"); + let back = title + vec2(2.0, 0.0); + h.frame(vec![Event::PointerMoved(back)]); + h.frame(vec![button(back, false)]); + settle(&mut h); + assert!(h.app.ui.toolbar_pos.is_some(), "released where it started, Tools docks nowhere, set before: {beside}"); + assert_eq!(h.app.ui.tools_beside_canvas, beside, "the setting is unchanged"); } } diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 37edb59d6d..d95481dc2c 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -542,8 +542,9 @@ pub struct UiState { pub toolbar_pos: Option<[f32; 2]>, /// The docked Tools panel sits between the left-side panels and the canvas instead of at the /// window's left edge (Window › Toolbars › Keep Tools Beside the Canvas, - /// `window.toolsBesideCanvas`). Dropping Tools on the canvas's left edge turns it on, and on the - /// window's left edge turns it off. Off by default, and off in state saved without it. + /// `window.toolsBesideCanvas`). Dropping Tools on the canvas's left edge, right of panels docked + /// on the left, turns it on, and on the window's left edge turns it off; with no panels docked on + /// the left, a drop leaves it as it is. Off by default, and off in state saved without it. #[serde(default)] pub tools_beside_canvas: bool, /// The docked Tools panel stands on the right, between the canvas and the panels, instead of on diff --git a/crates/ui-egui/src/tools_float.rs b/crates/ui-egui/src/tools_float.rs index 2dd62af1cb..1511958ff1 100644 --- a/crates/ui-egui/src/tools_float.rs +++ b/crates/ui-egui/src/tools_float.rs @@ -168,7 +168,8 @@ enum Dock { /// panels docked on the left, both left strips put Tools in the same place, and a drop on either /// docks it where `beside_canvas` puts it; with panels collapsed narrower than the window's strip, /// so does a drop in the column the two strips share. The canvas's strip lights up where both are -/// under `at` and `beside_canvas` is on. Without `canvas_laid_out`, the canvas's strip is skipped. +/// under `at` and `beside_canvas` is on; with no panels docked on the left, the window's strip lights +/// up, where Tools docks. Without `canvas_laid_out`, the canvas's strip is skipped. fn drop_zone(ctx: &egui::Context, at: Pos2, beside_canvas: bool, canvas_laid_out: bool) -> Option<(Rect, Dock)> { let (canvas, window, right, area_left) = ctx.data(|d| { let canvas = d.get_temp::(tools_zone_id()).filter(|_| canvas_laid_out); @@ -177,9 +178,11 @@ fn drop_zone(ctx: &egui::Context, at: Pos2, beside_canvas: bool, canvas_laid_out let panels_left = matches!((canvas, area_left), (Some(c), Some(left)) if c.left() > left + 0.5); let shared = !panels_left || matches!((canvas, window), (Some(c), Some(w)) if c.x_range().contains(at.x) && w.x_range().contains(at.x)); let follow = |beside: bool| Dock::Left((!shared).then_some(beside)); + // With no panels docked on the left, Tools docks at the window's edge either way. + let shown = |hit: Rect| if panels_left { hit } else { window.unwrap_or(hit) }; match (canvas.filter(|r| r.contains(at)), window.filter(|r| r.contains(at))) { - (Some(c), Some(w)) => return Some((if beside_canvas { c } else { w }, follow(beside_canvas))), - (Some(c), None) => return Some((c, follow(true))), + (Some(c), Some(w)) => return Some((shown(if beside_canvas { c } else { w }), follow(beside_canvas))), + (Some(c), None) => return Some((shown(c), follow(true))), (None, Some(w)) => return Some((w, follow(false))), (None, None) => {} } @@ -189,6 +192,12 @@ fn drop_zone(ctx: &egui::Context, at: Pos2, beside_canvas: bool, canvas_laid_out (r.contains(at) || at_edge).then_some((r, Dock::Right)) } +/// The strip that lights up with the pointer at `at` during a move. +#[cfg(test)] +pub(crate) fn drop_highlight(ctx: &egui::Context, at: Pos2, beside_canvas: bool) -> Option { + drop_zone(ctx, at, beside_canvas, true).map(|(zone, _)| zone) +} + fn highlight(ctx: &egui::Context, zone: Rect) { let t = Tokens::get(ctx); let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::unique("tools-float-drop"))); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 3ddc49aeaa..816edba221 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -497,7 +497,9 @@ window. `ui.toolbar_pos` in `ui.inspect` is the Tools panel's corner (null: dock `window.panel.dock` with `panel: "tools"` float it at `x`, `y` or dock it on the window's left edge. With `window.toolsBesideCanvas {on?}` (Window › Toolbars › Keep Tools Beside the Canvas, off by default; `ui.tools_beside_canvas`) the docked Tools panel sits between left-side panels and the canvas, and `window.panel.dock` docks it there. Dropping -a floating Tools panel on the canvas's left edge turns the setting on, and on the window's left edge turns it off. +a floating Tools panel on the canvas's left edge, right of panels docked on the left, turns the setting on, and on the +window's left edge turns it off; with no panels docked on the left, a drop leaves the setting as it is +(`docs/mcp.md` › Tools panel placement). Flatten Transparency: `ui.flattenTransparencyDialog` opens the `flattenTransparency` dialog for the selection (fields `preset`: a preset name, setting it loads that preset's options; the option keys of diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index d735501037..f6623bf63d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -994,7 +994,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Window › Toolbars › Manage Toolbars… and Manage Toolbars… in the All Tools drawer's menu open a dialog that lists the toolbars made with New Toolbar: a new name typed for the selected toolbar renames it, + copies it with its tools (with none selected, + makes a blank toolbar), and the trash can deletes it. Each change shows under Window › Toolbars and stays in the workspace (; `window.toolbar.manage`, `window.toolbar.rename`, `window.toolbar.duplicate`, `window.toolbar.delete`; `manage_toolbars_renames_duplicates_and_deletes`). - A toolbar made with New Toolbar docks in a lane along the window's left or right edge when its title bar is dropped on that edge, or with Dock to Left and Dock to Right in the title bar's context menu. Toolbars docked at one edge stack from the top, each with its share of the lane's height, and the lane is as wide as its widest toolbar; a lane too short for its stack wraps it into more columns, up to half the window's width, and past that the toolbars show only their title bars, which the mouse wheel scrolls through when even they do not fit. Dragging the title bar out of the lane, or Float Toolbar, floats it again, and Escape during the drag puts it back. Hiding and renaming keep its place, and the workspace keeps it. New toolbars still start floating. The lanes and the stacking are VectorCraft's own rules (#1759; `window.toolbar.dock`, `window.toolbar.float`; `toolbars_dock_and_float_by_their_commands`, `docked_toolbars_stack_in_lanes_along_the_window_edges`, `a_title_bar_dropped_on_an_edge_docks_the_toolbar`). - The status bar shows the errors of the toolbars made with New Toolbar (a missing, empty, too long or taken name, the 64-toolbar limit, a `side` or `order` that `window.toolbar.dock` does not take, and New Toolbar's dialog and Manage Toolbars) in every language that translates every message, with the toolbar's name, the parameter key and the value given kept as they are; the error the command returns stays English (`custom_toolbar_command_errors_are_translated`). - - Window › Toolbars › Keep Tools Beside the Canvas, a VectorCraft layout option that is off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and workspaces keep the setting. A floating Tools panel dropped on the canvas's left edge docks there and turns the setting on, and one dropped on the window's left edge docks there and turns it off (#7837). Scores are unchanged (`window.toolsBesideCanvas`; `docked_tools_keep_the_window_edge_unless_kept_beside_the_canvas`, `tools_dropped_on_a_left_edge_dock_there_and_the_setting_follows`, `tools_dropped_where_the_left_edges_overlap_keep_the_setting`, `tools_dropped_beside_a_collapsed_left_dock_follow_the_strip_dropped_on`). + - Window › Toolbars › Keep Tools Beside the Canvas, a VectorCraft layout option that is off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and workspaces keep the setting. A floating Tools panel dropped on the canvas's left edge, right of panels docked on the left, docks there and turns the setting on, and one dropped on the window's left edge docks there and turns it off; with no panels docked on the left, a drop leaves the setting as it is (#7837). Scores are unchanged (`window.toolsBesideCanvas`; `docked_tools_keep_the_window_edge_unless_kept_beside_the_canvas`, `tools_dropped_on_a_left_edge_dock_there_and_the_setting_follows`, `tools_dropped_where_the_left_edges_overlap_keep_the_setting`, `tools_dropped_beside_a_collapsed_left_dock_follow_the_strip_dropped_on`). - Hindi (2026-11-06): Hindi (`hi`): 7,877-row machine-assisted catalog, zero/one singular plurals, desktop font fallback and optional Devanagari craft-fonts fallback; all 55 translation tests pass; native review and a web font remain; scores and estimates unchanged. [Terminology and limitations](localization-hi.md). - Gujarati (2026-11-14, #6613): `gu` has 4,673 catalog rows, zero/one singular plurals, installed desktop font fallback and support for optional `Gujr` craft-font faces. The original 4,286 rows remain unchanged; all 387 additions are contributor-reviewed and approved, with 11 wording corrections. Status/error messages remain partial; the pinned fonts and web startup list have no Gujarati face, so web selection remains unavailable until one is bundled. Current-head validation is recorded in the PR; scores and estimates unchanged. - Hindi wording (2026-11-13): rows outside the plug-in messages keep their English's meaning, quantities and clauses, and use the catalog's save, swatch, crop, resolution, path and type terms; a test checks those terms and the point unit in every row; native review remains; scores and estimates unchanged.