Skip to main content

ElementBuilder

Trait ElementBuilder 

Source
pub trait ElementBuilder: Sized {
Show 52 methods // Required method fn element(&mut self) -> &mut Element; // Provided methods fn style(self, f: impl FnOnce(&mut Style)) -> Self { ... } fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self { ... } fn width(self, value: impl IntoValue<Length>) -> Self { ... } fn height(self, value: impl IntoValue<Length>) -> Self { ... } fn min_width(self, value: impl IntoValue<Length>) -> Self { ... } fn min_height(self, value: impl IntoValue<Length>) -> Self { ... } fn max_width(self, value: impl IntoValue<Length>) -> Self { ... } fn max_height(self, value: impl IntoValue<Length>) -> Self { ... } fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self { ... } fn padding(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_x(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_y(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_start(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_end(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_top(self, value: impl IntoValue<Length>) -> Self { ... } fn padding_bottom(self, value: impl IntoValue<Length>) -> Self { ... } fn margin(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_x(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_y(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_start(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_end(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_top(self, value: impl IntoValue<Length>) -> Self { ... } fn margin_bottom(self, value: impl IntoValue<Length>) -> Self { ... } fn grow(self, value: impl IntoValue<f32>) -> Self { ... } fn shrink(self, value: impl IntoValue<f32>) -> Self { ... } fn basis(self, value: impl IntoValue<Length>) -> Self { ... } fn align_self(self, value: impl IntoValue<Align>) -> Self { ... } fn justify_self(self, value: impl IntoValue<Align>) -> Self { ... } fn top(self, value: impl IntoValue<Length>) -> Self { ... } fn bottom(self, value: impl IntoValue<Length>) -> Self { ... } fn start(self, value: impl IntoValue<Length>) -> Self { ... } fn end(self, value: impl IntoValue<Length>) -> Self { ... } fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self { ... } fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self { ... } fn direction(self, value: impl IntoValue<TextDirection>) -> Self { ... } fn hidden(self, value: impl IntoValue<bool>) -> Self { ... } fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self { ... } fn absolute(self) -> Self { ... } fn tooltip(self, text: impl IntoValue<String>) -> Self { ... } fn context_menu(self, entries: impl MenuEntries) -> Self { ... } fn context_menu_with<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self { ... } fn context_menu_on_open<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self { ... } fn a11y_label(self, label: impl IntoValue<String>) -> Self { ... } fn a11y_description(self, description: impl IntoValue<String>) -> Self { ... } fn a11y_role(self, role: Role) -> Self { ... } fn a11y_hidden(self) -> Self { ... } fn on_focus(self, handler: impl Fn() + 'static) -> Self { ... } fn on_blur(self, handler: impl Fn() + 'static) -> Self { ... } fn tab_index(self, index: u32) -> Self { ... } fn node_ref(self, node: NodeRef) -> Self { ... } fn test_id(self, id: impl Into<String>) -> Self { ... }
}
Expand description

Style, semantics and test hooks shared by every widget builder.

Every style setter accepts a literal, a signal or a closure; reactive values update the layout whenever they change.

Required Methods§

Source

fn element(&mut self) -> &mut Element

Provided Methods§

Source

fn style(self, f: impl FnOnce(&mut Style)) -> Self

Escape hatch: edit the style directly (static).

Source

fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self

Escape hatch: edit the style reactively. f re-runs whenever the signals it reads change, and must set every field it cares about.

Source

fn width(self, value: impl IntoValue<Length>) -> Self

Source

fn height(self, value: impl IntoValue<Length>) -> Self

Source

fn min_width(self, value: impl IntoValue<Length>) -> Self

Source

fn min_height(self, value: impl IntoValue<Length>) -> Self

Source

fn max_width(self, value: impl IntoValue<Length>) -> Self

Source

fn max_height(self, value: impl IntoValue<Length>) -> Self

Source

fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self

Source

fn padding(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_x(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_y(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_start(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_end(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_top(self, value: impl IntoValue<Length>) -> Self

Source

fn padding_bottom(self, value: impl IntoValue<Length>) -> Self

Source

fn margin(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_x(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_y(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_start(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_end(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_top(self, value: impl IntoValue<Length>) -> Self

Source

fn margin_bottom(self, value: impl IntoValue<Length>) -> Self

Source

fn grow(self, value: impl IntoValue<f32>) -> Self

Source

fn shrink(self, value: impl IntoValue<f32>) -> Self

Source

fn basis(self, value: impl IntoValue<Length>) -> Self

Source

fn align_self(self, value: impl IntoValue<Align>) -> Self

Source

fn justify_self(self, value: impl IntoValue<Align>) -> Self

Alignment inside a grid cell along the inline axis.

Source

fn top(self, value: impl IntoValue<Length>) -> Self

Inset from the top of the containing block (with absolute()).

Source

fn bottom(self, value: impl IntoValue<Length>) -> Self

Source

fn start(self, value: impl IntoValue<Length>) -> Self

Inset from the inline start (left in LTR, right in RTL).

Source

fn end(self, value: impl IntoValue<Length>) -> Self

Source

fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self

Source

fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self

Source

fn direction(self, value: impl IntoValue<TextDirection>) -> Self

Source

fn hidden(self, value: impl IntoValue<bool>) -> Self

Not laid out, not visible, not focusable, not in the a11y tree. Un-hiding restores whatever display the node had.

Source

fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self

Source

fn absolute(self) -> Self

Takes the node out of flow; position it with top/start/….

Source

fn tooltip(self, text: impl IntoValue<String>) -> Self

A tooltip: text the platform shows, its own way, when the pointer rests on the widget, and assistive technology reads as its description. Empty: none.

Source

fn context_menu(self, entries: impl MenuEntries) -> Self

A context menu: the platform shows it its own way, on a right-click, a long press or the menu key, and over children without one of their own. Takes items, separators and submenus, as a Menu does, with the same reactive titles, states and check marks:

ⓘ
Text::new(name).context_menu((
    MenuItem::new("Rename").on_select(rename),
    MenuSeparator,
    MenuItem::new("Delete").on_select(delete),
))
Source

fn context_menu_with<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self

A context menu built by entries, and built again whenever what it reads changes, as Menu::children_with builds its entries.

Source

fn context_menu_on_open<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self

A context menu built by entries each time the platform opens it, for a menu that depends on what’s selected or under the pointer at that moment: a table row’s menu acting on the selection. What it reads is read then, not followed.

Source

fn a11y_label(self, label: impl IntoValue<String>) -> Self

Source

fn a11y_description(self, description: impl IntoValue<String>) -> Self

Source

fn a11y_role(self, role: Role) -> Self

Source

fn a11y_hidden(self) -> Self

Source

fn on_focus(self, handler: impl Fn() + 'static) -> Self

Called when this control gains keyboard focus.

Source

fn on_blur(self, handler: impl Fn() + 'static) -> Self

Called when this control loses keyboard focus.

Source

fn tab_index(self, index: u32) -> Self

Moves this control ahead in the Tab order. Controls with a tab index come first (lowest first); the rest follow in reading order. Prefer arranging the tree in the order users should visit it.

Source

fn node_ref(self, node: NodeRef) -> Self

Points node at this widget’s node, for use_size and to focus it from code (NodeRef::focus).

Source

fn test_id(self, id: impl Into<String>) -> Self

Last-resort handle for tests; prefer finding nodes by role and name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ElementBuilder for Element

Source§

impl<T: 'static, K: 'static, R> ElementBuilder for List<T, K, R>

Source§

impl<T: 'static, K: 'static, R> ElementBuilder for Tree<T, K, R>

Source§

impl<T: 'static, K: 'static> ElementBuilder for Table<T, K>

Source§

impl<W: CustomWidget, P> ElementBuilder for Custom<W, P>