pub struct Column<C: Fn(ColumnContent<'_, '_, '_>) -> Option<()>> {
pub content: C,
pub gap: f32,
pub collapse: bool,
}Expand description
A container that arranges child elements vertically with optional gaps.
Elements are laid out from top to bottom with configurable spacing between them. Supports page breaking and collapsing behavior for empty elements.
§Gap Behavior
Gaps are only applied between elements that have actual height. Elements with
None height (collapsed elements) don’t get gaps before or after them.
§Collapse Behavior
When collapse: true (default):
- If all children have
Noneheight, the column returnsNoneheight - If all children have
Nonewidth, the column returnsNonewidth - The gaps around a child with a
Noneheight are collapsed into one.
When collapse: false:
- Empty columns return
Some(0.0)for height/width instead ofNone - Useful when you need a column to always occupy space even when empty
- A child with a
Noneheight will still have a gap on either side
§Page Breaking
In breakable contexts, when a child element causes a page break, the column’s accumulated height is reset and continues on the new page.
Fields§
§content: CClosure that gets called for adding the content.
The closure is basically an internal iterator that produces elements by calling
ColumnContent::add. For short circuiting with the ? operator ColumnContent::add and
this closure return an Option.
If the column is in a context that measures it before drawing (such as BreakWhole), this
function will be called twice. In more complicated nested layouts 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 allocation outside of this closure.
gap: f32Vertical spacing between elements in millimeters
collapse: boolWhether to collapse to None size when all children are collapsed. When false, empty columns return Some(0.0) instead of None.
Implementations§
Trait Implementations§
Source§impl<C: Fn(ColumnContent<'_, '_, '_>) -> Option<()>> Element for Column<C>
impl<C: Fn(ColumnContent<'_, '_, '_>) -> Option<()>> Element for Column<C>
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<C> Freeze for Column<C>where
C: Freeze,
impl<C> RefUnwindSafe for Column<C>where
C: RefUnwindSafe,
impl<C> Send for Column<C>where
C: Send,
impl<C> Sync for Column<C>where
C: Sync,
impl<C> Unpin for Column<C>where
C: Unpin,
impl<C> UnwindSafe for Column<C>where
C: 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.