Skip to main content

LayoutBuilder

Struct LayoutBuilder 

Source
pub struct LayoutBuilder { /* private fields */ }
Expand description

Places children in a row or column. Children’s x/y become offsets from their layout position.

Builder for a Layout node: set the initial values, then pass it to add.

Implementations§

Source§

impl LayoutBuilder

Source

pub fn direction(self, v: impl Into<Direction>) -> Self

Sets the initial direction.

Source

pub fn align(self, v: impl Into<LayoutAlign>) -> Self

Sets the initial align.

Source

pub fn justify(self, v: impl Into<Justify>) -> Self

Sets the initial justify.

Source§

impl LayoutBuilder

Source

pub fn gap(self, v: impl Len) -> Self

Space between children, in pixels or a theme step (.gap(Sm)).

Source

pub fn padding(self, v: impl Len) -> Self

Space inside the edges, in pixels or a theme step (.padding(Md)).

Source

pub fn radius(self, v: impl Corner) -> Self

Corner radius, in pixels or a theme step.

Source§

impl LayoutBuilder

Source

pub fn wrap(self, v: bool) -> Self

Wrap children onto several lines when they do not fit.

Source

pub fn grid(self, columns: u16) -> Self

CSS grid with n equal columns instead of a row/column.

Source

pub fn row(self) -> Self

Children side by side (the default).

Source

pub fn column(self) -> Self

Children stacked top to bottom.

Source

pub fn width(self, v: impl Into<Span>) -> Self

Fixed width in pixels or pct(80) (otherwise sized to content).

Source

pub fn height(self, v: impl Into<Span>) -> Self

Fixed height in pixels or a percentage (otherwise sized to content).

Trait Implementations§

Source§

impl Debug for LayoutBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LayoutBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl NodeBuilder for LayoutBuilder

Source§

type Handle = Layout

Handle returned by Node::add.
Source§

fn name(self, v: impl Into<String>) -> Self

Name shown in the editor and in oxframe check / oxframe inspect. Without it, the node is labeled by the add call site (src/main.rs:42).
Source§

fn x(self, v: f64) -> Self

Horizontal position; 0 is the parent’s center, positive is right.
Source§

fn y(self, v: f64) -> Self

Vertical position; 0 is the parent’s center, positive is down.
Source§

fn position(self, v: impl Into<Vec2>) -> Self

Sets x and y together, e.g. .position((100.0, -50.0)).
Source§

fn rotation(self, v: f64) -> Self

Degrees, clockwise.
Source§

fn scale(self, v: f64) -> Self

Uniform scale; 1 is the natural size.
Source§

fn scale_xy(self, v: impl Into<Vec2>) -> Self

Separate horizontal and vertical scale.
Source§

fn opacity(self, v: f64) -> Self

Opacity of the node and its children, 0 (invisible) to 1.
Source§

fn fill(self, v: impl IntoPaint) -> Self

Fill color: a Color or a theme role such as Accent. Default: transparent, except text, which uses the theme’s text color.
Source§

fn stroke(self, v: impl IntoPaint) -> Self

Outline color; also set line_width. A theme role works the same as a color. Default: transparent.
Source§

fn line_width(self, v: f64) -> Self

Outline width in pixels. Default: 0 (no outline).
Source§

fn start(self, v: f64) -> Self

Start of the drawn part of the outline, fraction of its length.
Source§

fn end(self, v: f64) -> Self

End of the drawn part of the outline; animate 0 → 1 to draw it on.
Source§

fn fill_gradient(self, g: Gradient) -> Self

Gradient fill (local coordinates, origin at the node center); overrides fill.
Source§

fn stroke_gradient(self, g: Gradient) -> Self

Gradient outline; overrides stroke.
Source§

fn dash(self, pattern: impl Into<Vec<f64>>) -> Self

Dash pattern: on, off, on, … lengths. Animate dash_offset for marching ants.
Source§

fn dash_offset(self, v: f64) -> Self

Shifts the dash pattern along the outline.
Source§

fn line_cap(self, v: LineCap) -> Self

Shape of outline ends. Default: round.
Source§

fn line_join(self, v: LineJoin) -> Self

Shape of outline corners. Default: round.
Source§

fn blur(self, v: f64) -> Self

Gaussian blur of the node and its children (standard deviation, in the node’s units).
Source§

fn shadow( self, color: impl IntoPaint, blur: f64, offset: impl Into<Vec2>, ) -> Self

Drop shadow under the node and its children.
Source§

fn elevation(self, step: Step) -> Self

The theme’s shadow for this step (Xs and Sm are the small one, Xl the large).
Source§

fn glow(self, color: impl IntoPaint, blur: f64) -> Self

A shadow without offset.
Source§

fn clip(self, v: bool) -> Self

Clip children to this node’s outline (or box).
Source§

fn blend(self, v: BlendMode) -> Self

How the node is composited onto what is below it.
Source§

fn z_index(self, v: f64) -> Self

Paint order among siblings; higher is on top.
Source§

fn anchor(self, v: impl Into<Vec2>) -> Self

Pivot and placement point: (-1, -1) top-left … (1, 1) bottom-right.
Source§

fn grow(self, v: f64) -> Self

Inside a Layout: share of the free space this node takes.
Source§

fn shrink(self, v: f64) -> Self

Inside a Layout: how much this node gives up when space is short.
Source§

fn basis(self, v: f64) -> Self

Inside a Layout: main-axis size before growing/shrinking.
Source§

fn margin(self, v: impl Len) -> Self

Inside a Layout: space around this node, in pixels or a theme step (.margin(Md)).
Source§

fn align_self(self, v: LayoutAlign) -> Self

Inside a Layout: overrides the layout’s cross-axis alignment.
Source§

fn next_to(self, other: impl Into<Node>, side: Side) -> Self

Sits just outside other, on side. The gap is the theme’s Md step. Recomputed every frame, so this node follows other.
Source§

fn align_to(self, other: impl Into<Node>, edge: Edge) -> Self

Lines this node’s edge up with the same edge of other.
Source§

fn to_edge(self, edge: Edge) -> Self

Pins one edge to the safe area (not the raw frame edge). The other axis stays at x or y.
Source§

fn center_in(self, other: impl Into<Node>) -> Self

Same center as other. Pass the view to center in the frame.
Source§

fn child<C: NodeBuilder>(self, child: C) -> Self

Adds a child created together with this node. Use Node::add when you need the child’s handle.

Auto Trait Implementations§

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> ErasedDestructor for T
where T: 'static,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V