Palette Parts
alikit:palette_parts is a copyable, parts-based variant of the command palette’s
result list. It owns the retained virtual list, published List_Box collection,
selection reconciliation by stable Item_ID, enabled-row navigation, reveal, and one
activation event. The application owns the query, matching and ranking, commands, modal shell,
dismissal, and focus restoration.
Preview
Section titled “Preview”
Responsibility split
Section titled “Responsibility split”| Layer | Responsibility |
|---|---|
| Alicorn | Virtual list, scroll region, Button owners, List_Box semantics, focus, and rendering. |
palette_parts | Row drawing, selection by stable ID, enabled navigation, reveal, List_Box collection, and one activation event. |
| Application | Query field, matching/ranking, commands, modal shell, dismissal, and focus restoration. |
This package deliberately does not wrap alikit:command_palette. It exists to show which pieces
of the stock palette are ordinary public Alicorn facilities and which policy remains
application-owned. The stock palette remains the complete choice.
Copyable implementation
Section titled “Copyable implementation”Files: palette_parts/parts.odin, palette_parts/parts_test.odin,
palette_parts/pilot_test.odin, examples/palette_parts/main.odin.
import alicorn "alicorn:runtime"import ui "alicorn:ui"import model "alikit:palette_model"import parts "alikit:palette_parts"
ITEMS := [2]model.Item{ {id=model.Item_ID(1), title="Open File", description="Browse the workspace"}, {id=model.Item_ID(2), title="Build Project", keywords="compile"},}
App :: struct { matches: [2]model.Match, visible: int, results: parts.State,}
render :: proc(app: ^App, ctx: ^ui.UI) { app.visible, _ = model.filter(ITEMS[:], "", app.matches[:]) event := parts.results( ctx, &app.results, ITEMS[:], app.matches[:app.visible], key=alicorn.key_string("app-palette-results"), options=parts.Options{accessible_label="Commands"}, ) if event.kind == .Activated { // Dispatch event.item_id in application code. }}Pass a fresh visible slice each description. The part never stores item strings. handle_key is
the application’s keyboard path when its query field owns focus:
handled, event := parts.handle_key(&app.results, rt, ITEMS[:], app.matches[:app.visible], key)When the list owns focus, its retained interaction scope delivers the same keys through
interaction_event_next during the next description. Both paths use palette_model.move and
palette_model.activate; there is no second selection policy. request_focus asks for one
after-frame focus of the list.
Parts and identities
Section titled “Parts and identities”| Part | Identity | What can be replaced |
|---|---|---|
| Virtual list | list_begin/list_end | Row height, maximum height, and accessible name. |
| Row owner | stable Item_ID | item_begin/item_end owns List_Box_Option; draw any compatible subtree. |
| Leading icon | icon part | Replace the accent tile with an icon or swatch. |
| Label / description | label / description parts | Restyle without changing identity. |
| Selected indicator | indicator part | Replace the check glyph; keep the selected state. |
| Group | group_begin/group_end | Single-level semantic group for shorts lists where all rows are realized. |
| Empty | empty | No-results label. |
| List collection | list_semantic_id(namespace) | The List_Box identity and logical count. |
results is a convenience wrapper over list_begin, item_begin, the optional visual parts,
item_end, and list_end. command_palette uses the same public parts for its modal result list,
so the two paths share one contract.
Each realized row is a button_begin(presentation=.Custom) owner with a List_Box_Option
semantic record. Rows expose Selected, Current, Disabled, and Select/Focus actions. The
scroll region owns the List_Box collection with a logical count, realized range, and
selected/current identity.
Styling, motion, and theme
Section titled “Styling, motion, and theme”- Visual parts are attached for
.Icon,.Label,.Content, and.Selected_Indicator, so an application can restyle without changing behavior. - The part uses Alicorn core roles (
Surface,Text,Muted_Text,Selection,Accent); it declares no theme contract. Optionscarries the accessible label, empty label, row height, list maximum height, semantic namespace, andfocus_on_pointer.- There is no part-authored motion. Reveal is a retained virtual-list request, not a second layout pass.
Keyboard and accessibility contract
Section titled “Keyboard and accessibility contract”| Input | Result |
|---|---|
Up / Down | palette_model.move with wrapping and disabled skipping. |
Home / End | First/last enabled visible row. |
Return | One activation event for the selected stable item. |
| pointer | Row activation through the ordinary Button owner. |
semantic Select | The same activation through List_Box_Option. |
| caller reorder/removal | Selection follows Item_ID; reconcile falls back to the first enabled row. |
The part publishes only realized rows. virtual_list_ensure_visible is requested after
navigation; the list remains a single Tab stop with non-focusable rows.
Conformance tests
Section titled “Conformance tests”palette_parts/parts_test.odin covers the list part; the stock-versus-parts pilot now lives in
command_palette/pilot_test.odin because the palette consumes this package:
- retained virtual rows, published
List_Box/List_Box_Optionsemantics, and logical count; - Up/Down wrapping, disabled skipping, Home/End, and Return activation;
- pointer and semantic activation parity;
- stable selection across caller reorder and removal;
- reveal and focus request behavior, and idle return after navigation;
- the stock-versus-parts comparison recorded in the issue 3 research note.
odin test palette_parts -define:ODIN_TEST_THREADS=1 -collection:alicorn=<alicorn> -collection:alikit=../out/palette_parts_example.exe --smokeNo dedicated testui pattern kind fits a result-list part; the suite uses explicit drive and
semantic assertions. The .Roving_List pattern requires a List_Box container and a different
focus owner model.
API reference
Section titled “API reference”| Declaration | Notes |
|---|---|
Event / Event_Kind | One Activated event carrying item_id. |
Options | Accessible label, empty label, row height, maximum list height, namespace, pointer focus. |
State | Selection, derived visible index, list owner, namespace, reveal/focus flags. |
List, Row, Group | Per-description contexts. |
results | Describe the default list and return an activation event. |
list_begin, list_end, item_begin, item_end | Public list/row parts. |
row_surface, icon, label, description, indicator | Optional default visuals. |
empty, group_begin, group_end | Empty and single-level group parts. |
handle_key | Navigation when the query field owns focus. |
request_focus | Ask for one after-frame focus of the list. |
selection_visible_index | Report the selected row’s current visible position without retained state. |
item_semantic_id, list_semantic_id, group_semantic_id, row_key | Stable identities and retained keys. |
Limits
Section titled “Limits”- It is a result-list part, not a modal palette. Add the application’s own overlay/query shell.
- It does not implement type-ahead; the query field owns text input.
Page Up/Page Downare not handled, matching the stock palette’s current keyboard contract.- Headless tests do not validate native IME or a platform accessibility bridge.
- At the pinned Alicorn revision, row text layout can elide some labels under the current fit-content/grow measurement limits; the pilot record tracks the core layout gap. The part’s identity, navigation, semantics, and activation do not depend on the painted label width.
Compatibility
Section titled “Compatibility”47c9d4a7cd1f637876190fec899daeeac00a30ae. See
Compatibility and pinning.