pub struct Align<W> { /* private fields */ }Expand description
A widget wrapper that aligns a child within the available area.
By default, uses the full width/height of the parent area. When explicit
child_width or child_height are set, the child is positioned according
to the chosen horizontal and vertical alignment.
§Example
ⓘ
use ftui_widgets::align::{Align, VerticalAlignment};
use ftui_widgets::block::Alignment;
let centered = Align::new(my_widget)
.horizontal(Alignment::Center)
.vertical(VerticalAlignment::Middle)
.child_width(20)
.child_height(5);Implementations§
Source§impl<W> Align<W>
impl<W> Align<W>
Sourcepub fn horizontal(self, alignment: Alignment) -> Self
pub fn horizontal(self, alignment: Alignment) -> Self
Set horizontal alignment.
Sourcepub fn vertical(self, alignment: VerticalAlignment) -> Self
pub fn vertical(self, alignment: VerticalAlignment) -> Self
Set vertical alignment.
Sourcepub fn child_width(self, width: u16) -> Self
pub fn child_width(self, width: u16) -> Self
Set the child’s width. If None, the child uses the full parent width.
Sourcepub fn child_height(self, height: u16) -> Self
pub fn child_height(self, height: u16) -> Self
Set the child’s height. If None, the child uses the full parent height.
Sourcepub fn aligned_area(&self, area: Rect) -> Rect
pub fn aligned_area(&self, area: Rect) -> Rect
Compute the aligned child rect within the parent area.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consume and return the inner widget.
Trait Implementations§
Source§impl<W: StatefulWidget> StatefulWidget for Align<W>
impl<W: StatefulWidget> StatefulWidget for Align<W>
Auto Trait Implementations§
impl<W> Freeze for Align<W>where
W: Freeze,
impl<W> RefUnwindSafe for Align<W>where
W: RefUnwindSafe,
impl<W> Send for Align<W>where
W: Send,
impl<W> Sync for Align<W>where
W: Sync,
impl<W> Unpin for Align<W>where
W: Unpin,
impl<W> UnwindSafe for Align<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
Mutably borrows from an owned value. Read more