pub struct View<CID, CA, CS, CM>{ /* private fields */ }Expand description
The view is the struct that holds all your components. You’ll only have one view in your app but as many components as you want. Those components will be orchestrated by the view. This includes handling their layout, the focused one and forward event to them if needed.
Every component must implement two traits: Component and MockComponent.
Component; its sole responsibility is to alter its state based on the events it receives.
MockComponent; it is responsible for rendering the component and holding its state.
Implementations§
Source§impl<CID, CA, CS, CM> View<CID, CA, CS, CM>
impl<CID, CA, CS, CM> View<CID, CA, CS, CM>
Sourcepub fn cycle_focus(&mut self) -> Result<()>
pub fn cycle_focus(&mut self) -> Result<()>
Set the focus to a component
§Errors
ViewError::ComponentNotFoundif the component to be focused is not mounted
Sourcepub fn initial_focus(self, id: &EzCptId<CID>) -> Result<Self>
pub fn initial_focus(self, id: &EzCptId<CID>) -> Result<Self>
Set the focus to a component
§Errors
ViewError::ComponentNotFoundif the initial component is not mounted
Sourcepub fn initial_legend(self, matchers: &[Matcher]) -> Self
pub fn initial_legend(self, matchers: &[Matcher]) -> Self
Set an initial dynamic legend to be used by the view.
It can later be updated by sending the EzEvent::UpdateLegend message to the view.
§Errors
ViewError::ComponentNotFoundif the component is not mounted
Sourcepub fn blur(&mut self) -> Result<()>
pub fn blur(&mut self) -> Result<()>
Remove current focus and focus the last focused component
§Errors
ViewError::ComponentNotFoundif the component to be focused is not mounted
Sourcepub fn mount(self, id: CID, component: BoxedComponent<CID, CA, CS, CM>) -> Self
pub fn mount(self, id: CID, component: BoxedComponent<CID, CA, CS, CM>) -> Self
Mount a new component to the view
§Errors
ViewError::ComponentAlreadyMountedif the component is already mounted
Sourcepub fn umount(self, id: &CID) -> Result<Self>
pub fn umount(self, id: &CID) -> Result<Self>
Unmount a component from the view
§Errors
ViewError::ComponentNotFoundif the component is not mounted
Sourcepub fn layout(self, layout: CustomLayout<EzCptId<CID>>) -> View<CID, CA, CS, CM>
pub fn layout(self, layout: CustomLayout<EzCptId<CID>>) -> View<CID, CA, CS, CM>
Set the CustomLayout to be used by the view
Notes: This should be called after you call Self::initial_legend
Sourcepub fn query_cpt(
&self,
id: &EzCptId<CID>,
query: Attribute,
) -> Result<Option<AttrValue>>
pub fn query_cpt( &self, id: &EzCptId<CID>, query: Attribute, ) -> Result<Option<AttrValue>>
Query a component for an attribute
§Errors
ViewError::ComponentNotFoundif the component is not mounted
Sourcepub fn set_cpt_attr(
&mut self,
id: &EzCptId<CID>,
attr: Attribute,
value: AttrValue,
) -> Result<()>
pub fn set_cpt_attr( &mut self, id: &EzCptId<CID>, attr: Attribute, value: AttrValue, ) -> Result<()>
Set an attribute to a component
§Errors
ViewError::ComponentNotFoundif the component is not mounted
Trait Implementations§
Auto Trait Implementations§
impl<CID, CA, CS, CM> !RefUnwindSafe for View<CID, CA, CS, CM>
impl<CID, CA, CS, CM> !Send for View<CID, CA, CS, CM>
impl<CID, CA, CS, CM> !Sync for View<CID, CA, CS, CM>
impl<CID, CA, CS, CM> !UnwindSafe for View<CID, CA, CS, CM>
impl<CID, CA, CS, CM> Freeze for View<CID, CA, CS, CM>where
Option<CustomLayout<EzCptId<CID>>>: Freeze,
LinkedHashMap<EzCptId<CID>, Box<dyn Component<CID, CA, CS, CM>>>: Freeze,
FocusStack<CID>: Freeze,
impl<CID, CA, CS, CM> Unpin for View<CID, CA, CS, CM>where
Option<CustomLayout<EzCptId<CID>>>: Unpin,
LinkedHashMap<EzCptId<CID>, Box<dyn Component<CID, CA, CS, CM>>>: Unpin,
FocusStack<CID>: Unpin,
impl<CID, CA, CS, CM> UnsafeUnpin for View<CID, CA, CS, CM>where
Option<CustomLayout<EzCptId<CID>>>: UnsafeUnpin,
LinkedHashMap<EzCptId<CID>, Box<dyn Component<CID, CA, CS, CM>>>: UnsafeUnpin,
FocusStack<CID>: UnsafeUnpin,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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