Module nav_row
Expand description
One navigation row and one navigation section header, painted the same everywhere.
NavList paints every row through paint_nav_row and every section header through
paint_nav_section; a painted app that cannot host a NavList calls the same two functions
with the same faces, so a sidebar drawn by hand is pixel-for-pixel the widget’s. The geometry
(nav_row_layout, nav_section_layout) is public so a painted host hit-tests exactly what
was painted.
A row is the list’s s2 inset from both edges; its selection is the neutral lift of the ground
it stands on (super::paint_row_selection), with primary ink. Counts are Caption tabular
figures in tertiary ink; a NavCount::Live count (unread, needs attention) is the one filled
badge, in the person’s own colour. Section headers are sentence-case Subheading in secondary
ink.
Every part a row can show, leading to trailing:
| Part | Face | Look |
|---|---|---|
| check | NavRowFace::checked | a crate::widget::CheckboxFace; the whole row toggles it |
| icon, swatch or avatar | NavRowFace::icon, NavRowFace::swatch, NavRowFace::avatar | a ui::icons glyph, the content colour the row stands for, or the person it stands for |
| badge | NavRowFace::badge | a short classifying code on a quiet pill, in a column shared by its section |
| label | NavRowFace::new | Body; Body.strong() while selected |
| secondary | NavRowFace::secondary | one Caption line under the label, in secondary ink |
| level | NavRowFace::level | a usage bar under the text, on the progress bar’s track and fill |
| presence | NavRowFace::presence | the people on it, as marks in their colour |
| status label | NavRowFace::status_label | a quiet tinted badge (“Active”) |
| meta | NavRowFace::meta | a tertiary Caption figure (a size) |
| count | NavRowFace::count | quiet tabular figures, or the live badge |
| status | NavRowFace::status | a dot at the trailing edge |
Hover and focus swap the trailing parts for the row’s actions.
Draw with the theme of the ground the rows stand on
(theme.in_region(Region::Sidebar) in a sidebar, theme.on_ground(..) elsewhere): the painter
reads that ground from surfaces.content.
Structs§
- NavRow
Face - Everything a navigation row shows. Build with
NavRowFace::newand paint withpaint_nav_row. - NavRow
Layout - Where each part of a navigation row lands. Painting and hit-testing both read it.
- NavSection
Face - A section header in a navigation list.
- NavSection
Layout - Where each part of a section header lands.
Enums§
- NavCount
- How many items a navigation row stands for, beside its label.
- NavRow
Style - A row laid out as a list row or as a tile in an icon-over-label rail.
Functions§
- label_
measure_ style - The heavier of a row’s two weights: elision is measured with it, so a label that fits selected also fits unselected.
- label_
style - The style a row’s label is set in:
Body, orBody.strong()while the row is selected. Measure elision withlabel_measure_styleso the label does not jump when the weight changes. - nav_
badge_ column - The width of the badge column a section’s rows share: the widest of
codeson its pill. - nav_
item_ height - Height of a list row that carries a secondary line and/or a usage bar
under its label: the stacked text inside the row’s
s2padding, never shorter thannav_row_height. - nav_
list_ width_ fitting - How wide an icon-led list of these destination
labelsmust be for every label to stand whole beside its icon: the row’s padding, its icon and gap, and the widest label. Where a sidebar is narrower than this, its destinations read better as a rail’s tiles than as cut-off rows, so this is where a navigation sidebar turns from rail into list. - nav_
rail_ item_ height - Height of the rail tile for
labelin a railwidthwide: one caption line more thannav_rail_row_heightwhen the caption wraps. - nav_
rail_ row_ height - Height of one rail tile: the icon over a caption line inside the row padding.
- nav_
row_ description - The spoken form of a row’s extra parts, for its accessible description: the secondary line, the meta, the state.
- nav_
row_ height - Height of one list row:
crate::tokens::Metrics::nav_row_height, grown with the body line at large text. - nav_
row_ layout - Lay out
faceinside its row (seeNavRowLayout). - nav_
section_ height - Height of a section header. Every section after the first is separated
from the rows above it by
s3of space, not by a line. - nav_
section_ layout - Lay out a section header (see
NavSectionLayout). - paint_
nav_ row - Paint one navigation row.
themeis the theme of the ground the row stands on; itssurfaces.contentis that ground. - paint_
nav_ section - Paint a section header: the title in
Subheading, secondary ink; a collapsible section’s chevron while the pointer or focus is on it (or while it is collapsed, so a hidden section is never mistaken for an empty one); and its trailing action. - rail_
caption_ fits - Whether
labelstands whole in a rail tilewidthwide: on at most two caption lines, broken only at spaces, with nothing elided. - rail_
caption_ lines - A rail caption broken into at most two lines of
max_w, only at spaces: a single word never breaks inside, it elides when it is longer than the line, and so does the second line. - rail_
width_ fitting - How wide a rail of these destination
labelsis: its stock width, grown with the text so its longest single word fits whole, but never past the stock width times the text’s growth normetrics.rail_max_width. A fragment such as “Cha…” names nothing, so the rail widens before any word is shortened; only past that cap does a word elide. - sidebar_
rail_ width_ fitting - How wide a sidebar’s rail of these destination
labelsis: its stock width, grown so its longest single word fits whole, up tometrics.rail_max_width. A sidebar the person can widen into a list grows its rail to the word before it shortens one (“Subscriptions”, never “Subscript…”); a fixed rail keepsrail_width_fitting’s cap.