Skip to main content

RenderStackBase

Trait RenderStackBase 

Source
pub trait RenderStackBase: RenderBoxContainerDefaultsMixin<ParentDataType = StackParentData> {
Show 25 methods // Required methods fn stack_data(self: RenderHandle<Self>, app: &App) -> &RenderStackData; fn stack_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderStackData; // Provided methods fn setup_parent_data( self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject, ) { ... } fn resolved_alignment(self: RenderHandle<Self>, app: &mut App) -> Alignment { ... } fn mark_need_resolution(self: RenderHandle<Self>, app: &mut App) { ... } fn alignment(self: RenderHandle<Self>, app: &App) -> AlignmentGeometry { ... } fn set_alignment( self: RenderHandle<Self>, app: &mut App, value: AlignmentGeometry, ) { ... } fn text_direction( self: RenderHandle<Self>, app: &App, ) -> Option<TextDirection> { ... } fn set_text_direction( self: RenderHandle<Self>, app: &mut App, value: Option<TextDirection>, ) { ... } fn fit(self: RenderHandle<Self>, app: &App) -> StackFit { ... } fn set_fit(self: RenderHandle<Self>, app: &mut App, value: StackFit) { ... } fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip { ... } fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip) { ... } fn compute_min_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64 { ... } fn compute_max_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64 { ... } fn compute_min_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64 { ... } fn compute_max_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64 { ... } fn compute_distance_to_actual_baseline( self: RenderHandle<Self>, app: &mut App, baseline: TextBaseline, ) -> Option<f64> { ... } fn compute_dry_baseline( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, baseline: TextBaseline, ) -> Option<f64> { ... } fn compute_dry_layout( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, ) -> Size { ... } fn compute_size( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, layout_child: impl FnMut(&mut App, AnyRenderBox, BoxConstraints) -> Size, ) -> Size { ... } fn perform_layout(self: RenderHandle<Self>, app: &mut App) { ... } fn paint_stack( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, ) { ... } fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, ) { ... } fn dispose(self: RenderHandle<Self>, app: &mut App) { ... }
}
Expand description

Implements the stack layout algorithm.

In a stack layout, the children are positioned on top of each other in the order in which they appear in the child list. First, the non-positioned children (those with null values for top, right, bottom, and left) are laid out and initially placed in the upper-left corner of the stack. The stack is then sized to enclose all of the non-positioned children. If there are no non-positioned children, the stack becomes as large as possible.

The final location of non-positioned children is determined by the alignment parameter. The left of each non-positioned child becomes the difference between the stack’s width and the child’s width multiplied by (alignment.x + 1.0) / 2.0. The top of each non-positioned child is computed similarly from the stack’s height, the child’s height, and alignment.y.

Next, the positioned children are laid out. If a child has top and bottom values that are both non-null, the child is given a fixed height determined by subtracting the sum of the top and bottom values from the height of the stack. Similarly, if the child has right and left values that are both non-null, the child is given a fixed width derived from the stack’s width. Otherwise, the child is given unbounded constraints in the non-fixed dimensions.

Once the child is laid out, the stack positions the child according to the top, right, bottom, and left properties of their StackParentData. If the child extends beyond the bounds of the stack, the stack will clip the child’s painting to the bounds of the stack.

Flutter’s RenderStack bodies. RenderStack is the plain leaf; RenderIndexedStack implements this trait too and overrides paint_stack.

Required Methods§

Source

fn stack_data(self: RenderHandle<Self>, app: &App) -> &RenderStackData

Mixin field access.

Source

fn stack_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderStackData

Provided Methods§

Source

fn setup_parent_data( self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject, )

Installs StackParentData unless the child already has it.

The body of Flutter’s setupParentData override; call it from RenderBox::setup_parent_data.

Source

fn resolved_alignment(self: RenderHandle<Self>, app: &mut App) -> Alignment

The alignment resolved against text_direction, cached until either changes.

Source

fn mark_need_resolution(self: RenderHandle<Self>, app: &mut App)

Drops the resolved alignment and marks layout dirty.

Source

fn alignment(self: RenderHandle<Self>, app: &App) -> AlignmentGeometry

How to align the non-positioned or partially-positioned children in the stack.

The non-positioned children are placed relative to each other such that the points determined by the alignment are co-located. For example, if the alignment is AlignmentGeometry::TOP_LEFT, then the top left corner of each non-positioned child will be located at the same global coordinate.

Partially-positioned children, those that do not specify an alignment in a particular axis (e.g. that have neither top nor bottom set), use the alignment to determine how they should be positioned in that under-specified axis.

If this is set to a directional alignment, then text_direction must not be None.

Source

fn set_alignment( self: RenderHandle<Self>, app: &mut App, value: AlignmentGeometry, )

Sets alignment.

Source

fn text_direction(self: RenderHandle<Self>, app: &App) -> Option<TextDirection>

The text direction with which to resolve alignment.

This may be changed to None, but only after the alignment has been changed to a value that does not depend on the direction.

Source

fn set_text_direction( self: RenderHandle<Self>, app: &mut App, value: Option<TextDirection>, )

Source

fn fit(self: RenderHandle<Self>, app: &App) -> StackFit

How to size the non-positioned children in the stack.

The constraints passed into the stack from its parent are either loosened (StackFit::Loose) or tightened to their biggest size (StackFit::Expand).

Source

fn set_fit(self: RenderHandle<Self>, app: &mut App, value: StackFit)

Sets fit.

Source

fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip

How to clip the children that overflow the stack.

Stacks only clip children whose geometry overflows the stack. A child that paints outside its bounds (e.g. a box with a shadow) will not be clipped, regardless of the value of this property. Similarly, a child that itself has a descendant that overflows the stack will not be clipped, as only the geometry of the stack’s direct children are considered.

Defaults to Clip::HardEdge.

Source

fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip)

Source

fn compute_min_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64

The stack’s minimum intrinsic width: the widest non-positioned child’s.

Source

fn compute_max_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64

The stack’s maximum intrinsic width: the widest non-positioned child’s.

Source

fn compute_min_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64

The stack’s minimum intrinsic height: the tallest non-positioned child’s.

Source

fn compute_max_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64

The stack’s maximum intrinsic height: the tallest non-positioned child’s.

Source

fn compute_distance_to_actual_baseline( self: RenderHandle<Self>, app: &mut App, baseline: TextBaseline, ) -> Option<f64>

The stack’s baseline: the highest of its children’s.

Source

fn compute_dry_baseline( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, baseline: TextBaseline, ) -> Option<f64>

The baseline the stack would have, measuring its children dry.

Source

fn compute_dry_layout( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, ) -> Size

The size the stack would take, measuring its non-positioned children dry.

Source

fn compute_size( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, layout_child: impl FnMut(&mut App, AnyRenderBox, BoxConstraints) -> Size, ) -> Size

Flutter’s _computeSize: measures the non-positioned children with layout_child and sizes the stack.

Source

fn perform_layout(self: RenderHandle<Self>, app: &mut App)

The body of Flutter’s performLayout override.

Source

fn paint_stack( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )

Override in subclasses to customize how the stack paints.

By default, the stack uses default_paint. This function is called by paint after potentially applying a clip to contain visual overflow.

Source

fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )

The body of Flutter’s paint override.

Source

fn dispose(self: RenderHandle<Self>, app: &mut App)

Flutter’s dispose: drop the clip layer handle, then super.dispose().

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§