NavigationShell¶
Header: winui/ui/navigation/NavigationShell.hpp. Spec: winui/ui/navigation/NavigationShell.hpp.
A navigation view: a pane of navigation items (left, compact, minimal or a top bar) beside a content area that shows the selected item's page.
Items are NavEntry values. The selection is reported as keys: an item's NavEntry::key, else its text, and "settings" for the Settings item. The positional calls (set_expanded(), text_at(), item_bounds()) take a pre-order index over the menu items, then the footer items, with Settings for the Settings item. A selected item shows its own content, or the view's content from set_content() when it has none. In Auto mode the pane adapts to the control's width. It opens and closes on its toggle button, and closes on a click outside when it overlays the content. It can host an AutoSuggestBox, a pane header, custom content and a footer, all owned by the view. The items are one tab stop with a keyboard cursor. The declarative form is ui::NavigationShell with ui::NavItem.
Example:
auto nav = std::make_unique<ui::NavigationShellControl>();
nav->set_pane_display_mode(ui::NavigationShellPaneDisplayMode::Left);
nav->set_pane_title("My app");
nav->add_item("Home", std::make_unique<ui::TextControl>("Welcome home"));
nav->add_item("Library", std::make_unique<ui::TextControl>("Your library"));
nav->on_selection_changed([](const std::string& key) {
if (key == ui::NavigationShellControl::SettingsKey)
std::println("open the settings page");
});
ui::NavigationShellControl* view = window.set_content(std::move(nav));
view->set_header(view->selected_key()); // "Home": the first item is selected, keyed by its text
// Or declaratively, with one shared content region driven by the selection:
ui::Property<std::string> page;
window.set_content(ui::NavigationShell{
.selected_key = page, // "home" at first, then whatever the user picks
.pane_display_mode = ui::NavigationShellPaneDisplayMode::Top,
.content = ui::Text{.text = page},
.items = {ui::NavItem{.text = "Home", .key = "home", .icon = ui::symbol_glyph(ui::Symbol::Home)},
ui::NavItem{.text = "Mail", .key = "mail", .icon = ui::symbol_glyph(ui::Symbol::Mail)}},
});
ui::NavigationShell¶
A pane of navigation items over swappable content. Builds a ui::NavigationShellControl.
The selection is a key: an item's .key, else its text, and "settings" for the Settings item. Auto display mode picks Expanded, Compact or Minimal from the view's width against the two thresholds.
Example:
ui::Property<std::string> page{"mail"};
window.set_content(ui::NavigationShell{
.selected_key = page, // two-way: a click writes the new key
.pane_display_mode = ui::NavigationShellPaneDisplayMode::Left,
.on_selection_changed = [&](const std::string& key) {
if (key == ui::NavigationShellControl::SettingsKey)
open_settings();
},
.items = {
ui::NavItem{ .text = "Home", .key = "home", .icon = ui::IconGlyph{0xE80F}, .content = ui::Text{ .text = "Welcome" } },
ui::NavItem{ .text = "Mail", .key = "mail", .icon = ui::IconGlyph{0xE715}, .content = ui::Text{ .text = "Inbox" } },
},
.footer_items = { ui::NavItem{ .text = "Account", .key = "account", .icon = ui::glyphs::Contact } },
});
Every field, in the order a designated initializer names them:
ui::NavigationShell{
.header, .pane_title, .selected_key, .is_pane_open, .pane_width, .item_row_height,
.pane_display_mode, .always_show_header, .settings_visible, .back_button_visible,
.back_enabled, .pane_toggle_button_visible, .pane_visible, .selection_follows_focus,
.compact_pane_length, .compact_mode_threshold_width, .expanded_mode_threshold_width,
.style, .margin, .width, .height, .min_width, .min_height, .max_width, .max_height,
.horizontal_alignment, .vertical_alignment, .visible, .tool_tip, .enabled, .accessibility,
.on_selection_changed, .on_item_invoked, .on_display_mode_changed, .on_pane_opening,
.on_pane_opened, .on_pane_closing, .on_pane_closed, .on_back_requested,
.on_pointer_entered, .on_pointer_exited, .on_got_focus, .on_lost_focus, .on_key_down,
.on_wheel, .control, .content, .items, .footer_items, .auto_suggest_box,
.pane_header_content, .pane_custom_content, .pane_footer_content
}
Fields, in declaration order (designators must follow it):
| Field | Type | Default | |
|---|---|---|---|
header |
ui::Binding<std::string> |
The title over the content area; empty draws none. | |
pane_title |
ui::Binding<std::string> |
Text beside the hamburger button while the pane is open. | |
selected_key |
ui::TwoWayField<std::string> |
The selected item's key ("settings" for Settings). Empty, or a key no item has, leaves the first item selected. Bound two-way, the property then takes the key that is selected. | |
is_pane_open |
ui::TwoWayField<bool> |
{true} |
Whether the pane is open. A Minimal or Compact pane starts closed whatever this says; bind it to open one later. |
pane_width |
ui::Binding<float> |
{320.0f} |
The expanded pane's width, in DIPs. |
item_row_height |
ui::Binding<float> |
{40.0f} |
The height of one item row in the left pane, in DIPs (a 36-DIP pill in a 40-DIP slot). |
pane_display_mode |
ui::Binding<ui::NavigationShellPaneDisplayMode> |
{ui::NavigationShellPaneDisplayMode::Auto} |
Where the items go: Left, Top, LeftCompact, LeftMinimal, or Auto (width-driven). |
always_show_header |
ui::Binding<bool> |
{true} |
False shows the header only in Minimal mode. |
settings_visible |
ui::Binding<bool> |
{true} |
Shows the built-in Settings item at the bottom of the pane. |
back_button_visible |
ui::Binding<ui::AutoVisibility> |
{ui::AutoVisibility::Auto} |
Whether the back button shows; Auto behaves as Visible. |
back_enabled |
ui::Binding<bool> |
{false} |
A visible back button is disabled until this is set (bind it to can_go_back). |
pane_toggle_button_visible |
ui::Binding<bool> |
{true} |
Shows the hamburger button. |
pane_visible |
ui::Binding<bool> |
{true} |
False hides the pane (and its toggle button) altogether. |
selection_follows_focus |
ui::Binding<ui::NavigationShellSelectionFollowsFocus> |
{ui::NavigationShellSelectionFollowsFocus::Disabled} |
Whether moving the keyboard cursor also selects. |
compact_pane_length |
ui::Binding<float> |
{48.0f} |
The closed pane's width in Compact mode, in DIPs. |
compact_mode_threshold_width |
ui::Binding<float> |
{641.0f} |
The width below which Auto is Minimal. |
expanded_mode_threshold_width |
ui::Binding<float> |
{1008.0f} |
The width from which Auto is Expanded (Left). |
on_selection_changed |
ui::Callback<void(const std::string&)> |
Called with the new key whenever the selection moves. | |
on_item_invoked |
ui::Callback<void(const std::string&)> |
Called with the item's key on every click or Enter/Space on an item (Settings included), selected or not, before the selection moves. | |
on_display_mode_changed |
ui::Callback<void(ui::NavigationShellDisplayMode)> |
Called when the resolved mode changes, including on the first layout. | |
on_pane_opening |
ui::Callback<void()> |
Called when the pane is about to open. | |
on_pane_opened |
ui::Callback<void()> |
Called when the pane has opened. | |
on_pane_closing |
ui::Callback<ui::Decision()> |
Called when the pane is about to close; return ui::Cancel to keep it open. | |
on_pane_closed |
ui::Callback<void()> |
Called when the pane has closed. | |
on_back_requested |
ui::Callback<void()> |
Raised when the back button is clicked. | |
on_pointer_entered |
ui::Action |
The pointer moved onto the control. | |
on_pointer_exited |
ui::Action |
The pointer left the control. | |
on_got_focus |
ui::Action |
Keyboard focus arrived on the control, or on anything inside it, from outside it. A control with nothing focusable in it never gets focus, and never raises this. | |
on_lost_focus |
ui::Action |
Keyboard focus left the control and everything inside it. | |
on_key_down |
ui::Callback<ui::Handling(const ui::KeyEvent&)> |
A key pressed while focus is on the control or inside it, before the control's own handling; ui::Handled stops it there (Element::on_key_down()). | |
on_wheel |
ui::Callback<ui::Handling(const ui::PointerEvent&)> |
A wheel turn over the control, before the control scrolls; ui::Handled stops it there (Element::on_wheel()). | |
control |
ui::ControlOut<ui::NavigationShell> |
Out: the handle that receives the built control. | |
content |
ui::Spec |
The shared content region, shown for any selected item that carries no .content of its own, typically a ui::NavigationFrame (ui::NavigationShellControl::set_content). |
|
items |
ui::NavList |
The pane's entries, top to bottom. | |
footer_items |
ui::NavList |
Entries pinned to the bottom of the pane, above Settings. | |
auto_suggest_box |
ui::Spec |
A search box at the top of the pane. | |
pane_header_content |
ui::Spec |
Content beside the pane toggle button. | |
pane_custom_content |
ui::Spec |
Custom pane content: above the menu items, after them in Top mode. | |
pane_footer_content |
ui::Spec |
Content at the very bottom of the pane. |
Plus the common fields style, margin, width, height, min_width, min_height, max_width, max_height, horizontal_alignment, vertical_alignment, visible, tool_tip, enabled, accessibility every spec carries (conventions).
build¶
Consumes the spec and returns the built ui::NavigationShellControl; the caller owns it.
ui::NavItem¶
One navigation entry: the text in the pane, the content shown while it is selected, and any nested items it groups. A non-empty children makes the row a collapsible group with a chevron.
.content may be left unset. The view's own ui::NavigationShell::content is then shown for this item.
Example:
ui::NavItem{ .text = "Basic input",
.key = "input",
.expanded = true,
.selects_on_invoke = false,
.icon = ui::IconGlyph{0xE73A},
.children = {
ui::NavItem{ .text = "Button", .key = "button", .content = ui::Text{ .text = "Button page" } },
ui::NavItem{ .text = "CheckBox", .key = "checkbox", .content = ui::Text{ .text = "CheckBox page" } },
} }
Every field, in the order a designated initializer names them:
ui::NavItem{
.text, .key, .expanded, .selects_on_invoke, .icon, .kind, .tool_tip, .animated_icon,
.content, .info_badge, .children
}
Fields, in declaration order (designators must follow it):
| Field | Type | Default | |
|---|---|---|---|
text |
ui::Binding<std::string> |
The row's text, and its tooltip while the pane is compact. A bound item should have a .key, or its key changes with its text. |
|
key |
std::string |
What identifies the item in .selected_key and the selection events. Empty uses the text. "settings" is taken by the Settings item. |
|
expanded |
bool |
false |
A group starts with its children showing. |
selects_on_invoke |
bool |
true |
Whether invoking the row selects it; false makes the row a pure heading. |
icon |
ui::IconSource |
The row's icon. | |
kind |
ui::NavEntryKind |
ui::NavEntryKind::Item |
An item, a section header (text as its title) or a separator. |
animated_icon |
const ui::AnimatedIconSource* |
nullptr |
An animated icon over this source (not owned), with icon as its fallback; the row plays its PointerOver/Pressed/Normal transitions. |
content |
ui::Spec |
The page shown while this item is selected; unset falls back to the view's .content. |
|
info_badge |
ui::Spec |
A ui::InfoBadge on the row; any other spec is ignored. | |
children |
ui::NavList |
The items nested under this one. |
Plus the common fields tool_tip every spec carries (conventions).
ui::NavList¶
A built, owned list of navigation entries, the braced-list form of the move-only ui::NavEntry. Callers never name it, since a braced list of ui::NavItem{...} converts to it.
Every field, in the order a designated initializer names them:
Fields, in declaration order (designators must follow it):
| Field | Type | Default | |
|---|---|---|---|
entries |
std::vector<Entry> |
The entries, in pane order. |
operator=¶
operator=¶
struct Entry¶
One entry with its content and badge already built; mirrors ui::NavItem's fields.
| Field | Type | Default | |
|---|---|---|---|
text |
Binding<std::string> |
||
key |
std::string |
||
node |
std::unique_ptr<Element> |
||
children |
std::vector<Entry> |
||
expanded |
bool |
false |
|
selects_on_invoke |
bool |
true |
|
icon |
IconSource |
||
info_badge |
std::unique_ptr<Element> |
||
kind |
NavEntryKind |
NavEntryKind::Item |
|
tool_tip |
std::string |
||
animated_icon |
const AnimatedIconSource* |
nullptr |
ui::NavigationShellControl¶
Derives from ui::Element, ui::ValueProvider.
A navigation view: a pane of navigation items (left, compact, minimal or a top bar) beside a content area that shows the selected item's page.
Items are NavEntry values. The selection is reported as keys: an item's NavEntry::key, else its text, and "settings" for the Settings item. The positional calls (set_expanded(), text_at(), item_bounds()) take a pre-order index over the menu items, then the footer items, with Settings for the Settings item. A selected item shows its own content, or the view's content from set_content() when it has none. In Auto mode the pane adapts to the control's width. It opens and closes on its toggle button, and closes on a click outside when it overlays the content. It can host an AutoSuggestBox, a pane header, custom content and a footer, all owned by the view. The items are one tab stop with a keyboard cursor. The declarative form is ui::NavigationShell with ui::NavItem.
Example:
auto nav = std::make_unique<ui::NavigationShellControl>();
nav->set_pane_display_mode(ui::NavigationShellPaneDisplayMode::Left);
nav->set_pane_title("My app");
nav->add_item("Home", std::make_unique<ui::TextControl>("Welcome home"));
nav->add_item("Library", std::make_unique<ui::TextControl>("Your library"));
nav->on_selection_changed([](const std::string& key) {
if (key == ui::NavigationShellControl::SettingsKey)
std::println("open the settings page");
});
ui::NavigationShellControl* view = window.set_content(std::move(nav));
view->set_header(view->selected_key()); // "Home": the first item is selected, keyed by its text
// Or declaratively, with one shared content region driven by the selection:
ui::Property<std::string> page;
window.set_content(ui::NavigationShell{
.selected_key = page, // "home" at first, then whatever the user picks
.pane_display_mode = ui::NavigationShellPaneDisplayMode::Top,
.content = ui::Text{.text = page},
.items = {ui::NavItem{.text = "Home", .key = "home", .icon = ui::symbol_glyph(ui::Symbol::Home)},
ui::NavItem{.text = "Mail", .key = "mail", .icon = ui::symbol_glyph(ui::Symbol::Mail)}},
});
Settings¶
The Settings item's index in the positional calls (text_at(), item_bounds(), set_selected_index()).
SettingsKey¶
The Settings item's key, as selected_key() reports it and set_selected_key() takes it.
NavigationShellControl¶
An empty view in Auto mode with an open pane, the Settings item visible and the back button shown but disabled; it creates its own back, toggle, close and search buttons.
~NavigationShellControl¶
NavigationShellControl¶
operator=¶
set_items¶
Replaces the menu items and resets the selection to the first selectable item. A selected Settings item stays selected. The keyboard cursor and the selection indicator's animation reset too.
set_footer_items¶
Items at the bottom of the pane (the right of the top bar), above the Settings item, in the same selection model. Their indices follow every menu item's. Keeps the selection when it was a menu item or Settings.
add_item¶
Appends a leaf at the top level of the menu items, taking ownership of its content, and returns a non-owning observer to the content. The first item added becomes selected. Use set_items() for nested items.
set_content¶
The content region used by any selected item whose own content is null, usually a NavigationFrame. Takes ownership and hands back a non-owning observer.
item_count¶
Every item in the tree, menu and footer, collapsed ones included. This is the pre-order index space of selected_index() and set_expanded().
footer_item_count¶
How many of those are footer items (the last ones).
visible_row_count¶
How many menu rows are currently drawn in the pane, i.e. not hidden inside a collapsed ancestor. Footer rows are not counted.
text_at¶
The text of the item at pre-order index ("Settings" for Settings), or an empty string if out of range.
set_text¶
Changes the text of the item at pre-order index; updates the layout and redraws. An item without a NavEntry::key is keyed by its text, so its key changes too. Out of range, and Settings, are no-ops.
key_at¶
The key of the item at pre-order index: its NavEntry::key, else its text; "settings" for Settings; empty out of range.
index_of¶
The pre-order index of the first item with key, Settings for "settings"; unset when no item has it.
info_badge_at¶
The badge of the item at pre-order index, or null.
set_info_badge¶
Replaces (or with null, removes) the badge of the item at pre-order index, and returns the new one as an observer. Out of range is a no-op returning null.
set_selects_on_invoke¶
Changes NavEntry::selects_on_invoke of the item at pre-order index. Out of range is a no-op.
item_at_row¶
The item drawn at menu row row (pre-order index); unset if out of range.
selected_key¶
The selected item's key ("settings" for Settings), or empty when nothing is selected.
set_selected_key¶
Selects the first item with key; "settings" selects the Settings item and an empty key clears the selection. A key no item has is a no-op, otherwise as set_selected_index().
selected_index¶
The selected item's pre-order index, or Settings; unset when nothing is selected.
set_selected_index¶
Selects the item at pre-order index, clamped to the item list. Settings selects the Settings item and unset clears the selection. Does nothing, and fires nothing, if the item is already selected, is a heading (selects_on_invoke == false), a header or a separator, or is Settings while it is hidden. Either way the left pane scrolls the item into view on the next layout, after laying out any expansion made just before.
settings_selected¶
Whether the Settings item is the selection.
on_selection_changed¶
Fired with the new key whenever the selection changes (a click, the keyboard, set_selected_key(), set_selected_index()); empty when it was cleared. A call that lands on the already-selected item does not fire it.
on_item_invoked¶
Fired with the item's key on every click or Enter/Space on an item, Settings included, whether or not it changes the selection. It is raised before the selection moves.
selection_follows_focus¶
Whether moving the keyboard cursor also selects. Disabled by default.
set_selection_follows_focus¶
Takes effect on the next cursor move; it does not select the item under the cursor now.
expanded¶
Whether the group at pre-order index is expanded; false for a leaf or out of range.
set_expanded¶
Expands or collapses the group at index. A no-op on an item with no children.
on_expanded_changed¶
Fired whenever a group's expansion changes, by click, chevron or keyboard.
pane_display_mode¶
Where the items go. Auto (the default) adapts to the control's width.
set_pane_display_mode¶
Switching between LeftMinimal and Left opens or closes the pane to match; switching to Top closes it.
display_mode¶
What the pane resolved to at the last arrange (Minimal until the first one).
on_display_mode_changed¶
Raised from arrange when display_mode() resolves to a new value, including the first time.
compact_mode_threshold_width¶
The width below which Auto is Minimal, in DIPs; 641 by default.
set_compact_mode_threshold_width¶
Updates the layout; the new threshold applies from the next width change.
expanded_mode_threshold_width¶
The width from which Auto is Expanded, in DIPs; 1008 by default.
set_expanded_mode_threshold_width¶
Updates the layout; the new threshold applies from the next width change.
is_pane_open¶
Whether the pane is open. Opening raises on_pane_opening and on_pane_opened; closing raises on_pane_closing (cancelable only for a light dismiss) and on_pane_closed. In Top mode the pane never opens.
set_pane_open¶
Opens or closes the pane with the same slide a SidePane uses. Closing an Expanded pane this way counts as a user close, so growing back into Expanded does not reopen it.
on_pane_opening¶
Raised when the pane starts to open, before its transition.
on_pane_opened¶
Raised once the pane is open, as soon as its state flips (not after the slide).
on_pane_closing¶
Raised before the pane closes; return ui::Cancel to keep it open. Only a light dismiss can be canceled. The toggle button and set_pane_open(false) always close it.
on_pane_closed¶
Raised once the pane is closed, as soon as its state flips (not when canceled).
pane_width¶
The open pane's width in DIPs, 320 by default, clamped to the control's own width.
set_pane_width¶
Updates the layout. The width is clamped only when the pane is arranged.
compact_pane_length¶
The closed strip's width in DIPs, 48 by default, which is also the width of the toggle and search buttons.
set_compact_pane_length¶
Updates the layout with the new strip width.
is_pane_visible¶
Whether the pane shows (true). False hides the pane and its toggle button altogether.
set_pane_visible¶
Shows or hides the pane; the layout adapts to it on the next arrange.
is_pane_toggle_button_visible¶
Whether the hamburger button shows (true).
set_pane_toggle_button_visible¶
Shows or hides the hamburger button and updates the layout.
pane_title¶
The pane title, shown beside the hamburger while the pane is open.
set_pane_title¶
Sets the title (on the toggle button, or at the top bar's left in Top mode) and updates the layout.
back_button_visible¶
Whether the back button shows; Auto, the default, shows it.
set_back_button_visible¶
Shows or hides the back button and updates the layout.
is_back_enabled¶
Whether the back button is enabled; false by default. A visible back button is disabled until this is set.
set_back_enabled¶
Enables or disables the back button; typically bound to a frame's can_go_back().
on_back_requested¶
Raised when the back button is clicked.
is_settings_visible¶
Whether the Settings item shows at the end of the footer items (true).
set_settings_visible¶
Shows or hides the Settings item; hiding it while selected clears the selection.
set_auto_suggest_box¶
The search box slot: any Element, placed in the pane under the toggle button (in the top bar's right in Top mode). Null removes it.
auto_suggest_box¶
The search box slot's element (owned by the view), or null.
set_pane_header_content¶
The pane header: any Element, under the toggle button, beside it in Top mode.
pane_header_content¶
The pane header element (owned by the view), or null.
set_pane_custom_content¶
Custom pane content: any Element, above the menu items, after them in Top mode.
pane_custom_content¶
The custom pane content element (owned by the view), or null.
set_pane_footer_content¶
The pane footer: any Element, above the footer items, before them in Top mode.
pane_footer_content¶
The pane footer element (owned by the view), or null.
header¶
The content's header text, drawn 28px SemiBold above the content. Empty (the default) draws no header row.
set_header¶
Sets the header text and updates the content area's layout.
always_show_header¶
Whether the header shows in every display mode (true). False shows it only in Minimal.
set_always_show_header¶
Updates the content area's layout.
item_row_height¶
The height of one item row in the left pane, in DIPs: 40 by default (a 36-DIP pill in a 40-DIP slot).
set_item_row_height¶
Updates the pane's layout with the new row height.
pane_scroll_offset¶
How far the menu items are scrolled, in DIPs. Menu items taller than their viewport scroll on the wheel and through an overlay scrollbar.
set_pane_scroll_offset¶
Scrolls the menu items, clamped to 0..(content height - viewport height) from the last arrange; redraws when it moved.
pane_bounds¶
The part of the pane showing right now (animation included); empty in Top mode and while a Minimal pane is closed.
content_bounds¶
The content area: right of an inline pane, under the top bar in Top mode.
item_bounds¶
The drawn rect of the item at pre-order index (Settings for Settings), or nullopt if it has no row showing (hidden in a collapsed group, in the overflow, or scrolled away).
overflow_button_bounds¶
The rect of the top bar's overflow ("More") button, or nullopt when nothing overflows.
in_overflow¶
Whether the item at index is behind the overflow button in Top mode.
flyout_open¶
Whether a children or overflow flyout is open.
back_button¶
The internal buttons, for automation: back, pane toggle, close (Minimal, while open) and search (the search box's stand-in while closed compact).
toggle_button¶
The pane toggle (hamburger) button, owned by the view.
close_button¶
The close button a Minimal pane shows while open, owned by the view.
search_button¶
The search button shown in the search box's place while closed compact, owned by the view.
close_on_escape¶
Closes an overlaying pane on Escape, as a light dismiss. The window calls it while focus is inside the pane.
focused¶
Whether the items' tab stop holds keyboard focus (the cursor's pill then shows the ring).
focusable¶
The items are one tab stop whenever there is one to reach.
takes_focus_at¶
That stop is the items alone. A press on the menu or footer rows, or on a slot in Top mode, focuses the view. A press on the hosted page reaches the controls there.
collect_focusables¶
In tab order: the back, close and toggle buttons, the pane header, the search button or search box, the pane custom content, the items (this), the pane footer, then the active content. While an overlaying pane is open, only the pane's own stops.
sync_native¶
Passes native-control hosting on to the owned elements and the active content only. Native controls on an inactive item's page are hidden.
automation_children¶
Only the active content and the owned pane elements are automation children. The items are drawn rows, and the control exposes the selected item's text as a read-only value.
automation_role¶
AutomationRole::List.
build_visual_tree_override¶
Adds the active content, which for_each_child() leaves out.
measure_override¶
Fills available on whichever axes are bounded.
arrange_override¶
Resolves the display mode for the new width (raising on_display_mode_changed), then lays out the pane or top bar, the header and the content.
render_override¶
Draws the pane or top bar, the rows with their selection indicator, the header, then the active content; an overlaying pane is drawn over the content.
pointer_override¶
Hover, press and click on the rows, chevrons and overflow button. A click on the content while an overlaying pane is open closes the pane.
wheel_override¶
Scrolls the pane; the content has had the turn first.
hit_test_children¶
The buttons over everything, the row tooltip, the pane's elements, then the content where nothing covers it.
covers_children_at¶
The pane's overlay scrollbars.
clear_dirty_override¶
Clears the view's flags and those of every owned element.
tick_override¶
Advances the pane's open/close transition, the indicator's slide and the animated icons.
take_focus_request¶
Asks the Window to move focus into an overlaying pane as it opens (and back out as it closes); the request is handed over once.
enabled_changed¶
is_enabled() flipped, through set_enabled() here or on an ancestor, or a move to another parent. Drop any press or hover state. The element is redrawn either way. No-op by default.
key_override¶
The items' keyboard model: the arrows move the cursor (selecting with selection_follows_focus()), Enter/Space invoke, Left/Right collapse and expand a group.
focus_changed¶
Gaining focus puts the cursor on the selected item when it has nowhere valid to be.
focus_ring_rect¶
Around the item under the keyboard cursor; none while a flyout of the pane is open.
struct NavEntry¶
One navigation entry: the text in the pane, the content shown while it is selected, and any nested items it groups. It is plain data, not an Element, but it owns its content subtree.
That makes it move-only, so a std::vector<NavEntry> is built by pushing into it. For a braced list use ui::NavItem/ui::NavList from this header.
Example:
auto nav = std::make_unique<ui::NavigationShellControl>();
std::vector<ui::NavEntry> items;
ui::NavEntry home{"Home"};
home.icon = ui::symbol_glyph(ui::Symbol::Home);
home.content = std::make_unique<ui::TextControl>("Welcome");
items.push_back(std::move(home));
ui::NavEntry mail{"Mail"};
mail.icon = ui::symbol_glyph(ui::Symbol::Mail);
mail.expanded = true;
mail.info_badge = std::make_unique<ui::InfoBadgeControl>();
mail.children.push_back(ui::NavEntry{"Inbox"});
mail.children.push_back(ui::NavEntry{"Sent"});
items.push_back(std::move(mail));
nav->set_items(std::move(items)); // pre-order indices: Home 0, Mail 1, Inbox 2, Sent 3
| Field | Type | Default | |
|---|---|---|---|
text |
std::string |
The row's text; a header's title. Also the tooltip and the automation value when the item is selected. | |
content |
std::unique_ptr<Element> |
The content shown while this item is selected. May be null, and then the view's own content (NavigationShellControl::set_content) is shown instead. That is usually a NavigationFrame when the items carry no pages at all. | |
children |
std::vector<NavEntry> |
Nested items. A non-empty list makes this row a collapsible group with a chevron. | |
expanded |
bool |
false |
Whether a group shows its children inline in the left pane. False by default. |
selects_on_invoke |
bool |
true |
Whether invoking the row selects it. False makes the row a pure heading: it still expands and collapses, but never becomes the selection. |
icon |
IconSource |
The icon, drawn at 16 DIPs in the row's icon column: a Symbol, a glyph, a path or a picture. | |
info_badge |
std::unique_ptr<InfoBadgeControl> |
A badge drawn between the text and the chevron. | |
kind |
NavEntryKind |
NavEntryKind::Item |
An item, a section header or a separator. A header shows text and a separator nothing; neither is ever selected, invoked or given the keyboard cursor. |
tool_tip |
std::string |
The row's tooltip. Empty shows the text, and only while the pane is closed compact. A non-empty one shows in every mode. | |
animated_icon |
std::unique_ptr<AnimatedIconControl> |
An animated icon, drawn instead of icon in the pane's rows and the top bar in the row's text color. Its state follows the row's: PointerOver while hovered, Pressed while pressed, Normal otherwise. icon still names the row's icon everywhere else (the overflow and children flyouts), so set it to the animated icon's fallback glyph. |
|
key |
std::string |
What identifies the item in selected_key() and the selection events. Empty uses text. "settings" is taken by the Settings item. |
struct NavigationShellExpandedChangedArgs¶
What NavigationShellControl::on_expanded_changed() gets: the group whose expansion changed, and whether it is expanded now.
| Field | Type | Default | |
|---|---|---|---|
index |
std::size_t |
0 |
The group's pre-order index. |
expanded |
bool |
false |
True when it opened. |
Enumerations¶
NavigationShellPaneDisplayMode¶
Where a NavigationShell puts its items.
| Value | |
|---|---|
Auto |
Expanded from expanded_mode_threshold_width() on, Minimal below compact_mode_threshold_width(), Compact between. |
Left |
Always Expanded: an inline pane, a compact strip while closed. |
Top |
The items in a 48-DIP bar across the top; what does not fit goes behind "More". |
LeftCompact |
Always Compact: an icon strip, opening over the content. |
LeftMinimal |
Always Minimal: no pane until the toggle button opens one over the content. |
NavigationShellDisplayMode¶
What a NavigationShell's pane is doing right now.
| Value | |
|---|---|
Minimal |
No pane showing while closed. An open pane overlays the content and closes on a click outside it. |
Compact |
An icon strip (compact_pane_length() wide) while closed; an open pane overlays the content. |
Expanded |
An inline pane beside the content, shrinking to the strip when closed. |
NavigationShellSelectionFollowsFocus¶
Whether a NavigationShell selects the item the arrow keys land on.
| Value | |
|---|---|
Disabled |
The default: the arrow keys move a cursor, Enter/Space select. |
Enabled |
Whatever item the arrow keys land on is selected at once. |
NavEntryKind¶
What a NavEntry is: an item, a section header or a separator.
| Value | |
|---|---|
Item |
A selectable, invokable row. |
Header |
A section title showing the entry's text; folded away while the pane is closed compact. |
Separator |
A horizontal rule between groups of items. |
Tests¶
tests/test_navigation_shell.cpp