Struct druid::AppLauncher
source · pub struct AppLauncher<T> { /* private fields */ }
Expand description
Handles initial setup of an application, and starts the runloop.
Implementations§
source§impl<T: Data> AppLauncher<T>
impl<T: Data> AppLauncher<T>
sourcepub fn with_window(window: WindowDesc<T>) -> Self
pub fn with_window(window: WindowDesc<T>) -> Self
Create a new AppLauncher
with the provided window.
sourcepub fn configure_env(self, f: impl Fn(&mut Env, &T) + 'static) -> Self
pub fn configure_env(self, f: impl Fn(&mut Env, &T) + 'static) -> Self
Provide an optional closure that will be given mutable access to the environment and immutable access to the app state before launch.
This can be used to set or override theme values.
sourcepub fn delegate(self, delegate: impl AppDelegate<T> + 'static) -> Self
pub fn delegate(self, delegate: impl AppDelegate<T> + 'static) -> Self
Set the AppDelegate
.
sourcepub fn use_simple_logger(self) -> Self
👎Deprecated since 0.8.0: Use log_to_console instead
pub fn use_simple_logger(self) -> Self
Initialize a minimal logger with DEBUG max level for printing logs out to stderr.
This is meant for use during development only.
Panics
Panics if the logger fails to initialize.
sourcepub fn start_console_logging(self, enable: bool) -> Self
pub fn start_console_logging(self, enable: bool) -> Self
Initialize a minimal tracing subscriber with DEBUG max level for printing logs out to stderr.
This is meant for quick-and-dirty debugging. If you want more serious trace handling, it’s probably better to implement it yourself.
Panics
Panics if enable
is true
and the subscriber fails to initialize,
for example if a tracing
/tracing_wasm
global logger was already set.
Never panics when enable
is false
, or have any other side effect.
Passing in false is useful if you want to enable a global logger as feature but log to console otherwise.
sourcepub fn log_to_console(self) -> Self
pub fn log_to_console(self) -> Self
Calls start_console_logging
with true
.
sourcepub fn localization_resources(
self,
resources: Vec<String>,
base_dir: String
) -> Self
pub fn localization_resources(
self,
resources: Vec<String>,
base_dir: String
) -> Self
Use custom localization resource
resources
is a list of file names that contain strings. base_dir
is a path to a directory that includes per-locale subdirectories.
This directory should be of the structure base_dir/{locale}/{resource}
,
where ‘{locale}’ is a valid BCP47 language tag, and {resource} is a .ftl
included in resources
.
sourcepub fn get_external_handle(&self) -> ExtEventSink
pub fn get_external_handle(&self) -> ExtEventSink
Returns an ExtEventSink
that can be moved between threads,
and can be used to submit commands back to the application.
sourcepub fn launch(self, data: T) -> Result<(), PlatformError>
pub fn launch(self, data: T) -> Result<(), PlatformError>
Build the windows and start the runloop.
Returns an error if a window cannot be instantiated. This is usually a fatal error.