fix(line): clamp thickness <= length to avoid ^GB promotion#71
Merged
Conversation
Zebra firmware promotes ^GB w,h,t with t > min(w,h) to max(w,t) x max(h,t), so a vertical line emitted as ^GB t,length,t prints as a t x t square once thickness exceeds length rather than the declared length x t band. Enforce the t <= length invariant at every edit path: - Thickness side-handle drag caps at p.length - Property panel thickness gets max=p.length, length gets min=p.thickness (NumberInput already clamps typed values, so the cap is authoritative) - Start/end handle drag commits cap thickness to the new length so shrinking a line below its current thickness pulls thickness down rather than violating the invariant Existing stored lines with t > length keep their data and continue to print the promoted square; touching any handle or input snaps them back into a valid state. An explicit import-time warning for this case will follow in a separate change.
There was a problem hiding this comment.
Code Review
This pull request ensures that a line's thickness does not exceed its length to prevent ZPL rendering issues where the printer would otherwise output a square instead of a line. Changes include clamping thickness during canvas interactions and adding constraints to the property panel inputs. Feedback suggests improving the live preview's visual consistency during drags by applying clamping to the rendering logic and refining the property panel's UX by automatically adjusting thickness instead of using a restrictive minimum length constraint.
Two follow-ups from Gemini review on PR #71: - LineObject visual stroke is now capped at the live endpoint distance so an endpoint-shrink no longer briefly renders a band wider than the line is long. The data model invariant (t <= length) already holds in steady state, so the cap is a no-op outside of an active drag. - Length input drops the min=p.thickness floor; instead the onChange shrinks thickness alongside length, matching the endpoint-handle commit. Thickness max=p.length stays — the inverse direction (typing thickness larger than length would auto-grow length) isn't a natural user intent.
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.