pub struct Flex { /* private fields */ }Expand description
A flexible layout container.
Implementations§
Source§impl Flex
impl Flex
Sourcepub fn horizontal() -> Flex
pub fn horizontal() -> Flex
Create a new horizontal flex layout.
Sourcepub fn constraints(
self,
constraints: impl IntoIterator<Item = Constraint>,
) -> Flex
pub fn constraints( self, constraints: impl IntoIterator<Item = Constraint>, ) -> Flex
Set the constraints.
Sourcepub fn flow_direction(self, flow: FlowDirection) -> Flex
pub fn flow_direction(self, flow: FlowDirection) -> Flex
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) -> Flex
pub fn overflow(self, overflow: OverflowBehavior) -> Flex
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) -> SmallVec<[Rect; 8]>
pub fn split(&self, area: Rect) -> SmallVec<[Rect; 8]>
Split the given area into smaller rectangles according to the configuration.
Sourcepub fn split_with_measurer<F>(
&self,
area: Rect,
measurer: F,
) -> SmallVec<[Rect; 8]>
pub fn split_with_measurer<F>( &self, area: Rect, measurer: F, ) -> SmallVec<[Rect; 8]>
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,
) -> SmallVec<[Rect; 8]>
pub fn split_with_measurer_stably<F>( &self, area: Rect, measurer: F, cache: &mut CoherenceCache, ) -> SmallVec<[Rect; 8]>
Split area using intrinsic sizing and temporal coherence.
Combines the content-aware sizing of split_with_measurer
with the stability of split_stably.
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 UnsafeUnpin for Flex
impl UnwindSafe for Flex
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().