Skip to main content

Node

Struct Node 

Source
pub struct Node<'a> {
Show 19 fields pub kind: WidgetKind, pub text: Option<String>, pub icon: Option<IconRole>, pub children: Vec<Node<'a>>, pub id_out: Option<&'a mut WidgetId>, pub bg_color: Option<Color>, pub style: Style, pub direction: Option<ContainerDirection>, pub wrap: Option<ContainerWrap>, pub gap: Option<i32>, pub padding: Option<i32>, pub align_self: Option<AlignSelf>, pub min_width: Option<f32>, pub max_width: Option<f32>, pub min_height: Option<f32>, pub max_height: Option<f32>, pub flex_shrink: Option<f32>, pub flex_basis: Option<Dimension>, pub split_ratio: Option<u8>,
}
Expand description

A declarative representation of a UI widget tree.

Fields§

§kind: WidgetKind§text: Option<String>§icon: Option<IconRole>§children: Vec<Node<'a>>§id_out: Option<&'a mut WidgetId>§bg_color: Option<Color>§style: Style§direction: Option<ContainerDirection>§wrap: Option<ContainerWrap>§gap: Option<i32>§padding: Option<i32>§align_self: Option<AlignSelf>§min_width: Option<f32>§max_width: Option<f32>§min_height: Option<f32>§max_height: Option<f32>§flex_shrink: Option<f32>§flex_basis: Option<Dimension>§split_ratio: Option<u8>

Implementations§

Source§

impl<'a> Node<'a>

Source

pub fn new(kind: WidgetKind) -> Self

Source

pub fn split_ratio(self, ratio: u8) -> Self

Sets the split ratio percentage (0..=100) for SplitPane widgets.

Source

pub fn text(self, text: impl Into<String>) -> Self

Source

pub fn icon(self, icon: IconRole) -> Self

Sets an optional stock-art icon.

Source

pub fn optional_icon(self, icon: Option<IconRole>) -> Self

Sets or clears the stock-art icon with an optional value.

Source

pub fn child(self, child: Node<'a>) -> Self

Source

pub fn bind_id(self, id_out: &'a mut WidgetId) -> Self

Source

pub fn bind(self, id_out: &'a mut WidgetId) -> Self

Alias for Self::bind_id.

Source

pub fn mount<B: Backend>( &mut self, ui: &mut Ui<B>, parent: Option<WidgetId>, ) -> GuiResult<WidgetId>

Renders this node tree into ui and optionally attaches the root to parent.

Source

pub fn bg_color(self, color: Color) -> Self

Source

pub fn size(self, width: f32, height: f32) -> Self

Sets explicit logical-pixel layout dimensions.

For windows, render also forwards both rounded dimensions to the backend before presentation. They must round to positive i32 values. Other widget kinds retain flex-layout sizing.

Source

pub fn flex_direction(self, direction: FlexDirection) -> Self

Source

pub fn wrap(self, wrap: ContainerWrap) -> Self

Sets container wrapping mode.

Source

pub fn flow_gap(self, gap: i32) -> Self

Sets uniform flow gap in logical pixels.

Source

pub fn flex_grow(self, grow: f32) -> Self

Source

pub fn flex_wrap(self, wrap: FlexWrap) -> Self

Wraps children onto new rows/lines when the container runs out of space on the main axis (wrapsizer).

Source

pub fn align_items(self, align: AlignItems) -> Self

Cross-axis alignment of the children inside each line.

Source

pub fn justify_content(self, justify: JustifyContent) -> Self

Main-axis distribution of the children (e.g. SpaceBetween).

Source

pub fn align_content(self, align: AlignContent) -> Self

Distribution of wrapped lines on the cross axis.

Source

pub fn percent_size(self, width_pct: f32, height_pct: f32) -> Self

Source

pub fn gap(self, width: f32, height: f32) -> Self

Sets the gap between items.

For container widgets (Container, GroupBox), this spacing is also forwarded to the backend container’s flow spacing (Ui::set_container_gap) during DeclarativeUi::render. This aligns native flow containers (such as GTK4, whose flow containers pack children into a GtkBox ignoring computed layout coordinates) with the shared layout model.

Source

pub fn padding(self, val: f32) -> Self

Sets uniform padding across all sides.

For container widgets (Container, GroupBox), this inset is forwarded to the backend container properties (Ui::set_container_padding) during DeclarativeUi::render.

Source

pub fn margin(self, val: f32) -> Self

Source

pub fn align_self(self, align: AlignSelf) -> Self

Overrides cross-axis alignment for this child (equivalent to wxALIGN_* or wxEXPAND).

Source

pub fn min_width(self, width: f32) -> Self

Sets the minimum width in logical pixels (equivalent to wxWindow::SetMinSize / wxSizer::SetItemMinSize).

Source

pub fn max_width(self, width: f32) -> Self

Sets the maximum width in logical pixels (equivalent to wxWindow::SetMaxSize).

Source

pub fn min_height(self, height: f32) -> Self

Sets the minimum height in logical pixels (equivalent to wxWindow::SetMinSize / wxSizer::SetItemMinSize).

Source

pub fn max_height(self, height: f32) -> Self

Sets the maximum height in logical pixels (equivalent to wxWindow::SetMaxSize).

Source

pub fn min_size(self, width: f32, height: f32) -> Self

Sets both minimum width and minimum height in logical pixels.

Source

pub fn max_size(self, width: f32, height: f32) -> Self

Sets both maximum width and maximum height in logical pixels.

Source

pub fn flex_shrink(self, shrink: f32) -> Self

Sets the flex shrink factor (relative rate at which item shrinks when space is constrained).

Source

pub fn flex_basis(self, basis: Dimension) -> Self

Sets the initial main-axis size of the item before space distribution.

Source

pub fn display(self, display: Display) -> Self

Sets the layout display model (e.g. Display::Flex or Display::Grid).

Source

pub fn spacer() -> Node<'static>

Creates an expanding spacer (Container with flex_grow = 1.0 and no children), equivalent to wxSizer::AddStretchSpacer().

Source

pub fn stretch_spacer() -> Node<'static>

Alias for Node::spacer, equivalent to wxSizer::AddStretchSpacer().

Source

pub fn grid() -> Node<'static>

Creates a CSS Grid container (Container with display = Display::Grid), equivalent to wxGridBagSizer or wxFlexGridSizer.

Auto Trait Implementations§

§

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

§

impl<'a> Forget for Node<'a>

§

impl<'a> Freeze for Node<'a>

§

impl<'a> Move for Node<'a>

§

impl<'a> RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>
where RawVecInner: Send, BoxRaw<TrackSizingFunction>: Send,

§

impl<'a> Sync for Node<'a>
where RawVecInner: Sync, BoxRaw<TrackSizingFunction>: Sync,

§

impl<'a> Unpin for Node<'a>
where *const u8 is !null: Unpin, &'a mut WidgetId: Unpin, Box<TrackSizingFunction>: Unpin,

§

impl<'a> UnsafeUnpin for Node<'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<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, 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.