JFLib

Shell parts: navigation, command bar, splitter, breadcrumb, wizard steps#

Source: lib/ui/shell.rs

shell -- the parts of an application shell: navigation pane, command bar, splitter,
breadcrumb, segmented control, wizard step list

  nav_begin(id, &mut NavState)        vertical navigation pane (next_size sets its width;
                                      the style's surface), items scroll when they do not fit
  nav_toggle(id, label)               the pane's menu button: toggles NavState::compact
  nav_section(label)                  a group caption (compact: a divider)
  nav_item(id, icon, label, selected, badge) -> EV   EV_ACT when clicked; badge: a count
  nav_footer()                        the items after it stay at the bottom of the pane
  nav_end()
  command_bar(id, items) -> Option<id>   a row of subtle icon + label buttons; what does not
                                      fit goes into a "…" menu; CBI_END starts the group
                                      aligned to the end, CBI_SEP a separator; ST_ACCENT /
                                      ST_DISABLED / ST_CHECKED per item
  split_begin(id, pos, vertical)      two panes: the first `pos` DIP wide (vertical: high),
  split_next()                        a draggable grip, the second fills
  split_end(&mut pos) -> changed      the dragged position (DIP)
  breadcrumb(id, parts) -> Option<i>  path of links, the last part is the current page
  segmented(id, &mut sel, items) -> EV   a segmented control (EV_ACT when sel changed)
  wizard_steps(id, steps, current, states) -> Option<i>   vertical step list; a click on
                                      a done step (or one before the current) returns it

Ids: parts (id << 3 | k) | 0x80000000; items of segmented / wizard / breadcrumb id + 1 + i.
  • struct NavState the app-owned state of a navigation pane

    • compact: bool -- icons only
  • struct CmdItem<'a> an item of a command bar

    • id: u32
    • icon: u32
    • label: &'a str
    • flags: u32 -- ST_ACCENT, ST_DISABLED, ST_CHECKED, CBI_SEP, CBI_END

impl<'a> CmdItem<'a>

  • const fn new(id: u32, icon: u32, label: &'a str) -> CmdItem<'a>
  • const fn flags(mut self, f: u32) -> CmdItem<'a> add flags (ST_ACCENT, CBI_SEP, ...; in any order with enabled())
  • const fn enabled(mut self, on: bool) -> CmdItem<'a> disabled unless on

impl Ui

  • fn nav_begin(&mut self, id: u32, nav: &mut NavState) ui_nav_begin(id, &mut nav): open the pane (always call nav_end)
  • fn nav_toggle(&mut self, id: u32, label: &str, nav: &mut NavState) -> u32 ui_nav_toggle(id, label): the menu button of the pane (toggles compact)
  • fn nav_section(&mut self, label: &str) ui_nav_section(label): a group caption (a divider when the pane is compact)
  • fn nav_item(&mut self, id: u32, icon: u32, label: &str, selected: bool, badge: Option<&str>) -> u32 ui_nav_item(id, icon, label, selected, badge) -> EV_* (EV_ACT clicked)
  • fn nav_end(&mut self) ui_nav_end
  • fn command_bar(&mut self, id: u32, items: &[CmdItem]) -> Option<u32> ui_command_bar(id, items) -> the id of the item clicked in this pass
  • fn split_begin(&mut self, id: u32, pos: i32, vertical: bool) ui_split_begin(id, pos, vertical): two panes, the first pos DIP wide (vertical: high); emit the first pane, split_next, the second pane, split_end
  • fn split_next(&mut self) ui_split_next: the grip, then the second pane
  • fn split_end(&mut self, pos: &mut i32) -> bool ui_split_end(&mut pos) -> the grip moved (pos updated, DIP; the mouse or the keyboard: F8 focuses the grip, arrows move it)
  • fn breadcrumb(&mut self, id: u32, parts: &[&str]) -> Option<usize> ui_breadcrumb(id, parts) -> the index of a clicked part (the last one is the current page and not a link)
  • fn segmented(&mut self, id: u32, sel: &mut i32, items: &[&str]) -> u32 ui_segmented(id, &mut sel, items) -> EV_* (EV_ACT when sel changed)
  • fn wizard_steps(&mut self, id: u32, steps: &[&str], current: usize, states: &[i32]) -> Option<usize> ui_wizard_steps(id, steps, current, states) -> a step to go back to (clicked); states: WS_* per step (missing: done before the current, todo after it)
  • fn page_header(&mut self, title: &str, subtitle: &str) ui_page_header(title, subtitle): a page title (TS_TITLE) with an optional secondary line under it
  • fn key_value(&mut self, key: &str, value: &str, key_width: i32) ui_key_value(key, value, key_width): a "label: value" row (TS_BODY, the key in the secondary colour, key_width DIP)
  • fn empty_state(&mut self, icon: u32, title: &str, text: &str) ui_empty_state(icon, title, text): a centred hint for an empty view (icon 0 = none); the text wraps at 360 DIP, or at the enclosing box's width when that is narrower

Source: docs/API.md in the JFLib repository.