Struct vizia_winit::application::Application
source · pub struct Application { /* private fields */ }
Expand description
Creating a new application creates a root Window
and a Context
. Views declared within the closure passed to Application::new()
are added to the context and rendered into the root window.
§Example
Application::new(|cx|{
// Content goes here
})
.run();
Calling run()
on the Application
causes the program to enter the event loop and for the main window to display.
Implementations§
source§impl Application
impl Application
pub fn new<F>(content: F) -> Self
sourcepub fn ignore_default_theme(self) -> Self
pub fn ignore_default_theme(self) -> Self
Sets the default built-in theming to be ignored.
pub fn should_poll(self) -> Self
sourcepub fn on_idle<F: 'static + Fn(&mut Context)>(self, callback: F) -> Self
pub fn on_idle<F: 'static + Fn(&mut Context)>(self, callback: F) -> Self
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| {
// 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 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)
source§impl WindowModifiers for Application
impl WindowModifiers for Application
source§fn title<T: ToString>(self, title: impl Res<T>) -> Self
fn title<T: ToString>(self, title: impl Res<T>) -> Self
ToString
. Read moresource§fn inner_size<S: Into<WindowSize>>(self, size: impl Res<S>) -> Self
fn inner_size<S: Into<WindowSize>>(self, size: impl Res<S>) -> Self
WindowSize
]. Read moresource§fn min_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self
fn min_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self
WindowSize
]. Read moresource§fn max_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self
fn max_inner_size<S: Into<WindowSize>>(self, size: impl Res<Option<S>>) -> Self
WindowSize
]. Read moresource§fn position<P: Into<WindowPosition>>(self, position: impl Res<P>) -> Self
fn position<P: Into<WindowPosition>>(self, position: impl Res<P>) -> Self
Position
]. Read moresource§fn resizable(self, flag: impl Res<bool>) -> Self
fn resizable(self, flag: impl Res<bool>) -> Self
source§fn minimized(self, flag: impl Res<bool>) -> Self
fn minimized(self, flag: impl Res<bool>) -> Self
source§fn maximized(self, flag: impl Res<bool>) -> Self
fn maximized(self, flag: impl Res<bool>) -> Self
source§fn visible(self, flag: bool) -> Self
fn visible(self, flag: bool) -> Self
source§fn transparent(self, flag: bool) -> Self
fn transparent(self, flag: bool) -> Self
source§fn decorations(self, flag: bool) -> Self
fn decorations(self, flag: bool) -> Self
source§fn always_on_top(self, flag: bool) -> Self
fn always_on_top(self, flag: bool) -> Self
source§fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Self
fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Self
fn on_close(self, _callback: impl Fn(&mut EventContext<'_>)) -> Self
fn on_create(self, _callback: impl Fn(&mut EventContext<'_>)) -> Self
Auto Trait Implementations§
impl !Freeze for Application
impl !RefUnwindSafe for Application
impl !Send for Application
impl !Sync for Application
impl Unpin for Application
impl !UnwindSafe 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<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.