Struct Application
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§
§impl Application
impl Application
pub fn new<F>(content: F) -> Application
pub 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
pub 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();
pub 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§
§impl ApplicationHandler<UserEvent> for Application
impl ApplicationHandler<UserEvent> for Application
§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
.§fn resumed(&mut self, event_loop: &ActiveEventLoop)
fn resumed(&mut self, event_loop: &ActiveEventLoop)
§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, )
§fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
§fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause)
fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause)
§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)
§impl WindowModifiers for Application
impl WindowModifiers for Application
§fn title<T>(self, title: impl Res<T>) -> Applicationwhere
T: ToString,
fn title<T>(self, title: impl Res<T>) -> Applicationwhere
T: ToString,
ToString
. Read more§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 more§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 more§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 more§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 morefn offset<P>(self, offset: impl Res<P>) -> Applicationwhere
P: Into<WindowPosition>,
fn anchor<P>(self, anchor: impl Res<P>) -> Application
fn anchor_target<P>(self, anchor_target: impl Res<P>) -> Applicationwhere
P: Into<AnchorTarget>,
fn parent_anchor<P>(self, parent_anchor: impl Res<P>) -> Application
§fn resizable(self, flag: impl Res<bool>) -> Application
fn resizable(self, flag: impl Res<bool>) -> Application
§fn minimized(self, flag: impl Res<bool>) -> Application
fn minimized(self, flag: impl Res<bool>) -> Application
§fn maximized(self, flag: impl Res<bool>) -> Application
fn maximized(self, flag: impl Res<bool>) -> Application
§fn visible(self, flag: impl Res<bool>) -> Application
fn visible(self, flag: impl Res<bool>) -> Application
§fn transparent(self, flag: bool) -> Application
fn transparent(self, flag: bool) -> Application
§fn decorations(self, flag: bool) -> Application
fn decorations(self, flag: bool) -> Application
§fn always_on_top(self, flag: bool) -> Application
fn always_on_top(self, flag: bool) -> Application
§fn vsync(self, flag: bool) -> Application
fn vsync(self, flag: bool) -> Application
§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.