mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-19 02:10:15 -05:00
* #2573: Picture Format › Size takes sizes in any unit, pixels too, and opens a Size dialog
The picture size options were too limited (#2573, and #1901's request to enter pixels without
deforming the picture): the ribbon's W/H fields were points only, rejected "300 px", resized on
every keystroke (one undo step per digit), and there was no way to scale from the original
size, lock or unlock the aspect ratio, or reset the size.
- Picture Format › Size: W/H show the interface unit (Options › Advanced) and take a size typed
in any unit, `px` included; it applies on Enter as one undo step, and the other side follows
so the picture keeps its proportions. A drag still applies live.
- The Size group's launcher (and `picture.size` run without a size) opens a Size dialog: height
and width, scale of the original size or of the size it opened with, Lock aspect ratio,
Relative to original picture size, the original size with its pixels, and Reset.
- `picture.size {"original": true, "scale"?}` sizes from the picture's original size (its pixels
at 96 ppi, read from the image adjustments started from, less what is cropped). A size past
4000 pt that keeps the proportions now shrinks as a whole instead of flattening.
- New strings translated in every interface catalog.
The crop tool already exists (Picture Format › Size › Crop) and is being extended in #2027 and
#2440; options cut off in a narrow window are what #708 and #1293 (ribbon groups that shrink to
fit) address.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* contributors: credit @matteo-andreuzza by their GitHub profile name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* #2573: Size keeps the proportions at the 1–4000 pt limits and follows the selection
Review follow-ups (CodeRabbit on #2889):
- Size dialog Reset on a photo larger than 4000 pt (a 6000 px wide one is 4500 pt) set it to
the original size, which `picture.size` then clamped side by side: the picture was flattened.
Reset now shrinks both sides by one factor.
- Locked, a side typed past the limit clamped the other on its own (15×30 pt with width 4000
became 4000×4000). Both sides now scale by one factor.
- `fit_size` (engine) only shrank: a proportional size under 1 pt (scale 1% of 50×200 pt) became
1×2 pt. It now picks the factor nearest 1 that brings both sides within 1–4000 pt, falling
back to side-by-side clamping only for shapes too long and thin for any; the dialog uses it.
- Dialogs aren't modal: picking another picture while the Size dialog was open made OK size it
with the first one's numbers. The form now follows the selection (starts over on the new
object, closes when nothing is left to size).
- Doc comments on the Size form's methods.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* #2573: Size dialog reads the picture again after a crop, change or resize
Review follow-ups (CodeRabbit on #2889):
- The open Size form only compared the selected object's position. A crop from the ribbon,
Change Picture or a handle drag while the dialog is open left Reset and OK working from the
old crop and size. The form now remembers the picture, crop and size it was read from (bit for
bit, without comparing whole objects that may hold large embedded data) and reads them again
when any changes.
- An egui harness test drives the dialog end to end: launcher, a height typed in pixels, nothing
applied before OK, OK sizes in proportion as one undo step and closes the dialog.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* #2573: size fields never resize a picture just by showing it
Review follow-up (CodeRabbit on #2889): egui's DragValue clamps a value already outside its
range when it is drawn and reports that as a change. The Size fields act on changes, so:
- Picture Format's W/H resized a picture smaller than 1 pt (a 1×1 px spacer is 0.75 pt) or
larger than 4000 pt as soon as the tab was shown, an edit and an undo step nobody asked for.
The code before this PR had the same problem with its 4–2000 pt range.
- The Size dialog's scale fields silently changed a picture enlarged past 10000% (a small icon
made large), and its lengths a size outside 1–4000 pt, which OK then applied.
The range now bounds only what is typed or dragged (`clamp_existing_to_range(false)`). Both
regression tests fail without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* #2573: Shape Format and Chart Design size fields leave existing sizes alone too
Review follow-up (CodeRabbit on #2889, outside the diff): the same egui clamp as in d56a105.
Shape Format's W/H (4–2000 pt) and Chart Design's (36–2000 pt) clamped a size outside their
range as soon as the tab was shown and resized the object unasked. The new Size dialog makes this
easier to reach, since it takes shapes up to 4000 pt, but a thin line under 4 pt was already cut.
Both now show such a size as it is and act only on a new value. Shape Format's range follows
`picture.size` (1–4000 pt), so dragging a 3000 pt shape no longer snaps it back to 2000.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
* #2573: Esc cancels a size typed in Picture Format; a typed size applies when the field is left
Review follow-up (CodeRabbit on #2889, outside the diff) asked to apply typed sizes on Enter only.
That is not done: a field keeps what was typed when it loses focus, as text fields do, and
otherwise typing a height in the Size dialog and clicking OK would throw it away. A harness test
now pins that path with a real click (press, then release frames later).
Checking it turned up a real bug: Esc did not cancel in the ribbon's W/H fields. egui 0.36 keeps
a DragValue's typed text after Esc and applies it the next frame, when the field still counts as
having just lost focus but Esc is no longer pressed. The fields now remember when Esc ended the
typing and drop that late value. (In the dialog Esc cancels the whole dialog, so nothing applies
there either; both are tested.)
Docs and comments now say "applied once typed (Enter, Tab or a click elsewhere; Esc cancels)"
instead of "applied on Enter".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZArmeAT48gF84aKj7Zx4C
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>