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).
First add zng
to your Cargo.toml
, or call cargo add zng -F view_prebuilt
:
[dependencies]
zng = { version = "0.12.9", features = ["view_prebuilt"] }
Then create your first window:
use zng::prelude::*;
fn main() {
zng::env::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 documentation
for more details.
You can also use cargo zng new
to generate a new project with useful boilerplate and distribution
packaging already setup.
cargo install cargo-zng
cargo zng new "My App!"
The example above installs cargo-zng
and uses it to generate a new './my-app' crate from the default template.
The zng
crate is the only dependency you need to create apps, it re-exports the primary API of the other
crates in well organized and documented modules.
The other crates provide the full API that you might need to implement more advanced features, for example, a custom property that modifies the behavior of a widget might need to reference the widget's internal state, this internal API will only be available in the widget's crate.
The Cargo features of each crate are documented in the README file for that crate. See ./crates/zng
for the Cargo features of the main crate.
"view"
and "view_software"
feature:
CC
and CXX
must be set to "clang-cl".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
"view_prebuilt"
feature:
Cross compilation for Android requires some setup. The project default template provides most of this setup, you only need to install some packages:
sdkmanager
tool
or the "Android Studio Settings / Android SDK" UI to install:
ANDROID_HOME
and ANDROID_NDK_HOME
environment variables.aarch64-linux-android
.See Android Setup for more help on how to setup the crate and build script.
Avif image format support is tricky to build, if you need AVIF and are building with "view"
feature see Avif Setup.
Avif support is already included in the prebuilt view-process.
Clone this repository and call cargo do run <example>
to run an example.
See the ./examples
README file for a list of examples with description and screenshots.
Licensed under either of
at your option.
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.