Skip to content

feat(design): inspector corner radius for rectangles and frames - #753

Open
prakashUXtech wants to merge 1 commit into
devfrom
claude/corner-radius-inspector-1uzc5a
Open

prakashUXtech wants to merge 1 commit into
devfrom
claude/corner-radius-inspector-1uzc5a

Conversation

@prakashUXtech

Copy link
Copy Markdown
Contributor

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-written init(from:) decodes it with decodeIfPresent ?? 0, so files saved before this change still open, with square corners. New error DesignTreeError.noCorners.
  • DesignModel/DesignCorners.swift (new):
    • DesignNodeKind.hasCorners is true for rectangle and frame only. cornerlessHelp holds the reason line for every other kind.
    • DesignNode.maxCornerRadius is half the shorter side. drawnCornerRadius is the stored radius kept within that maximum, so a layer resized smaller still draws a valid shape.
    • DesignWorkspace.setCornerRadius(_:_:) clamps to 0...min(w, h)/2 and ignores non-finite values. It goes through editNode, so a locked layer, or one inside a locked group, refuses. It coalesces on radius-<id>, so a scrub run is one undo step, the same as the frame fields.
    • cornerRadiusHelp returns the reason the row is off: nothing selected, no corners, or the lock line from lockHelp.
  • DesignModel/DesignFile.swift: a file with a negative or non-finite radius is refused as invalidNumber.
  • DesignApp:
    • The inspector's Frame section has a new Radius row, a SuiteUI ScrubField labelled "Corner radius". When cornerRadiusHelp is non-nil the row is .disabled and shows that reason as .help.
    • New intent .setCornerRadius, wired in DesignWindow.
    • The canvas fills (and for frames, outlines) rectangles and frames with Path(roundedRect:cornerRadius:style: .circular) at drawnCornerRadius × zoom.
  • C4: added DesignCorners and the radius to the DesignModel description.

Tests

Tests/DesignModelTests/DesignCornerRadiusTests.swift runs on Linux. I wrote it before the code, so it failed first. It covers:

  • the clamp to half the shorter side, plus negative, NaN and infinity
  • the drawn radius after a shrink
  • a 20-edit run is one undo step, and undo/redo restore it
  • frames take a radius
  • ellipse and group refuse with noCorners, and an unknown id is refused
  • a layer inside a locked group refuses and nothing changes
  • each cornerRadiusHelp reason (nothing selected, ellipse, group, text, group lock, own lock)
  • an old file with no cornerRadius opens with 0
  • save → open round trip
  • a negative radius in a file is refused

scripts/ci prints CI: PASS on Linux after rebasing on origin/dev.

Journey: UITests/DesignJourneyTests.swift has a new testRoundARectanglesCorners. 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's onEnd is 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. setNodeFrame behaves the same way today. Any other edit or an undo ends the run.

Docs: I checked Path on Apple's developer docs (apple-docs MCP) for init(roundedRect:cornerRadius:style:). No other new platform API is used.

Belt-Run: act-1a137c2086a-voa8

Fast-Check: pass
Head: 9fd3950


Generated by Claude Code

@prakashUXtech prakashUXtech added the fast-lane Merge automatically when small, green and outside protected paths label Oct 14, 2026 — with Claude
@github-actions

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-lane Merge automatically when small, green and outside protected paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design: inspector corner radius, stroke and Auto Layout (rest of #18)

2 participants