Skip to content

Give the ttk widgets the space of the modern theme - #1090

Open
beetlebugorg wants to merge 2 commits into
mainfrom
ttk-padding
Open

beetlebugorg wants to merge 2 commits into
mainfrom
ttk-padding

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

Closes #1070. Part of #1067.

A theme of Tk puts space in a few places, so a script with little -padx of its own still has room. ztk gave those places about 0, so the Login dialog of tkchat 1.600 had no margins. As the owner decided, the space comes from the theme of ztk. Wish shows only which places get space.

Before After
before after

(The Login dialog of tkchat as a small script, in the headless backend, from ztk::snapshot. The pictures are on the branch shots/ttk-padding; delete it after the merge.)

The places, from the new spacing scale of modern.css (--space-1 to --space-5: 2, 4, 8, 12, 16 px):

Place CSS ttk::style lookup
Tabs and client area of a notebook, from its edge TNotebook { padding } TNotebook -padding → 8 4 8 8
Around the row of tabs TNotebook::tabs { padding } (new part) TNotebook -tabmargins → 4 0
The page, inside the client area TNotebook::client { padding } 8, inside a border of 1
Focus-ring room of a button and a menu button TButton, TMenubutton { margin } TButton -margin → 4 2
The same for a check button and a radio button TCheckbutton, TRadiobutton { margin } TCheckbutton -margin → 2
Around the text of a label TLabel { padding } TLabel -padding → 2
The content of a label frame TLabelframe { padding } TLabelframe -padding → 8
  • src/ttk/notebook.zig: the outer inset, the tab margins, and the client insets come from the CSS (the client border was a fixed 1 px).
  • src/ttk/widgets.zig: the margin of a button, check button, radio button, or menu button is inside its window, as in Tk. The request size grows, and the box is drawn inside it. In a flex container the margin stays outside, as flex places it. Two checks that found a menubutton or a label by its function pointers now use the class (menubutton.zig, checks.zig).
  • src/ttk/style.zig: in a theme that is not classic, lookup of -padding, -margin, or -tabmargins with no setting of the script gives the CSS value of a probe widget of the style. configure -margin and configure TNotebook -tabmargins write rules. The classic theme keeps the values of wish (lookup TButton -padding is 3m 1m).
  • A change of behavior: ttk::style lookup TButton -padding in the default theme was 3 3 (the number of wish) and is now 12 6 (what ztk draws). src/tests/ttk.zig changes with it.
  • Test: src/tests/notebook.zig, "the Login dialog of tkchat has room at each edge": the room at each edge, the lookups, configure, and the classic theme.
  • Goldens: none changed (zig build test passes with no update).
  • Not in this PR: the margin of TCombobox (its text hit test would need the offset), the defaults of the classic widgets, and Treeview cells. The native looks of Look and feel native on each platform, indistinguishable from native apps #154 later set their own values in aqua-macos.css and the others (macOS look: the rest of the controls in aqua-macos.css, and the ttk forms of each #1071).
  • Docs: "The space of the theme" in docs/styling.md, docs/differences.md, CHANGELOG.

Lines: estimate 250, actual +300 −18.

A theme of Tk puts space in a few places, so a script with little -padx
of its own still has room. ztk gave those places about 0, so the Login
dialog of tkchat had no margins. The modern theme now fills them from a
new spacing scale (--space-1 to --space-5):

- the notebook insets its tabs and its client area from its edge, keeps
  margins around the row of tabs (the part ::tabs), and insets the page
  inside the client area;
- a ttk button, check button, radio button, and menu button keep a
  margin for the focus ring inside their window;
- a ttk label and label frame have padding.

ttk::style lookup of -padding, -margin, and -tabmargins gives the value
of the theme in the modern look, and configure of those options changes
it. The classic theme keeps the values of wish.
The -padding option of a notebook went into its CSS padding too, so it
replaced the space of the theme at the edge of the notebook. It is the
space around the pages, inside the client area, as in Tk.

Two examples of docs/reference/ttk-notebook.tcl depended on the space
at the edge: the one of -width compares two widths, and the one of
identify uses a point inside the first tab.

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.

Give the ttk theme of ztk its own paddings and margins where the themes of Tk have them

1 participant