Skip to main content

Layer

Struct Layer 

Source
pub struct Layer {
    pub components: Vec<Box<dyn Component>>,
    pub layout: Option<Layout>,
    pub shadow: Shadow,
    pub visible: bool,
    pub kind: LayerKind,
}
Expand description

A full-terminal-size surface that holds its own components and layout.

Layers stack from index 0 (bottom/floor) to N (top/front). The TUI renders each layer independently and then composites them front-to-back, stripping cells that are hidden by higher layers.

Fields§

§components: Vec<Box<dyn Component>>

Components owned by this layer.

§layout: Option<Layout>

Optional layout for splitting the layer among its components.

§shadow: Shadow

Visual effect applied to lower layers behind this layer.

§visible: bool

Whether this layer participates in rendering.

§kind: LayerKind

TUI classification of this layer.

Implementations§

Source§

impl Layer

Source

pub fn new() -> Self

Create a new empty layer.

Source

pub fn with_component(component: Box<dyn Component>) -> Self

Create a layer that already contains a single component.

Source

pub fn set_layout(&mut self, layout: Layout)

Assign a layout to this layer.

Source

pub fn mount(&mut self, component: Box<dyn Component>)

Append a component to this layer.

Source

pub fn with_kind(self, kind: LayerKind) -> Self

Set the layer kind.

Source

pub fn render( &self, width: u16, height: u16, focused_index: Option<usize>, ) -> Rendered

Render this layer to a full-terminal-size buffer.

The returned Rendered has exactly height lines. focused_index identifies which of this layer’s components currently has focus so that its cursor can be translated into screen coordinates.

Trait Implementations§

Source§

impl Default for Layer

Source§

fn default() -> Layer

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Layer

§

impl !Send for Layer

§

impl !Sync for Layer

§

impl !UnwindSafe for Layer

§

impl Freeze for Layer

§

impl Unpin for Layer

§

impl UnsafeUnpin for Layer

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.