Feat/ellipse toggle lock aspect#80
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.