Struct druid::AppLauncher [−][src]
pub struct AppLauncher<T> { /* fields omitted */ }
Expand description
Handles initial setup of an application, and starts the runloop.
Implementations
Create a new AppLauncher
with the provided window.
Examples found in repository
More examples
- druid/examples/identity.rs
- druid/examples/panels.rs
- druid/examples/anim.rs
- druid/examples/scroll_colors.rs
- druid/examples/view_switcher.rs
- druid/examples/lens.rs
- druid/examples/open_save.rs
- druid/examples/switches.rs
- druid/examples/transparency.rs
- druid/examples/invalidation.rs
- druid/examples/multiwin.rs
- druid/examples/timer.rs
- druid/examples/styled_text.rs
- druid/examples/disabled.rs
- druid/examples/list.rs
- druid/examples/calc.rs
- druid/examples/hello.rs
- druid/examples/textbox.rs
- druid/examples/image.rs
- druid/examples/markdown_preview.rs
- druid/examples/sub_window.rs
- druid/examples/tabs.rs
- druid/examples/cursor.rs
- druid/examples/event_viewer.rs
- druid/examples/game_of_life.rs
- druid/examples/flex.rs
- druid/examples/async_event.rs
- druid/examples/text.rs
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.
Examples found in repository
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
pub fn main() {
//describe the main window
let main_window = WindowDesc::new(build_root_widget())
.title("Event Viewer")
.window_size((760.0, 680.0));
//start the application
AppLauncher::with_window(main_window)
.log_to_console()
.configure_env(|env, _| {
env.set(theme::UI_FONT, FontDescriptor::default().with_size(12.0));
env.set(theme::TEXT_COLOR, TEXT_COLOR);
env.set(theme::WIDGET_PADDING_HORIZONTAL, 2.0);
env.set(theme::WIDGET_PADDING_VERTICAL, 2.0);
})
.launch(AppState {
text_input: String::new(),
events: Arc::new(Vec::new()),
})
.expect("Failed to launch application");
}
Set the AppDelegate
.
Examples found in repository
More examples
38 39 40 41 42 43 44 45 46 47 48 49
pub fn main() {
let main_window = WindowDesc::new(ui_builder()).menu(make_menu).title(
LocalizedString::new("multiwin-demo-window-title").with_placeholder("Many windows!"),
);
AppLauncher::with_window(main_window)
.delegate(Delegate {
windows: Vec::new(),
})
.log_to_console()
.launch(State::default())
.expect("launch failed");
}
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
pub fn main() {
// describe the main window
let main_window = WindowDesc::new(build_root_widget())
.title(WINDOW_TITLE)
.menu(make_menu)
.window_size((700.0, 600.0));
// create the initial app state
let initial_state = AppState {
raw: TEXT.to_owned(),
rendered: rebuild_rendered_text(TEXT),
};
// start the application
AppLauncher::with_window(main_window)
.log_to_console()
.delegate(Delegate)
.launch(initial_state)
.expect("Failed to launch application");
}
👎 Deprecated since 0.7.0: Use log_to_console instead
Use log_to_console instead
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.
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 the subscriber fails to initialize.
Examples found in repository
More examples
- druid/examples/panels.rs
- druid/examples/anim.rs
- druid/examples/scroll_colors.rs
- druid/examples/view_switcher.rs
- druid/examples/open_save.rs
- druid/examples/switches.rs
- druid/examples/transparency.rs
- druid/examples/invalidation.rs
- druid/examples/multiwin.rs
- druid/examples/timer.rs
- druid/examples/styled_text.rs
- druid/examples/disabled.rs
- druid/examples/list.rs
- druid/examples/calc.rs
- druid/examples/hello.rs
- druid/examples/textbox.rs
- druid/examples/image.rs
- druid/examples/markdown_preview.rs
- druid/examples/sub_window.rs
- druid/examples/tabs.rs
- druid/examples/cursor.rs
- druid/examples/event_viewer.rs
- druid/examples/game_of_life.rs
- druid/examples/flex.rs
- druid/examples/async_event.rs
- druid/examples/text.rs
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
.
Returns an ExtEventSink
that can be moved between threads,
and can be used to submit commands back to the application.
Examples found in repository
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
pub fn main() {
let window = WindowDesc::new(make_ui()).title("External Event Demo");
let launcher = AppLauncher::with_window(window);
// If we want to create commands from another thread `launcher.get_external_handle()`
// should be used. For sending commands from within widgets you can always call
// `ctx.submit_command`
let event_sink = launcher.get_external_handle();
// We create a new thread and generate colours in it.
// This happens on a second thread so that we can run the UI in the
// main thread. Generating some colours nicely follows the pattern for what
// should be done like this: generating something over time
// (like this or reacting to external events), or something that takes a
// long time and shouldn't block main UI updates.
thread::spawn(move || generate_colors(event_sink));
launcher
.log_to_console()
.launch(Color::BLACK)
.expect("launch failed");
}
Build the windows and start the runloop.
Returns an error if a window cannot be instantiated. This is usually a fatal error.
Examples found in repository
More examples
- druid/examples/identity.rs
- druid/examples/panels.rs
- druid/examples/anim.rs
- druid/examples/scroll_colors.rs
- druid/examples/view_switcher.rs
- druid/examples/lens.rs
- druid/examples/open_save.rs
- druid/examples/switches.rs
- druid/examples/transparency.rs
- druid/examples/invalidation.rs
- druid/examples/multiwin.rs
- druid/examples/timer.rs
- druid/examples/styled_text.rs
- druid/examples/disabled.rs
- druid/examples/list.rs
- druid/examples/calc.rs
- druid/examples/hello.rs
- druid/examples/textbox.rs
- druid/examples/image.rs
- druid/examples/markdown_preview.rs
- druid/examples/sub_window.rs
- druid/examples/tabs.rs
- druid/examples/cursor.rs
- druid/examples/event_viewer.rs
- druid/examples/game_of_life.rs
- druid/examples/flex.rs
- druid/examples/async_event.rs
- druid/examples/text.rs
Auto Trait Implementations
impl<T> !RefUnwindSafe for AppLauncher<T>
impl<T> !Send for AppLauncher<T>
impl<T> !Sync for AppLauncher<T>
impl<T> Unpin for AppLauncher<T> where
T: Unpin,
impl<T> !UnwindSafe for AppLauncher<T>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
pub fn round_from(x: T) -> T
Performs the conversion.
pub fn round_into(self) -> U
pub fn round_into(self) -> U
Performs the conversion.
type Output = T
type Output = T
Should always be Self
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more