Widgets#
Source: lib/ui/basic.rs
basic -- the basic widgets [src/ui/ui_basic.s]
text(style, s) TS_* | TX_* flags (TX_ELLIPSIS: cut with "…" at
the placed width, record value 1 when cut;
TX_WRAP: lines at the layout width, value = lines;
TX_HYPHENATE: words that do not fit hyphenated,
hyph.rs; soft hyphens always)
button(id, label) -> EV standard button
accent_button(id, label) -> EV accent (primary) button
icon_button(id, icon, label) -> EV subtle toolbar button (label = tooltip / name;
ST_LARGE shows it under a big icon)
toggle_button(id, label, &mut v) -> EV checked look while v != 0; toggles v
tool_button(id, icon, label, &mut sel, mine) -> EV selects sel = mine (tool palettes)
checkbox(id, label, &mut v) -> EV v: 0, 1, 2 = indeterminate
radio(id, label, &mut v, mine) -> EV v = mine when clicked
checkbox_wrap / radio_wrap the same with a label that wraps (next_size(-1, 0)): a mark
beside a long text, a click on the text counts
switch(id, label, &mut v) -> EV toggle switch
slider(id, &mut v, &range) -> EV EV_ACT while the value changes, EV_COMMIT on release
progress(id, v, max) progress bar
separator() divider line across the current box
icon(cp, size_dip) an icon in the text colour
image(id, &sf, ver) -> EV a surface at its natural size (or next_size)
canvas(id, draw, user, version) -> &UiInput custom area: draw.draw(g, rect) at render
time, clipped; bump `version` when its content
changes
hair() -> px border width for the current dpi
Label strings are copied, so they may live in scratch buffers.
impl Ui
fn hair(&self) -> i32ui_hair: max(1, (dpi + 24) / 96)fn focus_ring_draw(&mut self, ev: u32)ui_focus_ring_draw(ev): the style's focus visual around last_rect when it is shown (ev: the widget's events; custom widgets built on hit_rect / behave call it last)fn text(&mut self, style: u32, s: &str)ui_text(style, s): a text in a text style (TS_* | TX_*)fn heading(&mut self, level: u32, style: u32, s: &str)A section title:text(style, s)that screen readers know as a heading oflevel(1 the top level ..= 9; record K_HEADING, value: the level) -- their heading navigation finds it.fn link(&mut self, id: u32, label: &str, typography: u32) -> u32A hyperlink-style text action: accent-coloured text (T_ACCENT_TEXT), underlined while the pointer is over it, hand cursor, focus ring, no button surface. TS_*/TX_* typography as in text(); a narrower slot than the text ellipsizes it.fn checkbox(&mut self, id: u32, label: &str, v: &mut i32) -> u32ui_checkbox(id, label, &mut v) -> EV_*: v 0, 1, 2 = indeterminate (Space toggles, Enter is the dialog's)fn checkbox_wrap(&mut self, id: u32, label: &str, v: &mut i32) -> u32ui_checkbox_wrap(id, label, &mut v) -> EV_*: a check box for a text that may be long: the mark, beside it the label wrapped at the width the layout gives (next_size(-1, 0)); a click on the text toggles too; the record is the check box's, named by the textfn radio_wrap(&mut self, id: u32, label: &str, v: &mut i32, mine: i32) -> u32ui_radio_wrap(id, label, &mut v, mine) -> EV_*: a radio for a text that may be long, as checkbox_wrapfn radio(&mut self, id: u32, label: &str, v: &mut i32, mine: i32) -> u32ui_radio(id, label, &mut v, mine) -> EV_*: v = mine when clicked; the radios of one variable are one Tab stop, the arrows select inside (kbnav.rs)fn switch(&mut self, id: u32, label: &str, v: &mut i32) -> u32ui_switch(id, label, &mut v) -> EV_*: toggle switchfn slider(&mut self, id: u32, v: &mut i32, rg: &Range) -> u32ui_slider(id, &mut v, &range) -> EV_*: EV_ACT while the value changes, EV_COMMIT on releasefn progress(&mut self, id: u32, v: i32, max: i32)ui_progress(id, v, max): progress barfn separator(&mut self)ui_separator: divider across the current box (the style draws it)fn icon(&mut self, cp: u32, size: i32)ui_icon(cp, size_dip): an icon in the text colourfn image(&mut self, id: u32, sf: &Rc<Surface>, ver: u32) -> u32ui_image(id, sf, ver) -> EV_* (clickable when id != 0): a surface at its natural size (or next_size); ver stands for its SF_AUX versionfn canvas(&mut self, id: u32, draw: Option<DrawRef>, user: usize, version: u32) -> &UiInputui_canvas(id, draw, user, version) -> &UiInput: a custom area. The hit box wants every pointer move; the cursor comes from next_flags bits 12..15 (CUR_* << HB_CURSOR_SHIFT), default crosshair (with HB_CURSOR_SET as given: 0 is the arrow). next_flags(HB_KEYS): every key is the canvas's while it has the focus (a press gives it the focus, so does ui.focus(id)); it takes them with ui.key_take.fn canvas_label(&mut self, label: &str)(E14) the name of the next canvas's own K_CANVAS record ("Webseite"): what a screen reader says for it and a script'scanvas:"Webseite"selector; the records the canvas publishes for its content (sem_rect) stay as they are