Skip to content

The segmented look as public Style classes; Enablement::and public (#346, PR 2) - #425

Merged
samitbasu merged 5 commits into
mainfrom
segclass-346
Nov 19, 2026
Merged

samitbasu merged 5 commits into
mainfrom
segclass-346

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Part of #346: PR 2 of the design note, the segmented control's look as public classes, so the tabs widget can look exactly like it.

What changes

  • Style::segmented_track, Style::segmented_cell, Style::segmented_icon return the classes Builder::segmented draws its track, a cell and a cell's icon with. Each takes the egui Context and a Size. The track and the cell also take a SegmentedRows and an Enablement, and the cell takes whether it's the chosen one (Cell::Pressed / Cell::Released).
    • segmented now builds its own track, cells and icon through the same code, so the look is defined once.
    • The size is looked up once per control. An unknown size is still reported at the caller (#[track_caller]), as before.
    • A cell's classes don't sense input; the caller adds sense_click(), as the doc says.
  • owned::SegmentedRows (One, Wrapping) is public, for those methods: a track on one row, or one that wraps its cells. It was to be Rows, but Table: rows_with, group rows and per-table stripes (part of #370/#371) #399 has since taken that name for the table's rows, so this name is for you to check.
  • Enablement::and is public (#[must_use], with a doctest), so a widget combines its own enablement with the subtree's as own.and(b.enablement()) and doesn't spell the rule as a match.
  • A widget gets the size and enablement its subtree gives from Badge, Chip and Spinner in eggshell-ui-extras #360's Builder::control_size() and Builder::enablement(). The new test builds its track that way.

Decisions (with the eggshell session; for review)

  • The user picked this shape, methods on Style with the rows enum public, from the options in the note.
  • Methods on Style, not on SegmentedStyle: a cell's classes need the whole style (the text role, the transition, how disabled controls are drawn).
  • Builder::size_of and enablement_of stay private, as you asked. Badge, Chip and Spinner in eggshell-ui-extras #360's getters serve instead, and I proposed no combining form beyond Enablement::and.

Breaking changes

None. Everything is new public surface.

Tests

New in tests/it/segmented_classes.rs: the library's segmented and a track hand-built from the public methods, side by side through the real build, layout and draw. Every descendant's path, size and position relative to its track must match, as must the track's fill and each cell's fill and text colour.

  • public_classes_draw_the_library_s_control
  • they_follow_the_size_a_subtree_gives: under control_size(SM), with a precondition that the small track is another height.
  • they_follow_an_inert_subtree
  • they_fade_as_the_style_fades_disabled_controls: under Disabled::Faded, with a precondition that the faded track is drawn otherwise.
  • a_wrapping_track_matches_too

Every existing test passes unchanged, and no golden changed.

Reversion check: on main the suite doesn't compile, because the API is new. Each mutation of the public methods below fails tests, and the unmutated branch passes them all:

  • the track ignores its size: 1 fails;
  • the track ignores SegmentedRows: 1 fails;
  • the track ignores its enablement: 1 fails (the faded test, added because the default style draws a disabled track unchanged);
  • the cell ignores its size: 1 fails;
  • the cell ignores whether it's chosen: 5 fail;
  • the cell ignores its enablement: 1 fails;
  • the icon ignores its size: 1 fails.

One mutation isn't caught, and can't be: the cell ignoring SegmentedRows. A wrapping track is h_auto, where a cell's h_full resolves to auto, the same as h_auto.

Checks

TODO(prose)

Style::segmented_track, segmented_cell, segmented_icon, SegmentedRows and its variants, and Enablement::and have one-line drafts for you to rewrite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o

samitbasu and others added 5 commits November 19, 2026 10:24
)

A tab list should look exactly like a segmented control, and the tabs
widget can't reach the segmented control's look from outside the core.
Style::segmented_track, segmented_cell and segmented_icon give the
classes the segmented control itself builds, at a size, a Rows layout
and an enablement, and the segmented control now builds its own track,
cells and icon through them, so the look is defined once. Rows is
public for them. Enablement::and is public, so a widget can combine its
own enablement with the subtree's without spelling the rule as a match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
Under the default style (Disabled::Colors) a disabled track looks like an
enabled one, so no test saw a track that ignored its enablement. This one
draws both under Disabled::Faded, and checks first that the faded track
really is drawn otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
#399 made the table's Rows public at owned::Rows, so the segmented
control's rows enum takes the name SegmentedRows, beside SegmentedChain
and SegmentedMetrics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user on its tests, name SegmentedRows (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit d3dce3d into main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant