Skip to main content

Ui

Struct Ui 

Source
pub struct Ui<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Ui<'a>

Source

pub fn with_filler(core: &'a mut Core, filler: &'a mut dyn Fill) -> Self

Self::wrap with something to fill the slots the frame declares — for a frontend that drives Core directly and keeps an extension list of its own (the C context, a headless Node one), so its slot and finish are this type’s rather than a copy of them.

Source

pub fn core(&mut self) -> &mut Core

Escape hatch to the underlying core (e.g. for FFI view callbacks).

Source

pub fn wrap(core: &'a mut Core) -> Self

The inverse escape hatch: wraps a borrowed core mid-frame so foreign frontends that drive Core directly (FFI, Node) can call widgets::*.

Source

pub fn slot(&mut self, name: &str)

Declares a slot here, with no parameters: whatever fills it draws now, as children of the node this view is inside, at this position among its siblings. name is the full name, namespace/slot — the namespace the host gave the extension when it loaded it, and the slot in the extension’s own vocabulary ("fs/panel"). "ns/root" is the fill that follows the host’s view for an extension listing no slots, and declaring it moves that fill here.

Source

pub fn slot_with(&mut self, name: &str, params: &Value) -> bool

slot with parameters the extension reads this frame (Slot::params); a Value because it is the type that already crosses to an extension. Nothing is retained — pass what is true this frame, every frame.

Whether the slot was declared: false for a name this frame already declared (which warns, duplicate-slot) or outside a frame. True whether or not anything filled it — a host with nothing loaded still gets a placed, empty node to lay out around.

Source

pub fn slot_declared(&self, name: &str) -> bool

Whether the full name name was declared this frame so far.

Source

pub fn devtools_tab(&mut self, name: &str, label: &str, slot: &str)

Declares a devtools tab an extension fills: name is the tab’s identity, label what the strip shows, slot the full slot name ("ts/panel") the extension names. While the tab is the one on show, the panel declares the slot in the tab’s body and the fill is drawn there; otherwise the slot is not declared and the extension is not asked, though its naming the slot raises no unknown-slot. Made every frame, panel on or off. A name declared twice in a frame warns duplicate-tab.

Source

pub fn devtools_tab_with( &mut self, name: &str, label: &str, f: impl FnOnce(&mut Ui<'_>), )

Declares a devtools tab the host draws itself, and draws it only when it is shown: f runs when the panel is on, docked in this window, and name is the tab on show — otherwise this declares and returns, and the tab costs nothing. What f builds is the host’s: its keys, labels and origin, its events reaching the host untouched — laid out and painted as a layer over the panel’s tab body, clipped to it, in the dock’s focus region. The panel’s facts are read through devtools_selected and its siblings.

Source

pub fn devtools_tab_shown(&self, name: &str) -> bool

Whether the host form of tab name is shown this frame — what devtools_tab_with asks before running its closure, for a caller that builds the content some other way.

Source

pub fn devtools_tab_declare( &mut self, name: &str, label: &str, slot: Option<&str>, ) -> bool

The bare declaration either form makes: slot for the extension form, None for a host form whose content is built some other way or not at all this frame. Whether the declaration stood — false for a name already declared this frame (duplicate-tab) or outside a frame.

Source

pub fn devtools_tab_declared( &mut self, name: &str, label: &str, f: impl FnOnce(&mut Ui<'_>), )

The host form for a binding that decided the laziness on its own side (a Node encoder or a Lua converter that already read which tab is on show): declares the tab and builds f as its content whether or not the tab is shown here — a content whose body the panel did not build anchors to nothing and paints nothing, and a name already declared this frame (duplicate-tab) builds into a node of no size, so the caller’s stream stays in step either way. devtools_tab_with is the door for a caller that can skip the work.

Source

pub fn devtools_selected(&self) -> Option<Key>

The panel’s selected node (Core::devtools_selected).

Source

pub fn devtools_hovered(&self) -> Option<Key>

The panel’s hovered tree row (Core::devtools_hovered).

Source

pub fn devtools_picked(&self) -> Option<Key>

The node the picker is over (Core::devtools_picked).

Source

pub fn devtools_picking(&self) -> bool

Whether the panel’s picker is up (Core::devtools_picking).

Source

pub fn devtools_current_tab(&self) -> String

The tab the panel is on, by name (Core::devtools_current_tab).

Source

pub fn add_extension( &mut self, namespace: &str, ext: Box<dyn Extension>, ) -> Result<OriginId, String>

Loads ext under namespace into the list filling this frame’s slots, and answers with the origin it got. This is how an extension hosts an extension of its own: the guest asks mid-frame, when it knows what it wants, and the plugin lands in the same list as the host’s own — one namespace map, one origin per extension, however deep the loading went (crate::slot).

Fails when the namespace is taken, or empty with an extension that names itself nothing, exactly as Extensions::push_as does, and when this frame was begun without a filler (Core::frame) or with one that is not a list.

Source

pub fn fill( &mut self, origin: OriginId, slot: &Slot<'_>, f: impl FnOnce(&mut Ui<'_>), )

Runs f as the fill of slot under origin: nodes it opens are tagged with the origin, keyed under the slot’s key, and closed for it if it leaves any open. What a Fill implementation calls per extension; see Core::fill.

Source

pub fn fill_within( &mut self, origin: OriginId, slot: &Slot<'_>, filler: &mut dyn Fill, f: impl FnOnce(&mut Ui<'_>), )

fill, with filler answering the slots the fill declares — an extension hosting extensions of its own. Extensions::fill_one passes itself, which is what makes one namespace map do for every level; see crate::slot.

Source

pub fn origin(&self) -> OriginId

The origin the nodes opened right now are tagged with: OriginId::HOST in the host’s own view, the filling extension’s inside a fill. What records who declared a slot, and so where the replies of whatever fills it go.

Source

pub fn viewport(&self) -> Size

The viewport this frame lays out into: the window, less the devtools’ dock while the panel is docked (Core::viewport).

Source

pub fn env_facts(&self) -> EnvFacts

The env reading’s inputs, the frame’s facts included (Core::env_facts): what a binding’s env table is filled from.

Source

pub fn env(&self) -> Env

Host facts pushed by the frame driver (refresh rate, focus).

Source

pub fn theme(&self) -> Theme

This frame’s palette: the named colours the stock widgets paint with, derived from env.system unless the app pinned something else (see crate::theme).

By value, because it is Copy and a view that took a reference could not then touch ui. let t = ui.theme(); at the top of a widget is the idiom.

Source

pub fn has_accent(&self) -> bool

Whether anyone chose the theme’s accent, or it is kui’s fallback blue — see Core::has_accent.

Source

pub fn metrics(&self) -> Metrics

The sizes the stock widgets are built from (Metrics), by value like the theme and for the same reason. What a view reads to make its own controls agree with the stock ones on a radius and a padding.

Source

pub fn set_tokens(&mut self, tokens: Tokens)

Declares the tokens this origin references by name (see crate::tokens and Core::set_tokens). Inside a fill the table is the extension’s own.

Source

pub fn tokens(&self) -> TokenLookup<'_>

What a $name resolves to this frame — the running origin’s table over the host’s, the roles in front of both — for a view that reads a token by name rather than holding its id.

Source

pub fn token_color(&mut self, name: &str) -> Option<Color>

A colour token by name, this frame’s half. A name that resolves to nothing, or to a length, raises unknown-token and answers None, so the view leaves the slot at its default (.bg(ui.token_color("peach").unwrap_or(t.surface))) rather than painting a transparent that would hide the node a typo was on.

Source

pub fn token_length(&mut self, name: &str) -> Option<f32>

A length token by name; unknown warns and answers None, as above.

Source

pub fn window_title(&mut self, title: &str)

Declares this frame’s window title (declare every frame you care; the driver diffs and applies changes).

Source

pub fn always_on_top(&mut self, on_top: bool)

Declares that this frame wants the window kept above every other app’s; see crate::Core::set_always_on_top. Declare it every frame you want it — a frame that does not lowers the window again, which is what makes a pin button a toggle — and read whether the platform agreed from env().window.always_on_top.

Source

pub fn secure_input(&mut self, on: bool)

Declares that this frame wants secure keyboard entry while the window has the keyboard (a password prompt); see crate::Core::set_secure_input. Declare it every frame the prompt is up: a frame that does not turns it off.

Source

pub fn option_as_alt(&mut self, option_as_alt: OptionAsAlt)

Declares which Option keys act as Alt in this window on macOS, so Option-u arrives as the chord A-u rather than composing an accent; see crate::Core::set_option_as_alt. Declare it every frame: a frame that does not gives the Option keys back to the layout.

Source

pub fn ime_off(&mut self, off: bool)

Declares that this window takes the keyboard as keys, with the platform’s input method off — no composition, and on a Mac no dead keys and no press-and-hold, so a held letter repeats; see crate::Core::set_ime_off. A modal editor’s normal mode. Declare it every frame: a frame that does not gives the IME back.

Source

pub fn window(&mut self, name: &str, config: WindowConfig)

Declares that a window named name exists this frame; see Core::declare_window. It opens on the first frame that declares it (config is read then and never again), stays open while any window’s frame keeps declaring it, and closes when none does. view is then called for it too, with Ui::window_name saying which window is being drawn.

Source

pub fn window_name(&self) -> Rc<str>

The name of the window this frame is drawing: "main" for the one the launcher opened, else the name the declaration that opened it used. env().window.id is the same window as a number.

Source

pub fn set_origin(&mut self, origin: OriginId)

Sets the origin the nodes opened from here on are tagged with; see Ui::origin.

Source

pub fn configure_root(&mut self, spec: NodeSpec)

The root node’s spec for this frame: its direction, padding, gap and background. Call it first; the default root is a fit column.

Source

pub fn child_key(&self, label: &str) -> Key

The key a child opened under label would get here, without opening it: read it before the node exists to ask is_hovered or is_focused while building it.

Source

pub fn child_key_indexed(&self, i: u64) -> Key

The key the ith child gets from auto-keying; see open_indexed.

Source

pub fn is_hovered(&self, key: Key) -> bool

Whether the pointer is over key, as of the last input. Only a node that tracks hover answers true (one with a click, a drag, a hover background or hoverable).

Source

pub fn is_pressed(&self, key: Key) -> bool

Whether the primary button is held on key.

Source

pub fn is_drop_target(&self, key: Key) -> bool

Whether files dragged in from the OS are over key, for drop-dependent layout; a colour swap is drop_bg.

Source

pub fn drop_target(&self) -> Option<Key>

The zone the dragged files are over, if any.

Source

pub fn is_group_hovered(&self, group: u64) -> bool

Whether any member of a hover group (NodeSpec::hover_group) is hovered; the id comes from NodeSpec::hover_group_id.

Source

pub fn is_group_pressed(&self, group: u64) -> bool

Whether any member of a hover group is pressed.

Source

pub fn modifiers(&self) -> KeyMods

Physical modifier state (the host also receives it as a {kind="modifiers"} event whenever it changes).

Source

pub fn caret_visible(&self) -> bool

The caret’s blink phase — true draws it; see Core::caret_visible. A custom editor draws its caret node on the on phase and skips it on the off, keeping the caret row on its line either way (that row is what the clock is armed on).

Source

pub fn request_frame(&mut self)

Asks for one more frame after this one; see Core::request_frame.

Source

pub fn measure_text( &mut self, content: &str, style: &TextStyle, max_w: Option<f32>, ) -> TextMetrics

Measures text the way layout would, without adding a node; see Core::measure_text. Sizing a column to its widest label, or choosing a tier that fits, is arithmetic on these numbers instead of hand-tuned constants. The metrics do not scale linearly: measured × zoom is not measure(size × zoom), because shaping rounds per size, so anything that zooms measures at the size it draws.

Source

pub fn text_hit(&self, key: Key, point: Vec2) -> Option<TextHit>

Where a point lands in the text node key drew, as a byte offset and a visual line; see Core::text_hit. During a build it answers from the last frame, which is the layout a click was made against.

Source

pub fn selection_text(&self) -> Option<String>

The window’s selected text — a selectable scope’s, or the focused editor’s; see Core::copy_selection.

Source

pub fn selection_ends(&self) -> Option<(RangeEnd, RangeEnd)>

The text selection’s two ends as the drag made them — anchor, then focus — each a virtualised row’s data index (or none) and a byte; see Core::selection_ends.

Source

pub fn cell_selection(&self) -> Option<CellSelection>

The window’s selection when it lives in a cells grid — its ends as absolute lines and columns; see Core::cell_selection.

Offered where the text selection offers only Self::selection_text because a grid’s ends mean something to the app: they are the session’s own line numbers, not byte offsets into runs the app never laid out.

Source

pub fn open_menu(&mut self, menu: Menu)

Opens a context menu; see Core::open_menu.

Source

pub fn close_menu(&mut self) -> bool

Closes whatever menu is open; see Core::close_menu.

Source

pub fn request_copy(&mut self) -> CopyRequest

Asks for the selection as text; see Core::request_copy.

Source

pub fn answer_selection_range(&mut self, text: &str) -> bool

Answers a selectionrange ask; see Core::answer_selection_range.

Source

pub fn selection_html(&self) -> Option<String>

The selection as HTML; see Core::selection_html.

Source

pub fn set_clipboard(&mut self, text: impl Into<String>, html: Option<String>)

Puts text on the system clipboard; see Core::set_clipboard.

Source

pub fn set_clipboard_secret(&mut self, text: impl Into<String>)

Puts a secret on the system clipboard marked concealed and transient, the way a password manager does; see Core::set_clipboard_secret.

Source

pub fn request_paste(&mut self)

Asks for the clipboard’s text, delivered as a text event on the focused sink or as typing into the focused editor; see Core::request_paste.

Source

pub fn awaiting_paste(&self) -> bool

Whether a paste asked for is still unanswered; see Core::awaiting_paste.

Source

pub fn request_files(&mut self, dialog: FileDialog) -> bool

Asks the host for a file dialog; the answer is a files event to whoever’s view asked. False when one is already outstanding. See Core::request_files.

Source

pub fn awaiting_files(&self) -> bool

Core::awaiting_files.

Source

pub fn select_all_in(&mut self, key: Key) -> bool

Selects everything in the scope key declared; see Core::select_all_in.

Source

pub fn clear_selection(&mut self) -> bool

Drops the window’s selection; see Core::clear_selection.

Source

pub fn caret_rect(&self, key: Key, byte: usize) -> Option<Rect>

The caret rect for a byte offset in the text node key drew; see Core::caret_rect.

Source

pub fn measure_rich_text( &mut self, spans: &[Span<'_>], base: &TextStyle, max_w: Option<f32>, ) -> TextMetrics

measure_text for a rich-text paragraph.

Source

pub fn open(&mut self, spec: NodeSpec) -> Key

Opens a node under the next auto key; its children follow until Self::close. Self::with is the scoped form, and the one to prefer: an open without its close is a node-left-open warning.

Source

pub fn open_keyed(&mut self, label: &str, spec: NodeSpec) -> Key

Self::open under a label key: stable across frames whatever the siblings before it, and what key_of(label) finds.

Source

pub fn open_key(&mut self, key: Key, spec: NodeSpec) -> Key

Opens a node under a key the caller built rather than a label: ui.child_key("gap").index(id) is a label and an index with no string formatted and no clash with the sibling-index keys open_indexed gives, and a key kept from an earlier child_key — read for is_hovered first — is opened as it is instead of spelled twice. Build it from this parent’s child_key: two nodes under one key in a frame are a duplicate-key warning, as two labels are. It has no label, so key_of does not find it.

Source

pub fn with_key( &mut self, key: Key, spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

Source

pub fn leaf_key(&mut self, key: Key, spec: NodeSpec) -> Key

Self::leaf under a key the caller built; see Self::open_key.

Source

pub fn open_indexed(&mut self, i: u64, spec: NodeSpec) -> Key

open_keyed by sibling index: the key auto-keying would have given the ith child. A virtualizing list opens each row with its data index, so a row keeps its identity when the built range slides past it. See Core::open_indexed.

Source

pub fn close(&mut self)

Closes the node the last open* opened.

Source

pub fn with(&mut self, spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>)) -> Key

Opens a node, runs f for its children and closes it. The usual way to declare a container:

ui.with(NodeSpec::row().gap(8.0).pad(4.0), |ui| {
    ui.text("Name", TextStyle::new(14.0));
    ui.text("Ada", TextStyle::new(14.0));
});
Source

pub fn with_keyed( &mut self, label: &str, spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

Source

pub fn leaf(&mut self, spec: NodeSpec) -> Key

A node with no children: a spacer, a rule, a swatch, a hit area — with(spec, |_| {}) without the empty closure.

Source

pub fn leaf_keyed(&mut self, label: &str, spec: NodeSpec) -> Key

Self::leaf under a label key.

Source

pub fn leaf_indexed(&mut self, i: u64, spec: NodeSpec) -> Key

Self::leaf under a data index; see Self::open_indexed.

Source

pub fn row_count(&mut self, n: u64)

Declares how many indexed rows the open node’s virtual list has, built or not; see crate::Core::row_count.

Source

pub fn with_indexed( &mut self, i: u64, spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

Scoped open_indexed: the ith child’s auto-key, given to a node that is not in the ith slot.

Source

pub fn text(&mut self, content: &str, style: TextStyle)

A paragraph of plain text in one style, wrapped at the width its parent gives it. A text has no box of its own (no padding, background, key or click); Self::text_in puts it in one.

ui.text("Plain, in the theme's foreground", TextStyle::new(14.0));
ui.text("Bold-ish, mono, red", TextStyle::new(13.0).mono().color(Color::hex(0xd43b3bff)));
let badge = ui.text_in(NodeSpec::row().pad_xy(6.0, 2.0).radius(4.0), "3", TextStyle::new(12.0));
Source

pub fn text_in( &mut self, spec: NodeSpec, content: &str, style: TextStyle, ) -> Key

A box of spec holding one text: with(spec, |ui| ui.text(…)) for the label, the cell, the badge that needs a width, a background, a click or a role. Returns the box’s key.

Source

pub fn text_in_keyed( &mut self, label: &str, spec: NodeSpec, content: &str, style: TextStyle, ) -> Key

Self::text_in under a label key.

Source

pub fn text_in_indexed( &mut self, i: u64, spec: NodeSpec, content: &str, style: TextStyle, ) -> Key

Self::text_in under a data index; see Self::open_indexed.

Source

pub fn cells(&mut self, grid: &CellGrid<'_>, spec: NodeSpec)

A cell grid (a terminal’s screen) as one node; see crate::cells. The spec is the node’s own.

Source

pub fn cells_indexed(&mut self, i: u64, grid: &CellGrid<'_>, spec: NodeSpec)

Self::cells under a data index; see Self::open_indexed.

Source

pub fn cells_keyed(&mut self, label: &str, grid: &CellGrid<'_>, spec: NodeSpec)

Self::cells under a declared key.

Source

pub fn rich_text(&mut self, spans: &[Span<'_>], base: TextStyle)

A paragraph of styled spans, shaped and wrapped as one flow.

Source

pub fn image(&mut self, id: ImageId, spec: NodeSpec)

A registered image; see Core::image_node for sizing semantics.

Source

pub fn image_with(&mut self, id: ImageId, opts: ImageOpts, spec: NodeSpec)

Self::image with its sampling and fit rows; see Core::image_node_with.

Source

pub fn fragment( &mut self, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, ) -> Key

A box a registered WGSL function paints; see Core::fragment_node for what it is, and Core::add_fragment for where the handle comes from. It has no intrinsic size, so give it one.

frag is the handle, or handle.with_image(img) for a function that reads a registered image through kui_sample(uv): a waveform, a heatmap, an image effect.

Source

pub fn fragment_with( &mut self, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

A fragment holding children, which paint over it: a gradient card with a title and buttons on top of it.

Source

pub fn fragment_keyed( &mut self, label: &str, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, ) -> Key

Self::fragment under a label key, for one that transitions or exits and needs a stable identity across frames.

Source

pub fn fragment_with_keyed( &mut self, label: &str, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

Self::fragment_with under a label key.

Source

pub fn fragment_indexed( &mut self, i: u64, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, ) -> Key

Self::fragment under a data index; see Self::open_indexed.

Source

pub fn fragment_with_indexed( &mut self, i: u64, frag: impl Into<FragmentRef>, params: &[f32], spec: NodeSpec, f: impl FnOnce(&mut Ui<'_>), ) -> Key

Self::fragment_with under a data index.

Source

pub fn line(&mut self, from: Vec2, to: Vec2, stroke: Stroke, spec: NodeSpec)

A round-capped segment from from to to, in the parent’s box space; see Core::line_node for what it is and is not.

Source

pub fn line_keyed( &mut self, label: &str, from: Vec2, to: Vec2, stroke: Stroke, spec: NodeSpec, )

Self::line under a label key.

Source

pub fn line_indexed( &mut self, i: u64, from: Vec2, to: Vec2, stroke: Stroke, spec: NodeSpec, )

Self::line under a data index; see Self::open_indexed.

Source

pub fn polyline(&mut self, points: &[Vec2], stroke: Stroke, spec: NodeSpec)

A stroke through points: a polyline, or a smooth curve through them with Stroke::curve; see Core::line_node.

Source

pub fn polyline_indexed( &mut self, i: u64, points: &[Vec2], stroke: Stroke, spec: NodeSpec, )

Self::polyline under a data index; see Self::open_indexed.

Source

pub fn polyline_keyed( &mut self, label: &str, points: &[Vec2], stroke: Stroke, spec: NodeSpec, )

Self::polyline under a label key.

Source

pub fn polygon(&mut self, points: &[Vec2], spec: NodeSpec)

A filled polygon through points in the parent’s box space, the fill in spec’s bg; see Core::polygon_node for what it is and is not.

Source

pub fn polygon_keyed(&mut self, label: &str, points: &[Vec2], spec: NodeSpec)

Self::polygon under a label key.

Source

pub fn polygon_indexed(&mut self, i: u64, points: &[Vec2], spec: NodeSpec)

Self::polygon under a data index; see Self::open_indexed.

Source

pub fn path(&mut self, path: &Path, spec: NodeSpec)

A path — any outline — filled with spec’s bg and stroked by the path’s own stroke; see Core::path_node for what it is and is not.

Source

pub fn path_keyed(&mut self, label: &str, path: &Path, spec: NodeSpec)

Self::path under a label key.

Source

pub fn path_indexed(&mut self, i: u64, path: &Path, spec: NodeSpec)

Self::path under a data index; see Self::open_indexed.

Source

pub fn path_d( &mut self, d: &str, rule: FillRule, stroke: Option<Stroke>, turn: Option<Turn>, spec: NodeSpec, )

Self::path from SVG path data; data that does not parse raises path-malformed and draws nothing. See Core::path_d_node.

Source

pub fn path_d_keyed( &mut self, label: &str, d: &str, rule: FillRule, stroke: Option<Stroke>, turn: Option<Turn>, spec: NodeSpec, )

Self::path_d under a label key.

Source

pub fn audio(&mut self, spec: AudioSpec) -> Key

An audio node: a playback retained for as long as the view keeps declaring it; see Core::audio_node.

Source

pub fn audio_keyed(&mut self, label: &str, spec: AudioSpec) -> Key

audio with a label-derived key; see Core::audio_node_keyed.

Source

pub fn play(&mut self, sound: SoundId, opts: PlayOptions) -> PlaybackId

Starts a playback from a view; see Core::play. Views run every frame, so gate it on state that changes once (or use audio).

Source

pub fn text_edit( &mut self, label: &str, initial: &str, opts: &EditOptions, spec: NodeSpec, ) -> Key

An editable text node; state retained by key. See Core::text_edit.

Source

pub fn is_focused(&self, key: Key) -> bool

Whether key holds keyboard focus — any node: an editor, a key sink, a button Tab landed on (see Core::focus).

Source

pub fn focused(&self) -> Option<Key>

The node holding keyboard focus, if any.

Source

pub fn focus_visible(&self) -> bool

Whether focus got where it is by keyboard or assistive technology (a Tab press, a reader’s request) rather than a click — when a view that styles its own focus should show it.

Source

pub fn key_of(&mut self, label: &str) -> Option<Key>

The key of the node opened under label — in this frame so far, then in the last finished one. For a caller that holds only the label and cannot spell the path (child_key is the same question asked from the parent); see Core::key_of.

Source

pub fn focus(&mut self, key: Key)

Moves keyboard focus to key now (an editor, an on_key sink, a control, a focusable node); see Core::set_focus.

Source

pub fn blur(&mut self)

Drops keyboard focus.

Source

pub fn focus_next(&mut self)

Moves focus to the next focusable node in tree order, wrapping — what Tab does. A key sink that binds Tab itself calls this to hand the keyboard on.

Deferred, unlike the rest of this handle: a Ui only exists while a frame is being built, and begin_frame cleared the tree the Tab ring is made of, so stepping now would walk an empty ring. The step is applied at finish, against the frame this call is part of — so a view that declares three rows and asks to step lands on one of them, without waiting a frame for them to exist. Outside a frame (a driver handling a key press) Core::focus_next steps at once.

Source

pub fn focus_prev(&mut self)

Shift-Tab: the previous focusable node. Deferred to finish for the reason Ui::focus_next gives.

Source

pub fn focus_region(&mut self, key: Option<Key>)

Enters a focus region (the node key names, declared focus_region), or the main ring for None: focus lands on what that ring last held if the node is still there, else its initial_focus, else its first stop, and shows. Deferred to finish like Ui::focus_next, so a view may name the region it is declaring right now — the dock this frame toggles on. A key the frame does not declare as a region raises focus-region-without-node.

Source

pub fn region(&self) -> Option<Key>

The focus region in effect — the node whose ring Tab walks — or None for the main ring. What a chord that toggles between a dock and the app reads to know which way it is going.

Source

pub fn edit_text(&self, key: Key) -> Option<String>

An editor’s current text, by its key; None for a key no editor holds.

Source

pub fn set_edit_text(&mut self, key: Key, text: &str) -> bool

Replaces an editor’s text, caret at the end (Core::set_edit_text). Returns whether it reached an editor now, or was held for the frame that declares the key.

Source

pub fn set_edit_text_by_label(&mut self, label: &str, text: &str) -> bool

The same by the label the view declares, for a caller with no key yet: an update opening a field the editor has not fired an event from (Core::set_edit_text_by_label).

Source

pub fn announce(&mut self, text: &str, live: Live)

Says something once, with no node behind it (Core::announce). Takes effect at once, unlike focus_next: the queue is not made of a finished tree.

A view runs every frame, so a call made from here needs a guard the app clears; the core reports the unguarded case as announcement-repeated. A region whose message is on screen is the live prop instead.

Source

pub fn reveal(&mut self, key: Key)

Scrolls whatever contains key so the node shows — “scroll to the selected row”, without the container geometry the app cannot see. Resolved when this frame finishes laying out, so a row the view is declaring right now reveals fine; a key the frame does not declare, or one nothing scrollable contains, is a no-op. See Core::reveal.

Source

pub fn system_font(&mut self, name: &str) -> Option<FontId>

The handle for an installed or loaded font family by name (what family = "Name" resolves to in the declarative bindings), so a Rust view names a face without reaching for the core. None when no face matches. Idempotent.

Source

pub fn reveal_label(&mut self, label: &str)

Self::reveal by label, resolved when this frame finishes; see Core::reveal_label.

Source

pub fn set_scroll_label(&mut self, label: &str, offset: Vec2)

set_scroll by label, resolved before this frame lays out; see Core::set_scroll_label.

Source

pub fn scroll_offset(&self, key: Key) -> Vec2

A scroll container’s retained offset, clamped as of the last layout — the number to stash in a model and hand back to set_scroll later. Zero for a node that never scrolled.

Source

pub fn set_scroll(&mut self, key: Key, offset: Vec2)

Sets that offset, the way the wheel would: Vec2::ZERO jumps to the top, a large value to the end (the next layout clamps it).

Source

pub fn shift_scroll(&mut self, key: Key, drawn: Vec2, target: Vec2)

Moves a container’s scroll state by the content that moved under it (drawn for the drawn place and an eased leg’s start, target for the offset) with no ease asked or ended: a variable-height list’s height correction. See Core::shift_scroll.

Source

pub fn scroll_geometry(&self, key: Key) -> Option<ScrollGeometry>

What the last layout resolved for a scroll container — its box, its content size and the clamped offset — so a view can build only the rows that fit and two spacers instead of ten thousand rows. None until a layout has resolved key as a container. It describes the previous frame; see Core::scroll_geometry, or widgets::uniform_list for the uniform-row case.

Source

pub fn layout_of(&self, key: Key) -> Option<Rect>

The rect the last frame laid an on_layout node out at; see Core::layout_of.

Source

pub fn take_key_focus(&mut self, key: Key)

Declares this node focused: it takes keyboard focus when the declaration starts (the first frame it is made), and a Tab press afterwards is not clobbered by the view repeating it. An on_key sink then gets presses in on_event as {kind="key", code, ctrl, alt, shift, super, text, repeat, tag}. To move focus at any time, focus(key).

Source

pub fn key_focus(&self) -> Option<Key>

The node holding keyboard focus (the same as focused).

Source

pub fn window_command(&mut self, cmd: WindowCommand)

Asks the frame driver to apply a window command (close from a keymap, minimize from a command line).

Source

pub fn set_window_size(&mut self, window: WindowId, size: Size)

Asks the driver to resize a window (logical px) — a request applied on the driver’s next pump and ignored headlessly, not a declaration: the user owns a window’s size once it exists. ui.env().window.id is the window this view is drawing. See Core::set_window_size.

Source

pub fn focus_window(&mut self, window: WindowId)

Asks the driver to give a window keyboard focus; queued the same way. See Core::focus_window.

Source

pub fn finish(self)

Runs layout and emission; results land in Core::output(). A frame begun with a filler lets it finish first: the "root" fill, unless the view declared it, and the unknown-slot check. An open context menu is drawn after both, which is what makes it the frame’s modal scope and its topmost float.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Ui<'a>

§

impl<'a> !Send for Ui<'a>

§

impl<'a> !Sync for Ui<'a>

§

impl<'a> !UnwindSafe for Ui<'a>

§

impl<'a> Freeze for Ui<'a>

§

impl<'a> Unpin for Ui<'a>

§

impl<'a> UnsafeUnpin for Ui<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.