pub struct Row<F: Fn(&mut RowContent<'_, '_, '_>)> {
pub gap: f32,
pub expand: bool,
pub collapse: bool,
pub content: F,
}Expand description
A container that arranges child elements horizontally with flexible sizing.
Elements can be sized as self-sized, fixed width, or expanding to fill available space.
The expand option makes all children the same height by passing the maximum height
and break count as preferred_height and preferred_height_break_count, enabling
features like bottom alignment and background fills.
The preferred_height_break_count represents the number of page breaks, with
preferred_height being the height on the final page. For example, if
preferred_height_break_count = 2 and preferred_height = 15.0, it means
"break twice, then use 15mm on the final page".
§Flex System
Flex::SelfSized: Element uses its natural widthFlex::Fixed(width): Element uses the specified widthFlex::Expand(weight): Element gets a portion of remaining space based on weight
Remaining space is calculated as: total_width - sum(self_sized_widths) - sum(fixed_widths) Then distributed proportionally: element_width = remaining_space * (weight / total_weights)
§Performance Note
When expand: false, only self-sized elements are measured in the first pass.
When expand: true, all elements must be measured before drawing to determine
the maximum height, which requires an additional measurement pass.
Fields§
§gap: f32Horizontal spacing between elements in millimeters
expand: boolWhether to expand all children to the same height by passing preferred_height
collapse: boolWhether to collapse when all children have None height/width
content: FClosure that gets called for adding the content.
The closure is basically an internal iterator that produces elements by calling RowContent::add.
This closure will be called at least twice because the non-expanded elements need to be measured first. Depending on the surrounding context it could be called more than that (though in real world layouts this effect should be minimal as not all containers need a measure pass before drawing). Because of this it’s beneficial to keep expensive computations and allocations outside of this closure.
Implementations§
Trait Implementations§
Source§impl<F: Fn(&mut RowContent<'_, '_, '_>)> Element for Row<F>
impl<F: Fn(&mut RowContent<'_, '_, '_>)> Element for Row<F>
fn first_location_usage( &self, ctx: FirstLocationUsageCtx<'_>, ) -> FirstLocationUsage
fn measure(&self, ctx: MeasureCtx<'_>) -> ElementSize
fn draw(&self, ctx: DrawCtx<'_, '_>) -> ElementSize
fn with_padding_top(self, padding: f32) -> Padding<Self>where
Self: Sized,
fn with_vertical_padding(self, padding: f32) -> Padding<Self>where
Self: Sized,
fn debug(self, color: u8) -> Debug<Self>where
Self: Sized,
Auto Trait Implementations§
impl<F> Freeze for Row<F>where
F: Freeze,
impl<F> RefUnwindSafe for Row<F>where
F: RefUnwindSafe,
impl<F> Send for Row<F>where
F: Send,
impl<F> Sync for Row<F>where
F: Sync,
impl<F> Unpin for Row<F>where
F: Unpin,
impl<F> UnwindSafe for Row<F>where
F: UnwindSafe,
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
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<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.