Struct vizia::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) -> 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| {
// 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>(self, title: impl Res<T>) -> Applicationwhere
T: ToString,
fn title<T>(self, title: impl Res<T>) -> Applicationwhere
T: ToString,
ToString
. Read moresource§fn inner_size<S>(self, size: impl Res<S>) -> Applicationwhere
S: Into<WindowSize>,
fn inner_size<S>(self, size: impl Res<S>) -> Applicationwhere
S: Into<WindowSize>,
WindowSize
]. Read moresource§fn min_inner_size<S>(self, size: impl Res<Option<S>>) -> Applicationwhere
S: Into<WindowSize>,
fn min_inner_size<S>(self, size: impl Res<Option<S>>) -> Applicationwhere
S: Into<WindowSize>,
WindowSize
]. Read moresource§fn max_inner_size<S>(self, size: impl Res<Option<S>>) -> Applicationwhere
S: Into<WindowSize>,
fn max_inner_size<S>(self, size: impl Res<Option<S>>) -> Applicationwhere
S: Into<WindowSize>,
WindowSize
]. Read moresource§fn position<P>(self, position: impl Res<P>) -> Applicationwhere
P: Into<WindowPosition>,
fn position<P>(self, position: impl Res<P>) -> Applicationwhere
P: Into<WindowPosition>,
Position
]. Read moresource§fn resizable(self, flag: impl Res<bool>) -> Application
fn resizable(self, flag: impl Res<bool>) -> Application
source§fn minimized(self, flag: impl Res<bool>) -> Application
fn minimized(self, flag: impl Res<bool>) -> Application
source§fn maximized(self, flag: impl Res<bool>) -> Application
fn maximized(self, flag: impl Res<bool>) -> Application
source§fn visible(self, flag: bool) -> Application
fn visible(self, flag: bool) -> Application
source§fn transparent(self, flag: bool) -> Application
fn transparent(self, flag: bool) -> Application
source§fn decorations(self, flag: bool) -> Application
fn decorations(self, flag: bool) -> Application
source§fn always_on_top(self, flag: bool) -> Application
fn always_on_top(self, flag: bool) -> Application
source§fn vsync(self, flag: bool) -> Application
fn vsync(self, flag: bool) -> Application
source§fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Application
fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Application
fn on_close(self, _callback: impl Fn(&mut EventContext<'_>)) -> Application
fn on_create(self, _callback: impl Fn(&mut EventContext<'_>)) -> Application
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.