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>
impl<ComponentId, Msg, UserEvent> View<ComponentId, Msg, UserEvent>
Sourcepub fn mount(
&mut self,
id: &ComponentId,
component: Box<dyn AppComponent<Msg, UserEvent>>,
) -> ViewResult<()>
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
Sourcepub fn umount(&mut self, id: &ComponentId) -> ViewResult<()>
pub fn umount(&mut self, id: &ComponentId) -> ViewResult<()>
Umount component from View
Sourcepub fn remount(
&mut self,
id: &ComponentId,
component: Box<dyn AppComponent<Msg, UserEvent>>,
) -> ViewResult<()>
pub fn remount( &mut self, id: &ComponentId, component: Box<dyn AppComponent<Msg, UserEvent>>, ) -> ViewResult<()>
Remount component. This method WON’T change the focus stack
Sourcepub fn umount_all(&mut self)
pub fn umount_all(&mut self)
Umount all components in the view and clear focus stack and state
Sourcepub fn mounted(&self, id: &ComponentId) -> bool
pub fn mounted(&self, id: &ComponentId) -> bool
Returns whether component id is mounted
Sourcepub fn get_component(
&self,
id: &ComponentId,
) -> Option<&dyn AppComponent<Msg, UserEvent>>
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.
Sourcepub fn get_component_mut(
&mut self,
id: &ComponentId,
) -> Option<&mut dyn AppComponent<Msg, UserEvent>>
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.
Sourcepub fn view(&mut self, id: &ComponentId, f: &mut Frame<'_>, area: Rect)
pub fn view(&mut self, id: &ComponentId, f: &mut Frame<'_>, area: Rect)
Render component called id
Sourcepub fn query<'a>(
&'a self,
id: &ComponentId,
query: Attribute,
) -> ViewResult<Option<QueryResult<'a>>>
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.
Sourcepub fn attr(
&mut self,
id: &ComponentId,
attr: Attribute,
value: AttrValue,
) -> ViewResult<()>
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
Sourcepub fn state(&self, id: &ComponentId) -> ViewResult<State>
pub fn state(&self, id: &ComponentId) -> ViewResult<State>
Get state for component id.
Returns Err if component doesn’t exist
Sourcepub fn active(&mut self, id: &ComponentId) -> ViewResult<()>
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.
Sourcepub fn blur(&mut self) -> ViewResult<()>
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.
Sourcepub fn add_injector(&mut self, injector: Box<dyn Injector<ComponentId>>)
pub fn add_injector(&mut self, injector: Box<dyn Injector<ComponentId>>)
Add an injector to the view
Trait Implementations§
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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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