Fixes#2223. Carries the in-place flat Save of #5865 (closed as superseded by this PR) and revives what #2515 (@kayrockscreenprinting, closed when its author stepped away) added beyond it.
File › Save now writes back over a flat file when that file still holds the document: one plain opaque layer the format can store, and only when the file held a single image. A JPEG (and a TIFF, Targa or DDS) asks its format options first, as Photoshop does; Cancel writes nothing. A JPEG whose lone layer has transparency it can't keep is offered as a PNG. Multi-image files (animations, multi-page TIFFs, multi-size icons, multi-part EXRs) still go through Save As; the source image count is kept through crash recovery.
Co-authored-by: kayrockscreenprinting <257643019+kayrockscreenprinting@users.noreply.github.com>
* fix(ui): Delete on an anchor selected with Add Anchor Point removes it, not the layer (#12703)
With the Add Anchor Point tool and one anchor selected (Ctrl+click), Delete
and Backspace fell through to Edit > Clear and deleted the active layer.
They now remove the anchor and its two segments, as in the reference
application: a closed subpath opens there. One history step, Delete Anchor
Point.
- vector: edit::delete_anchor_and_segments (a closed subpath opens at the
anchor; an open one loses an end or splits at an inner anchor)
- engine: path.deleteAnchor takes "segments": bool (default false keeps
joining the neighbours, as the tool's click does)
- ui: delete_key_deletes_anchor next to delete_key_deletes_work_path, and a
Delete/Backspace branch before the work path's
* test(vector): Delete on one anchor of a closed two-anchor subpath leaves the other, open (#12703)
The kept anchor retains its handles and smooth flag, and the subpath keeps its path operation.
paint.sharpen and its live stroke fail with the reference application's
alert text, and a press with the Sharpen tool opens that alert, as the
Dodge tool does since #12686.
* 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>
* Fix targeted vector mask flips via path transform (#12283)
* Target vector masks explicitly in path transforms
A shape layer's path is its content, so path.transform's layer target
took the shape path even when the layer's separate vector mask was
targeted. Add an explicit vectorMask flag to path.transform and have the
Transform presets use it, leaving the shape path and cache alone.
The UI's vector-mask target now yields to an active alpha channel or
Quick Mask, and an explicit target in the params still wins. Add engine
and UI regressions for the shape-plus-mask case and undo/redo.
* test(ui): fix vector-mask target precedence fixture
* chore: restart CI after wasm-bindgen download timeout
* fix: respect vector mask locks and cover rotation presets
* fix: guard implicit vector mask path transforms too
---------
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* Add path text placement ranges and drag gestures
* Preview path placement and track bounded canvas damage
* Preserve legacy path anchors and show overflow markers
* Match path marker hit targets and directional cursors
* Fix path placement lint failures
* Cover path text body movement and position locks
* Keep open path text movable at range endpoints
* Target the type path after attaching text
* Fix path text range rendering and placement lifecycle
* Map vertical path text and preserve drag branch continuity
* Cover path placement lifecycle and preview damage regressions
* Preserve closest branch projection and fix CI regressions
* Normalize path endpoints and bind gestures to their viewport
* Simplify viewport ownership guards for Clippy
* Document path placement invariants and regression cases
* Fix path placement ownership, validation and geometry caching
* Correct path placement regression fixtures
* Ignore transient path geometry cache in UI state equality
* fix: allow path text flips with stale placement ranges
* fix: retain path text handles after shortening curves
* test: account for layer translation in path placement drags
* fix: mark path text range with x and o markers on the path
The beginning marker is an x and the end a small circle, both on the
path, with a plus in the circle while the range hides glyphs. The
cursor's triangle points right over the beginning, left over the end,
and both ways over the text body, which moves the whole range.
Direct Selection leaves an anchor or handle under a marker to path
editing; Path Selection always takes the marker.
* fix: resolve coincident path text markers by lap or drag direction
The x and o markers coincide on a closed path's full lap and on an
empty or end-clamped open range. A full lap now moves the whole text;
otherwise the first motion picks the beginning (backward) or the end
(forward). Marker fixtures press on the path, where the markers now
sit.
* fix: let either end of a full-lap path text range be dragged
Text attached to a closed path fills one lap, so its x and o markers
coincide and every press moved the whole text, leaving no way to
shorten the range. As the text begins just ahead of that point and
ends just behind it, a press ahead along the path now grabs the
beginning and one behind grabs the end; the point itself still moves
the whole text.
* test: check full-lap marker drags do not flip the text
* fix: read and write the path text range in PSD
Type on a path keeps its range in the Txt2 frame as /2 /6 [start end],
in curve-segment units with -1 for the default. Three reference-editor
files in ag-psd's test set fix the mapping: text-path ends a third into
the first segment and draws only "so" of "some text", and
text-path-26/27 move the start on an open path.
Import reads both ends (and the flipped flag) into the layer's start and
end. Export writes an open path whole with its start and end in the
range, instead of cutting the path at the start, and a closed path's
limited end as a range from its start. Path text in a document that
never came from a PSD now gets a Txt2 block, so its path is saved at
all, and the warning that the end limit is lost is gone.
* fix: let both selection tools grab a path text marker on an anchor
Direct Selection gave an anchor under a marker the click, so an open
path's default markers (on its end anchors) and a closed path's
coincident full-lap markers (on its first anchor) could not be moved
with that tool. In the reference editor either selection tool drags a
marker wherever the pointer shows the text bar with a triangle, so the
marker now wins for both tools.
The Direct Selection tests for reshaping a type path (#9114) drag its
last anchor, where the default end marker sits; they now end the
range short of it. To reshape at an anchor under a marker, drag the
marker off it or select the anchor with a marquee and nudge it.
* fix: keep explicit and empty path text ranges through PSD
An explicit end at the path's end stays explicit, so centered and right type keeps its alignment within the span. A closed range whose ends meet reads as empty, not as a full lap.
* ci: re-run checks after a download outage
* ci: re-run checks after a download outage
* fix: preserve legacy path text anchors through PSD
* ci: re-run checks against current main
---------
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
select.object (rectangle and point) returns the reference application's
alert text in these two modes and leaves the selection and History alone;
a click or drag with the tool opens that alert with OK instead of running.
After Image > Mode the source state from before the change was converted
and painted; Photoshop refuses it. Compare the document modes, not the
pixel formats, which read Indexed and Multichannel as RGB. A bit depth
change still converts. The History Brush keeps its behaviour (#12842).
A horizontal split now turns the vertical thirds into anchor columns and drops the horizontal ones (3 x 2), a vertical split the mirror (2 x 3). Crosswise and splits of an already split grid are unchanged. The two tests that expected every third to stay now expect the cut in place of the dropped thirds.
* Eraser: add Erase to History (Brush, Pencil and Block modes)
Photoshop's Eraser has an Erase to History option; PhotoCraft had only the History Brush.
With it ticked, the Eraser paints the History panel's source state back instead of
erasing, through paint.historyBrush with eraseToHistory. Pencil and Block modes paint back
through their hard tips. A layer that did not exist in the source state paints that
state's visible image; the History Brush itself still refuses such a layer, as Photoshop's
does.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* Keep tool_event within clippy's complexity limit
* Test Erase to History at every depth and tip
* Update the History Brush params comment for Erase to History
* Erase to History paints a layer made since only from a single-layer state
Compared with Photoshop 27.11.0: on a layer the source state does not hold, Erase to History paints
when that state holds a single layer, Background or not, and gives an error when it holds a second
layer, even an empty one. The composite of a multi-layer state is gone; those states now refuse
the layer with the History Brush's error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History paints a single source layer's own pixels
Photoshop 27.11.0 paints a layer made since with the source layer's pixels: a 50% opacity layer
gives a solid stroke, where the composite gave a faded one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: Pencil mode paints at full flow; test a group-only source state
Pencil mode has no Flow control, so a lower Flow set in Brush mode must not carry over. A source
state holding only a group has no pixels of its own and refuses a layer made since.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History keeps its options if a tool key is pressed mid-stroke
The stroke read the current tool and brush when it was committed, so pressing a tool's letter
during the drag dropped eraseToHistory and the stroke failed on a layer made since. The options
and the Eraser's tip are now captured at the press.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: a single solid shape paints its colour; name the History row
Photoshop 27.11.0 paints a shape layer's solid colour along the whole stroke, past its path, and
calls the stroke History Eraser in the History panel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: a single shape without a solid fill paints white
Observed in Photoshop 27.11.0: a gradient, pattern or no fill paints plain white along the whole stroke, past the path and whatever the outline, in RGB, CMYK, Grayscale and Lab.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Eraser: Alt at the press reverses Erase to History for that stroke
As in Photoshop 27.11.0: with the option off Alt restores, with it on Alt erases. Alt pressed or released during the stroke changes nothing, and the option itself is left as it was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: name the Photoshop version compared
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: review fixes for the error and the History Brush tip
A layer without pixels now gets the error that the target did not exist
in that history state, not "no active document". The History Brush keeps
its size, hardness and spacing from the press, as the Eraser does, if a
tool key is pressed mid-stroke.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Brush parity: add the Eraser's Erase to History
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Erase to History: document the functions this change touches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* History Brush and Erase to History keep their whole brush from the press
Only mode, opacity, flow, size, hardness and spacing were kept from the press; the rest of the brush (tip shape, sampled tip, angle, dynamics, smoothing) came from the session brush at release. A tool key mid-stroke changed that brush, the commit rejected the live preview, and the fallback repainted the whole stroke with the new tool's brush. The stroke's params now carry the press-time brush as "brush" (stored tips as references, as each tool's remembered brush), and paint.historyBrush deep-merges it onto the session brush, so the live preview, the commit, its fallback and a replayed action all paint with it. Tests: a tool switch mid-stroke paints exactly what the same stroke paints without it, for the History Brush and Erase to History in Brush, Pencil and Block mode, across tip shape, sampled tips, dynamics and smoothing; a "brush" param paints as the session brush would; a malformed one is refused.
* History Brush docs: say "outside its shape", not "past its path"
The automation crate flags any command whose params text mentions a path as a possible filesystem path (registry_filesystem_path_params_are_classified); the eraseToHistory description meant a shape's vector outline. Also a test that a state whose one root item is a group of several layers is refused like the one-layer group: a group has no pixels to paint back.
* Test that a Shift-click Erase to History line commits its live pixels unsmoothed
Main's Shift-click fix (#11887) and this branch's press-time History
Brush params meet in finish_stroke_with; check the commit sends
smoothing 0 beside the brush param in all three Eraser modes.
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
A click that runs but changes no pixel (a blue pupil, a transparent area, an
empty layer, Darken Amount 0) now adds one unchanged history state instead of
the "no red-eye pixels" error, as in Photoshop. Non-RGB/Lab documents, channel
and mask targets, hidden layers and clicks outside the selection or the canvas
keep the error and add no state.
With Create new layer on, the result layer was "Layer N". Name it as the
reference does: "Remove tool edits", then "Remove tool edits 1", "2"...
taking the first free name.
path.convertPoint and path.moveHandle take an optional stepName (only
that one name is accepted, as with edit.transform), and the Convert Point
tool sends it. Direct Selection, the Pen's Alt conversion and the
Curvature Pen keep Convert Point and Drag Direction Point.
paint.dodge and its live stroke return the reference application's
message in Indexed Color and Bitmap documents and tone nothing; a press
with the Dodge tool shows it as a modal alert. Other modes keep dodging.
A saved path whose only anchor is deleted keeps its place in the Paths panel with no subpaths, as in Photoshop. The Work Path, a shape's path, a vector mask and a Type Path still refuse it.
Photoshop adds one unchanged "Art History Brush" state when the Tolerance holds back every dab. A stroke that could write nothing anyway (wholly outside the selection, on locked transparent pixels) stays a quiet no-op, and refusals still add no state.