pub trait MutCap<E, M>: Cap + Deref<Target = dyn Cap> {
// Required methods
fn data_mut(&mut self, widget: Id) -> &mut dyn Any;
fn add_widget(
&mut self,
parent: Id,
new_data: Box<dyn FnOnce() -> Box<dyn Any>>,
new_widget: Box<dyn FnOnce(Id, &mut dyn MutCap<E, M>) -> Box<dyn Widget<E, M>>>
) -> Id;
fn show(&mut self, widget: Id);
fn hide(&mut self, widget: Id);
fn focus(&mut self, widget: Id);
fn hook_events(
&mut self,
widget: Id,
hook_fn: Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>
) -> Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>
where E: Mergeable;
fn send<'life0, 'async_trait>(
&'life0 mut self,
widget: Id,
message: M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn call<'life0, 'life1, 'async_trait>(
&'life0 mut self,
widget: Id,
message: &'life1 mut M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
A mutable capability allowing for various widget related operations.
Required Methods§
sourcefn data_mut(&mut self, widget: Id) -> &mut dyn Any
fn data_mut(&mut self, widget: Id) -> &mut dyn Any
Retrieve a mutable reference to a widget’s data.
sourcefn add_widget(
&mut self,
parent: Id,
new_data: Box<dyn FnOnce() -> Box<dyn Any>>,
new_widget: Box<dyn FnOnce(Id, &mut dyn MutCap<E, M>) -> Box<dyn Widget<E, M>>>
) -> Id
fn add_widget( &mut self, parent: Id, new_data: Box<dyn FnOnce() -> Box<dyn Any>>, new_widget: Box<dyn FnOnce(Id, &mut dyn MutCap<E, M>) -> Box<dyn Widget<E, M>>> ) -> Id
Add a widget to the Ui
represented by the capability.
sourcefn show(&mut self, widget: Id)
fn show(&mut self, widget: Id)
Show a widget, i.e., set its and its parents’ visibility flag.
This method sets the referenced widget’s visibility flag as well as those of all its parents.
sourcefn hide(&mut self, widget: Id)
fn hide(&mut self, widget: Id)
Hide a widget, i.e., unset its visibility flag.
This method makes sure that widget referenced is no longer displayed. If the widget has children, all those children will also be hidden.
sourcefn focus(&mut self, widget: Id)
fn focus(&mut self, widget: Id)
Focus a widget.
The focused widget is the one receiving certain types of events (such as key events) first but may also be rendered in a different color or be otherwise highlighted. Note that being focused implies being visible. This invariant is enforced internally.
sourcefn hook_events(
&mut self,
widget: Id,
hook_fn: Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>
) -> Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>where
E: Mergeable,
fn hook_events(
&mut self,
widget: Id,
hook_fn: Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>
) -> Option<&'static dyn for<'f> Fn(&'f dyn Widget<E, M>, &'f mut dyn MutCap<E, M>, Option<&'f E>) -> Pin<Box<dyn Future<Output = Option<E>> + 'f>>>where
E: Mergeable,
Install or remove an event hook handler.
The event hook handler is a call back function that is invoked for
all events originating outside of the UI, i.e., those that come in
through the Ui::handle
method. For such events, the event hook
handler gets to inspect the event before any widget gets a chance
to handle it “officially” through the Handleable::handle
method
(pre-hook).
Furthermore, after widgets handled the event, the hook will be
invoked again, this time without an actual event (post-hook).
Event hook handlers are allowed to emit an event on their own,
just as “normal” event handlers. The events of all hooks get
merged into a single event. As such, they must be mergeable. Note
that the order in which multiple event hooks are invoked relative
to each other is unspecified, and that should be taken into
account when providing a Mergeable
implementation for the
provided event type.
Furthermore, the final merged event is not passed to widgets, but
returned straight back.
Note that event hook functions are only able to inspect events and not change or discard them.
A widget (identified by the given Id
) may only register one
handler and subsequent requests will overwrite the previously
installed one. The method returns the handler that was previously
installed, if any.
sourcefn send<'life0, 'async_trait>(
&'life0 mut self,
widget: Id,
message: M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 mut self,
widget: Id,
message: M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send the provided message to the given widget.
sourcefn call<'life0, 'life1, 'async_trait>(
&'life0 mut self,
widget: Id,
message: &'life1 mut M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call<'life0, 'life1, 'async_trait>(
&'life0 mut self,
widget: Id,
message: &'life1 mut M
) -> Pin<Box<dyn Future<Output = Option<M>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send the provided message to the given widget, without transferring ownership of the message.