2d071a1f96
Some services (like focus), use `DInstant::EPOCH` to initialize timestamps and then compare it to `INSTANT.now`. This caused a sporadic bug where highlight was enabled for the first focus event in a test run. |
||
---|---|---|
.cargo | ||
.github/workflows | ||
.vscode | ||
TODO | ||
docs | ||
examples | ||
tests | ||
tools | ||
zng | ||
zng-app | ||
zng-app-context | ||
zng-app-proc-macros | ||
zng-clone-move | ||
zng-color | ||
zng-color-proc-macros | ||
zng-ext-clipboard | ||
zng-ext-config | ||
zng-ext-font | ||
zng-ext-fs-watcher | ||
zng-ext-image | ||
zng-ext-input | ||
zng-ext-l10n | ||
zng-ext-l10n-proc-macros | ||
zng-ext-undo | ||
zng-ext-window | ||
zng-handle | ||
zng-l10n-scraper | ||
zng-layout | ||
zng-state-map | ||
zng-task | ||
zng-task-proc-macros | ||
zng-time | ||
zng-txt | ||
zng-unique-id | ||
zng-unit | ||
zng-var | ||
zng-var-proc-macros | ||
zng-view | ||
zng-view-api | ||
zng-view-prebuilt | ||
zng-wgt | ||
zng-wgt-access | ||
zng-wgt-ansi-text | ||
zng-wgt-button | ||
zng-wgt-checkerboard | ||
zng-wgt-container | ||
zng-wgt-data | ||
zng-wgt-data-view | ||
zng-wgt-fill | ||
zng-wgt-filter | ||
zng-wgt-grid | ||
zng-wgt-image | ||
zng-wgt-input | ||
zng-wgt-inspector | ||
zng-wgt-layer | ||
zng-wgt-markdown | ||
zng-wgt-material-icons | ||
zng-wgt-menu | ||
zng-wgt-panel | ||
zng-wgt-rule-line | ||
zng-wgt-scroll | ||
zng-wgt-size-offset | ||
zng-wgt-stack | ||
zng-wgt-style | ||
zng-wgt-text | ||
zng-wgt-text-input | ||
zng-wgt-toggle | ||
zng-wgt-tooltip | ||
zng-wgt-transform | ||
zng-wgt-undo | ||
zng-wgt-undo-history | ||
zng-wgt-webrender-debug | ||
zng-wgt-window | ||
zng-wgt-wrap | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
do | ||
do.bat | ||
do.ps1 | ||
rustfmt.toml |
README.md
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 printsparking_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. TheLocalContext
tracks what app is currently running in each thread andapp_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 theHyphenation::dictionary_source
method.dyn_node
— Use more dynamic dispatch at the node level by enablingUiNode::cfg_boxed
to box.dyn_app_extension
— Use dynamic dispatch at the app-extension level.dyn_closure
— Box closures at opportune places, such asVar::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 thedyn_*
andinspector
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
andCXX
must be set to "clang-cl". - You can install clang using the Visual Studio installer or by installing LLVM directly.
- Env vars
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.
- The
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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.