Skip to content

Feat/ellipse toggle lock aspect#80

Merged
u8array merged 5 commits into
mainfrom
feat/ellipse-toggle-lock-aspect
May 20, 2026
Merged

Feat/ellipse toggle lock aspect#80
u8array merged 5 commits into
mainfrom
feat/ellipse-toggle-lock-aspect

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 20, 2026

No description provided.

u8array added 5 commits May 20, 2026 22:59
A user who wants to flip an ellipse into a circle (or back) had to
delete the object and pick the Circle palette entry — lockAspect was
write-once at creation time. The new checkbox in the ellipse
PropertiesPanel makes the constraint editable on existing objects:

- Enabling collapses width and height to min(width, height) so the
  resulting circle fits inside the prior bbox. max would push past
  the user's visual extent on one axis; min keeps the move inward
  and matches the intent of "sperren" — constrain, don't grow.
- Disabling drops the flag (undefined, matching the parser-emitted
  shape) without touching the dimensions, so width and height are
  immediately editable again with their previous values.

uniformScale already reads lockAspect via a predicate on props, so
the Konva transformer's enabled anchors recompute on the same render
as the flag flip — no extra wiring needed.
With the new Properties-Panel toggle, the Circle palette entry was a
duplicate path to the same shape: ellipse with lockAspect=true. Drops
the virtual-entries layer entirely (it had only the circle case) and
removes the unused t.types.circle label across all 32 locales.

t.registry.circle.diameter stays — it labels the Properties-Panel
diameter input when an ellipse is locked. The v2→v3 store migration
also stays so old saves with type:'circle' still rewrite cleanly to
ellipse + lockAspect on load.
^GE / ^GC support field-level inversion via ^LR like every other
graphic field; the ellipse PropertiesPanel and emit just never wired
it through. EllipseProps gains reverse?: boolean, the emitter wraps
the ^GE/^GC command with ^LRY/^LRN when set, and the parser's GE/GC
handlers now collect getReverseFlag() so a round-trip through ^LR
keeps the checkbox state intact. Properties Panel checkbox sits at
the bottom of the panel, mirroring box.

New locale key registry.ellipse.reverse, reusing the box.reverse
translation across all 32 locales so the two checkboxes read
identically to the user.
…as box

The ellipse renderer never adopted the reverse-aware fill / stroke
swap and globalCompositeOperation='difference' that box uses. ZPL
output flipped correctly via ^LRY/^LRN but the canvas kept drawing
the original colours, so the editor and Labelary disagreed visually
for any reversed ellipse / circle. Pulls the same isReverse branch
into the ellipse path.
Two helpers replace the inline reverse-handling that had drifted into
four registry files and two canvas render paths:

- wrapReverse(reverse, body) in registry/zplHelpers wraps a field body
  in ^LRY/^LRN. Box, ellipse, line, and text emit through it instead
  of inlining the conditional pair. Line's previous lr[0]/lr[1] split
  collapses into one wrap per branch.
- reverseShapeStyle(reverse, color, renderFilled) in Canvas/ returns
  stroke / fill / globalCompositeOperation for the box and ellipse
  render paths. The colour table and the difference-blend stay in one
  place so a future tweak doesn't have to keep two render paths in
  sync. The long comment explaining the special-cases (filled +
  reverse banding, white-fill grey workaround) moves onto the helper.

Line's canvas path stays separate — it only needs a stroke colour, no
fill or blend, so factoring it into the same helper would dilute the
signature for no shared logic.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the handling of inverted (^LRY) fields and the 'Circle' object type. It introduces shared helpers, reverseShapeStyle for canvas rendering and wrapReverse for ZPL generation, to ensure consistent behavior across boxes, ellipses, lines, and text. Additionally, the 'Circle' object has been integrated into the ellipse component as a lockAspect property, simplifying the object registry and palette. I have no feedback to provide.

@u8array u8array merged commit 923984c into main May 20, 2026
2 checks passed
@u8array u8array deleted the feat/ellipse-toggle-lock-aspect branch May 20, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant