Expand description
§vivi
vivi
is a custom component library for Slint.
§How to use
First of all you have to add slint
as dependency to the Cargo.toml
file of your project and vivi_ui
and slint-build
as build
dependency.
§Cargo.toml
[package]
...
build = "build.rs"
edition = "2021"
[dependencies]
slint = { version = "1.7" }
...
[build-dependencies]
slint-build = { version = "1.7" }
vivi_ui = "0.2.0"
As next use the API of the slint-build crate in the build.rs
file and vivi to include the import paths.
§build.rs
ⓘ
fn main() {
slint_build::compile_with_config(
"ui/index.slint",
slint_build::CompilerConfiguration::new().with_library_paths(vivi_ui::import_paths()),
)
.unwrap();
}
vivi
can now be used inside of your Slint files:
§index.slint
import { MagicVerticalBox, FilledButton } from "@vivi/magic.slint";
export component HelloWorld inherits Window {
MagicVerticalBox {
FilledButton {
text: "Click Me";
clicked => { self.text = "Hello World"; }
}
}
}
Finally, use the [include_modules!
] macro in your main.rs
:
§main.rs
ⓘ
slint::include_modules!();
fn main() {
HelloWorld::new().unwrap().run().unwrap();
}
Functions§
- Provides the
vivi
library paths used by slint-build to make them accessible through@vivi
in Slint.