mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 08:26:28 +00:00
Arrange: a Selection drag released in another document's tiled pane drops the artwork there
Under Window › Arrange › Tile, a Selection move dragged from the current pane and released over another document's pane copies the artwork into that document with edit.dropSelection, with no tab hover first. The pane becomes the current window, and the grab point lands under the pointer in that pane's own zoom and rotation. A release over another view of the source document moves the artwork with object.move, and Alt copies it. The source move is rolled back before the canvas sees the release, also when the pointer enters the pane and the button goes up in one frame. Artwork carried to a document through its tab can also be released in a third document's pane. A release over a pane's rulers or scroll bars, or after Escape, changes neither document, and a press in another pane with no artwork carried still only makes its document current. Dragging into a floating document window and the tab overflow menu are not covered. Docs: development.md, target-app-parity.md, gaps.md, roadmap.md, ui-parity.md.
This commit is contained in:
@@ -42,7 +42,7 @@ pub use cursor::{HOVER_STILL_SECS, STILL_SECS, ViewKey};
|
||||
use cursor::{cursor_icon, hover_cursor, hover_wait, still_wait};
|
||||
use drag::drag_id;
|
||||
pub use drag::{apply_requests, dispatch, mods};
|
||||
pub(crate) use drag::{end_document_drag, pose_on_page, release_art_in_window, release_over_panel};
|
||||
pub(crate) use drag::{art_out, end_art_move, end_document_drag, pose_on_page, release_art_in_window, release_over_panel};
|
||||
#[cfg(test)]
|
||||
use drag::{frame_moves, tool_drag_doc_id, tool_drag_moved, tool_frame_moves, tool_press_doc_id};
|
||||
pub use fill::Fill;
|
||||
|
||||
@@ -29,6 +29,11 @@ pub(crate) fn end_document_drag(ctx: &egui::Context) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Whether a Selection tool move has left the canvas ([`drag_art_out`]) and still waits there.
|
||||
pub(crate) fn art_out(ctx: &egui::Context) -> bool {
|
||||
matches!(ctx.data(|d| d.get_temp::<Drag>(drag_id())), Some(Drag::Art))
|
||||
}
|
||||
|
||||
/// Temp-memory key for the active canvas drag state.
|
||||
pub(super) fn drag_id() -> egui::Id {
|
||||
egui::Id::unique("canvas-drag")
|
||||
@@ -355,8 +360,9 @@ pub(crate) fn release_art_in_window(app: &mut VectorcraftApp, ctx: &egui::Contex
|
||||
}
|
||||
}
|
||||
|
||||
/// Roll back the art move dragged off the canvas; a panel takes the art instead.
|
||||
fn end_art_move(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
/// Roll back the art move dragged off the canvas, and end the canvas's drag; a panel or another
|
||||
/// window's tiled pane takes the art instead.
|
||||
pub(crate) fn end_art_move(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
// With no document open there is nothing to roll back; the tool still gets its mouse-up.
|
||||
let _ = app.session.cancel_interaction();
|
||||
let view = app.view_info();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! Window › Arrange › Tile: every open document in a pane of its own, edge to edge in the document
|
||||
//! area. The current document's pane is the canvas ([`super::show`]). Each other pane draws its
|
||||
//! document from a render of its own, with its artboards, guides and selected objects, and a press
|
||||
//! in it makes its document the current one. Each view Window › New Window opened has a pane of
|
||||
//! its own ([`crate::doc_windows`]).
|
||||
//! in it makes its document the current one. A Selection drag released in it drops the dragged
|
||||
//! artwork into its document ([`crate::document_drag::drop_on_pane`]). Each view Window › New
|
||||
//! Window opened has a pane of its own ([`crate::doc_windows`]).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
@@ -243,12 +244,18 @@ pub(crate) fn tiled_area(app: &mut VectorcraftApp, ui: &mut Ui) -> bool {
|
||||
let areas: Vec<(Win, egui::Rect)> = cells.iter().map(|(w, cell)| (*w, view_rects(app, *cell, ppp).1)).collect();
|
||||
let unfitted = refit_resized(app, &areas);
|
||||
let mut activate = None;
|
||||
let (mut cursor, mut dropped) = (None, None);
|
||||
// The other panes first, so that what the canvas draws past its pane (the Contextual Task Bar)
|
||||
// stays over them.
|
||||
for (w, cell) in cells.iter().copied().filter(|(w, _)| Some(*w) != active) {
|
||||
for ((w, cell), (_, area)) in cells.iter().copied().zip(areas.iter().copied()).filter(|((w, _), _)| Some(*w) != active) {
|
||||
if pane(app, ui, w, cell) {
|
||||
activate = Some(w);
|
||||
}
|
||||
match artwork_over(app, ui, w, area) {
|
||||
Some(Over::Held(c)) => cursor = Some(c),
|
||||
Some(Over::Released(at, carried)) => dropped = Some((w, at, carried)),
|
||||
None => {}
|
||||
}
|
||||
ui.painter().rect_stroke(cell, 0.0, Stroke::new(1.0, t.border), StrokeKind::Inside);
|
||||
}
|
||||
if let Some((_, cell)) = cells.iter().copied().find(|(w, _)| Some(*w) == active) {
|
||||
@@ -256,6 +263,10 @@ pub(crate) fn tiled_area(app: &mut VectorcraftApp, ui: &mut Ui) -> bool {
|
||||
super::show(app, &mut canvas);
|
||||
ui.painter().rect_stroke(cell, 0.0, Stroke::new(1.5, t.accent), StrokeKind::Inside);
|
||||
}
|
||||
// After the canvas, which sets the cursor of the drag it holds.
|
||||
if let Some(c) = cursor {
|
||||
ui.ctx().set_cursor_icon(c);
|
||||
}
|
||||
// Note the fits this frame made, for `refit_resized`.
|
||||
for ((w, area), was_unfitted) in areas.iter().zip(unfitted) {
|
||||
if let (true, Some(v), Some(s)) = (was_unfitted, crate::doc_windows::view(app, *w).filter(|v| v.fitted).copied(), slot(app, *w)) {
|
||||
@@ -263,12 +274,40 @@ pub(crate) fn tiled_area(app: &mut VectorcraftApp, ui: &mut Ui) -> bool {
|
||||
}
|
||||
}
|
||||
app.canvas.panes.last = cells;
|
||||
if let Some(w) = activate {
|
||||
if let Some((w, at, carried)) = dropped {
|
||||
crate::document_drag::drop_on_pane(app, ui.ctx(), w, at, carried);
|
||||
} else if let Some(w) = activate {
|
||||
crate::doc_windows::show_window(app, w);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// A Selection drag's artwork over another window's tiled pane.
|
||||
enum Over {
|
||||
/// Held there: the cursor that shows whether a release moves or copies it.
|
||||
Held(egui::CursorIcon),
|
||||
/// Released there, at a document point in the pane's own view.
|
||||
Released(Point, crate::document_drag::Carried),
|
||||
}
|
||||
|
||||
/// A Selection drag's artwork over `area`, the part of window `w`'s pane inside its rulers and
|
||||
/// scroll bars, where no panel or floating window is over the pointer. A release there takes the
|
||||
/// artwork before the canvas sees the release ([`crate::document_drag::take_for_pane`]).
|
||||
fn artwork_over(app: &mut VectorcraftApp, ui: &Ui, w: Win, area: egui::Rect) -> Option<Over> {
|
||||
let (uid, _) = slot(app, w)?;
|
||||
let p = ui.input(|i| i.pointer.interact_pos())?;
|
||||
if !area.contains(p) || ui.ctx().layer_id_at(p).is_some_and(|l| l != ui.layer_id()) {
|
||||
return None;
|
||||
}
|
||||
let cursor = crate::document_drag::pane_cursor(app, ui.ctx(), uid)?;
|
||||
if !ui.input(|i| i.pointer.primary_released()) {
|
||||
return Some(Over::Held(cursor));
|
||||
}
|
||||
let v = crate::doc_windows::view(app, w).copied()?;
|
||||
let at = Xf::at(area, &v, ui.ctx().zoom_factor()).to_doc(p);
|
||||
Some(Over::Released(at, crate::document_drag::take_for_pane(app, ui.ctx())?))
|
||||
}
|
||||
|
||||
/// Window `w`'s [`Slot`].
|
||||
fn slot(app: &VectorcraftApp, (i, n): Win) -> Option<Slot> {
|
||||
app.session.documents().get(i).map(|d| (d.uid, n))
|
||||
|
||||
@@ -165,6 +165,222 @@ fn a_press_in_another_pane_makes_its_document_current_without_drawing() {
|
||||
assert!(app.session.documents()[1..].iter().all(|d| d.doc.art_bounds().is_none()));
|
||||
}
|
||||
|
||||
/// One headless frame at `time` seconds as the app runs it: a Selection move released off the
|
||||
/// canvas ends first ([`crate::canvas::release_over_panel`]), then the tabs and the panes draw.
|
||||
fn timed_frame(app: &mut VectorcraftApp, ctx: &egui::Context, time: Option<f64>, events: Vec<egui::Event>) -> egui::FullOutput {
|
||||
let raw = egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))),
|
||||
max_texture_side: Some(8192),
|
||||
time,
|
||||
events,
|
||||
..Default::default()
|
||||
};
|
||||
let mut out = ctx.run_ui(raw, |ui| {
|
||||
crate::canvas::release_over_panel(app, ui.ctx());
|
||||
app.canvas_area(ui);
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
out
|
||||
}
|
||||
|
||||
/// [`timed_frame`] without a time. → the cursor.
|
||||
fn app_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> egui::CursorIcon {
|
||||
timed_frame(app, ctx, None, events).platform_output.cursor_icon
|
||||
}
|
||||
|
||||
/// Two 400 × 300 pt documents tiled side by side: the first, current, holds a selected 100 pt
|
||||
/// square at 50, 50 and the second a 50 pt square at 300, 230. The Selection tool is chosen.
|
||||
fn tiled_pair() -> (VectorcraftApp, egui::Context) {
|
||||
let mut app = app_with(0);
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap();
|
||||
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("document.activate", json!({"index": 0})).unwrap();
|
||||
app.select_tool("selection");
|
||||
app.ui.task_bar = false;
|
||||
app.run("window.arrange.tile", json!({})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
(app, ctx)
|
||||
}
|
||||
|
||||
/// Press on document point `at` on the canvas and move the pointer 20 × 10 points, still on the
|
||||
/// canvas: the Selection tool moves the art under it.
|
||||
fn grab(app: &mut VectorcraftApp, ctx: &egui::Context, at: Point) {
|
||||
let p = Xf::at(app.canvas_rect.unwrap(), app.view().unwrap(), 1.0).to_screen(at);
|
||||
app_frame(app, ctx, vec![egui::Event::PointerMoved(p), button(p, true)]);
|
||||
app_frame(app, ctx, vec![egui::Event::PointerMoved(p + vec2(20.0, 10.0))]);
|
||||
assert!(app.session.in_interaction(), "the Selection tool moves the art");
|
||||
}
|
||||
|
||||
/// Window `w`'s pane: the screen point that shows document point `at` in it, and the pane.
|
||||
fn in_pane(app: &VectorcraftApp, ctx: &egui::Context, w: Win, at: Point) -> (Pos2, egui::Rect) {
|
||||
let (_, cell) = app.canvas.panes.last.iter().copied().find(|(o, _)| *o == w).unwrap();
|
||||
let area = view_rects(app, cell, ctx.pixels_per_point()).1;
|
||||
(Xf::at(area, crate::doc_windows::view(app, w).unwrap(), 1.0).to_screen(at), cell)
|
||||
}
|
||||
|
||||
/// 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 bounds of the one object selected in the current document.
|
||||
fn selected_bounds(app: &VectorcraftApp) -> Rect {
|
||||
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()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_selection_drag_released_in_another_documents_pane_copies_the_art_there() {
|
||||
let (mut app, ctx) = tiled_pair();
|
||||
// The target's view differs from the source's: the grab point still lands under the pointer.
|
||||
app.views[1].zoom *= 0.6;
|
||||
app.views[1].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, Point::new(100.0, 100.0));
|
||||
let (drop, _) = in_pane(&app, &ctx, (1, 1), Point::new(170.0, 120.0));
|
||||
// The release comes in the first frame the pointer is over the pane.
|
||||
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), "the pane's document is the current one");
|
||||
let placed = selected_bounds(&app);
|
||||
assert!((placed.center().x - 170.0).abs() < 0.01 && (placed.center().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);
|
||||
app.run("edit.redo", json!({})).unwrap();
|
||||
assert_eq!(app.session.documents()[1].history.undo.len(), target_undo + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn art_held_over_another_pane_shows_a_copy_and_drags_back_the_other_way() {
|
||||
let (mut app, ctx) = tiled_pair();
|
||||
grab(&mut app, &ctx, Point::new(100.0, 100.0));
|
||||
let (over, _) = in_pane(&app, &ctx, (1, 1), Point::new(200.0, 150.0));
|
||||
let cursor = app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(over)]);
|
||||
assert_eq!(cursor, egui::CursorIcon::Copy, "over another document's pane the art is copied");
|
||||
assert_eq!(app.session.active_index(), Some(0), "holding the art over a pane does not switch documents");
|
||||
let (drop, _) = in_pane(&app, &ctx, (1, 1), Point::new(120.0, 90.0));
|
||||
app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(drop)]);
|
||||
app_frame(&mut app, &ctx, vec![button(drop, false)]);
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(app.session.active_index(), Some(1));
|
||||
assert_eq!(objects(&app, 1), 2, "the copy joins the target's square");
|
||||
// From the target, now the canvas, back into the first document's pane.
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
grab(&mut app, &ctx, Point::new(325.0, 255.0));
|
||||
let (back, _) = in_pane(&app, &ctx, (0, 1), Point::new(300.0, 200.0));
|
||||
app_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(back), button(back, false)]);
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(app.session.active_index(), Some(0));
|
||||
let placed = selected_bounds(&app);
|
||||
assert!((placed.center().x - 300.0).abs() < 0.01 && (placed.center().y - 200.0).abs() < 0.01, "{placed:?}");
|
||||
assert_eq!(objects(&app, 0), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_selection_drag_into_another_view_of_its_document_moves_the_art() {
|
||||
let (mut app, ctx) = tiled_pair();
|
||||
app.run("window.newWindow", json!({})).unwrap();
|
||||
app.run("window.arrange.tile", json!({})).unwrap();
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
let current = crate::doc_windows::current(&app).unwrap();
|
||||
let other = app.canvas.panes.last.iter().map(|(w, _)| *w).find(|w| w.0 == 0 && *w != current).unwrap();
|
||||
let undo = app.session.documents()[0].history.undo.len();
|
||||
let target = app.session.documents()[1].doc.clone();
|
||||
grab(&mut app, &ctx, Point::new(100.0, 100.0));
|
||||
let (drop, _) = in_pane(&app, &ctx, other, Point::new(250.0, 200.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!(crate::doc_windows::current(&app), Some(other), "the pane's view is the current window");
|
||||
assert_eq!(objects(&app, 0), 1, "the square moved, not copied");
|
||||
let moved = selected_bounds(&app);
|
||||
assert!((moved.center().x - 250.0).abs() < 0.01 && (moved.center().y - 200.0).abs() < 0.01, "{moved:?}");
|
||||
assert_eq!(app.session.documents()[0].history.undo.len(), undo + 1);
|
||||
assert_eq!(app.session.documents()[1].doc, target, "the other document is untouched");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn art_carried_through_a_tab_drops_into_a_third_documents_pane() {
|
||||
let (mut app, ctx) = tiled_pair();
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
app.run("window.arrange.tile", json!({})).unwrap();
|
||||
let source = app.session.documents()[0].doc.clone();
|
||||
let third = app.session.documents()[2].doc.clone();
|
||||
let titles = |out: egui::FullOutput| -> Vec<egui::Rect> {
|
||||
let mut t: Vec<_> = out
|
||||
.shapes
|
||||
.iter()
|
||||
.filter_map(|s| match &s.shape {
|
||||
Shape::Text(t) if t.galley.text().contains(" @ ") => Some(egui::Rect::from_min_size(t.pos, t.galley.size())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
t.sort_by(|a, b| a.left().total_cmp(&b.left()));
|
||||
t
|
||||
};
|
||||
timed_frame(&mut app, &ctx, Some(0.0), vec![]);
|
||||
let tabs = titles(timed_frame(&mut app, &ctx, Some(0.01), vec![]));
|
||||
assert_eq!(tabs.len(), 3);
|
||||
let p = Xf::at(app.canvas_rect.unwrap(), app.view().unwrap(), 1.0).to_screen(Point::new(100.0, 100.0));
|
||||
timed_frame(&mut app, &ctx, Some(0.05), vec![egui::Event::PointerMoved(p), button(p, true)]);
|
||||
timed_frame(&mut app, &ctx, Some(0.1), vec![egui::Event::PointerMoved(p + vec2(20.0, 10.0))]);
|
||||
timed_frame(&mut app, &ctx, Some(0.2), vec![egui::Event::PointerMoved(tabs[2].center())]);
|
||||
timed_frame(&mut app, &ctx, Some(0.25), vec![]);
|
||||
timed_frame(&mut app, &ctx, Some(0.8), vec![]);
|
||||
assert_eq!(app.session.active_index(), Some(2), "holding the art over the third tab makes that document current");
|
||||
timed_frame(&mut app, &ctx, Some(0.85), vec![]);
|
||||
let (drop, _) = in_pane(&app, &ctx, (1, 1), Point::new(150.0, 100.0));
|
||||
timed_frame(&mut app, &ctx, Some(0.9), vec![egui::Event::PointerMoved(drop)]);
|
||||
timed_frame(&mut app, &ctx, Some(1.0), vec![button(drop, false)]);
|
||||
timed_frame(&mut app, &ctx, Some(1.1), vec![]);
|
||||
assert_eq!(app.session.active_index(), Some(1), "the pane's document is the current one");
|
||||
assert_eq!(objects(&app, 1), 2, "the copy joins the second document's square");
|
||||
let placed = selected_bounds(&app);
|
||||
assert!((placed.center().x - 150.0).abs() < 0.01 && (placed.center().y - 100.0).abs() < 0.01, "{placed:?}");
|
||||
assert_eq!(app.session.documents()[0].doc, source);
|
||||
assert_eq!(app.session.documents()[2].doc, third, "the document the tab showed is untouched");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_drag_released_off_a_panes_art_area_or_after_escape_changes_nothing() {
|
||||
for (case, escape) in [("scroll bar", false), ("art area after Escape", true)] {
|
||||
let (mut app, ctx) = tiled_pair();
|
||||
let docs: Vec<_> = app.session.documents().iter().map(|d| (d.doc.clone(), d.history.undo.len())).collect();
|
||||
grab(&mut app, &ctx, Point::new(100.0, 100.0));
|
||||
let (inside, cell) = in_pane(&app, &ctx, (1, 1), Point::new(200.0, 150.0));
|
||||
let at = if escape { inside } else { pos2(cell.right() - 2.0, cell.center().y) };
|
||||
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 consolidate_all_windows_shows_one_document_again() {
|
||||
let mut app = app_with(2);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! A selection dragged across document tabs remains editable and leaves its source intact.
|
||||
//! A selection dragged across document tabs, or into another document's tiled pane, remains
|
||||
//! editable and leaves its source intact.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -90,13 +91,15 @@ pub(crate) fn cleanup(app: &VectorcraftApp, ctx: &Context) {
|
||||
|| i.multi_touch().is_some()
|
||||
|| i.events.iter().any(|e| matches!(e, egui::Event::Touch { phase: egui::TouchPhase::Cancel, .. }))
|
||||
});
|
||||
let outside_release =
|
||||
ctx.input(|i| i.pointer.primary_released() && !app.canvas_rect.is_some_and(|r| i.pointer.interact_pos().is_some_and(|p| r.contains(p))));
|
||||
// The canvas and the other windows' tiled panes take a release ([`drop_on_pane`]).
|
||||
let target = |p: egui::Pos2| app.canvas_rect.is_some_and(|r| r.contains(p)) || app.canvas.panes.last.iter().any(|(_, r)| r.contains(p));
|
||||
let outside_release = ctx.input(|i| i.pointer.primary_released() && !i.pointer.interact_pos().is_some_and(target));
|
||||
if !valid || cancel || outside_release || app.ui.dialog.is_some() {
|
||||
egui::DragAndDrop::clear_payload(ctx);
|
||||
}
|
||||
}
|
||||
if !ctx.input(|i| i.pointer.primary_down()) {
|
||||
// The source and grab point last through the release, for the pane it is released over.
|
||||
if !ctx.input(|i| i.pointer.primary_down() || i.pointer.primary_released()) {
|
||||
ctx.data_mut(|d| {
|
||||
d.remove::<Origin>(origin_id());
|
||||
d.remove::<Hover>(hover_id());
|
||||
@@ -210,3 +213,83 @@ pub(crate) fn drop_on_canvas(app: &mut VectorcraftApp, resp: &Response, xf: &can
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The artwork a Selection drag carries out of its canvas, taken by another window's tiled pane
|
||||
/// ([`take_for_pane`]): its source and grab point, and the objects that travel.
|
||||
pub(crate) struct Carried {
|
||||
origin: Origin,
|
||||
ids: Vec<NodeId>,
|
||||
}
|
||||
|
||||
/// The artwork a Selection drag carries: the transfer a tab hover started, or a Selection move of
|
||||
/// the current document that left its canvas. The canvas hands that move over as a panel drag
|
||||
/// ([`widgets::PanelDrag::Art`]) the frame after the pointer leaves, and Escape drops that; until
|
||||
/// then the move under way is the drag. Either way the objects the move started with travel, not
|
||||
/// an Alt-drag's preview copies.
|
||||
fn carried(app: &VectorcraftApp, ctx: &Context) -> Option<Carried> {
|
||||
if ctx.input(|i| !i.focused || i.multi_touch().is_some() || i.key_pressed(egui::Key::Escape)) || app.ui.dialog.is_some() {
|
||||
return None;
|
||||
}
|
||||
if let Some(art) = egui::DragAndDrop::payload::<Artwork>(ctx) {
|
||||
return Some(Carried { origin: art.origin.clone(), ids: art.ids.clone() });
|
||||
}
|
||||
let origin = ctx.data(|d| d.get_temp::<Origin>(origin_id()))?;
|
||||
let st = app.session.active().filter(|d| d.uid == origin.uid)?;
|
||||
let ids = match egui::DragAndDrop::payload::<widgets::PanelDrag>(ctx).as_deref() {
|
||||
Some(widgets::PanelDrag::Art(ids)) => ids.clone(),
|
||||
Some(_) => return None,
|
||||
None if canvas::art_out(ctx) => return None,
|
||||
None => st.interaction.as_ref().filter(|i| i.label == "Move" || i.label == "Copy")?.selection.objects.clone(),
|
||||
};
|
||||
(!ids.is_empty()).then_some(Carried { origin, ids })
|
||||
}
|
||||
|
||||
/// Over the tiled pane of a window of document `uid`, while a Selection drag carries artwork: the
|
||||
/// cursor that shows a move for another view of the source document without Alt, and a copy
|
||||
/// otherwise. None when no artwork is carried.
|
||||
pub(crate) fn pane_cursor(app: &VectorcraftApp, ctx: &Context, uid: u64) -> Option<egui::CursorIcon> {
|
||||
let c = carried(app, ctx)?;
|
||||
let copy = ctx.input(|i| i.modifiers.alt);
|
||||
Some(if c.origin.uid == uid && !copy { egui::CursorIcon::Move } else { egui::CursorIcon::Copy })
|
||||
}
|
||||
|
||||
/// A release over another window's tiled pane takes the carried artwork: the drag ends, and a
|
||||
/// move still under way on the canvas goes back to where it started, before the canvas sees the
|
||||
/// release ([`canvas::end_art_move`]).
|
||||
pub(crate) fn take_for_pane(app: &mut VectorcraftApp, ctx: &Context) -> Option<Carried> {
|
||||
let c = carried(app, ctx)?;
|
||||
let moving = !egui::DragAndDrop::has_payload_of_type::<Artwork>(ctx) && app.session.in_interaction();
|
||||
egui::DragAndDrop::clear_payload(ctx);
|
||||
ctx.data_mut(|d| d.remove::<Origin>(origin_id()));
|
||||
if moving {
|
||||
canvas::end_art_move(app, ctx);
|
||||
}
|
||||
Some(c)
|
||||
}
|
||||
|
||||
/// The artwork `c` taken over window `w`'s tiled pane ([`take_for_pane`]), released at document
|
||||
/// point `at` in that pane's view: `w` becomes the current window, and the artwork lands with its
|
||||
/// grab point at `at`. Into another document it is copied (`edit.dropSelection`), and the source
|
||||
/// stays as it was; in another view of the source document it moves, and Alt copies it
|
||||
/// (`object.move`). When the command fails, the window that was current stays current and the
|
||||
/// status bar shows the error.
|
||||
pub(crate) fn drop_on_pane(app: &mut VectorcraftApp, ctx: &Context, w: crate::doc_windows::Win, at: Point, c: Carried) {
|
||||
let Carried { origin, ids } = c;
|
||||
let Some(uid) = app.session.documents().get(w.0).map(|d| d.uid) else { return };
|
||||
let before = crate::doc_windows::current(app);
|
||||
app.ui.home = None;
|
||||
crate::doc_windows::show_window(app, w);
|
||||
let result = if uid == origin.uid {
|
||||
let copy = ctx.input(|i| i.modifiers.alt);
|
||||
app.run("object.move", json!({"ids": ids, "dx": at.x - origin.grab.x, "dy": at.y - origin.grab.y, "copy": copy}))
|
||||
} else {
|
||||
app.run("edit.dropSelection", json!({"sourceDocument": origin.uid, "ids": ids, "grab": [origin.grab.x, origin.grab.y], "at": [at.x, at.y]}))
|
||||
};
|
||||
if let Err(e) = result {
|
||||
if let Some(b) = before {
|
||||
crate::doc_windows::show_window(app, b);
|
||||
}
|
||||
app.status(e);
|
||||
}
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
+15
-1
@@ -497,7 +497,21 @@ 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
|
||||
cross-window dragging remain outside this change.
|
||||
dragging into a floating document window 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
|
||||
the current window, the grab point lands under the pointer in that pane's own zoom and rotation, and
|
||||
the source move is rolled back, including when the pointer enters the pane and the button is released
|
||||
in the same frame. A release over another view of the source document (Window › New Window) moves the
|
||||
artwork there with `object.move`, and Alt copies it. While the artwork is held over a pane, the cursor
|
||||
shows a copy or a move. A release over a pane's rulers or scroll bars, or after Escape, changes
|
||||
neither document. A press in another pane with no artwork carried still only makes its document
|
||||
current. Page 14 of [the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf)
|
||||
describes documents arranged side by side, with items dragged from one document into another.
|
||||
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 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
|
||||
|
||||
+4
-2
@@ -875,8 +875,10 @@ sampling coexistence. Scores and estimates unchanged. See [development.md](devel
|
||||
Selection drags activate another visible document tab after 400 ms, then copy editable artwork
|
||||
on canvas release with the original grab point. Source and clipboard preservation, resource
|
||||
rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression
|
||||
coverage (`tests_document_drag`, `tests_clipboard`). Overflow-menu and cross-window drag remain
|
||||
separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22).
|
||||
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).
|
||||
|
||||
## Pathfinder › Trap (2026-10-23)
|
||||
|
||||
|
||||
+4
-2
@@ -201,8 +201,10 @@ sampling coexistence. Scores and estimates unchanged. See [development.md](devel
|
||||
Selection drags activate another visible document tab after 400 ms, then copy editable artwork
|
||||
on canvas release with the original grab point. Source and clipboard preservation, resource
|
||||
rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression
|
||||
coverage (`tests_document_drag`, `tests_clipboard`). Overflow-menu and cross-window drag remain
|
||||
separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22).
|
||||
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).
|
||||
|
||||
## Revision history
|
||||
|
||||
|
||||
@@ -2266,8 +2266,10 @@ sampling coexistence. Scores and estimates unchanged. See [development.md](devel
|
||||
Selection drags activate another visible document tab after 400 ms, then copy editable artwork
|
||||
on canvas release with the original grab point. Source and clipboard preservation, resource
|
||||
rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression
|
||||
coverage (`tests_document_drag`, `tests_clipboard`). Overflow-menu and cross-window drag remain
|
||||
separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22).
|
||||
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).
|
||||
|
||||
## Gradient dither (2026-10-22)
|
||||
|
||||
|
||||
+5
-3
@@ -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; overflow and cross-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); overflow-menu and floating-window drag 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 |
|
||||
@@ -541,8 +541,10 @@ sampling coexistence. Scores and estimates unchanged. See [development.md](devel
|
||||
Selection drags activate another visible document tab after 400 ms, then copy editable artwork
|
||||
on canvas release with the original grab point. Source and clipboard preservation, resource
|
||||
rendering, swatch conflicts, cancellation, rotated/zoomed views and target Undo/Redo have regression
|
||||
coverage (`tests_document_drag`, `tests_clipboard`). Overflow-menu and cross-window drag remain
|
||||
separate. Scores and hours unchanged. [Behavior and command details](development.md#drag-artwork-between-document-tabs-2026-10-22).
|
||||
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).
|
||||
|
||||
## Live Paint Bucket
|
||||
|
||||
|
||||
Reference in New Issue
Block a user