Skip to main content

View

Struct View 

Source
pub struct View<ComponentId, Msg, UserEvent>
where ComponentId: Eq + PartialEq + Clone + Hash, Msg: PartialEq, UserEvent: Eq + PartialEq + Clone,
{ /* private fields */ }
Expand description

View is the wrapper and manager for all the components. A View is a container for all the components in a certain layout. Each View can have only one focused component at the time. At least one component must be always focused

Implementations§

Source§

impl<ComponentId, Msg, UserEvent> View<ComponentId, Msg, UserEvent>
where ComponentId: Eq + PartialEq + Clone + Hash, Msg: PartialEq + 'static, UserEvent: Eq + PartialEq + Clone + 'static,

Source

pub fn mount( &mut self, id: &ComponentId, component: Box<dyn AppComponent<Msg, UserEvent>>, ) -> ViewResult<()>

Mount component on View. Returns error if the component is already mounted

Source

pub fn umount(&mut self, id: &ComponentId) -> ViewResult<()>

Umount component from View

Source

pub fn remount( &mut self, id: &ComponentId, component: Box<dyn AppComponent<Msg, UserEvent>>, ) -> ViewResult<()>

Remount component. This method WON’T change the focus stack

Source

pub fn umount_all(&mut self)

Umount all components in the view and clear focus stack and state

Source

pub fn mounted(&self, id: &ComponentId) -> bool

Returns whether component id is mounted

Source

pub fn get_component( &self, id: &ComponentId, ) -> Option<&dyn AppComponent<Msg, UserEvent>>

Get a reference to the registered component for the given id, if there is one.

Source

pub fn get_component_mut( &mut self, id: &ComponentId, ) -> Option<&mut dyn AppComponent<Msg, UserEvent>>

Get a mutable reference to the registered component for the given id, if there is one.

Source

pub fn view(&mut self, id: &ComponentId, f: &mut Frame<'_>, area: Rect)

Render component called id

Source

pub fn query<'a>( &'a self, id: &ComponentId, query: Attribute, ) -> ViewResult<Option<QueryResult<'a>>>

Query view component for a certain AttrValue Returns error if the component doesn’t exist Returns None if the attribute doesn’t exist.

Source

pub fn attr( &mut self, id: &ComponentId, attr: Attribute, value: AttrValue, ) -> ViewResult<()>

Set attribute for component id Returns error if the component doesn’t exist

Source

pub fn state(&self, id: &ComponentId) -> ViewResult<State>

Get state for component id. Returns Err if component doesn’t exist

Source

pub fn active(&mut self, id: &ComponentId) -> ViewResult<()>

Shorthand for attr(id, Attribute::Focus(AttrValue::Flag(true))). It also sets the component as the current one having focus. Previous active component, if any, GETS PUSHED to the STACK Returns error: if component doesn’t exist. Use mounted() to check if component exists

NOTE: users should always use this function to give focus to components.

Source

pub fn blur(&mut self) -> ViewResult<()>

Blur selected element AND DON’T PUSH CURRENT ACTIVE ELEMENT INTO THE STACK Shorthand for attr(id, Attribute::Focus(AttrValue::Flag(false))). It also unset the current focus and give it to the first element in stack. Returns error: if no component has focus

NOTE: users should always use this function to remove focus to components.

Source

pub fn add_injector(&mut self, injector: Box<dyn Injector<ComponentId>>)

Add an injector to the view

Trait Implementations§

Source§

impl<ComponentId, Msg, UserEvent> Default for View<ComponentId, Msg, UserEvent>
where ComponentId: Eq + PartialEq + Clone + Hash, Msg: PartialEq, UserEvent: Eq + PartialEq + Clone,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<ComponentId, Msg, UserEvent> Freeze for View<ComponentId, Msg, UserEvent>
where ComponentId: Freeze,

§

impl<ComponentId, Msg, UserEvent> !RefUnwindSafe for View<ComponentId, Msg, UserEvent>

§

impl<ComponentId, Msg, UserEvent> !Send for View<ComponentId, Msg, UserEvent>

§

impl<ComponentId, Msg, UserEvent> !Sync for View<ComponentId, Msg, UserEvent>

§

impl<ComponentId, Msg, UserEvent> Unpin for View<ComponentId, Msg, UserEvent>
where ComponentId: Unpin,

§

impl<ComponentId, Msg, UserEvent> UnsafeUnpin for View<ComponentId, Msg, UserEvent>
where ComponentId: UnsafeUnpin,

§

impl<ComponentId, Msg, UserEvent> !UnwindSafe for View<ComponentId, Msg, UserEvent>

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

Source§

type Output = T

Should always be Self
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.