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
druid/examples/layout.rs (line 85)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app()).title("Very flexible");

    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0)
        .expect("launch failed");
}
More examples
druid/examples/either.rs (line 52)
50
51
52
53
54
55
56
pub fn main() {
    let main_window = WindowDesc::new(ui_builder()).title("Switcheroo");
    AppLauncher::with_window(main_window)
        .log_to_console()
        .launch(AppState::default())
        .expect("launch failed");
}
druid/examples/custom_widget.rs (line 158)
156
157
158
159
160
161
162
pub fn main() {
    let window = WindowDesc::new(CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch("Druid + Piet".to_string())
        .expect("launch failed");
}
druid/examples/blocking_function.rs (line 108)
105
106
107
108
109
110
111
112
fn main() {
    let main_window =
        WindowDesc::new(ui_builder()).title(LocalizedString::new("Blocking functions"));
    AppLauncher::with_window(main_window)
        .delegate(Delegate {})
        .launch(AppState::default())
        .expect("launch failed");
}
druid/examples/split_demo.rs (line 85)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app())
        .title(LocalizedString::new("split-demo-window-title").with_placeholder("Split Demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}
druid/examples/scroll.rs (line 30)
27
28
29
30
31
32
33
34
pub fn main() {
    let window = WindowDesc::new(build_widget())
        .title(LocalizedString::new("scroll-demo-window-title").with_placeholder("Scroll demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}

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
druid/examples/event_viewer.rs (lines 340-345)
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
druid/examples/blocking_function.rs (line 109)
105
106
107
108
109
110
111
112
fn main() {
    let main_window =
        WindowDesc::new(ui_builder()).title(LocalizedString::new("Blocking functions"));
    AppLauncher::with_window(main_window)
        .delegate(Delegate {})
        .launch(AppState::default())
        .expect("launch failed");
}
More examples
druid/examples/open_save.rs (line 33)
28
29
30
31
32
33
34
35
36
37
pub fn main() {
    let main_window = WindowDesc::new(ui_builder())
        .title(LocalizedString::new("open-save-demo").with_placeholder("Opening/Saving Demo"));
    let data = "Type here.".to_owned();
    AppLauncher::with_window(main_window)
        .delegate(Delegate)
        .log_to_console()
        .launch(data)
        .expect("launch failed");
}
druid/examples/multiwin.rs (lines 43-45)
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");
}
druid/examples/markdown_preview.rs (line 112)
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

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
druid/examples/layout.rs (line 86)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app()).title("Very flexible");

    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0)
        .expect("launch failed");
}
More examples
druid/examples/either.rs (line 53)
50
51
52
53
54
55
56
pub fn main() {
    let main_window = WindowDesc::new(ui_builder()).title("Switcheroo");
    AppLauncher::with_window(main_window)
        .log_to_console()
        .launch(AppState::default())
        .expect("launch failed");
}
druid/examples/custom_widget.rs (line 159)
156
157
158
159
160
161
162
pub fn main() {
    let window = WindowDesc::new(CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch("Druid + Piet".to_string())
        .expect("launch failed");
}
druid/examples/split_demo.rs (line 86)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app())
        .title(LocalizedString::new("split-demo-window-title").with_placeholder("Split Demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}
druid/examples/scroll.rs (line 31)
27
28
29
30
31
32
33
34
pub fn main() {
    let window = WindowDesc::new(build_widget())
        .title(LocalizedString::new("scroll-demo-window-title").with_placeholder("Scroll demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}
druid/examples/identity.rs (line 52)
45
46
47
48
49
50
51
52
53
54
55
pub fn main() {
    let window = WindowDesc::new(make_ui()).title("identity example");
    let data = OurData {
        counter_one: 0,
        counter_two: 0,
    };
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(data)
        .expect("launch failed");
}

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
druid/examples/async_event.rs (line 44)
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
druid/examples/layout.rs (line 87)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app()).title("Very flexible");

    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0)
        .expect("launch failed");
}
More examples
druid/examples/either.rs (line 54)
50
51
52
53
54
55
56
pub fn main() {
    let main_window = WindowDesc::new(ui_builder()).title("Switcheroo");
    AppLauncher::with_window(main_window)
        .log_to_console()
        .launch(AppState::default())
        .expect("launch failed");
}
druid/examples/custom_widget.rs (line 160)
156
157
158
159
160
161
162
pub fn main() {
    let window = WindowDesc::new(CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch("Druid + Piet".to_string())
        .expect("launch failed");
}
druid/examples/blocking_function.rs (line 110)
105
106
107
108
109
110
111
112
fn main() {
    let main_window =
        WindowDesc::new(ui_builder()).title(LocalizedString::new("Blocking functions"));
    AppLauncher::with_window(main_window)
        .delegate(Delegate {})
        .launch(AppState::default())
        .expect("launch failed");
}
druid/examples/split_demo.rs (line 87)
82
83
84
85
86
87
88
89
pub fn main() {
    let window = WindowDesc::new(build_app())
        .title(LocalizedString::new("split-demo-window-title").with_placeholder("Split Demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}
druid/examples/scroll.rs (line 32)
27
28
29
30
31
32
33
34
pub fn main() {
    let window = WindowDesc::new(build_widget())
        .title(LocalizedString::new("scroll-demo-window-title").with_placeholder("Scroll demo"));
    AppLauncher::with_window(window)
        .log_to_console()
        .launch(0u32)
        .expect("launch failed");
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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