Skip to main content

Align

Struct Align 

Source
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>

Source

pub fn new(inner: W) -> Self

Wrap a child widget with default alignment (top-left, full area).

Source

pub fn horizontal(self, alignment: Alignment) -> Self

Set horizontal alignment.

Source

pub fn vertical(self, alignment: VerticalAlignment) -> Self

Set vertical alignment.

Source

pub fn child_width(self, width: u16) -> Self

Set the child’s width. If None, the child uses the full parent width.

Source

pub fn child_height(self, height: u16) -> Self

Set the child’s height. If None, the child uses the full parent height.

Source

pub fn aligned_area(&self, area: Rect) -> Rect

Compute the aligned child rect within the parent area.

Source

pub const fn inner(&self) -> &W

Get a shared reference to the inner widget.

Source

pub fn inner_mut(&mut self) -> &mut W

Get a mutable reference to the inner widget.

Source

pub fn into_inner(self) -> W

Consume and return the inner widget.

Trait Implementations§

Source§

impl<W: Clone> Clone for Align<W>

Source§

fn clone(&self) -> Align<W>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W: Debug> Debug for Align<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: StatefulWidget> StatefulWidget for Align<W>

Source§

type State = <W as StatefulWidget>::State

The state type associated with this widget.
Source§

fn render(&self, area: Rect, frame: &mut Frame<'_>, state: &mut Self::State)

Render the widget into the frame, potentially modifying state. Read more
Source§

impl<W: Widget> Widget for Align<W>

Source§

fn render(&self, area: Rect, frame: &mut Frame<'_>)

Render the widget into the frame at the given area. Read more
Source§

fn is_essential(&self) -> bool

Whether this widget is essential and should always render. Read more

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> UnsafeUnpin for Align<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for Align<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more