Go to file
Samuel Guerra c7fdc20225 Fix CI. 2024-04-04 19:59:38 -03:00
.cargo Refactored do to be a cargo alias. 2021-11-09 20:18:21 -03:00
.github/workflows Fix CI. 2024-04-04 19:59:38 -03:00
.vscode Fixed doc links and spellcheck. 2024-03-26 21:57:36 -03:00
TODO Remove style TODO. 2024-04-04 14:13:01 -03:00
docs Convert some TODOs into issues. 2024-04-03 15:51:30 -03:00
examples Changed version of every crate to 0.2.0. 2024-03-30 17:30:08 -03:00
tests Remove "expected one update" from var integration tests. 2024-04-04 13:45:09 -03:00
tools Add CI concurrency, manual start. 2024-04-04 15:28:46 -03:00
zng Fix doc test generating files inside ./zng. 2024-04-03 12:25:16 -03:00
zng-app Fix warning. 2024-04-04 16:25:08 -03:00
zng-app-context Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-app-proc-macros Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-clone-move Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-color Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-color-proc-macros Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-clipboard Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-config Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-font Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-fs-watcher Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-image Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-input Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-l10n Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-l10n-proc-macros Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-undo Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-ext-window Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-handle Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-l10n-scraper Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-layout Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-state-map Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-task Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-task-proc-macros Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-time Change `INSTANT.epoch()` to now - 1 day. 2024-04-04 18:11:45 -03:00
zng-txt Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-unique-id Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-unit Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-var Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-var-proc-macros Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-view Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-view-api Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-view-prebuilt Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-access Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-ansi-text Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-button Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-checkerboard Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-container Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-data Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-data-view Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-fill Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-filter Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-grid Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-image Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-input Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-inspector Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-layer Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-markdown Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-material-icons Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-menu Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-panel Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-rule-line Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-scroll Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-size-offset Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-stack Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-style Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-text Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-text-input Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-toggle Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-tooltip Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-transform Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-undo Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-undo-history Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-webrender-debug Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-window Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
zng-wgt-wrap Update cargo authors metadata. 2024-04-02 23:45:03 -03:00
.gitattributes More EOF fixes. 2021-09-06 15:22:40 -03:00
.gitignore Changed instances of 'zero_ui' to 'zng'. 2024-03-26 21:12:13 -03:00
.gitmodules Changed webrender to be linked directly from git again. 2023-07-13 15:35:44 -03:00
CHANGELOG.md * Added LICENSE and CHANGELOG. 2021-07-29 18:46:39 -03:00
CODE_OF_CONDUCT.md Added dual license and code of conduct. 2024-03-30 19:04:53 -03:00
Cargo.toml Test audit CI. 2024-04-03 13:17:39 -03:00
LICENSE-APACHE Added dual license and code of conduct. 2024-03-30 19:04:53 -03:00
LICENSE-MIT Fix MIT license. 2024-04-03 16:42:47 -03:00
README.md Fix license badges. 2024-04-03 16:27:24 -03:00
do Refactored do to be a cargo alias. 2021-11-09 20:18:21 -03:00
do.bat Refactored do to be a cargo alias. 2021-11-09 20:18:21 -03:00
do.ps1 Refactored do to be a cargo alias. 2021-11-09 20:18:21 -03:00
rustfmt.toml Fmt. 2024-03-01 19:36:31 -03:00

README.md

License-APACHE License-MIT Crates.io docs.rs

zng

Zng is a cross-platform GUI framework, it provides ready made highly customizable widgets, responsive layout, live data binding, easy localization, automatic focus navigation and accessibility, async and multi-threaded tasks, robust multi-process architecture and more.

Zng is pronounced "zing", or as an initialism: ZNG (z+nesting+graphics).

Usage

First add this to your Cargo.toml:

[dependencies]
zng = { version = "0.2.0", features = ["view_prebuilt"] }

Then create your first window:

use zng::prelude::*;

fn main() {
    zng::view_process::prebuilt::init();
    APP.defaults().run_window(async {
        let size = var(layout::Size::new(800, 600));
        Window! {
            title = size.map(|s| formatx!("Button Example - {s}"));
            size;
            child_align = Align::CENTER;
            child = Button! {
                on_click = hn!(|_| {
                    println!("Button clicked!");
                });
                text::font_size = 28;
                child = Text!("Click Me!");
            }
        }
    })
}

See the API docs for more details.

Cargo Features

Zng provides the following features which can be enabled in your Cargo.toml file:

  • view — Include the default view-process implementation.
  • view_prebuilt — Include the default view-process implementation as an embedded precompiled binary.
  • inspector — Instrument each property and widget instance with inspector nodes and extend windows to be inspected on Ctrl+Shift+I.
  • trace_widget — Instrument every widget outer-most node to trace UI methods.
  • trace_wgt_item — Instrument every property and intrinsic node to trace UI methods.
  • deadlock_detection — Spawns a thread on app creation that checks and prints parking_lot deadlocks.
  • http — Enables HTTP tasks, images download.
  • test_util — Test utilities.
  • multi_app — Allows multiple app instances per-process, one app per thread at a time. The LocalContext tracks what app is currently running in each thread and app_local! statics switch to the value of each app depending on the current thread.
  • hyphenation_embed_all — Embed hyphenation dictionaries for all supported languages. If enabled some 2.8MB of data is embedded, you can provide an alternative dictionary source using the Hyphenation::dictionary_source method.
  • dyn_node — Use more dynamic dispatch at the node level by enabling UiNode::cfg_boxed to box.
  • dyn_app_extension — Use dynamic dispatch at the app-extension level.
  • dyn_closure — Box closures at opportune places, such as Var::map, reducing the number of monomorphised types.
  • toml — Enable TOML configs.
  • ron — Enable RON configs.
  • yaml — Enable YAML configs.
  • material_icons — Include all Material Icons icon sets, each icon set embeds some 300KB of data.
  • material_icons_outlined Include Material Icons Outlined icon set. If enabled some icons of this set are used for some of the commands.
  • material_icons_filled Include Material Icons Filled icon set.
  • material_icons_rounded Include Material Icons Rounded icon set.
  • material_icons_sharp Include Material Icons Sharp icon set.

These features are enabled by default:

  • debug_default — Enable the dyn_* and inspector features for debug builds only.
  • ipc — Enables pre-build views and connecting to views running in another process.
  • view_software — Enables software renderer fallback in the default view-process ("view").

Requirements

On Windows:

  • To build with "view" and "view_software" feature:
    • Env vars CC and CXX must be set to "clang-cl".
    • You can install clang using the Visual Studio installer or by installing LLVM directly.

On Windows 8 or older:

  • To build with "view_prebuilt" feature:
    • The curl command is required, it is available in Windows 10+, but must be installed in older Windows and must be added to the PATH env var.

on Linux:

  • Packages needed to build:

    • pkg-config
    • libfontconfig1-dev
  • Packages needed to build with "http" feature:

    • libssl-dev
  • Packages needed to build with "view_prebuilt" feature:

    • curl

cargo do

Do is a built-in task runner for managing this project, run cargo do help or ./do help for details.

The task runner is implemented as a Rust crate in tools/do-tasks and an alias in .cargo/config.toml. The builds the tool silently in the first run, after, it runs without noticeable delay.

Shell script to run do are also provided:

  • cmd.exe: do help.
  • PowerShell: ./do.ps1 help.
  • Bash: /.do help.

cargo do run <example>

The task runner can be used to run the examples in ./examples folder, for example: cargo do run calculator runs the ./examples/calculator.rs example.

cargo do install

The task runner depends on multiple cargo commands, you can run cargo do install to see a list of all required commands and run cargo do install --accept to run the installation commands.

VSCode & Rust Analyzer

Some workspace settings are included in the repository, in particular, rust-analyzer "checkOnSave" and runnables are redirected to the do tool.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.