Skip to main content

View

Struct View 

Source
pub struct View {
Show 14 fields pub direction: Direction, pub border: Option<BorderType>, pub border_style: Style, pub title: Option<String>, pub title_bottom: Option<String>, pub title_style: Style, pub title_bottom_style: Style, pub padding: Cells, pub padding_top: Option<Cells>, pub padding_bottom: Option<Cells>, pub padding_left: Option<Cells>, pub padding_right: Option<Cells>, pub width: WidthConstraint, pub style: Style,
}
Expand description

A unified layout container with optional borders, padding, and background.

See the module-level docs for examples.

Fields§

§direction: Direction

Layout direction. Defaults to Direction::Column (vertical).

§border: Option<BorderType>

Border type. None means no border (default).

§border_style: Style

Style applied to the border lines.

§title: Option<String>

Title rendered at the top of the View. Most useful with a border.

§title_bottom: Option<String>

Title rendered at the bottom of the View. Most useful with a border.

§title_style: Style

Style applied to the top title text.

§title_bottom_style: Style

Style applied to the bottom title text.

§padding: Cells

Base padding applied to all sides (default 0). Each side uses this value unless overridden by a side-specific field (padding_top, etc.).

Accepts bare integer literals in the element! macro: padding: 1.

§padding_top: Option<Cells>

Padding above content. Overrides padding for the top side.

§padding_bottom: Option<Cells>

Padding below content. Overrides padding for the bottom side.

§padding_left: Option<Cells>

Padding left of content. Overrides padding for the left side.

§padding_right: Option<Cells>

Padding right of content. Overrides padding for the right side.

§width: WidthConstraint

Width constraint for this View when inside a Direction::Row parent.

§style: Style

Background/foreground style applied to the entire View area.

Implementations§

Source§

impl View

Source

pub fn builder() -> ViewBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building View. On the builder, call .direction(...)(optional), .border(...)(optional), .border_style(...)(optional), .title(...)(optional), .title_bottom(...)(optional), .title_style(...)(optional), .title_bottom_style(...)(optional), .padding(...)(optional), .padding_top(...)(optional), .padding_bottom(...)(optional), .padding_left(...)(optional), .padding_right(...)(optional), .width(...)(optional), .style(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of View.

Trait Implementations§

Source§

impl ChildCollector for View

Source§

type Collector = Elements

The type used to accumulate children.
Source§

type Output = ComponentWithSlot<View>

The output type after finalizing children. Read more
Source§

fn finish(self, collector: Elements) -> ComponentWithSlot<View>

Finalize children collection, producing the output value.
Source§

impl Component for View

Source§

type State = ()

State type for this component. The framework wraps it in Tracked<S> for automatic dirty detection.
Source§

fn update( &self, hooks: &mut Hooks<Self, Self::State>, state: &Self::State, children: Elements, ) -> Elements
where Self: Sized,

Combined lifecycle and view in a single call. Read more
Source§

impl Default for View

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

Blanket Implementations§

Source§

impl<T, V> AddTo<DataChildren<T>> for V
where V: Into<T>,

Source§

type Handle<'a> = DataHandle where T: 'a

Handle returned after adding. Supports .key() / .width() chaining.
Source§

fn add_to(self, collector: &mut DataChildren<T>) -> DataHandle

Add this value to the collector, returning a handle for chaining .key() and .width().
Source§

impl<C> AddTo<Elements> for C
where C: Component,

Source§

type Handle<'a> = ElementHandle<'a>

Handle returned after adding. Supports .key() / .width() chaining.
Source§

fn add_to(self, els: &mut Elements) -> ElementHandle<'_>

Add this value to the collector, returning a handle for chaining .key() and .width().
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.