JFLib

ui/action_card.rs#

Source: lib/ui/action_card.rs

action_card -- a card or a list row that does one thing when it is chosen: a template on a
start page, a recent file, a lesson

  ui.action_card(id, name, &CardDesc) -> EV_*   EV_ACT when it was clicked, or Enter or Space
                                                while it has the keyboard

CardDesc says what it shows: a title (with an icon and a badge beside it), a text below (wrapped,
or one line cut with "…"), a caption at the far end, and above them a picture area (`picture_h`
DIP, 0: none) with the app's drawing, without one the icon large and centred.  `name` is what
screen readers and scripts call it (K_BUTTON); the texts follow as records of their own.

next_size sets the width (natural: 200 DIP); the height follows the content, and in a row of
cards they all take the row's height.  next_flags: ST_SUBTLE a list row (no card at rest, the
hover fill alone), ST_CHECKED selected, ST_DISABLED no input (the texts in the disabled colour).
The card is one Tab stop; a button of its own (remove from a list) goes beside it, not into it.
  • struct CardDesc<'a> what an action card shows (ui.action_card); ..Default::default() for the parts it has not
    • title: &'a str
    • icon: u32 -- beside the title; with a picture area and no drawing, large in that area (0: none)
    • text: &'a str -- below the title ("": none)
    • one_line: bool -- title and text stay on one line, cut with "…" (lists); else they wrap
    • badge: Option<(u32, &'a str)> -- a BADGE_* kind and its label, beside the title
    • aside: &'a str -- a caption at the far end ("": none)
    • picture_h: i32 -- the height of the picture area above the texts (DIP; 0: none)
    • draw: Option<DrawRef> -- what it shows and the version of that drawing (render time, as cmd_custom)
    • draw_ver: u32

impl Ui

  • fn action_card(&mut self, id: u32, name: &str, d: &CardDesc) -> u32 action_card(id, name, &desc) -> EV_*: a card or list row that does one thing (the top of action_card.rs); next_size sets its width, next_flags ST_SUBTLE, ST_CHECKED, ST_DISABLED

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