Struct gui::Ui

source ·
pub struct Ui<E, M>
where E: 'static, M: 'static,
{ /* private fields */ }
Expand description

A Ui is a container for related widgets.

Implementations§

source§

impl<E, M> Ui<E, M>

source

pub fn new<D, W>(new_data: D, new_root_widget: W) -> (Self, Id)
where D: FnOnce() -> Box<dyn Any>, W: FnOnce(Id, &mut dyn MutCap<E, M>) -> Box<dyn Widget<E, M>>,

Create a new Ui instance containing one widget that acts as the root widget.

source

pub fn add_ui_widget<D, W>( &mut self, parent: Id, new_data: D, new_widget: W ) -> Id
where D: FnOnce() -> Box<dyn Any>, W: FnOnce(Id, &mut dyn MutCap<E, M>) -> Box<dyn Widget<E, M>>,

Add a widget to the Ui.

This method fulfills the exact same purpose as MutCap::add_widget, but it does not require boxing up the provided FnOnce.

source

pub fn render(&self, renderer: &dyn Renderer)

Render the Ui with the given Renderer.

source

pub async fn handle<T>(&mut self, event: T) -> Option<E>
where T: Into<E>,

Handle an event.

This function performs the initial determination of which widget is supposed to handle the given event and then passes it down to the actual event handler.

Trait Implementations§

source§

impl<E, M> Cap for Ui<E, M>

source§

fn data(&self, widget: Id) -> &dyn Any

Retrieve a reference to a widget’s data.

source§

fn children(&self, widget: Id) -> Iter<'_, Id>

Retrieve an iterator over the children. Iteration happens in z-order, from highest to lowest.

source§

fn root_id(&self) -> Id

Retrieve the Id of the root widget.

source§

fn parent_id(&self, widget: Id) -> Option<Id>

Retrieve the parent of the given widget.

source§

fn is_visible(&self, widget: Id) -> bool

Check whether a widget has its visibility flag set.

source§

fn is_displayed(&self, widget: Id) -> bool

Check whether a widget is actually being displayed.

source§

fn focused(&self) -> Option<Id>

Retrieve the currently focused widget.

source§

fn is_focused(&self, widget: Id) -> bool

Check whether the given widget is focused.

source§

impl<E, M> Debug for Ui<E, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<E, M> Deref for Ui<E, M>

§

type Target = dyn Cap

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<E, M> MutCap<E, M> for Ui<E, M>

source§

fn data_mut(&mut self, widget: Id) -> &mut dyn Any

Retrieve a mutable reference to a widget’s data.

source§

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.

source§

fn show(&mut self, widget: Id)

Show a widget, i.e., set its and its parents’ visibility flag.

source§

fn hide(&mut self, widget: Id)

Hide a widget, i.e., unset its visibility flag.

source§

fn focus(&mut self, widget: Id)

Focus a widget.

source§

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.

source§

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.

source§

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.

Auto Trait Implementations§

§

impl<E, M> !RefUnwindSafe for Ui<E, M>

§

impl<E, M> !Send for Ui<E, M>

§

impl<E, M> !Sync for Ui<E, M>

§

impl<E, M> Unpin for Ui<E, M>

§

impl<E, M> !UnwindSafe for Ui<E, M>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.