Repository navigation
SharedStyle: one style for every layout; Shadcn::apply and the fallback go (#497 stage 6) - #507
Merged
Merged
Conversation
A layout is given its style when it is made, LayoutState::new(style) or LayoutState::named(name, style), and draws, builds and gives egui its look from it alone; set_style still switches it, and style() reads it. There is no look outside a layout any more. - Deleted: Shadcn::apply, apply_both, apply_both_with, Shadcn::applied and Shadcn::of, theme::tokens (the context's token store), LayoutState::with_style and its Default, Style::fallback with its faces mapping every weight to egui's regular face, FontSet::install, Problem::UnstyledLayout (no layout is without a style). - The contrast warning is given where a layout gives egui a new style (the first build after new or set_style), once for a light and dark pair that are one style. - In a debug build, layouts on one context that give egui different looks in the same pass are reported, as Problem::EguiStyleClash. The looks compare as egui receives them, so one style built twice is no clash, and a style switched on every layout in one pass is none either. - Text measured before any build has applied faces is drawn in its family's regular face, unreported; a Ui that is no node's has the default Style (NodeUi::node_style). - The testing harnesses (Headless, Driver) lay out in shadcn's default style unless given one. Behaviour changes: - A layout's root text is its style's always; egui's Body is no longer read by a layout without a style. - A fontless style (no `fonts` feature, or Shadcn::with_fonts(None)) reports MissingFace for its weighted text, as the fallback's faces mapping is gone. - Goldens: the 8 layout-only goldens (kaolin_*, chrome_stacked_by_z) draw in Geist instead of egui's font; they are not updated in this commit, pending the user's review. Tests: the examples, tests and benches give each layout the style they draw with (support::shadcn, the examples' chosen style, shadcn's default); the rigs' bar follows its page's style. Deleted, as testing what is gone: the unstyled-layout reports (replaced by clash tests), the fallback, egui-Body root text, Shadcn::of, and egui-defaults sidebar cases. style, egui_look and contrast give a layout the preset where they applied it. The embedded pop-out screenshot scene is larger: the shadcn window frame did not fit the old one and egui squeezed it. Breaking: every LayoutState constructor, and the deleted items. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
Part names a widget's sheet part enum; the enums that name the nodes a widget draws (Part::Box and the like) are Node, as checkbox's, select's and the rest already are. The last private ones: stepper, the number readout, the text field, disclosure's section, markdown's build, and mount. Private names only. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
The user's design: a style is shared by handle, not given to each layout. SharedStyle::new(themed) is a cheap clonable handle; every LayoutState::new(&shared) or LayoutState::named(name, &shared) builds and draws with what it holds, and shared.set(themed) switches them all from their next build. shared.get() reads it. - Deleted: LayoutState::set_style and LayoutState::style (the handle switches and reads), Problem::EguiStyleClash and its detection (a second SharedStyle is a deliberate act), Kept's cached egui look. - Fontless styles stay quiet: when the tokens carry no font, Style::new declares egui's regular face for every weight (Faces:: egui_regular), so text draws as before with no MissingFace. - Testing: Headless and Driver take a &SharedStyle (.style) and make shadcn's default when given none; Driver::set_style sets its handle. - Examples: common::shared_style() makes an app's handle and common::adopt(ctx, &shared) registers it, so the style and palette pickers set it; ThemeBar::new takes the handle its layout shares. - Test rigs: the bar and the page are made from one handle; Rig gets a set_style that sets it, as Driver's does. Tests: the four clash tests are gone; layout_style switches through the handle and gains a test that two layouts from one handle both follow a set; font_weights' fontless case expects no report now, and layout_style's undeclared-medium precondition uses a style with no faces at all. Breaking: LayoutState::new/named take &SharedStyle; set_style and style() on LayoutState are gone; Headless/Driver::style take &SharedStyle; ThemeBar::new (examples) takes the handle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
The layout is now the one source of the look, so the 8 goldens that drew in egui's default sans because their layouts had no style of their own (kaolin_embedded_layout, kaolin_hello_world, kaolin_multi_column, kaolin_nested, kaolin_responsive, kaolin_sizing, kaolin_text_wrapping, chrome_stacked_by_z) draw in their style's font, Geist. Only the text face changed: every box, fill, border, radius and position is the same, and wrapped text breaks at the same words. Text is measured and painted in the same face: "Fit me" is laid out at Geist's advance, 45.46875 pt (egui's sans: 44.53125), and its box edge rounds to the same pixel either way; the wrapped rows end where Geist's metrics put them. Reviewed and approved by the user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
Owner
Author
|
Try it: |
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.
Stage 6 of #497: one
SharedStyleis the source of the look. #506 has merged, and main is merged in with no file changes, so the diff is stage 6 only.What changes (decided on #497)
SharedStyle::new(themed)is a clonable handle, re-exported at the crate root.LayoutState::new(&shared)orLayoutState::named(name, &shared).shared.set(..)switches every layout made from the handle, from their next build.shared.get()reads it.Shadcn::apply,apply_both,apply_both_with,appliedandof;theme::tokens);with_style,LayoutState::set_style,LayoutState::style()andLayoutState'sDefault;Style::fallbackwith its faces hack,FontSet::installandProblem::UnstyledLayout.MissingFace.Bodystyle is no longer read.HeadlessandDrivertake.style(&SharedStyle)and default to shadcn's default style.set.Goldens (approved by the user)
The 8 layout-only goldens (
kaolin_*,chrome_stacked_by_z) re-render in Geist instead of egui's sans, with the layout unchanged. Measurement matches paint: for example, "Fit me" is 45.47 pt in Geist against 44.53 pt in egui's sans, and both snap to the same pixel edge. The new PNGs are byte-identical to the reviewed images. No other golden moved.Checks
cargo xtask integrate: all green (11/11), 229/229 goldens.setswaps the style from the next build;set.Shadcn::of;For the user
TODO(prose)on the theme module docs, the field/tokens/fonts docs that namedShadcn::apply, the README line about registering Geist, and the style, egui_look and layout_style test module docs.🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76