diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index f708d0f454..ceb8f3cdeb 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -495,12 +495,14 @@ impl VectorcraftApp { /// The canvas panel's body: the document tabs, the canvas (a pane for each document while /// Window › Arrange › Tile is on) and the isolation bar over it. While the current document is - /// in a floating window, the tab strip's document draws as a pane. + /// in a floating window, the tab strip's document draws as a pane, which a Selection drag's + /// artwork can be released in ([`canvas::note_drop`]). pub(crate) fn canvas_area(&mut self, ui: &mut egui::Ui) { let t = theme::Tokens::get(ui.ctx()); // Tools may already occupy the left side of this panel. ui.painter().rect_filled(ui.available_rect_before_wrap(), 0.0, t.pasteboard); self.canvas.windows.strip = None; + self.canvas.windows.drops.clear(); if self.ui.screen_mode < 3 { chrome::doc_tabs(self, ui); } @@ -509,10 +511,15 @@ impl VectorcraftApp { if !canvas::tiled_area(self, ui) { if floats { let rect = ui.available_rect_before_wrap(); - if let Some(w) = crate::doc_windows::tab_window(self) - && canvas::pane(self, ui, w, rect) - { - crate::doc_windows::show_window(self, w); + if let Some(w) = crate::doc_windows::tab_window(self) { + let pressed = canvas::pane(self, ui, w, rect); + // A drag from a current window that is an OS window ends in that window. + if !crate::doc_windows::native(self, ui.ctx()) { + canvas::note_drop(self, ui, w, rect); + } + if pressed { + crate::doc_windows::show_window(self, w); + } } } else { canvas::show(self, ui); diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index b914d1f626..607f9c15ea 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -65,7 +65,7 @@ pub use overlays::SharedPaths; use overlays::selected_anchor; use overlays::{HandleLook, blend_widgets_overlay, draw_inside_overlay, draw_overlays, hover_highlight, ime_geometry, selection_overlay}; pub use panes::Panes; -pub(crate) use panes::{consolidate, pane, tile, tiled_area}; +pub(crate) use panes::{consolidate, note_drop, noted_cursor, pane, release_on_noted, tile, tiled_area}; use raster::{changed_pixels, frame_ppp, pixel_region, upload}; pub(crate) use raster::{color_image, color_image_owned, render_job}; pub use selection_marks::SelectionMarks; diff --git a/crates/ui-egui/src/canvas/drag.rs b/crates/ui-egui/src/canvas/drag.rs index 38be9651c7..68f06c70cc 100644 --- a/crates/ui-egui/src/canvas/drag.rs +++ b/crates/ui-egui/src/canvas/drag.rs @@ -325,6 +325,9 @@ pub(super) fn drag_art_out(app: &VectorcraftApp, ui: &Ui, resp: &egui::Response, /// panel that takes the art ([`widgets::PanelDrag::Art`]) takes it where it was, and no move is /// left open (#2826). The art stays where it last moved while the pointer is over the panel. pub(crate) fn release_over_panel(app: &mut VectorcraftApp, ctx: &egui::Context) { + // A floating window's pane, or the main window's while the current window floats, takes the + // art first. + super::release_on_noted(app, ctx); crate::document_drag::cleanup(app, ctx); let art = matches!(ctx.data(|d| d.get_temp::(drag_id())), Some(Drag::Art)); // Over a floating panel's own OS window the pointer is gone from this window, and the release diff --git a/crates/ui-egui/src/canvas/panes.rs b/crates/ui-egui/src/canvas/panes.rs index dd2fec382f..473bc53839 100644 --- a/crates/ui-egui/src/canvas/panes.rs +++ b/crates/ui-egui/src/canvas/panes.rs @@ -308,6 +308,52 @@ fn artwork_over(app: &mut VectorcraftApp, ui: &Ui, w: Win, area: egui::Rect) -> Some(Over::Released(at, crate::document_drag::take_for_pane(app, ui.ctx())?)) } +/// Note window `w`'s pane, drawn in `cell` of `ui` outside Tile (a floating window inside the main +/// window, or the main window while the current window floats), as a place a Selection drag's +/// artwork can be released in ([`release_on_noted`]): the part inside its rulers and scroll bars. +pub(crate) fn note_drop(app: &mut VectorcraftApp, ui: &Ui, w: Win, cell: egui::Rect) { + let Some(s) = slot(app, w) else { return }; + let area = view_rects(app, cell, ui.ctx().pixels_per_point()).1; + app.canvas.windows.drops.push((s, area, ui.layer_id())); +} + +/// The noted pane ([`note_drop`]) at `p`, where no panel or other window is over it: its window +/// and its art area. +fn noted_at(app: &VectorcraftApp, ctx: &egui::Context, p: egui::Pos2) -> Option<(Win, egui::Rect)> { + let top = ctx.layer_id_at(p); + let (s, area, _) = app.canvas.windows.drops.iter().rev().find(|(_, area, layer)| area.contains(p) && top.is_none_or(|l| l == *layer))?; + let w = crate::doc_windows::windows(app).into_iter().find(|w| slot(app, *w) == Some(*s))?; + Some((w, *area)) +} + +/// A Selection drag's artwork released over a pane the last frame noted ([`note_drop`]) drops into +/// its document ([`crate::document_drag::drop_on_pane`]), at the document point under the pointer +/// in that pane's own view. Runs at the start of a frame, before any canvas sees the release. +pub(crate) fn release_on_noted(app: &mut VectorcraftApp, ctx: &egui::Context) { + if app.canvas.windows.drops.is_empty() || !ctx.input(|i| i.pointer.primary_released()) { + return; + } + let Some(p) = ctx.input(|i| i.pointer.interact_pos()) else { return }; + let Some((w, area)) = noted_at(app, ctx, p) else { return }; + let Some(v) = crate::doc_windows::view(app, w).copied() else { return }; + let at = Xf::at(area, &v, ctx.zoom_factor()).to_doc(p); + if let Some(carried) = crate::document_drag::take_for_pane(app, ctx) { + crate::document_drag::drop_on_pane(app, ctx, w, at, carried); + } +} + +/// While a Selection drag's artwork is held over a pane this frame noted ([`note_drop`]), the cursor +/// shows whether a release there moves or copies it ([`crate::document_drag::pane_cursor`]). +pub(crate) fn noted_cursor(app: &VectorcraftApp, ctx: &egui::Context) { + let Some(p) = ctx.input(|i| i.pointer.interact_pos()) else { return }; + if let Some((w, _)) = noted_at(app, ctx, p) + && let Some((uid, _)) = slot(app, w) + && let Some(c) = crate::document_drag::pane_cursor(app, ctx, uid) + { + ctx.set_cursor_icon(c); + } +} + /// Window `w`'s [`Slot`]. fn slot(app: &VectorcraftApp, (i, n): Win) -> Option { app.session.documents().get(i).map(|d| (d.uid, n)) diff --git a/crates/ui-egui/src/doc_windows.rs b/crates/ui-egui/src/doc_windows.rs index 619c563e44..ba324558d3 100644 --- a/crates/ui-egui/src/doc_windows.rs +++ b/crates/ui-egui/src/doc_windows.rs @@ -4,7 +4,9 @@ //! the main window, it is a window inside the app's window, as floating panels are //! ([`crate::panel_docking`]). The current document's window holds the canvas //! ([`crate::canvas::show`]); each other window draws its document as a Tile pane does -//! ([`crate::canvas::pane`]), and a press in it makes its document the current one. +//! ([`crate::canvas::pane`]), and a press in it makes its document the current one. In a window +//! inside the app's window, a Selection drag released over that pane drops the dragged artwork into +//! its document ([`crate::canvas::release_on_noted`]); an OS window's pane does not take it. //! //! A document tab dragged off the tab strip floats its document in a window under the pointer, //! and a document window dragged onto the tab strip by its title bar (an OS window by the tab at @@ -95,6 +97,10 @@ pub struct Windows { known: Vec, /// The documents' views beyond the one each shows ([`views`]). pub(crate) views: Views, + /// The panes the last frame drew outside Tile that a Selection drag's artwork can be released + /// in ([`crate::canvas::note_drop`]): each window's view ([`views::key`]), the part of its pane + /// inside its rulers and scroll bars in the main window's points, and the layer it drew in. + pub(crate) drops: Vec<((u64, u32), egui::Rect, egui::LayerId)>, } impl Windows { @@ -325,7 +331,7 @@ pub(crate) fn dock_all(app: &mut VectorcraftApp) { /// floats panels by the same rule), and no control channel is attached. With a control channel the /// windows stay inside the main window, where `ui.click`, `ui.drag` and `ui.screenshot` reach them /// and `canvasRect` is in the main window's coordinates. -fn native(app: &VectorcraftApp, ctx: &egui::Context) -> bool { +pub(crate) fn native(app: &VectorcraftApp, ctx: &egui::Context) -> bool { if ctx.embed_viewports() || app.control_rx.is_some() { return false; } @@ -469,6 +475,8 @@ pub(crate) fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { activate = Some(win); } } + // After every canvas, which sets the cursor of the drag it holds. + crate::canvas::noted_cursor(app, ctx); // The tab strip a dragged window would go back under shows where it lands. if let Some(strip) = app.canvas.windows.strip.filter(|_| over_strip) { let t = crate::theme::Tokens::get(ctx); @@ -499,9 +507,10 @@ pub(crate) fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { /// Window `win`'s body in `ui`: the canvas for the current window, else (and while `blocked` by a /// modal) a pane. The view fits the body again when the body changed size since `fit` and the view -/// has not moved. → whether a press in the pane asks for its window to become the current one, the -/// body's rect and the fit after this frame. -fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, (win, blocked): (Win, bool), fit: Option) -> (bool, egui::Rect, Option) { +/// has not moved. With `drops`, a pane drawn while no modal blocks it is noted as a place a Selection +/// drag's artwork can be released in ([`crate::canvas::note_drop`]). → whether a press in the pane +/// asks for its window to become the current one, the body's rect and the fit after this frame. +fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, (win, blocked): (Win, bool), fit: Option, drops: bool) -> (bool, egui::Rect, Option) { let t = crate::theme::Tokens::get(ui.ctx()); let rect = ui.available_rect_before_wrap(); ui.painter().rect_filled(rect, 0.0, t.pasteboard); @@ -517,7 +526,11 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, (win, blocked): (Win, bool) crate::canvas::show(app, ui); false } else { - crate::canvas::pane(app, ui, win, rect) + let pressed = crate::canvas::pane(app, ui, win, rect); + if drops && !blocked { + crate::canvas::note_drop(app, ui, win, rect); + } + pressed }; ui.advance_cursor_after_rect(rect); let fit = match view(app, win) { @@ -564,7 +577,8 @@ fn os_window(app: &mut VectorcraftApp, ctx: &egui::Context, w: &DocWindow, (win, } let tab = crate::chrome::window_tab(app, ui, win); let (over_strip, dock) = if blocked { (false, false) } else { drag_tab(app, ui, ((w.uid, w.view), origin), &tab, strip) }; - let (pressed, rect, fit) = body(app, ui, (win, blocked), w.fit); + // The OS window's points are not the main window's: its pane takes no artwork. + let (pressed, rect, fit) = body(app, ui, (win, blocked), w.fit, false); let activate = pressed || (!blocked && (tab.clicked() || tab.drag_started())); // Keys the window's widgets left over run the main window's shortcuts and tool keys, as a // floating panel's do. @@ -649,7 +663,7 @@ fn app_window(app: &mut VectorcraftApp, ctx: &egui::Context, w: &DocWindow, (win .frame(frame) .open(&mut open) .show(ctx, |ui| { - let (pressed, r, f) = body(app, ui, (win, blocked), fit); + let (pressed, r, f) = body(app, ui, (win, blocked), fit, true); (activate, rect, fit) = (pressed, Some(r), f); }); // A press on its title bar or edges, which brings the window to the front, also makes its diff --git a/crates/ui-egui/src/doc_windows/tests.rs b/crates/ui-egui/src/doc_windows/tests.rs index 64a693a09b..0b4babec61 100644 --- a/crates/ui-egui/src/doc_windows/tests.rs +++ b/crates/ui-egui/src/doc_windows/tests.rs @@ -925,3 +925,220 @@ fn switching_views_targets_the_artboard_the_view_shows() { show_window(&mut app, (0, 2)); assert_eq!(app.session.tool_options()["active"], json!(1)); } + +/// One headless frame as the app runs it: a Selection move released off the canvas ends first +/// ([`crate::canvas::release_over_panel`]), then the tabs and the canvas or panes, then the floating +/// document windows. → the cursor. +fn app_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) -> egui::CursorIcon { + let raw = egui::RawInput { + screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))), + max_texture_side: Some(8192), + events, + ..Default::default() + }; + let mut out = ctx.run_ui(raw, |ui| { + crate::canvas::release_over_panel(app, ui.ctx()); + app.canvas_area(ui); + show(app, ui.ctx()); + }); + out.textures_delta.clear(); + out.platform_output.cursor_icon +} + +/// Two 400 × 300 pt documents on `ctx`: the first, current under its tab, holds a 50 pt square at +/// 300, 230, and the second, in a floating window, a 50 pt square at 50, 50. The Selection tool is +/// chosen. +fn floating_pair(ctx: &egui::Context) -> VectorcraftApp { + let mut app = app_with(0); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 300, "y": 230, "width": 50, "height": 50})).unwrap(); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 50, "height": 50})).unwrap(); + app.run("window.arrange.floatInWindow", json!({})).unwrap(); + app.run("document.activate", json!({"index": 0})).unwrap(); + app.select_tool("selection"); + app.ui.task_bar = false; + app_frame(&mut app, ctx, vec![]); + app_frame(&mut app, ctx, vec![]); + app +} + +/// Press on document point `at` on the canvas, clear of document 1's window when it floats, and +/// move the pointer 10 × 5 points: the Selection tool moves the art under it. +fn grab(app: &mut VectorcraftApp, ctx: &egui::Context, at: vectorcraft_geom::Point) { + let p = crate::canvas::Xf::at(app.canvas_rect.unwrap(), app.view().unwrap(), 1.0).to_screen(at); + if app.session.documents().len() > 1 && app.session.active_index() != Some(1) && is_floating(app, 1) { + assert!(!window_of(app, ctx, 1).contains(p), "the art is clear of the floating window"); + } + app_frame(app, ctx, vec![egui::Event::PointerMoved(p), button(p, true)]); + app_frame(app, ctx, vec![egui::Event::PointerMoved(p + vec2(10.0, 5.0))]); + assert!(app.session.in_interaction(), "the Selection tool moves the art"); +} + +/// The screen point that shows document point `at` in window `w`'s pane, which the last frame noted +/// as a place to release artwork in. +fn in_noted(app: &VectorcraftApp, w: Win, at: vectorcraft_geom::Point) -> Pos2 { + let k = key(app, w).unwrap(); + let (_, area, _) = app.canvas.windows.drops.iter().find(|(s, _, _)| *s == k).unwrap(); + crate::canvas::Xf::at(*area, view(app, w).unwrap(), 1.0).to_screen(at) +} + +/// How many objects document `i`'s first layer holds. +fn objects(app: &VectorcraftApp, i: usize) -> usize { + app.session.documents()[i].doc.layers[0].children().map_or(0, Vec::len) +} + +/// The center of the one object selected in the current document. +fn selected_center(app: &VectorcraftApp) -> vectorcraft_geom::Point { + let st = app.session.active().unwrap(); + assert_eq!(st.selection.objects.len(), 1, "one object is selected"); + st.doc.node(st.selection.objects[0]).unwrap().geometric_bounds().unwrap().center() +} + +#[test] +fn a_selection_drag_released_in_another_documents_floating_window_copies_the_art_there() { + let ctx = egui::Context::default(); + let mut app = floating_pair(&ctx); + // The target's view differs from the source's: the grab point still lands under the pointer. + let v = view_mut(&mut app, (1, 1)).unwrap(); + v.zoom *= 0.6; + v.rotation = 30.0; + app_frame(&mut app, &ctx, vec![]); + let source = app.session.documents()[0].doc.clone(); + let source_undo = app.session.documents()[0].history.undo.len(); + let target = app.session.documents()[1].doc.clone(); + let target_undo = app.session.documents()[1].history.undo.len(); + let clipboard = app.session.clipboard.clone(); + grab(&mut app, &ctx, vectorcraft_geom::Point::new(325.0, 255.0)); + let drop = in_noted(&app, (1, 1), vectorcraft_geom::Point::new(170.0, 120.0)); + let cursor = app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(drop)]); + assert_eq!(cursor, egui::CursorIcon::Copy, "over another document's window the art is copied"); + assert_eq!(app.session.active_index(), Some(0), "holding the art over the window does not switch documents"); + app_frame(&mut app, &ctx, vec![button(drop, false)]); + app_frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.active_index(), Some(1), "the window's document is the current one"); + assert_eq!(objects(&app, 1), 2, "the copy joins the target's square"); + let placed = selected_center(&app); + assert!((placed.x - 170.0).abs() < 0.01 && (placed.y - 120.0).abs() < 0.01, "{placed:?}"); + assert_eq!(app.session.documents()[1].history.undo.len(), target_undo + 1, "one step to undo"); + assert_eq!(app.session.documents()[0].doc, source, "the source keeps its art where it was"); + assert_eq!(app.session.documents()[0].history.undo.len(), source_undo); + assert_eq!(app.session.clipboard, clipboard, "the drag leaves the clipboard alone"); + assert!(!app.session.tool_busy()); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(app.session.documents()[1].doc, target); +} + +#[test] +fn a_release_in_the_first_frame_over_a_floating_window_still_copies_the_art() { + let ctx = egui::Context::default(); + let mut app = floating_pair(&ctx); + let source = app.session.documents()[0].doc.clone(); + grab(&mut app, &ctx, vectorcraft_geom::Point::new(325.0, 255.0)); + let drop = in_noted(&app, (1, 1), vectorcraft_geom::Point::new(200.0, 150.0)); + // The canvas has not handed the move over yet: the pane takes it before the canvas sees the + // release. + app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(drop), button(drop, false)]); + app_frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.active_index(), Some(1)); + assert_eq!(objects(&app, 1), 2); + let placed = selected_center(&app); + assert!((placed.x - 200.0).abs() < 0.01 && (placed.y - 150.0).abs() < 0.01, "{placed:?}"); + assert_eq!(app.session.documents()[0].doc, source); +} + +#[test] +fn art_dragged_from_a_floating_window_drops_into_the_main_windows_document() { + let ctx = egui::Context::default(); + let mut app = floating_pair(&ctx); + show_window(&mut app, (1, 1)); + app_frame(&mut app, &ctx, vec![]); + app_frame(&mut app, &ctx, vec![]); + assert!(current_floats(&app), "the floating window holds the canvas"); + let target = app.session.documents()[1].doc.clone(); + grab(&mut app, &ctx, vectorcraft_geom::Point::new(75.0, 75.0)); + // The main window draws document 0 as a pane; this point is clear of the floating window. + let at = vectorcraft_geom::Point::new(360.0, 40.0); + let drop = in_noted(&app, (0, 1), at); + assert!(!window_of(&app, &ctx, 1).contains(drop), "{drop:?}"); + let cursor = app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(drop)]); + assert_eq!(cursor, egui::CursorIcon::Copy); + app_frame(&mut app, &ctx, vec![button(drop, false)]); + app_frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.active_index(), Some(0), "the main window's document is the current one"); + assert_eq!(objects(&app, 0), 2); + let placed = selected_center(&app); + assert!((placed.x - at.x).abs() < 0.01 && (placed.y - at.y).abs() < 0.01, "{placed:?}"); + assert_eq!(app.session.documents()[1].doc, target, "the source in the floating window is untouched"); +} + +#[test] +fn a_selection_drag_into_a_floating_view_of_its_document_moves_the_art() { + let ctx = egui::Context::default(); + let mut app = app_with(0); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 300, "y": 230, "width": 50, "height": 50})).unwrap(); + app.run("window.newWindow", json!({})).unwrap(); + app.run("window.arrange.floatInWindow", json!({})).unwrap(); + show_window(&mut app, (0, 1)); + app.select_tool("selection"); + app.ui.task_bar = false; + app_frame(&mut app, &ctx, vec![]); + app_frame(&mut app, &ctx, vec![]); + assert!(floats(&app, (0, 2)) && current(&app) == Some((0, 1))); + let undo = app.session.documents()[0].history.undo.len(); + grab(&mut app, &ctx, vectorcraft_geom::Point::new(325.0, 255.0)); + let drop = in_noted(&app, (0, 2), vectorcraft_geom::Point::new(150.0, 100.0)); + let cursor = app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(drop)]); + assert_eq!(cursor, egui::CursorIcon::Move, "another view of the same document moves the art"); + app_frame(&mut app, &ctx, vec![button(drop, false)]); + app_frame(&mut app, &ctx, vec![]); + assert_eq!(current(&app), Some((0, 2)), "the floating view is the current window"); + assert_eq!(objects(&app, 0), 1, "the square moved, not copied"); + let moved = selected_center(&app); + assert!((moved.x - 150.0).abs() < 0.01 && (moved.y - 100.0).abs() < 0.01, "{moved:?}"); + assert_eq!(app.session.documents()[0].history.undo.len(), undo + 1); +} + +#[test] +fn a_drag_released_on_a_floating_windows_title_bar_or_after_escape_changes_nothing() { + for (case, escape) in [("title bar", false), ("art area after Escape", true)] { + let ctx = egui::Context::default(); + let mut app = floating_pair(&ctx); + let docs: Vec<_> = app.session.documents().iter().map(|d| (d.doc.clone(), d.history.undo.len())).collect(); + grab(&mut app, &ctx, vectorcraft_geom::Point::new(325.0, 255.0)); + let (window, body) = (window_of(&app, &ctx, 1), body_of(&app, 1)); + let at = if escape { + in_noted(&app, (1, 1), vectorcraft_geom::Point::new(200.0, 150.0)) + } else { + pos2(window.left() + 60.0, (window.top() + body.top()) / 2.0) + }; + app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at)]); + if escape { + let key = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + app_frame(&mut app, &ctx, vec![key]); + } + app_frame(&mut app, &ctx, vec![button(at, false)]); + app_frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.active_index(), Some(0), "{case}: the source stays current"); + let after: Vec<_> = app.session.documents().iter().map(|d| (d.doc.clone(), d.history.undo.len())).collect(); + assert!(after == docs, "{case}: neither document changes"); + assert!(!app.session.in_interaction(), "{case}: the move ended"); + } +} + +#[test] +fn an_os_windows_pane_is_not_a_place_to_release_art_in_the_main_windows_points() { + let _host = native_host(); + let ctx = egui::Context::default(); + ctx.set_embed_viewports(false); + if !native(&app_with(0), &ctx) { + // Wayland: the windows are inside the main window. + return; + } + let mut app = floating_pair(&ctx); + assert!(app.canvas.windows.drops.is_empty(), "the other document's OS window is not noted"); + show_window(&mut app, (1, 1)); + app_frame(&mut app, &ctx, vec![]); + assert!(app.canvas.windows.drops.is_empty(), "nor is the main window's pane while an OS window holds the canvas"); +} diff --git a/crates/ui-egui/src/document_drag.rs b/crates/ui-egui/src/document_drag.rs index 7be4cfa1c4..90595bd06e 100644 --- a/crates/ui-egui/src/document_drag.rs +++ b/crates/ui-egui/src/document_drag.rs @@ -1,5 +1,5 @@ -//! A selection dragged across document tabs, or into another document's tiled pane, remains -//! editable and leaves its source intact. +//! A selection dragged across document tabs, or into another document's tiled pane or floating +//! window, remains editable and leaves its source intact. use std::sync::Arc; diff --git a/docs/development.md b/docs/development.md index 8cf61cb285..37971d93e7 100644 --- a/docs/development.md +++ b/docs/development.md @@ -497,7 +497,7 @@ to the source tab resumes a move (Alt copies). Escape or release outside the can Changing the source revision or unexpectedly changing/closing the destination cancels a stale transfer; focus loss, touch cancellation and multitouch cancel too. Moving tabs under a stationary pointer does not activate further tabs until the pointer moves. The close icon does not activate a tab during a drag. Overflow-menu hover activation and -dragging into a floating document window remain outside this change. +dragging into a floating document window that is an OS window of its own remain outside this change. Under Window › Arrange › Tile, a Selection move released over another document's pane copies the artwork into that document through `edit.dropSelection`, with no tab hover first. The pane becomes @@ -512,6 +512,21 @@ describes documents arranged side by side, with items dragged from one document Evidence: the `canvas::panes` tests drive real pointer frames from the current pane into another document's pane, back the other way, into another view, through a tab into a third document's pane, and off a pane's art area. + +The same release works for documents in floating windows (Window › Arrange › Float in Window) where +those windows are drawn inside the main window: on the web, on Wayland and with a control channel +attached. A Selection move released over the art area of another document's floating window copies +the artwork into that document, and one released over the pane the main window draws while the +current document floats copies it into the main window's document. A floating window that shows +another view of the source document takes a move, and Alt copies. The release is taken at the start +of the frame, before any canvas sees it, so a release in the first frame over a window still drops the +artwork. A release on a window's title bar, rulers or scroll bars, or after Escape, changes neither +document. A floating window that is an OS window of its own, the default on Windows, macOS and X11, +does not take the artwork: its pointer positions are in that window's points, not the main window's. +Evidence: the `doc_windows` tests drive real pointer frames from the main window's canvas into a +floating window (rotated and zoomed, and in the frame the pointer arrives), from a floating window +into the main window's pane, into a floating view of the same document, and onto a title bar and +after Escape, and check that no OS window's pane is noted. The cited regressions assert the internal clipboard; they do not exercise the native system-clipboard adapter. Tab activation resets the Selection tool through `Session::set_active`; gesture regressions verify it is idle after switching, dropping diff --git a/docs/gaps.md b/docs/gaps.md index e9b658dc89..967fca7ce9 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -877,8 +877,10 @@ on canvas release with the original grab point. Source and clipboard preservatio rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression coverage (`tests_document_drag`, `tests_clipboard`). Under Window › Arrange › Tile, a release over another document's pane copies the artwork into that document as well, and a release over another -view of the source document moves it (`canvas::panes` tests). Overflow-menu drag and drag into a -floating document window remain separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). +view of the source document moves it (`canvas::panes` tests). A release over a floating document +window drawn inside the main window, or over the main window's pane while the current document +floats, does the same (`doc_windows` tests); a floating window that is an OS window of its own does +not take the artwork yet. Overflow-menu drag remains separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). ## Pathfinder › Trap (2026-10-23) diff --git a/docs/roadmap.md b/docs/roadmap.md index bb78bbff9b..c1afb4fbd2 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -203,8 +203,10 @@ on canvas release with the original grab point. Source and clipboard preservatio rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression coverage (`tests_document_drag`, `tests_clipboard`). Under Window › Arrange › Tile, a release over another document's pane copies the artwork into that document as well, and a release over another -view of the source document moves it (`canvas::panes` tests). Overflow-menu drag and drag into a -floating document window remain separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). +view of the source document moves it (`canvas::panes` tests). A release over a floating document +window drawn inside the main window, or over the main window's pane while the current document +floats, does the same (`doc_windows` tests); a floating window that is an OS window of its own does +not take the artwork yet. Overflow-menu drag remains separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). ## Revision history diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 79ac4cbc89..1a283e3b5a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2268,8 +2268,10 @@ on canvas release with the original grab point. Source and clipboard preservatio rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression coverage (`tests_document_drag`, `tests_clipboard`). Under Window › Arrange › Tile, a release over another document's pane copies the artwork into that document as well, and a release over another -view of the source document moves it (`canvas::panes` tests). Overflow-menu drag and drag into a -floating document window remain separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). +view of the source document moves it (`canvas::panes` tests). A release over a floating document +window drawn inside the main window, or over the main window's pane while the current document +floats, does the same (`doc_windows` tests); a floating window that is an OS window of its own does +not take the artwork yet. Overflow-menu drag remains separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). ## Gradient dither (2026-10-22) diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 50927bf211..5a67a5098e 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -384,7 +384,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Interaction | Status | Evidence | |---|---|---| | Ordinary Save refused by filesystem permissions/read-only storage offers Save As | focused UI regressions passed; native acceptance pending | #6146; `io::tests_read_only_save`; same name/format suggested; unchanged format keeps options, changed format opens its Save options; Documents folder, UID-bound continuation; cancellation and automation isolation | -| Selection artwork drag hovers a visible document tab to activate it, then drops editable artwork on its canvas | done | `tests_document_drag`, `edit.dropSelection`, lossless resource and one-step Undo regressions; a release over another document's tiled pane copies it there too (`canvas::panes` tests); overflow-menu and floating-window drag remain separate | +| Selection artwork drag hovers a visible document tab to activate it, then drops editable artwork on its canvas | done | `tests_document_drag`, `edit.dropSelection`, lossless resource and one-step Undo regressions; a release over another document's tiled pane copies it there too (`canvas::panes` tests), and so does a release over a floating window drawn inside the main window (`doc_windows` tests); overflow-menu drag and floating OS windows remain separate | | A document tab dragged along the tab strip moves its document; a line marks where it goes, the current document and every document's view stay as they were, and a drag off the strip still floats it | done | #5663, [public source](https://helpx.adobe.com/illustrator/using/customizing-workspace.html); `document.move`; `tests::tab_reorder`, `chrome::tests` (drop index with floating and view tabs), `engine` `tests::document_move` | | A middle-click on a document tab or its × closes it as the × does; closing a modified document's last view asks to save first (VectorCraft addition, as in PhotoCraft) | done | #6506; `chrome::tests::a_middle_click_on_a_tab_closes_it_as_the_close_box_does`; not scored | | Panels hidden by Tab or Shift+Tab show for a while when the pointer rests on the left or right edge of the window, over the canvas, and hide again when it moves away; Tab shows them for good | done | Part of #5661; `window.panels.peek` ([Workspace basics](https://web.archive.org/web/2014/https://helpx.adobe.com/illustrator/using/workspace-basics.html), "Hide or show all panels"); VectorCraft's own choices: the 6 pt band and the 0.3 s delays, only the docked panels on that side show (floating panels, Tools and the Control bar stay hidden), and nothing shows in Presentation Mode; `panel_docking::tests::resting_on_the_right_edge_shows_the_hidden_panels_over_the_canvas_until_the_pointer_leaves` and the tests after it | @@ -543,8 +543,10 @@ on canvas release with the original grab point. Source and clipboard preservatio rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression coverage (`tests_document_drag`, `tests_clipboard`). Under Window › Arrange › Tile, a release over another document's pane copies the artwork into that document as well, and a release over another -view of the source document moves it (`canvas::panes` tests). Overflow-menu drag and drag into a -floating document window remain separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). +view of the source document moves it (`canvas::panes` tests). A release over a floating document +window drawn inside the main window, or over the main window's pane while the current document +floats, does the same (`doc_windows` tests); a floating window that is an OS window of its own does +not take the artwork yet. Overflow-menu drag remains separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22). ## Live Paint Bucket