Skip to main content

Module toolbar

Module toolbar 

Source
Expand description

Toolbar contributions (docs/toolbars.md). The model (day_spec::ToolbarItem) is toolkit-neutral and carries only ids for its commands; the closures live here, keyed by id, the same shape as crate::menu and the same id space, so one closure can back both a toolbar button and its menu-bar twin.

Any piece can declare items. Where it sits decides which chrome carries them (the window’s own, or one navigation page’s), and its scope decides how long they stay: a contribution is withdrawn when the piece that registered it is disposed, so a command leaves with the content it acts on. Several pieces may contribute to one chrome; this module merges them in registration order and hands the result to the toolkit as one model.

Structs§

DocumentWindow
A resident document’s mutable presentation window. Contributions inherit this context so moving the document also moves its commands without rebuilding them.

Enums§

Chrome
Which chrome a contribution lands on.

Functions§

chrome_changed
The pieces layer, after a change to what is on screen (a push, a pop, a tab switch), so a one-bar-per-window toolkit is handed the showing pages’ items. No-op where every page has a bar of its own.
current_chrome
The chrome a contribution registered right now belongs to: the innermost navigation page being built, else the window being built, else the primary window.
current_page_column
Which column the page being built is; day_spec::ToolbarColumn::Window at the window root.
current_page_gate
The predicate for the page being built, if it has one.
current_page_window
The window the page being built belongs to, else the one being built.
dispatch_toolbar_value
Run the value callback registered for action (no-op if none). Called by the event pump on Event::ToolbarChanged, inside a reactive batch so multiple signal writes coalesce. action is the slot id the toolkit holds (the toolbar slot model); a raw closure id works too.
focus_toolbar_search
Focus the active window’s search control, revealing a collapsed desktop search item. Returns false when the active window has no toolbar search contribution.
patch_chrome
patch_toolbar against an explicit chrome. Also updates the retained model, so a later full replace does not resurrect the stale value.
patch_toolbar
Apply a targeted item update wherever the item lives: the path a bound signal writes through, so a search field keeps its focus and its insertion point.
register_contribution
Add one piece’s items to chrome and return the token that owns them. The caller withdraws them with unregister_contribution, normally from its own scope cleanup.
register_contribution_gated
register_contribution for a page, with the predicate that says whether that page is on screen. The caller also re-reads it inside an effect, which is what re-composes the bar when a pane collapses or the destination changes.
register_toolbar_value
Register a value callback for a search or toggle item and return its dispatch id (nonzero). The id comes from the menu action counter, so toolbar and menu ids never collide.
relabel_contribution
Give a contribution’s items new labels and tooltips, one (label, tooltip) per item in order, keeping everything else as it now stands (actions, a search field’s typed text): a language change relabeling a fixed toolbar (docs/toolbars.md).
reset_toolbars
Reset every chrome’s toolbar state (tests; pairs with uninstall_tree).
synthesize_toolbar_value
Synthetic input to a bar item (dayscript’s toolbar: step): paint the widget the way an app write would, then dispatch the value as the native control would. Both halves are needed, as for a text field (crate::synthesize_text): a real keystroke reaches Day with the field already showing it, so the dispatch alone records the text without touching the widget, and a synthesized one left the field empty while the app acted on the query.
toggle_sidebar
Show/hide the sidebar pane of the navigation host host: the behavior behind the sidebar affordance a nav host contributes for itself (day_spec::SIDEBAR_TOGGLE_ID). false when the toolkit has no pane to toggle there. The item’s action makes this call, and dayscript’s toolbar: step presses the item like any other, so a walkthrough drives the same path a click does (docs/toolbars.md).
toolbar_model
Every live item, across every chrome. dayscript’s toolbar: step walks it to resolve an item’s dispatch id, and an app has one bar per window at a time, so a duplicate id across two chromes would be an app bug rather than an ambiguity to resolve here.
unregister_contribution
Withdraw a contribution. Its items leave the chrome, and the closures only it owned go with them.
update_contribution
Replace one contribution’s items in place, keeping its position among its neighbors.
window_being_built
The window being built, else the primary root. Shared with the ambient environment lookup, which scopes the same way for the same reason: an app’s one size_class() call inside a shared build_shell must mean “this window”.
with_page
Run f with page as the navigation page contributions inside it belong to. The pieces layer wraps each destination, sidebar and content-list build in this.
with_page_gated
with_page with the predicate that says whether this page is on screen (a collapsed content-list pane, a destination that is not the one showing, a page covered by a push). The window’s one bar carries only the chromes that predicate admits (docs/toolbars.md).
with_page_in
with_page_gated naming the window explicitly. Callers that build pages lazily (every navigation host) pass the window they were built in.