Files
jyviko bb70f0d901 ui-kit: the Browser panel, data-driven, for any app to host (#15787)
* The Browser panel in the UI kit, drawn from the host's rows

A host emits its rows each frame (open branches only; next_visible/skip
let it skip rows scrolled out of view) and the panel draws them with
tree_row and returns events: Select (only, toggle, range, range add),
Click for rows that are no item, Open, Fold, Eye with the eye drag's
EyeGesture, Activate, Rename, Move (before or into), Action, NameAction,
Menu and Revealed. It never changes the host's state.

BrowserState keeps, per presentation, the Shift anchor and row order,
the slow second click that renames, the inline name editor (Enter keeps,
Escape cancels, refuse_rename reopens), the dragged rows and drop marks
under the host's rules, the eye drag, the row to reveal, the search text
and the keyboard cursor. Folds stay the host's; FoldMemory is the shared
store, order_before and cancel_drag the shared helpers. An optional
header has the title, count, fold chevron and search; search and
keyboard arrows are off by default.

tree_row also publishes its radio as radio:<handle>. Tests drive the
panel with a fake host; the gallery has a browser specimen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: rustfmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: scope ids, a token for the fold area, a reveal test that waits out the scroll

The panel's widget ids come from the scope id (Ui::id is deprecated);
the scope id is stable from frame to frame, and the show() doc says a
host showing two presentations in one scope pushes an id for each. The
drawn fold area's width is space_16 + space_3, as tree_row's is. The
reveal test ran six 1/60 s frames, shorter than egui's animated scroll
(0.1 to 0.3 s), so the row was never in view; it now waits 0.1 s a frame
for 1.2 s and still checks the reveal is reported once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: rustfmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: a fold shows in the rows the host emits next frame

The fold test read the rows of the click's own frame, drawn before the
host had the event. The panel returns events after drawing and draws
exactly the rows it is given, so the host's fold (children no longer
emitted) shows on the next frame, as in the model tree today, which
decides open before it toggles. The test now checks both frames, and the
module doc says the host stops emitting a closed row's children itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: host rename, per-row events, drag source and data, no-scroll and inactive presentations

What a host with its own row machinery needs from the panel:

- Rename per node: Inline (the panel's editor) or Host. A slow second
  click, F2 or BrowserState::request_rename renames a row its way; Host
  emits Event::RenameRequested and RowOut gives the row's widget id and
  name area for the host's own editor.
- Browser::events_per_row: each row's events come back in its RowOut as
  it is drawn, with its click, double and secondary click, drag start
  and the drop zone under a drag; the frame keeps the panel's own events.
- A drag carries its Source (scope and presentation) and the host's data
  (Payload, any type); Event::Move carries both. Whether it lands is the
  host's rule over source and target; without rules, within its scope.
- Rows::drag_with: on a row's drag start the host gives the set it
  carries, items no row draws included.
- Browser::scroll(false) lays the rows out in the host's layout.
- Browser::active(false) draws and emits nothing; an eye drag it holds
  ends with EyeGesture::End, and a row drag it began is cancelled.

Rename::SlowClick is now Rename::Inline; Move events in the tests carry
their source. Each behaviour has a test against the fake host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: rustfmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: a row's own drop rule, its widget response, passed rows, ending gestures from the context

Found mapping the model tree's rows onto the panel:

- Node:🉑 a row's own drop rule replaces the panel's for it (a
  host's rules read its document row by row). When the rules refuse the
  zone under the pointer, the row's other zone is tried.
- RowOut::response and RowOut::on_control, for tooltips and a host's
  own drag gestures.
- Rows::pass: a row the host lays out itself out of view stays in the
  order, so a Shift range across it is whole.
- end_gestures(ctx, state, source): what a presentation holds ends when
  it is not drawn at all, as an inactive one does.

Each has a test against the fake host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: a row's response has its eye's area

A host may publish its own target for a row's eye (the render
workspace's light mute). Tested against the fake host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Browser: a drop over a row's middle never lands before it

The refused-zone fallback went both ways, so a drag over the middle of a
row taking both zones landed before it when the rules refused inside,
against the host's rule test. The fallback now goes one way: in a row's
top part a refused "before" falls back to inside (a placement's top
part reparents when it is no sibling to reorder before); over the rest
of the row only inside is taken. The row-rule test asks for that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 04:21:18 +00:00

2.6 KiB

solidcraft-ui-kit

The UI kit: the tokenised egui controls every dialog, panel and menu is built from, and the components built from them. A component takes plain data (labels, icons, entries, values and the host's prefix for its names), draws with solidcraft_theme::Tokens, reads its text through solidcraft_ui_text, publishes its handles into solidcraft_ui_registry and returns what the user chose for the host to run. Nothing here reads an app's state.

What a host draws with is host data, installed once per process before the first frame or passed in: its icon set (icons::install; icons::IconSet::extended draws another host's set with a few masters of its own), its glyphs, its tab table (solidcraft_theme::install_tabs), its navigation catalogue (navigation_bar::install_catalogue), its message catalogs (solidcraft_ui_text::install), its built-in themes (theme_files::install_builtin) and its fonts. With none installed the kit still draws: icons draw nothing, text shows its message ids and there are no built-in themes.

API

Item What it is
Rows and fields: row, expr_row, text_row, choice_row, count_row, slider, checkbox, dropdown, ... The form controls, with aligned label columns
Container, Window, Panel, Menu, Confirm Every outer window, popup, panel and menu
icons The icon renderer over the host's installed icon set
type_face The kit's font weights over the host's fonts
ribbon, app_bar, history_bar, nav_bar, navigation_bar, view_compass, prefs_window, start_page, window_chrome Components: plain data in, the action chosen out
browser The Browser panel: the host emits its rows each frame, the panel returns events (select, fold, eye, rename, move, menu, reveal) and never changes host state
frame Dock dragging and bounded anchors
blur The blurred backing behind translucent panels
theme_files, theme_options Theme files: reading, validating, resolving to Tokens, their options; the host's built-in themes

The test-support feature adds the kit's test fixtures for a host's own tests of the kit with its data: test_support (a context with egui's default faces and the kit's English test catalog, headless frames and events, the CPU rasteriser), gallery (the specimens and their checks) and theme_files::fixtures.

See docs/ui-kit.md for the controls and their rules.

Licence

This crate is part of SolidCraft's brand and interface, under the SolidCraft Brand and Interface Licence (LICENSE). Use it as part of SolidCraft; using it in another program or product needs the maintainers' written permission first.