Trait iced_winit::application::Application
source · [−]pub trait Application: Program {
type Flags;
fn new(flags: Self::Flags) -> (Self, Command<Self::Message>);
fn title(&self) -> String;
fn subscription(&self) -> Subscription<Self::Message> { ... }
fn mode(&self) -> Mode { ... }
fn background_color(&self) -> Color { ... }
fn scale_factor(&self) -> f64 { ... }
fn should_exit(&self) -> bool { ... }
}
Expand description
An interactive, native cross-platform application.
This trait is the main entrypoint of Iced. Once implemented, you can run
your GUI application by simply calling run
. It will run in
its own window.
An Application
can execute asynchronous actions by returning a
Command
in some of its methods.
When using an Application
with the debug
feature enabled, a debug view
can be toggled by pressing F12
.
Required Associated Types
The data needed to initialize your Application
.
Required Methods
Initializes the Application
with the flags provided to
run
as part of the Settings
.
Here is where you should return the initial state of your app.
Additionally, you can return a Command
if you need to perform some
async action in the background on startup. This is useful if you want to
load state from a file, perform an initial HTTP request, etc.
Returns the current title of the Application
.
This title can be dynamic! The runtime will automatically update the title of your application when necessary.
Provided Methods
fn subscription(&self) -> Subscription<Self::Message>
fn subscription(&self) -> Subscription<Self::Message>
Returns the event Subscription
for the current state of the
application.
The messages produced by the Subscription
will be handled by
update
.
A Subscription
will be kept alive as long as you keep returning it!
By default, it returns an empty subscription.
Returns the current Application
mode.
The runtime will automatically transition your application if a new mode is returned.
By default, an application will run in windowed mode.
fn background_color(&self) -> Color
fn background_color(&self) -> Color
Returns the background [Color
] of the Application
.
By default, it returns [Color::WHITE
].
fn scale_factor(&self) -> f64
fn scale_factor(&self) -> f64
Returns the scale factor of the Application
.
It can be used to dynamically control the size of the UI at runtime (i.e. zooming).
For instance, a scale factor of 2.0
will make widgets twice as big,
while a scale factor of 0.5
will shrink them to half their size.
By default, it returns 1.0
.
fn should_exit(&self) -> bool
fn should_exit(&self) -> bool
Returns whether the Application
should be terminated.
By default, it returns false
.