Ui

Struct Ui 

Source
pub struct Ui<M: 'static + Component> { /* private fields */ }
Expand description

Entry point for the user interface.

Ui manages a root Component and processes it to a DrawList that can be rendered using your own renderer implementation. Alternatively, you can use one of the following included wrappers:

§Async support

Components can submit futures to the Context using wait() and stream(). These futures will update those components when they complete or yield messages. To support this, you must make sure that the poll method on Ui is called appropriately since the Ui can’t be submitted to a typical executor.

The Sandbox can serve as an example since it provides such a runtime for you through the winit event loop.

Implementations§

Source§

impl<C: 'static + Component> Ui<C>

Source

pub fn new<S, E>( root: C, viewport: Rectangle, hidpi_scale: f32, style: S, ) -> Result<Self>
where S: TryInto<Style, Error = E>, Error: From<E>,

Constructs a new Ui. Returns an error if the style fails to load.

Source

pub fn update_and_poll( &mut self, message: C::Message, waker: Waker, ) -> Vec<C::Output>

Updates the root component with a message.

If the ui has any pending futures internally, they are polled using the waker. Returns output messages from the root component if the update or the poll yielded any.

It’s up to the user to make sure that the waker will schedule a call to poll() on this Ui.

Source

pub fn handle_event_and_poll( &mut self, event: Event, waker: Waker, ) -> Vec<C::Output>

Handles a ui Event.

If the ui has any pending futures internally, they are polled using the waker. Returns output messages from the root component if the event or the poll yielded any.

It’s up to the user to make sure that the waker will schedule a call to poll() on this Ui.

Source

pub fn poll(&mut self, waker: Waker) -> Vec<C::Output>

If the ui has any pending futures internally, this method will poll them using the waker. Returns output messages from the root component if the poll yielded any.

It’s up to the user to make sure that the waker will schedule another call to poll().

Source

pub fn resize(&mut self, viewport: Rectangle)

Resizes the viewport. This forces the view to be rerendered.

Source

pub fn needs_redraw(&self) -> bool

Returns true if the ui needs to be redrawn. If the ui doesn’t need to be redrawn the Commands from the last draw may be used again.

Source

pub fn draw(&mut self) -> DrawList

Generate a DrawList for the view.

Trait Implementations§

Source§

impl<C: Component> Deref for Ui<C>

Source§

type Target = C

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<C: Component> DerefMut for Ui<C>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<M> !Freeze for Ui<M>

§

impl<M> !RefUnwindSafe for Ui<M>

§

impl<M> Send for Ui<M>

§

impl<M> !Sync for Ui<M>

§

impl<M> Unpin for Ui<M>

§

impl<M> !UnwindSafe for Ui<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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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

Source§

fn upcast(&self) -> Option<&T>