pub struct Flex { /* private fields */ }Expand description
A flexible layout container.
Implementations§
Source§impl Flex
impl Flex
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Create a new horizontal flex layout.
Sourcepub fn constraints(
self,
constraints: impl IntoIterator<Item = Constraint>,
) -> Self
pub fn constraints( self, constraints: impl IntoIterator<Item = Constraint>, ) -> Self
Set the constraints.
Sourcepub fn flow_direction(self, flow: FlowDirection) -> Self
pub fn flow_direction(self, flow: FlowDirection) -> Self
Set the horizontal flow direction (LTR or RTL).
When set to FlowDirection::Rtl,
horizontal layouts are mirrored: the first child appears at the right
edge instead of the left. Vertical layouts are not affected.
Sourcepub fn overflow(self, overflow: OverflowBehavior) -> Self
pub fn overflow(self, overflow: OverflowBehavior) -> Self
Set the overflow behavior for this container.
Sourcepub fn overflow_behavior(&self) -> OverflowBehavior
pub fn overflow_behavior(&self) -> OverflowBehavior
Get the current overflow behavior.
Sourcepub fn constraint_count(&self) -> usize
pub fn constraint_count(&self) -> usize
Number of constraints (and thus output rects from split).
Sourcepub fn split(&self, area: Rect) -> Rects
pub fn split(&self, area: Rect) -> Rects
Split the given area into smaller rectangles according to the configuration.
Sourcepub fn split_with_measurer<F>(&self, area: Rect, measurer: F) -> Rects
pub fn split_with_measurer<F>(&self, area: Rect, measurer: F) -> Rects
Split area using intrinsic sizing from a measurer callback.
This method enables content-aware layout with Constraint::FitContent,
Constraint::FitContentBounded, and Constraint::FitMin.
§Arguments
area: Available rectanglemeasurer: Callback that returnsLayoutSizeHintfor item at index
§Example
let flex = Flex::horizontal()
.constraints([Constraint::FitContent, Constraint::Fill]);
let rects = flex.split_with_measurer(area, |idx, available| {
match idx {
0 => LayoutSizeHint { min: 5, preferred: 20, max: None },
_ => LayoutSizeHint::ZERO,
}
});Sourcepub fn split_with_measurer_stably<F>(
&self,
area: Rect,
measurer: F,
cache: &mut CoherenceCache,
) -> Rects
pub fn split_with_measurer_stably<F>( &self, area: Rect, measurer: F, cache: &mut CoherenceCache, ) -> Rects
Split area using intrinsic sizing and temporal coherence.
Combines the content-aware sizing of split_with_measurer
with the stability of split_stably.