Files
photocraft/crates/engine/src
ca151c6b84 Paste into another artboard keeps the place on the board (#8788) (#10538)
* Paste into another artboard keeps the place on the board (#8788)

Copying from one artboard and pasting with another board (or a layer on it)
selected put the pixels at their old canvas spot on the first board, where
the second board hid them, or in the middle of the view; the new layer still
went beside the selected one, inside the second board.

The clipboard now remembers the artboard a Copy came from (the copied layer's
board, every copied layer's when several are selected, or for Copy Merged the
board under the middle of the copied area). Paste and Paste in Place into a
different board of the same document move the pixels by the offset between
the two boards' origins, so they land at the same spot on the new board, and
the layer goes inside it as before. Pasting on the same board, outside the
boards or into another document is unchanged, and Paste Into / Outside keep
centring on the selection.

Co-Authored-By: Claude <noreply@anthropic.com>

* Paste between artboards: copied layers and true middle for the source board

Review follow-ups:
- With a pixel selection, Copy takes the active layer only, even when several
  layers are selected, but the source board was worked out from every
  selected layer, so selected layers on another board cancelled it. It now
  uses the layers Copy actually takes.
- Copy Merged found the board under the middle of the copied area by halving
  each edge first, which rounds 9..11 to 9 and could pick the wrong one of two
  boards that meet. The edges are now added before halving.

Adds a test for each, both failing before.

Co-Authored-By: Claude <noreply@anthropic.com>

* Paste between artboards: locked boards and the placement midpoint

Review follow-ups:
- With a locked board itself selected, the pasted layer goes above the board,
  not into it, yet it was still moved to the board's spot. The board shift is
  now skipped in that case; a layer inside a locked board still lands on it.
- layer_place found the board a new layer lands on by halving each edge
  first, so a paste moved to 19..21 had its middle at 19 and was turned away
  from a board starting at 20. The edges are now added before halving, as for
  the copy's source board.

Adds a test for each, both failing before.

Co-Authored-By: Claude <noreply@anthropic.com>

* Paste between artboards: floored placement middle, pastes join smaller boards

Review follow-ups (FredApps):
- The placement middle truncated toward zero, so content at -4..3 (middle
  -0.5) counted as 0 and a board starting at x = 0 took it in. One helper,
  layer_place::centre, now adds the edges in i64 and floors the sum; Copy
  Merged's source board uses it too, and so does #10512's auto-nesting, with
  a byte-identical layer_place.rs so the two merge in either order.
- Pasting onto a smaller board kept the offset from its origin, but the
  layer's middle then fell past the board's edge and it was placed outside.
  A paste moved onto a board now joins it; the board clips the rest.

Tests: negative-boundary placement, a document without boards, a smaller
board (offset kept, board clips), each failing before where it applies.

Co-Authored-By: Claude <noreply@anthropic.com>

* Paste between artboards: keep a clipped paste's clipping on a board

Review follow-ups (CodeRabbit):
- A paste that joins a board always lost its clipping. It now keeps its own
  clipping flag (the copy's, from before placement) while the board holds a
  layer it can clip to, and drops it on an empty board, as a new layer does.
- Documented that boards more than the 32-bit range apart can't shift a paste,
  which then keeps its usual placement rather than wrapping around.

Adds a test (a clipped group pasted onto a board with a layer and onto an
empty one), failing before.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-05 04:55:07 +01:00
..
…
…
…
…