Files
photocraft/crates/engine/src
2ec3ecf243 Type: render a paragraph-box handle drag off the UI thread (#7032) (#12316)
* Type: render a paragraph-box handle drag off the UI thread (#7032)

While a box handle is dragged the document is left alone: each move
records the wanted box, a worker lays out (holding the shared text engine
only for layout) and rasterizes a copy of the layer, and the canvas shows
the document with the newest finished render. One render runs at a time
and the latest box wins. Releasing, committing or any other end of the
drag applies the box with the same type.edit as before, so the final
document and its single history step are unchanged. Without background
jobs (web, tests, scripts) every move still runs type.edit.

* Address review: end a box drag before other commands, on a stale preview and for Type Mask edits

- A command other than a view command (Free Transform, a menu item, a
  shortcut) applies the dragged box and ends the drag before it runs.
- A preview gone stale (the document changed some other way) ends the
  gesture instead of applying the press-time box over that change.
- Type Mask edits keep the synchronous drag: their overlay is drawn from
  the document's layout.
- apply_box keeps the stored size finite and documents its units.
- Tests: a width drag that rewraps, each of the above.

* Address review: Free Transform and Save mid-drag see the dragged box

UI_COMMANDS is every shell-handled command, not only view ones, so the
exemption skipped edit.freeTransform and file.save. Only view., window.
and help. commands now leave a box drag going. Adds a Free Transform test
and requires a box shape when the huge-box edit succeeds.

* Address review: the Free Transform test checks the command succeeds and its frame is the resized layer's

* Address review: only listed view commands leave a box drag going

view.clearSelectedGuides edits the document, so a prefix exemption for
view. commands let it make the preview stale and lose the dragged box.
The exemption is now an explicit list of commands that change nothing in
the document, and a test covers the guide command.

* Address review: switching documents, engine.execute and app.save end a box drag first

- window.* commands are no longer exempt: window.nextDocument and
  window.previousDocument switch documents mid-drag.
- The control channel's engine.execute (engine commands) and app.save
  bypass menus::invoke, so they end the drag themselves.
- Tests: a control engine.execute and app.save mid-drag, and a document
  switch mid-drag.

* Address review: panel toggles leave a box drag going

Opening or closing a panel (Cmd+T toggles the Character panel while
typing) only lays out windows, so window.panel.*, window.toggle.* and
type.panels.* no longer end a drag. A test covers three of them.

* Address review: doc comments on the functions this change touches

CodeRabbit's docstring coverage check was at 73.68% against 80%. Adds a
doc comment to each touched function that had none: the new helpers and
tests, and the existing functions this change edits.

---------

Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 17:38:56 +01:00
..
…
…
…
…
…
…