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

source

pub fn new<F>(content: F) -> Application
where F: 'static + FnOnce(&mut Context),

source

pub fn ignore_default_theme(self) -> Application

Sets the default built-in theming to be ignored.

source

pub fn should_poll(self) -> Application

source

pub fn on_idle<F>(self, callback: F) -> Application
where F: 'static + Fn(&mut Context),

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();
source

pub fn get_proxy(&self) -> ContextProxy

Returns a ContextProxy which can be used to send events from another thread.

source

pub fn run(self) -> Result<(), ApplicationError>

Trait Implementations§

source§

impl ApplicationHandler<UserEvent> for Application

source§

fn user_event(&mut self, _event_loop: &ActiveEventLoop, user_event: UserEvent)

Emitted when an event is sent from EventLoopProxy::send_event.
source§

fn resumed(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has been resumed. Read more
source§

fn window_event( &mut self, _event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent, )

Emitted when the OS sends an event to a winit window.
source§

fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)

Emitted when the event loop is about to block and wait for new events. Read more
source§

fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause)

Emitted when new events arrive from the OS to be processed. Read more
source§

fn exiting(&mut self, _event_loop: &ActiveEventLoop)

Emitted when the event loop is being shut down. Read more
§

fn device_event( &mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )

Emitted when the OS sends an event to a device.
§

fn suspended(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has been suspended. Read more
§

fn memory_warning(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has received a memory warning. Read more
source§

impl WindowModifiers for Application

source§

fn title<T>(self, title: impl Res<T>) -> Application
where T: ToString,

Sets the title of the window to the given value. Accepts a type, or lens to a type, which implements ToString. Read more
source§

fn inner_size<S>(self, size: impl Res<S>) -> Application
where S: Into<WindowSize>,

Sets the inner size of the window to the given value. Accepts a value, or lens, which can be converted to a [WindowSize]. Read more
source§

fn min_inner_size<S>(self, size: impl Res<Option<S>>) -> Application
where S: Into<WindowSize>,

Sets the minimum inner size of the window to the given value. Accepts an optional value, or lens, which can be converted to a [WindowSize]. Read more
source§

fn max_inner_size<S>(self, size: impl Res<Option<S>>) -> Application
where S: Into<WindowSize>,

Sets the maximum inner size of the window to the given value. Accepts an optional value, or lens, which can be converted to a [WindowSize]. Read more
source§

fn position<P>(self, position: impl Res<P>) -> Application
where P: Into<WindowPosition>,

Sets the position of the window to the given value. Accepts a value, or lens, which can be converted to a [Position]. Read more
source§

fn resizable(self, flag: impl Res<bool>) -> Application

Sets whether the window can be resized. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn minimized(self, flag: impl Res<bool>) -> Application

Sets whether the window is minimized. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn maximized(self, flag: impl Res<bool>) -> Application

Sets whether the window is maximized. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn visible(self, flag: bool) -> Application

Sets whether the window is visible. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn transparent(self, flag: bool) -> Application

Sets whether the window is transparent. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn decorations(self, flag: bool) -> Application

Sets whether the window has decorations. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn always_on_top(self, flag: bool) -> Application

Sets whether the window should be on top of other windows. Accepts a boolean value, or lens to a boolean value. Read more
source§

fn vsync(self, flag: bool) -> Application

Sets whether the window has vsync enabled. Read more
source§

fn icon(self, width: u32, height: u32, image: Vec<u8>) -> Application

Sets the icon used for the window. Read more
source§

fn on_close(self, _callback: impl Fn(&mut EventContext<'_>)) -> Application

source§

fn on_create(self, _callback: impl Fn(&mut EventContext<'_>)) -> Application

source§

fn enabled_window_buttons(self, window_buttons: WindowButtons) -> Application

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more