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 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) -> Vec<Rect>
pub fn split(&self, area: Rect) -> Vec<Rect>
Split the given area into smaller rectangles according to the configuration.
Sourcepub fn split_with_measurer<F>(&self, area: Rect, measurer: F) -> Vec<Rect>
pub fn split_with_measurer<F>(&self, area: Rect, measurer: F) -> Vec<Rect>
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,
}
});Trait Implementations§
Auto Trait Implementations§
impl Freeze for Flex
impl RefUnwindSafe for Flex
impl Send for Flex
impl Sync for Flex
impl Unpin for Flex
impl UnwindSafe for Flex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more