pub struct LayoutForm<W>{ /* private fields */ }Expand description
Create a layout with a single column of label+widget.
There are a number of possible constraints that influence the exact layout: FormLabel and FormWidget.
-
This layout can page break the form, if there is not enough space on one page. This can be used with SinglePager and friends.
-
Or it can generate an endless layout that will be used with scrolling logic like Clipper.
-
There is currently no functionality to shrink-fit the layout to a given page size.
The widgets can be grouped together and a Block can be set to highlight this grouping. Groups can cascade. Groups will be correctly broken by the page break logic. There is no special handling for orphans and widows.
Other features:
- Spacing/Line spacing.
- Supports Flex.
- Manual page breaks.
Implementations§
Source§impl<W> LayoutForm<W>
impl<W> LayoutForm<W>
pub fn new() -> Self
Sourcepub fn line_spacing(self, spacing: u16) -> Self
pub fn line_spacing(self, spacing: u16) -> Self
Empty lines between widgets.
Sourcepub fn mirror_odd_border(self) -> Self
pub fn mirror_odd_border(self) -> Self
Mirror the border given to layout between even and odd pages. The layout starts with page 0 which is even.
Sourcepub fn min_widget(self, width: u16) -> Self
pub fn min_widget(self, width: u16) -> Self
Set a reference widget width
Sourcepub fn start(&mut self, block: Option<Block<'static>>) -> BlockTag
pub fn start(&mut self, block: Option<Block<'static>>) -> BlockTag
Start a group/block.
This will create a block that covers all widgets added
before calling end().
Groups/blocks can be stacked, but they cannot interleave. An inner group/block must be closed before an outer one.
Sourcepub fn end(&mut self, tag: BlockTag)
pub fn end(&mut self, tag: BlockTag)
Closes the group/block with the given tag.
Panic Groups must be closed in reverse start order, otherwise this function will panic. It will also panic if there is no open group for the given tag.
Sourcepub fn widget(&mut self, key: W, label: FormLabel, widget: FormWidget)
pub fn widget(&mut self, key: W, label: FormLabel, widget: FormWidget)
Add label + widget constraint. Key must be a unique identifier.
Sourcepub fn page_break(&mut self)
pub fn page_break(&mut self)
Add a manual page break after the last widget.
This will panic if the widget list is empty.
Sourcepub fn endless(self, width: u16, border: Padding) -> GenericLayout<W>
pub fn endless(self, width: u16, border: Padding) -> GenericLayout<W>
Calculate a layout without page-breaks using the given layout-width and padding.
Sourcepub fn paged(self, page: Size, border: Padding) -> GenericLayout<W>
pub fn paged(self, page: Size, border: Padding) -> GenericLayout<W>
Calculate the layout for the given page size and padding.
Trait Implementations§
Source§impl<W> Debug for LayoutForm<W>
impl<W> Debug for LayoutForm<W>
Auto Trait Implementations§
impl<W> Freeze for LayoutForm<W>
impl<W> RefUnwindSafe for LayoutForm<W>where
W: RefUnwindSafe,
impl<W> Send for LayoutForm<W>where
W: Send,
impl<W> Sync for LayoutForm<W>where
W: Sync,
impl<W> Unpin for LayoutForm<W>where
W: Unpin,
impl<W> UnwindSafe for LayoutForm<W>where
W: 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 more