Skip to main content

LayoutOp

Enum LayoutOp 

Source
pub enum LayoutOp {
Show 13 variants Box { width: Option<f32>, height: Option<f32>, min_width: Option<f32>, max_width: Option<f32>, min_height: Option<f32>, max_height: Option<f32>, padding: [f32; 4], flex_grow: f32, flex_shrink: f32, aspect_ratio: Option<f32>, }, Flex { direction: FlexDirection, wrap: FlexWrap, flex_grow: f32, flex_shrink: f32, padding: [f32; 4], gap: Option<f32>, align_items: AlignItems, justify_content: JustifyContent, }, Grid { columns: Vec<GridTrack>, rows: Vec<GridTrack>, column_gap: Option<f32>, row_gap: Option<f32>, padding: [f32; 4], }, GridItem { row_start: GridPlacement, row_end: GridPlacement, col_start: GridPlacement, col_end: GridPlacement, }, Scroll { direction: FlexDirection, show_scrollbar: bool, width: Option<f32>, height: Option<f32>, min_width: Option<f32>, max_width: Option<f32>, min_height: Option<f32>, max_height: Option<f32>, padding: [f32; 4], flex_grow: f32, flex_shrink: f32, }, Embed { kind: EmbedKind, widget_id: WidgetNodeId, width: Option<f32>, height: Option<f32>, }, AbsoluteFill, Positioned { left: Option<f32>, top: Option<f32>, right: Option<f32>, bottom: Option<f32>, width: Option<f32>, height: Option<f32>, }, ZStack, Align, Flyout { anchor: NodeId, content: NodeId, }, Transform { transform: [f32; 16], }, Clip { path: Option<String>, },
}
Expand description

A layout operation that sizes and positions a node and its children.

LayoutOp covers every layout model in Fission: constrained boxes, flexbox, CSS Grid, scroll containers, absolute positioning, z-stacking, flyout menus, transforms, and clipping. Each variant maps to a distinct layout algorithm in the [fission_layout] crate.

§Padding convention

All padding fields use [left, right, top, bottom] order.

§Flex participation

Variants that have flex_grow and flex_shrink fields participate in flex layout when placed inside a Flex parent. flex_grow controls how much extra space the node claims; flex_shrink controls how much it gives up when the container overflows.

Variants§

§

Box

A constrained box that sizes itself and stacks its children.

This is the most common layout node. It applies optional fixed dimensions, min/max constraints, padding, and aspect ratio. Children are stacked on top of each other (like a single-child container).

Use Box when you need a container with specific size constraints, padding, or an aspect ratio, but do not need flex or grid distribution.

Fields

§width: Option<f32>

Fixed width in logical pixels, or None to size-to-content.

§height: Option<f32>

Fixed height in logical pixels, or None to size-to-content.

§min_width: Option<f32>

Minimum width. The node will never be narrower than this.

§max_width: Option<f32>

Maximum width. The node will never be wider than this.

§min_height: Option<f32>

Minimum height. The node will never be shorter than this.

§max_height: Option<f32>

Maximum height. The node will never be taller than this.

§padding: [f32; 4]

Inner padding: [left, right, top, bottom].

§flex_grow: f32

How much extra space this node claims when inside a flex container. 0.0 means it does not grow. Default: 0.0.

§flex_shrink: f32

How much this node shrinks when a flex container overflows. 1.0 means it shrinks proportionally. Default: 1.0.

§aspect_ratio: Option<f32>

If set, the node maintains this width/height ratio. For example, Some(16.0 / 9.0) gives a widescreen aspect ratio.

§

Flex

A flex container that distributes children along a main axis.

Implements CSS Flexbox semantics: children are measured, flex-grow/shrink is applied, and then children are positioned according to justify_content and align_items.

Fields

§direction: FlexDirection

Whether children flow horizontally (Row) or vertically (Column).

§wrap: FlexWrap

Whether children wrap onto multiple lines. Default: NoWrap.

§flex_grow: f32

How much extra space this flex container claims from its parent flex.

§flex_shrink: f32

How much this flex container shrinks when its parent overflows.

§padding: [f32; 4]

Inner padding: [left, right, top, bottom].

§gap: Option<f32>

Space between children along the main axis. None means 0.0.

§align_items: AlignItems

Cross-axis alignment of children. Default: Stretch.

§justify_content: JustifyContent

Main-axis distribution of children. Default: Start.

§

Grid

A CSS Grid container that places children into a row/column matrix.

Columns and rows are defined by GridTrack sizing functions. Children are placed either automatically (in source order) or explicitly via GridItem.

Fields

§columns: Vec<GridTrack>

Column track definitions. If empty, a single auto-width column is used.

§rows: Vec<GridTrack>

Row track definitions. If empty, rows are created automatically as needed.

§column_gap: Option<f32>

Horizontal gap between columns in logical pixels.

§row_gap: Option<f32>

Vertical gap between rows in logical pixels.

§padding: [f32; 4]

Inner padding: [left, right, top, bottom].

§

GridItem

A child of a Grid that specifies its row/column placement.

If a grid child does not use GridItem, the grid auto-placement algorithm assigns it the next available cell.

Fields

§row_start: GridPlacement

Which row line this item starts at. Default: Auto.

§row_end: GridPlacement

Which row line this item ends at. Default: Auto.

§col_start: GridPlacement

Which column line this item starts at. Default: Auto.

§col_end: GridPlacement

Which column line this item ends at. Default: Auto.

§

Scroll

A scrollable container.

The scroll container clips its content and shifts it by a scroll offset obtained from a ScrollDataSource. The layout engine gives the content infinite space along the scroll axis so it can measure its natural size.

Fields

§direction: FlexDirection

Scroll axis: horizontal (Row) or vertical (Column).

§show_scrollbar: bool

Whether to render a scrollbar indicator.

§width: Option<f32>

Fixed width, or None to size from constraints.

§height: Option<f32>

Fixed height, or None to size from constraints.

§min_width: Option<f32>

Minimum width constraint.

§max_width: Option<f32>

Maximum width constraint.

§min_height: Option<f32>

Minimum height constraint.

§max_height: Option<f32>

Maximum height constraint.

§padding: [f32; 4]

Inner padding: [left, right, top, bottom].

§flex_grow: f32

Flex grow factor when inside a flex parent.

§flex_shrink: f32

Flex shrink factor when inside a flex parent.

§

Embed

A placeholder for a platform-native surface (video, web view, etc.).

The layout engine allocates space for the embed; the platform layer is responsible for creating and positioning the actual native view.

Fields

§kind: EmbedKind

What kind of native surface to create.

§widget_id: WidgetNodeId

The widget that owns this native surface.

§width: Option<f32>

Fixed width, or None to use available space.

§height: Option<f32>

Fixed height, or None to use available space.

§

AbsoluteFill

A child that fills its parent’s entire bounds.

Equivalent to Positioned { left: 0, top: 0, right: 0, bottom: 0 } but expressed as a zero-field variant for clarity. Commonly used for overlays, backgrounds, and hit-test areas.

§

Positioned

A child positioned absolutely within its parent.

At least one of left/right and one of top/bottom should be set. If both left and right are set (and width is not), the width is inferred from the parent’s width minus both offsets.

Fields

§left: Option<f32>

Offset from the parent’s left edge.

§top: Option<f32>

Offset from the parent’s top edge.

§right: Option<f32>

Offset from the parent’s right edge.

§bottom: Option<f32>

Offset from the parent’s bottom edge.

§width: Option<f32>

Fixed width. If None, width is inferred from left/right.

§height: Option<f32>

Fixed height. If None, height is inferred from top/bottom.

§

ZStack

A container that stacks all children on top of each other.

Each child occupies the full size of the stack; later children paint on top of earlier ones. The stack’s own size is the union of its children.

§

Align

A container that centers its single child within the available space.

§

Flyout

An anchored popup container (dropdown menu, tooltip, etc.).

The content node is positioned relative to the anchor node’s screen location, typically directly below it. The layout engine resolves anchor positions after the main layout pass.

Fields

§anchor: NodeId

The node that the flyout is anchored to.

§content: NodeId

The node containing the flyout content.

§

Transform

Applies a 4x4 affine transform matrix to its child.

The matrix is column-major, matching OpenGL/wgpu convention. The transform does not affect layout; it is applied during painting.

Fields

§transform: [f32; 16]

A 4x4 column-major transform matrix.

§

Clip

Clips its child to a rectangular or path-defined region.

If path is None, the clip is the node’s layout rectangle. If path is set, it is an SVG-style path string.

Fields

§path: Option<String>

An optional SVG path string. None means clip to the layout rect.

Trait Implementations§

Source§

impl Clone for LayoutOp

Source§

fn clone(&self) -> LayoutOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutOp

Source§

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

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

impl<'de> Deserialize<'de> for LayoutOp

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<LayoutOp, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for LayoutOp

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LayoutOp

Source§

fn eq(&self, other: &LayoutOp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LayoutOp

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LayoutOp

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,