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>
impl<C: 'static + Component> Ui<C>
Sourcepub fn new<S, E>(
root: C,
viewport: Rectangle,
hidpi_scale: f32,
style: S,
) -> Result<Self>
pub fn new<S, E>( root: C, viewport: Rectangle, hidpi_scale: f32, style: S, ) -> Result<Self>
Constructs a new Ui
. Returns an error if the style fails to load.
Sourcepub fn update_and_poll(
&mut self,
message: C::Message,
waker: Waker,
) -> Vec<C::Output>
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
.
Sourcepub fn poll(&mut self, waker: Waker) -> Vec<C::Output>
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()
.
Sourcepub fn resize(&mut self, viewport: Rectangle)
pub fn resize(&mut self, viewport: Rectangle)
Resizes the viewport. This forces the view to be rerendered.