zng/examples
Samuel Guerra 30c5209fc0 More refactor. 2023-04-13 01:22:27 -03:00
..
res Started testing bidirectional text. 2023-01-14 12:14:01 -03:00
util All tests pass. 2023-02-28 23:53:56 -03:00
Cargo.toml Add regex to examples for a test. 2023-04-02 00:47:37 -03:00
README.md More refactor. 2023-04-12 15:42:03 -03:00
animation.rs More refactor. 2023-04-12 23:00:37 -03:00
border.rs More refactor. 2023-04-13 01:22:27 -03:00
button.rs More refactor. 2023-04-12 23:00:37 -03:00
calculator.rs More refactor. 2023-04-12 18:02:22 -03:00
config.rs More refactor. 2023-04-12 21:21:34 -03:00
countdown.rs More refactor. 2023-04-12 18:02:22 -03:00
cursor.rs More refactor. 2023-04-12 23:00:37 -03:00
focus.rs More refactor. 2023-04-12 23:00:37 -03:00
gradient.rs More refactor. 2023-04-12 23:00:37 -03:00
headless.rs More refactor. 2023-04-12 18:02:22 -03:00
hit_test.rs More refactor. 2023-04-12 18:02:22 -03:00
icon.rs More refactor. 2023-04-12 23:00:37 -03:00
image.rs More refactor. 2023-04-13 01:22:27 -03:00
layer.rs More refactor. 2023-04-12 23:00:37 -03:00
markdown.rs More refactor. 2023-04-12 23:00:37 -03:00
respawn.rs More refactor. 2023-04-12 23:00:37 -03:00
scroll.rs More refactor. 2023-04-12 23:00:37 -03:00
shortcuts.rs More refactor. 2023-04-12 18:02:22 -03:00
text.rs More refactor. 2023-04-12 23:00:37 -03:00
transform.rs More refactor. 2023-04-12 18:34:35 -03:00
window.rs More refactor. 2023-04-12 23:00:37 -03:00

README.md

Examples

This directory contains small example apps.

Running

To run an example use cargo do run $name.

Adding an Example

To add an example, create a file then add it in ./Cargo.toml.

Template

This is a good example template:

In ./foo.rs:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use zero_ui::prelude::*;

use zero_ui_view_prebuilt as zero_ui_view;

fn main() {
    examples_util::print_info();
    // zero_ui_view::run_same_process(app_main);

    zero_ui_view::init();
    app_main();
}

fn app_main() {
    App::default().run_window(async {
        Window! {
            title = "Foo Example";
            child = Text!("Bar");
        }
    })
}

Then add in ./Cargo.toml:

[[example]]
name = "foo"
path = "foo.rs"

Then run from the project root using cargo do run foo.