Skip to content

Draw the notebook, the group box, and the default button as AppKit - #1093

Open
beetlebugorg wants to merge 1 commit into
ttk-paddingfrom
aqua-controls
Open

beetlebugorg wants to merge 1 commit into
ttk-paddingfrom
aqua-controls

Conversation

@beetlebugorg

@beetlebugorg beetlebugorg commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Part of #1071 (part 1 of 2) and #154. Stacked on #1090 (the space of the theme).

The Login dialog of tkchat. The ztk pictures come from src/tests/aqua_look.zig (headless, Core Text, scale 2). The AppKit pictures are a real window on the screen (screencapture -l): a small AppKit program with the same dialog (an NSTabView, text fields, a check box, Cancel, and a default Login button) and the same made-up text.

ztk before ztk after AppKit (macOS 27)
Light ztk before, light ztk after, light AppKit macOS 27, light
Dark ztk before, dark ztk after, dark AppKit macOS 27, dark

For part 2, a segmented control (NSSegmentedControl, fillEqually) in a separate window:

AppKit (macOS 27)
Light AppKit segmented, light
Dark AppKit segmented, dark

(The pictures are on the branch shots/aqua-controls; delete it after the merge.)

The target, measured on this Mac: macOS 27.0 (build 26A428), for both native-ref and the capture. The sheet header says so.

What the capture shows, and what this PR follows:

  • An NSTabView on macOS 27 draws its tabs as a segmented track (the bezel fill, corner 6) with a near-white selected segment (light) or a light fill (dark), stroke 1 point, corner 5, inset 1.5 points in the track, and the label in labelColor. It has no accent. ttk::notebook follows it, as Tk's aqua theme maps the notebook to NSTabView.

  • An NSSegmentedControl (the separate window) draws the selected segment with the accent and white text, at full width with fillEqually. That is the form of the Battery page of System Settings. It is the form for a segmented control (ttk::radiobutton with the class segmented, in part 2). The notebook keeps the form of NSTabView.

  • cacheDisplayInRect does not draw the tabs of an NSTabView or the glass of the window, so those values come from the capture: the selected tab, the stroke of the pane (0.075), the stroke and corner of the text field (1 point, 6), and the dark window color (#232323).

  • Left to differ: the AppKit buttons in the capture are 28 points high because the program gives them that frame (a regular push button is 24); the placement of the widgets follows each program's own layout; -show * shows asterisks where AppKit shows bullets.

  • ttk::notebook: the tab view of AppKit (NSTabView, regular). The tabs are a segmented control of 24 points, centered on the top edge of the pane. The pane is 7 points in from the sides and 10 from the bottom, with a stroke of 1 point and a corner of 5. The page is 3 points in from the sides and the bottom of the pane, and 17 below its top. The selected tab is a near-white segment inset in the track (capture), with no accent.

  • src/ttk/notebook.zig: the part ::tabs centers the row with justify-content: center, paints its background as the track behind the row, and a negative margin-bottom moves the client area up under the row.

  • ttk::labelframe and labelframe: the group box (NSBox): the title in 11 points, the fill with a corner of 12 and no stroke, the content 5 points in.

  • Labels, check boxes, radio buttons, and the pages of a notebook draw no background in the macOS look, as in AppKit.

  • The default button: a button with -default active, of Tk or of ttk, gets the new pseudo-class :default (a state bit set in label.configured). The modern, macOS, and Windows sheets draw it as Button.primary.

  • tools/native-ref: also the tab view, the box, the combo box, the pull-down button, the legacy scroller, and the spinner, with the content rectangle of the tab view and the box in measures.json. AppKit does not draw the labels of the tabs of a tab view in cacheDisplayInRect, so the segments come from the render of NSSegmentedControl.

  • Test: the golden pictures tests/golden/aqua-login-light.png and -dark.png (macOS only, with a small tolerance for the glyphs of Core Text). zig build test passes.

Part 2 (next PR): the combo box, the pop-up and pull-down buttons, the progress bar and spinner, the legacy scroller, the table and outline view, the separator, the stepper, the size grip, and the menu.

Lines: estimate 300 for this part, actual +309 −32.

@beetlebugorg beetlebugorg added the opus-5.5 The agent that wrote this ran the model Opus 5.5 label Dec 4, 2026
@beetlebugorg
beetlebugorg force-pushed the aqua-controls branch 4 times, most recently from 7b7158a to 4d3a8bd Compare December 4, 2026 17:20
The macOS look draws ttk::notebook as the tab view of AppKit: the tabs
are a segmented control, centered on the top edge of a rounded pane.
The part ::tabs of the notebook centers the row with justify-content,
paints its background as the track, and a negative margin-bottom moves
the client area up under the row. ttk::labelframe and labelframe are
the group box of AppKit, and labels, check boxes, radio buttons, and
the pages of a notebook draw no background, so the fill shows.

A button with -default active, of Tk or of ttk, gets the new
pseudo-class :default, and each look draws it as Button.primary.

native-ref also renders and measures the tab view, the box, the combo
box, the pull-down button, the legacy scroller, and the spinner, with
the content rectangle of the tab view and the box. The values of the
sheet come from those measures, and from an on-screen capture of an
AppKit window on macOS 27 for what cacheDisplayInRect does not draw:
the tabs of the tab view (a near-white selected segment inset in the
track, with no accent), the stroke of the text field, and the dark
window color. The Login dialog of tkchat in the
macOS look, light and dark, is a golden picture.

This branch has not been deployed

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

Labels

opus-5.5 The agent that wrote this ran the model Opus 5.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant