Skip to content

Draw the other controls of the macOS look as AppKit - #1110

Open
beetlebugorg wants to merge 2 commits into
aqua-controlsfrom
aqua-controls-2
Open

beetlebugorg wants to merge 2 commits into
aqua-controlsfrom
aqua-controls-2

Conversation

@beetlebugorg

@beetlebugorg beetlebugorg commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Part of #1071 (part 2 of 2) and #154. Stacked on #1093 (part 1).

The other controls. 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 on macOS 27.0 (screencapture -l of tools/native-ref/macos/controls.swift), with the same controls and made-up text, converted to sRGB.

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

The edge of the selected segment, 3 times larger: AppKit (macOS 27) light, ztk light, AppKit dark, ztk dark. The shape and the place of the edge match, and the colors match within 16 levels (AppKit draws the selected segment in dark a little lighter, #107eff). The AppKit pictures are converted to sRGB, the space that ztk draws in: a capture is in the color space of the display, where the accent #007aff of AppKit (controlAccentColor, light and dark) reads as #2f77f6. The fallback accent of the sheet stays #007aff, and a real window uses controlAccentColor from the backend.

segment edge

A test (aqua look: a selected segment stays inside its cell) checks the pixels at the edge of the cells with each segment selected in turn, at the scale of 1 and 2, in light and dark; it fails on the first version.

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

Each value of aqua-macos.css names the control and comes from the capture:

  • Pop-up and pull-down button (NSPopUpButton; ttk::menubutton, menubutton, tk_optionMenu): the bezel fill, a corner of 6, no stroke, 24 points high.
  • Combo box (NSComboBox): the field with its stroke and a corner of 6, and an arrow button of the bezel fill inside the right edge.
  • Stepper (NSStepper): the arrows of a spinbox on the bezel fill.
  • Segmented control (NSSegmentedControl; a row of ttk::radiobutton with the class segmented): one track of the bezel fill with a corner of 6 and no gap between the cells; the selected cell fills its own part of the track in the accent, with its own round corners and white text. A parent frame with the class segmented is the track (ztk::class .seg add segmented); a segment outside such a frame draws its own track. Before, the selected label was white on white; the first version of this PR left a strip of the window color between the cells (fixed in the second commit).
  • Progress bar: the track (0.059 black, 0.071 white in dark).
  • Table and outline view (ttk::treeview, listbox): no stroke around the view, the header in 11 points and labelColor with a line between the columns, and the selection of AppKit: the accent while the view has the focus, else unemphasizedSelectedContentBackgroundColor (#dcdcdc, dark #464646).
  • Size grip: macOS draws none.
  • tools/native-ref/macos/controls.swift: the Login dialog and these controls in a real AppKit window, for screencapture -l. AppKit draws the tabs of a tab view and the glass only on the screen.
  • Golden pictures: tests/golden/aqua-controls-light.png and -dark.png (macOS only). zig build test and tools/ref-check.sh pass.

Left as it is, on purpose:

  • The headings of a treeview are centered, the default -anchor of Tk. AppKit puts them at the left; a script sets -anchor w.
  • An indeterminate ttk::progressbar is a bar in Tk, so it stays a bar; the spinner of AppKit has no ttk widget.
  • The scroller: the legacy scroller and the overlay scrollers are macOS look: scrolling with momentum, overlay scrollers, and the motion of AppKit (step 7) #1074 (scrolling and motion).
  • The accent in the pictures of ztk is the fallback blue of the sheet; in a real window the backend gives the accent of the user.

Lines: estimate 250, actual +363 −0 (with two golden pictures).

The pop-up and pull-down buttons, the combo box, the stepper of a
spinbox, the segmented control, the progress bar, and the table and
outline view of the macOS look now follow AppKit on macOS 27, from a
capture of a real window: the bezel fill with no stroke for the
buttons, the arrow button inside the combo box, the accent for the
selected segment, the track of the bar, and a table with no stroke, a
header of 11 points, and the gray selection of a view without the
focus. macOS draws no size grip.

tools/native-ref/macos/controls.swift shows the Login dialog and these
controls in a real AppKit window for screencapture -l, since AppKit
draws the tabs of a tab view and the glass only on the screen. The
controls in light and dark are golden pictures.
@beetlebugorg beetlebugorg added the opus-5.5 The agent that wrote this ran the model Opus 5.5 label Dec 4, 2026
The segments of the macOS look had a margin of 2 between them, and the
selected one stopped short of the next cell with a strip of the window
color, which read as an edge over the next segment. AppKit draws one
track with no gap, and the selected cell fills its own part of it with
round corners.

A frame with the class segmented is now the track in the macOS look,
and its segments have no margin and no fill of their own; the selected
one is the accent. In a parent with the class segmented, a segment
keeps its own corners, since the parent draws the track. A test checks
the pixels at the edge of the cells for each segment selected in turn,
at the scale of 1 and 2, in light and dark.

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