Repository navigation
feat(design): inspector corner radius for rectangles and frames - #753
Open
prakashUXtech wants to merge 1 commit into
Open
prakashUXtech wants to merge 1 commit into
prakashUXtech wants to merge 1 commit into
Conversation
Contributor
|
Fast lane: not merged, this PR conflicts with dev at head 9fd3950. Rebase on origin/dev, rerun scripts/ci, and update the Fast-Check marker. |
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.
Closes #532
This is slice 1 of #532: corner radius. Fill opacity, stroke and Auto Layout moved to #752, so closing #532 doesn't drop them.
What changed
DesignModel/DesignNode.swift:DesignNode.cornerRadius(default 0). A hand-writteninit(from:)decodes it withdecodeIfPresent ?? 0, so files saved before this change still open, with square corners. New errorDesignTreeError.noCorners.DesignModel/DesignCorners.swift(new):DesignNodeKind.hasCornersis true for rectangle and frame only.cornerlessHelpholds the reason line for every other kind.DesignNode.maxCornerRadiusis half the shorter side.drawnCornerRadiusis the stored radius kept within that maximum, so a layer resized smaller still draws a valid shape.DesignWorkspace.setCornerRadius(_:_:)clamps to0...min(w, h)/2and ignores non-finite values. It goes througheditNode, so a locked layer, or one inside a locked group, refuses. It coalesces onradius-<id>, so a scrub run is one undo step, the same as the frame fields.cornerRadiusHelpreturns the reason the row is off: nothing selected, no corners, or the lock line fromlockHelp.DesignModel/DesignFile.swift: a file with a negative or non-finite radius is refused asinvalidNumber.DesignApp:Radiusrow, a SuiteUIScrubFieldlabelled "Corner radius". WhencornerRadiusHelpis non-nil the row is.disabledand shows that reason as.help..setCornerRadius, wired inDesignWindow.Path(roundedRect:cornerRadius:style: .circular)atdrawnCornerRadius × zoom.Tests
Tests/DesignModelTests/DesignCornerRadiusTests.swiftruns on Linux. I wrote it before the code, so it failed first. It covers:noCorners, and an unknown id is refusedcornerRadiusHelpreason (nothing selected, ellipse, group, text, group lock, own lock)cornerRadiusopens with 0scripts/ciprintsCI: PASSon Linux after rebasing onorigin/dev.Journey:
UITests/DesignJourneyTests.swifthas a newtestRoundARectanglesCorners. It draws a rectangle, types 24 into Radius, expects "Undo Change Corner Radius", then undoes.Snapshots (new, from
DesignInspectorSnapshots.roundedCorners):design-inspector-radius-light.png,design-inspector-radius-dark.png,design-canvas-radius-light.png,design-canvas-radius-dark.png.Known limit:
ScrubField'sonEndis not public, so the view can't end a run when a drag ends. Two scrubs in a row on the same layer's radius therefore merge into one undo step.setNodeFramebehaves the same way today. Any other edit or an undo ends the run.Docs: I checked
Pathon Apple's developer docs (apple-docs MCP) forinit(roundedRect:cornerRadius:style:). No other new platform API is used.Belt-Run: act-1a137c2086a-voa8
Fast-Check: pass
Head: 9fd3950
Generated by Claude Code