pub struct Application { /* private fields */ }Expand description
Creating an application creates a Context. Create windows explicitly with Window::new.
§Example
Application::new(|cx| {
Window::new(cx, |cx| {
Label::new(cx, "Hello, Vizia!");
});
})
.run();Calling run() on the Application enters the event loop.
Implementations§
Source§impl Application
impl Application
pub fn new<F>(content: F) -> Application
Sourcepub fn ignore_default_theme(self) -> Application
pub fn ignore_default_theme(self) -> Application
Sets the default built-in theming to be ignored.
pub fn should_poll(self) -> Application
Sourcepub fn on_idle<F>(self, callback: F) -> Application
pub fn on_idle<F>(self, callback: F) -> Application
Takes a closure which will be called at the end of every loop of the application.
The callback provides a place to run ‘idle’ processing and happens at the end of each loop but before drawing. If the callback pushes events into the queue in state then the event loop will re-run. Care must be taken not to push events into the queue every time the callback runs unless this is intended.
§Example
Application::new(|cx| {
Window::new(cx, |cx| {
// Build application here
});
})
.on_idle(|cx| {
// Code here runs at the end of every event loop after OS and vizia events have been handled
})
.run();Sourcepub fn exit_when_no_windows(self, exit: bool) -> Application
pub fn exit_when_no_windows(self, exit: bool) -> Application
Controls whether the application exits automatically when all windows are closed.
Defaults to true. The exit only triggers once at least one window has been opened and
then all windows are closed, so applications that start without windows are not affected
until their first window is created and subsequently closed.
Set to false to keep the event loop running as a daemon even after all windows close.
Sourcepub fn get_proxy(&self) -> ContextProxy
pub fn get_proxy(&self) -> ContextProxy
Returns a ContextProxy which can be used to send events from another thread.
pub fn run(self) -> Result<(), ApplicationError>
Trait Implementations§
Source§impl ApplicationHandler<UserEvent> for Application
impl ApplicationHandler<UserEvent> for Application
Source§fn user_event(&mut self, _event_loop: &ActiveEventLoop, user_event: UserEvent)
fn user_event(&mut self, _event_loop: &ActiveEventLoop, user_event: UserEvent)
EventLoopProxy::send_event.Source§fn resumed(&mut self, event_loop: &ActiveEventLoop)
fn resumed(&mut self, event_loop: &ActiveEventLoop)
Source§fn window_event(
&mut self,
_event_loop: &ActiveEventLoop,
window_id: WindowId,
event: WindowEvent,
)
fn window_event( &mut self, _event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent, )
Source§fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
Source§fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause)
fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause)
Source§fn exiting(&mut self, _event_loop: &ActiveEventLoop)
fn exiting(&mut self, _event_loop: &ActiveEventLoop)
§fn device_event(
&mut self,
event_loop: &ActiveEventLoop,
device_id: DeviceId,
event: DeviceEvent,
)
fn device_event( &mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )
§fn suspended(&mut self, event_loop: &ActiveEventLoop)
fn suspended(&mut self, event_loop: &ActiveEventLoop)
§fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
Auto Trait Implementations§
impl !Freeze for Application
impl !RefUnwindSafe for Application
impl !Send for Application
impl !Sync for Application
impl !UnwindSafe for Application
impl Unpin for Application
impl UnsafeUnpin for Application
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.