Skip to main content

View

Struct View 

Source
pub struct View<CID, CA, CS, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,
{ /* 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>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source

pub fn new() -> Self

Create a new view with the given [AppArguments]

Source§

impl<CID, CA, CS, CM> View<CID, CA, CS, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source

pub fn set_theme(self, theme: Theme) -> Self

Set the thme to be used by the view

Source

pub fn focused(&mut self) -> Option<&EzCptId<CID>>

Get the current focus

Source

pub fn focus(&mut self, id: &EzCptId<CID>, forward: bool) -> Result<bool>

Try to focus a component

§Errors
Source

pub fn cycle_focus(&mut self) -> Result<()>

Set the focus to a component

§Errors
Source

pub fn initial_focus(self, id: &EzCptId<CID>) -> Result<Self>

Set the focus to a component

§Errors
Source

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
Source

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

Remove current focus and focus the last focused component

§Errors
Source

pub fn mount(self, id: CID, component: BoxedComponent<CID, CA, CS, CM>) -> Self

Mount a new component to the view

§Errors
Source

pub fn umount(self, id: &CID) -> Result<Self>

Unmount a component from the view

§Errors
Source

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

Check if the component is mounted

Source

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

Source

pub fn query_cpt( &self, id: &EzCptId<CID>, query: Attribute, ) -> Result<Option<AttrValue>>

Query a component for an attribute

§Errors
Source

pub fn set_cpt_attr( &mut self, id: &EzCptId<CID>, attr: Attribute, value: AttrValue, ) -> Result<()>

Set an attribute to a component

§Errors

Trait Implementations§

Source§

impl<CID, CA, CS, CM> Default for View<CID, CA, CS, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

fn default() -> Self

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

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more