View

Trait View 

Source
pub trait View:
    Debug
    + Clone
    + Default {
Show 17 methods // Required methods fn name_node(&mut self) -> &mut Name; fn node_node(&mut self) -> &mut Node; // Provided methods fn new() -> Self { ... } fn from_name(name: impl Into<Cow<'static, str>>) -> Self { ... } fn name(self, name: impl Into<Cow<'static, str>>) -> Self { ... } fn padding(self, padding: UiRect) -> Self { ... } fn frame(self, width: Val, height: Val) -> Self { ... } fn width(self, val: Val) -> Self { ... } fn max_width(self, val: Val) -> Self { ... } fn min_width(self, val: Val) -> Self { ... } fn height(self, val: Val) -> Self { ... } fn max_height(self, val: Val) -> Self { ... } fn min_height(self, val: Val) -> Self { ... } fn flex_grow(self, grow: f32) -> Self { ... } fn flex_shrink(self, shrink: f32) -> Self { ... } fn grid_row(self, row: GridPlacement) -> Self { ... } fn grid_column(self, column: GridPlacement) -> Self { ... }
}
Expand description

Provides a builder-style trait for configuring UI elements using a fluent interface.

Types implementing View must define how to access their Name and Node components. This trait simplifies layout and styling tasks through expressive method chaining.

Required Methods§

Source

fn name_node(&mut self) -> &mut Name

Provides mutable access to the underlying Name component.

This allows for direct manipulation or inspection of the Name.

Source

fn node_node(&mut self) -> &mut Node

Provides mutable access to the underlying Node component.

Useful when applying layout or transform properties.

Provided Methods§

Source

fn new() -> Self

Creates a new instance using the type’s Default implementation.

This is a convenient shorthand when no customization is needed.

Source

fn from_name(name: impl Into<Cow<'static, str>>) -> Self

Constructs a new instance and sets its Name component.

§Arguments
  • name - A name to assign to this instance, typically used for entity identification or debugging purposes.
Source

fn name(self, name: impl Into<Cow<'static, str>>) -> Self

Sets the Name component of this instance.

Helpful for tracking or debugging UI entities.

§Arguments
  • name - The name to assign, provided as a &str, String, or Cow.
Source

fn padding(self, padding: UiRect) -> Self

Sets the padding (insets) around the content of the Node.

§Arguments
  • padding - A UiRect defining spacing on all four sides.
Source

fn frame(self, width: Val, height: Val) -> Self

Sets both the width and height of the Node.

§Arguments
  • width - The desired width using Val::Px, Val::Percent, etc.
  • height - The desired height using the same Val enum.
Source

fn width(self, val: Val) -> Self

Sets the width of the Node.

§Arguments
  • val - The desired width value.
Source

fn max_width(self, val: Val) -> Self

Sets the maximum width constraint of the Node.

Prevents the node from expanding beyond this limit.

Source

fn min_width(self, val: Val) -> Self

Sets the minimum width constraint of the Node.

Ensures the node does not shrink below this value.

Source

fn height(self, val: Val) -> Self

Sets the height of the Node.

§Arguments
  • val - The desired height value.
Source

fn max_height(self, val: Val) -> Self

Sets the maximum height constraint of the Node.

Prevents the node from growing beyond this value.

Source

fn min_height(self, val: Val) -> Self

Sets the minimum height constraint of the Node.

Ensures the node maintains at least this size.

Source

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

Sets the flex_grow factor of the Node.

Determines how much the node should grow relative to its siblings.

Source

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

Sets the flex_shrink factor of the Node.

Controls how much the node should shrink when space is constrained.

Source

fn grid_row(self, row: GridPlacement) -> Self

Assigns this node to a specific grid row in a grid layout.

§Arguments
  • row - The grid row position.
Source

fn grid_column(self, column: GridPlacement) -> Self

Assigns this node to a specific grid column in a grid layout.

§Arguments
  • column - The grid column position.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§