Rename rust API

This commit is contained in:
Tobias Hunger 2022-02-02 11:16:18 +01:00
parent 8d1c852e89
commit cc3994b58d
No known key found for this signature in database
GPG key ID: 60874021D2F23F91
128 changed files with 631 additions and 627 deletions

View file

@ -11,7 +11,7 @@ image = "ghcr.io/sixtyfpsui/sixtyfps/riscv64gc-unknown-linux-gnu"
[build.env] [build.env]
passthrough = [ passthrough = [
"SLINT_NO_QT", "SLINT_NO_QT",
"SIXTYFPS_STYLE", "SLINT_STYLE",
"SIXTYFPS_TEST_FILTER", "SLINT_TEST_FILTER",
"SIXTYFPS_INTERPRETER_ERROR_WHITELIST", "SLINT_INTERPRETER_ERROR_WHITELIST",
] ]

View file

@ -2,12 +2,12 @@
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) # SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
[package] [package]
name = "sixtyfps-build" name = "slint-build"
version = "0.2.0" version = "0.2.0"
authors = ["SixtyFPS <info@sixtyfps.io>"] authors = ["SixtyFPS <info@sixtyfps.io>"]
edition = "2021" edition = "2021"
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)" license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
description = "Helper for SixtyFPS build script" description = "Helper for Slint build script"
repository = "https://github.com/sixtyfpsui/sixtyfps" repository = "https://github.com/sixtyfpsui/sixtyfps"
homepage = "https://sixtyfps.io" homepage = "https://sixtyfps.io"

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
/*! /*!
This crate serves as a companion crate for the sixtyfps crate. This crate serves as a companion crate for the slint crate.
It is meant to allow you to compile the `.slint` files from your `build.rs` script. It is meant to allow you to compile the `.slint` files from your `build.rs` script.
The main entry point of this crate is the [`compile()`] function The main entry point of this crate is the [`compile()`] function
@ -17,25 +17,25 @@ In your Cargo.toml:
build = "build.rs" build = "build.rs"
[dependencies] [dependencies]
sixtyfps = "0.1.6" slint = "0.2.0"
... ...
[build-dependencies] [build-dependencies]
sixtyfps-build = "0.1.6" slint-build = "0.2.0"
``` ```
In the `build.rs` file: In the `build.rs` file:
```ignore ```ignore
fn main() { fn main() {
sixtyfps_build::compile("ui/hello.slint").unwrap(); slint_build::compile("ui/hello.slint").unwrap();
} }
``` ```
Then in your main file Then in your main file
```ignore ```ignore
sixtyfps::include_modules!(); slint::include_modules!();
fn main() { fn main() {
HelloWorld::new().run(); HelloWorld::new().run();
} }
@ -164,7 +164,7 @@ impl<Sink: Write> Write for CodeFormatter<Sink> {
/// The following line need to be added within your crate in order to include /// The following line need to be added within your crate in order to include
/// the generated code. /// the generated code.
/// ```ignore /// ```ignore
/// sixtyfps::include_modules!(); /// slint::include_modules!();
/// ``` /// ```
/// ///
/// The path is relative to the `CARGO_MANIFEST_DIR`. /// The path is relative to the `CARGO_MANIFEST_DIR`.
@ -174,7 +174,7 @@ impl<Sink: Write> Write for CodeFormatter<Sink> {
/// result to make sure that cargo make the compilation fail in case there were /// result to make sure that cargo make the compilation fail in case there were
/// errors when generating the code. /// errors when generating the code.
/// ///
/// Please check out the documentation of the `sixtyfps` crate for more information /// Please check out the documentation of the `slint` crate for more information
/// about how to use the generated code. /// about how to use the generated code.
pub fn compile(path: impl AsRef<std::path::Path>) -> Result<(), CompileError> { pub fn compile(path: impl AsRef<std::path::Path>) -> Result<(), CompileError> {
compile_with_config(path, CompilerConfiguration::default()) compile_with_config(path, CompilerConfiguration::default())
@ -206,10 +206,10 @@ pub fn compile_with_config(
}; };
let mut rerun_if_changed = String::new(); let mut rerun_if_changed = String::new();
if std::env::var_os("SIXTYFPS_STYLE").is_none() && compiler_config.style.is_none() { if std::env::var_os("SLINT_STYLE").is_none() && compiler_config.style.is_none() {
compiler_config.style = std::env::var_os("OUT_DIR").and_then(|path| { compiler_config.style = std::env::var_os("OUT_DIR").and_then(|path| {
// Same logic as in slint-backend-selector-internal's build script to get the path // Same logic as in slint-backend-selector-internal's build script to get the path
let path = Path::new(&path).parent()?.parent()?.join("SIXTYFPS_DEFAULT_STYLE.txt"); let path = Path::new(&path).parent()?.parent()?.join("SLINT_DEFAULT_STYLE.txt");
// unfortunately, if for some reason the file is changed by the slint-backend-selector-internal's build script, // unfortunately, if for some reason the file is changed by the slint-backend-selector-internal's build script,
// it is changed after cargo decide to re-run this build script or not. So that means one will need two build // it is changed after cargo decide to re-run this build script or not. So that means one will need two build
// to settle the right thing. // to settle the right thing.
@ -238,7 +238,7 @@ pub fn compile_with_config(
.join( .join(
path.file_stem() path.file_stem()
.map(Path::new) .map(Path::new)
.unwrap_or_else(|| Path::new("sixtyfps_out")) .unwrap_or_else(|| Path::new("slint_out"))
.with_extension("rs"), .with_extension("rs"),
); );
@ -267,8 +267,8 @@ pub fn compile_with_config(
println!("cargo:rerun-if-changed={}", resource); println!("cargo:rerun-if-changed={}", resource);
} }
} }
println!("cargo:rerun-if-env-changed=SIXTYFPS_STYLE"); println!("cargo:rerun-if-env-changed=SLINT_STYLE");
println!("cargo:rustc-env=SIXTYFPS_INCLUDE_GENERATED={}", output_file_path.display()); println!("cargo:rustc-env=SLINT_INCLUDE_GENERATED={}", output_file_path.display());
Ok(()) Ok(())
} }

View file

@ -2,12 +2,12 @@
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) # SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
[package] [package]
name = "sixtyfps-macros" name = "slint-macros"
version = "0.2.0" version = "0.2.0"
authors = ["SixtyFPS <info@sixtyfps.io>"] authors = ["SixtyFPS <info@sixtyfps.io>"]
edition = "2021" edition = "2021"
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)" license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
description = "Macro helper for sixtyfps crate" description = "Macro helper for slint crate"
repository = "https://github.com/sixtyfpsui/sixtyfps" repository = "https://github.com/sixtyfpsui/sixtyfps"
homepage = "https://sixtyfps.io" homepage = "https://sixtyfps.io"

View file

@ -4,8 +4,8 @@
/*! /*!
**NOTE**: This library is an **internal** crate for the [SixtyFPS project](https://sixtyfps.io). **NOTE**: This library is an **internal** crate for the [SixtyFPS project](https://sixtyfps.io).
This crate should **not be used directly** by applications using SixtyFPS. This crate should **not be used directly** by applications using Slint.
You should use the `sixtyfps` crate instead. You should use the `slint` crate instead.
**WARNING**: This crate does not follow the semver convention for versioning and can **WARNING**: This crate does not follow the semver convention for versioning and can
only be used with `version = "=x.y.z"` in Cargo.toml. only be used with `version = "=x.y.z"` in Cargo.toml.
@ -311,10 +311,10 @@ fn extract_include_paths(
/// This macro allows you to use the `.slint` design markup language inline in Rust code. Within the braces of the macro /// This macro allows you to use the `.slint` design markup language inline in Rust code. Within the braces of the macro
/// you can use place `.slint` code and the named exported components will be available for instantiation. /// you can use place `.slint` code and the named exported components will be available for instantiation.
/// ///
/// [The documentation of the `sixtyfps`](./index.html) crate contains more information about the language specification and /// [The documentation of the `slint`](./index.html) crate contains more information about the language specification and
/// how to use the generated code. /// how to use the generated code.
#[proc_macro] #[proc_macro]
pub fn sixtyfps(stream: TokenStream) -> TokenStream { pub fn slint(stream: TokenStream) -> TokenStream {
let token_iter = stream.into_iter(); let token_iter = stream.into_iter();
let (token_iter, include_paths) = extract_include_paths(token_iter); let (token_iter, include_paths) = extract_include_paths(token_iter);
@ -339,7 +339,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
let mut compiler_config = let mut compiler_config =
CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Rust); CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Rust);
if std::env::var_os("SIXTYFPS_STYLE").is_none() { if std::env::var_os("SLINT_STYLE").is_none() {
// This file is written by the slint-backend-selector-internal's built script. // This file is written by the slint-backend-selector-internal's built script.
// It is in the target/xxx/build directory // It is in the target/xxx/build directory
let target_path = match std::env::var_os("OUT_DIR") { let target_path = match std::env::var_os("OUT_DIR") {
@ -349,7 +349,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
.unwrap() .unwrap()
.parent() .parent()
.unwrap() .unwrap()
.join("SIXTYFPS_DEFAULT_STYLE.txt"), .join("SLINT_DEFAULT_STYLE.txt"),
), ),
None => { None => {
// OUT_DIR is only defined when the crate having the macro has a build.rs script // OUT_DIR is only defined when the crate having the macro has a build.rs script
@ -363,7 +363,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
} }
} }
out_dir.map(|out_dir| { out_dir.map(|out_dir| {
Path::new(&out_dir).parent().unwrap().join("build/SIXTYFPS_DEFAULT_STYLE.txt") Path::new(&out_dir).parent().unwrap().join("build/SLINT_DEFAULT_STYLE.txt")
}) })
} }
}; };
@ -392,7 +392,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
.map(|p| quote! {const _ : &'static [u8] = ::core::include_bytes!(#p);}); .map(|p| quote! {const _ : &'static [u8] = ::core::include_bytes!(#p);});
result.extend(reload); result.extend(reload);
result.extend(quote! {const _ : Option<&'static str> = ::core::option_env!("SIXTYFPS_STYLE");}); result.extend(quote! {const _ : Option<&'static str> = ::core::option_env!("SLINT_STYLE");});
result.into() result.into()
} }

View file

@ -2,12 +2,12 @@
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) # SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
[package] [package]
name = "sixtyfps" name = "slint"
version = "0.2.0" version = "0.2.0"
authors = ["SixtyFPS <info@sixtyfps.io>"] authors = ["SixtyFPS <info@sixtyfps.io>"]
edition = "2021" edition = "2021"
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)" license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
description = "SixtyFPS Rust API" description = "Slint Rust API"
repository = "https://github.com/sixtyfpsui/sixtyfps" repository = "https://github.com/sixtyfpsui/sixtyfps"
homepage = "https://sixtyfps.io" homepage = "https://sixtyfps.io"
categories = ["gui", "rendering::engine"] categories = ["gui", "rendering::engine"]
@ -48,16 +48,16 @@ wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]
[dependencies] [dependencies]
slint-core-internal = { version = "=0.2.0", path="../../internal/core", default-features = false } slint-core-internal = { version = "=0.2.0", path="../../../internal/core", default-features = false }
sixtyfps-macros = { version = "=0.2.0", path = "../rs/macros" } slint-macros = { version = "=0.2.0", path = "../macros" }
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" } slint-backend-selector-internal = { version = "=0.2.0", path="../../../internal/backends/selector" }
const-field-offset = { version = "0.1.2", path = "../../helper_crates/const-field-offset" } const-field-offset = { version = "0.1.2", path = "../../../helper_crates/const-field-offset" }
vtable = { version = "0.1.5", path = "../../helper_crates/vtable" } document-features = { version = "0.1.0", path = "../../../helper_crates/document-features" }
vtable = { version = "0.1.5", path = "../../../helper_crates/vtable" }
once_cell = { version = "1.5", default-features = false, features = ["alloc"] } once_cell = { version = "1.5", default-features = false, features = ["alloc"] }
pin-weak = { version = "1.1", default-features = false } pin-weak = { version = "1.1", default-features = false }
document-features = { version = "0.1.0", path = "../../helper_crates/document-features" }
[package.metadata.docs.rs] [package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "docs/resources/slint-docs-preview.html", "--html-in-header", "docs/resources/slint-docs-highlight.html" ] rustdoc-args = [ "--html-in-header", "docs/resources/slint-docs-preview.html", "--html-in-header", "docs/resources/slint-docs-highlight.html" ]

View file

@ -1,12 +1,12 @@
# SixtyFPS-rs # Slint
[![Crates.io](https://img.shields.io/crates/v/sixtyfps)](https://crates.io/crates/sixtyfps) [![Crates.io](https://img.shields.io/crates/v/sixtyfps)](https://crates.io/crates/sixtyfps)
[![Docs.rs](https://docs.rs/sixtyfps/badge.svg)](https://docs.rs/sixtyfps) [![Docs.rs](https://docs.rs/sixtyfps/badge.svg)](https://docs.rs/sixtyfps)
# A Rust UI toolkit # A Rust UI toolkit
[SixtyFPS](https://sixtyfps.io/) is a UI toolkit that supports different programming languages. [Slint](https://sixtyfps.io/) is a UI toolkit that supports different programming languages.
SixtyFPS-rs is the Rust API to interact with a SixtyFPS UI design from Rust. Slint is the Rust API to interact with a Slint UI design from Rust.
The complete Rust documentation can be viewed online at https://sixtyfps.io/docs/rust/sixtyfps/. The complete Rust documentation can be viewed online at https://sixtyfps.io/docs/rust/sixtyfps/.
@ -22,13 +22,13 @@ In your `Cargo.toml` add:
```toml ```toml
[dependencies] [dependencies]
sixtyfps = "0.1.6" slint = "0.2.0"
``` ```
And in your `main.rs`: And in your `main.rs`:
```rust ```rust
sixtyfps::sixtyfps!{ slint::slint!{
HelloWorld := Window { HelloWorld := Window {
Text { Text {
text: "hello world"; text: "hello world";
@ -41,11 +41,11 @@ fn main() {
} }
``` ```
The [`sixtyfps` crate documentation](https://sixtyfps.io/docs/rust/sixtyfps/) The [`slint` crate documentation](https://sixtyfps.io/docs/rust/sixtyfps/)
contains more advanced examples and alternative ways to use this crate. contains more advanced examples and alternative ways to use this crate.
To quickly get started, you can use the [Template Repository](https://github.com/sixtyfpsui/sixtyfps-rust-template) with To quickly get started, you can use the [Template Repository](https://github.com/sixtyfpsui/sixtyfps-rust-template) with
the code of a minimal application using SixtyFPS that can be used as a starting point to your program. the code of a minimal application using Slint that can be used as a starting point to your program.
```bash ```bash
cargo install cargo-generate cargo install cargo-generate

View file

@ -8,8 +8,8 @@ This should work:
``` ```
mod x { mod x {
use sixtyfps::*; use slint::*;
sixtyfps!{ Hello := Rectangle { } } slint!{ Hello := Rectangle { } }
} }
``` ```
@ -17,8 +17,8 @@ But his not:
```compile_fail ```compile_fail
mod x { mod x {
use sixtyfps::*; use slint::*;
sixtyfps!{ Hello : = Rectangle { } } slint!{ Hello : = Rectangle { } }
} }
``` ```

View file

@ -4,7 +4,7 @@
#![cfg(doc)] #![cfg(doc)]
/*! /*!
This is a pseudo module which only exist for documentation purposes as a way to show This is a pseudo module which only exist for documentation purposes as a way to show
the SixtyFPS documentation as part of rustdoc. the Slint documentation as part of rustdoc.
- The [`generated_code`] module contains an [commented example](generated_code::SampleComponent) - The [`generated_code`] module contains an [commented example](generated_code::SampleComponent)
of what is generated from the `.slint` file of what is generated from the `.slint` file

View file

@ -2,13 +2,13 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
/*! /*!
# SixtyFPS # Slint
This crate is the main entry point for embedding user interfaces designed with This crate is the main entry point for embedding user interfaces designed with
[SixtyFPS UI](https://sixtyfps.io/) in Rust programs. [Slint UI](https://sixtyfps.io/) in Rust programs.
If you are new to SixtyFPS, start with the [Walk-through tutorial](https://sixtyfps.io/docs/tutorial/rust). If you are new to Slint, start with the [Walk-through tutorial](https://sixtyfps.io/docs/tutorial/rust).
If you are already familiar with SixtyFPS, the following topics provide related information. If you are already familiar with Slint, the following topics provide related information.
## Related topics ## Related topics
@ -38,7 +38,7 @@ information about the generation functions and how to use them.
This method combines your Rust code with the `.slint` design markup in one file, using a macro: This method combines your Rust code with the `.slint` design markup in one file, using a macro:
```rust ```rust
sixtyfps::sixtyfps!{ slint::slint!{
HelloWorld := Window { HelloWorld := Window {
Text { Text {
text: "hello world"; text: "hello world";
@ -59,7 +59,7 @@ When your design becomes bigger in terms of markup code, you may want move it to
Use a [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) to compile Use a [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) to compile
your main `.slint` file: your main `.slint` file:
In your Cargo.toml add a `build` assignment and use the `sixtyfps-build` crate in `build-dependencies`: In your Cargo.toml add a `build` assignment and use the `slint-build` crate in `build-dependencies`:
```toml ```toml
[package] [package]
@ -68,25 +68,25 @@ build = "build.rs"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
sixtyfps = "0.1.6" slint = "0.1.6"
... ...
[build-dependencies] [build-dependencies]
sixtyfps-build = "0.1.6" slint-build = "0.1.6"
``` ```
Use the API of the sixtyfps-build crate in the `build.rs` file: Use the API of the slint-build crate in the `build.rs` file:
```ignore ```ignore
fn main() { fn main() {
sixtyfps_build::compile("ui/hello.slint").unwrap(); slint::compile("ui/hello.slint").unwrap();
} }
``` ```
Finally, use the [`include_modules!`] macro in your `main.rs`: Finally, use the [`include_modules!`] macro in your `main.rs`:
```ignore ```ignore
sixtyfps::include_modules!(); slint::include_modules!();
fn main() { fn main() {
HelloWorld::new().run(); HelloWorld::new().run();
} }
@ -106,7 +106,7 @@ cargo generate --git https://github.com/sixtyfpsui/sixtyfps-rust-template
Currently, only the last component in a `.slint` source file is mapped to a Rust structure that be instantiated. We are tracking the Currently, only the last component in a `.slint` source file is mapped to a Rust structure that be instantiated. We are tracking the
resolution of this limitation in <https://github.com/sixtyfpsui/sixtyfps/issues/784>. resolution of this limitation in <https://github.com/sixtyfpsui/sixtyfps/issues/784>.
The component is generated and re-exported to the location of the [`include_modules!`] or [`sixtyfps!`] macro. It is represented The component is generated and re-exported to the location of the [`include_modules!`] or [`slint!`] macro. It is represented
as a struct with the same name as the component. as a struct with the same name as the component.
For example, if you have For example, if you have
@ -198,7 +198,7 @@ The following struct would be generated:
#[derive(Default, Clone, Debug, PartialEq)] #[derive(Default, Clone, Debug, PartialEq)]
struct MyStruct { struct MyStruct {
foo : i32, foo : i32,
bar: sixtyfps::SharedString, bar: slint::SharedString,
} }
``` ```
@ -235,7 +235,7 @@ compile_error!(
forward compatibility with future version of this crate" forward compatibility with future version of this crate"
); );
pub use sixtyfps_macros::sixtyfps; pub use slint_macros::slint;
pub use slint_core_internal::api::*; pub use slint_core_internal::api::*;
pub use slint_core_internal::graphics::{ pub use slint_core_internal::graphics::{
@ -248,7 +248,7 @@ pub use slint_core_internal::sharedvector::SharedVector;
pub use slint_core_internal::string::SharedString; pub use slint_core_internal::string::SharedString;
pub use slint_core_internal::timers::{Timer, TimerMode}; pub use slint_core_internal::timers::{Timer, TimerMode};
/// This function can be used to register a custom TrueType font with SixtyFPS, /// This function can be used to register a custom TrueType font with Slint,
/// for use with the `font-family` property. The provided slice must be a valid TrueType /// for use with the `font-family` property. The provided slice must be a valid TrueType
/// font. /// font.
#[doc(hidden)] #[doc(hidden)]
@ -257,7 +257,7 @@ pub fn register_font_from_memory(data: &'static [u8]) -> Result<(), Box<dyn std:
slint_backend_selector_internal::backend().register_font_from_memory(data) slint_backend_selector_internal::backend().register_font_from_memory(data)
} }
/// This function can be used to register a custom TrueType font with SixtyFPS, /// This function can be used to register a custom TrueType font with Slint,
/// for use with the `font-family` property. The provided path must refer to a valid TrueType /// for use with the `font-family` property. The provided path must refer to a valid TrueType
/// font. /// font.
#[doc(hidden)] #[doc(hidden)]
@ -534,15 +534,15 @@ pub mod testing {
} }
} }
/// Include the code generated with the sixtyfps-build crate from the build script. After calling `sixtyfps_build::compile` /// Include the code generated with the slint-build crate from the build script. After calling `slint_build::compile`
/// in your `build.rs` build script, the use of this macro includes the generated Rust code and makes the exported types /// in your `build.rs` build script, the use of this macro includes the generated Rust code and makes the exported types
/// available for you to instantiate. /// available for you to instantiate.
/// ///
/// Check the documentation of the `sixtyfps-build` crate for more information. /// Check the documentation of the `slint-build` crate for more information.
#[macro_export] #[macro_export]
macro_rules! include_modules { macro_rules! include_modules {
() => { () => {
include!(env!("SIXTYFPS_INCLUDE_GENERATED")); include!(env!("SLINT_INCLUDE_GENERATED"));
}; };
} }

View file

@ -41,7 +41,7 @@ to the [`ModelNotify`] instance that you previously used in `attach_peer`:
Old code: Old code:
```rust,ignore ```rust,ignore
fn attach_peer(&self, peer: sixtyfps::ModelPeer) { fn attach_peer(&self, peer: slint::ModelPeer) {
self.model_notify.attach_peer(peer); self.model_notify.attach_peer(peer);
} }
``` ```

View file

@ -1,15 +1,15 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use ::sixtyfps::sixtyfps; use ::slint::slint;
#[test] #[test]
fn simple_window() { fn simple_window() {
sixtyfps!(X := Window{}); slint!(X := Window{});
X::new(); X::new();
} }
#[test] #[test]
fn empty_stuff() { fn empty_stuff() {
sixtyfps!(); slint!();
sixtyfps!(struct Hei := { abcd: bool }); slint!(struct Hei := { abcd: bool });
} }

View file

@ -37,5 +37,5 @@ name = "memory_tutorial_game_logic_in_rust"
path = "main_game_logic_in_rust.rs" path = "main_game_logic_in_rust.rs"
[dependencies] [dependencies]
sixtyfps = { path = "../../../../api/rs/slint" } slint = { path = "../../../../api/rs/slint" }
rand = "0.8" rand = "0.8"

View file

@ -12,7 +12,7 @@ rand = "0.8" # Added
What we'll do is take the list of tiles declared in the .slint language, duplicate it, and shuffle it. What we'll do is take the list of tiles declared in the .slint language, duplicate it, and shuffle it.
We'll do so by accessing the `memory_tiles` property through the Rust code. For each top-level property, We'll do so by accessing the `memory_tiles` property through the Rust code. For each top-level property,
a getter and a setter function is generated - in our case `get_memory_tiles` and `set_memory_tiles`. a getter and a setter function is generated - in our case `get_memory_tiles` and `set_memory_tiles`.
Since `memory_tiles` is an array in the `.slint` language, it is represented as a [`Rc<dyn sixtyfps::Model>`](https://sixtyfps.io/docs/rust/sixtyfps/trait.model). Since `memory_tiles` is an array in the `.slint` language, it is represented as a [`Rc<dyn slint::Model>`](https://sixtyfps.io/docs/rust/sixtyfps/trait.model).
We can't modify the model generated by the .slint, but we can extract the tiles from it, and put it We can't modify the model generated by the .slint, but we can extract the tiles from it, and put it
in a [`VecModel`](https://sixtyfps.io/docs/rust/sixtyfps/struct.vecmodel) which implements the `Model` trait. in a [`VecModel`](https://sixtyfps.io/docs/rust/sixtyfps/struct.vecmodel) which implements the `Model` trait.
`VecModel` allows us to make modifications and we can use it to replace the static generated model. `VecModel` allows us to make modifications and we can use it to replace the static generated model.

View file

@ -3,7 +3,7 @@
#[allow(dead_code)] #[allow(dead_code)]
fn main() { fn main() {
use sixtyfps::Model; use slint::Model;
let main_window = MainWindow::new(); let main_window = MainWindow::new();
@ -19,7 +19,7 @@ fn main() {
// ANCHOR: game_logic // ANCHOR: game_logic
// Assign the shuffled Vec to the model property // Assign the shuffled Vec to the model property
let tiles_model = std::rc::Rc::new(sixtyfps::VecModel::from(tiles)); let tiles_model = std::rc::Rc::new(slint::VecModel::from(tiles));
main_window.set_memory_tiles(tiles_model.clone().into()); main_window.set_memory_tiles(tiles_model.clone().into());
let main_window_weak = main_window.as_weak(); let main_window_weak = main_window.as_weak();
@ -40,7 +40,7 @@ fn main() {
let main_window = main_window_weak.unwrap(); let main_window = main_window_weak.unwrap();
main_window.set_disable_tiles(true); main_window.set_disable_tiles(true);
let tiles_model = tiles_model.clone(); let tiles_model = tiles_model.clone();
sixtyfps::Timer::single_shot(std::time::Duration::from_secs(1), move || { slint::Timer::single_shot(std::time::Duration::from_secs(1), move || {
main_window.set_disable_tiles(false); main_window.set_disable_tiles(false);
t1.image_visible = false; t1.image_visible = false;
tiles_model.set_row_data(t1_idx, t1); tiles_model.set_row_data(t1_idx, t1);
@ -54,7 +54,8 @@ fn main() {
main_window.run(); main_window.run();
// ANCHOR_END: game_logic // ANCHOR_END: game_logic
} }
sixtyfps::sixtyfps! {
slint::slint! {
struct TileData := { struct TileData := {
image: image, image: image,
image_visible: bool, image_visible: bool,

View file

@ -6,7 +6,8 @@
fn main() { fn main() {
MainWindow::new().run(); MainWindow::new().run();
} }
sixtyfps::sixtyfps! {
slint::slint! {
MainWindow := Window { MainWindow := Window {
Text { Text {
text: "hello world"; text: "hello world";

View file

@ -5,7 +5,7 @@
fn main() { fn main() {
MainWindow::new().run(); MainWindow::new().run();
} }
sixtyfps::sixtyfps! { slint::slint! {
// ANCHOR: tile // ANCHOR: tile
MemoryTile := Rectangle { MemoryTile := Rectangle {
width: 64px; width: 64px;

View file

@ -5,7 +5,7 @@
fn main() { fn main() {
MainWindow::new().run(); MainWindow::new().run();
} }
sixtyfps::sixtyfps! { slint::slint! {
// ANCHOR: tile_data // ANCHOR: tile_data
// Added: // Added:

View file

@ -5,7 +5,7 @@
fn main() { fn main() {
MainWindow::new().run(); MainWindow::new().run();
} }
sixtyfps::sixtyfps! { slint::slint! {
// ANCHOR: tile // ANCHOR: tile
MemoryTile := Rectangle { MemoryTile := Rectangle {
callback clicked; callback clicked;

View file

@ -4,7 +4,7 @@
#[allow(dead_code)] #[allow(dead_code)]
// ANCHOR: tiles // ANCHOR: tiles
fn main() { fn main() {
use sixtyfps::Model; use slint::Model;
let main_window = MainWindow::new(); let main_window = MainWindow::new();
@ -19,13 +19,14 @@ fn main() {
tiles.shuffle(&mut rng); tiles.shuffle(&mut rng);
// Assign the shuffled Vec to the model property // Assign the shuffled Vec to the model property
let tiles_model = std::rc::Rc::new(sixtyfps::VecModel::from(tiles)); let tiles_model = std::rc::Rc::new(slint::VecModel::from(tiles));
main_window.set_memory_tiles(tiles_model.into()); main_window.set_memory_tiles(tiles_model.into());
main_window.run(); main_window.run();
} }
// ANCHOR_END: tiles // ANCHOR_END: tiles
sixtyfps::sixtyfps! { slint::slint! {
struct TileData := { struct TileData := {
image: image, image: image,
image_visible: bool, image_visible: bool,

View file

@ -14,5 +14,5 @@ path = "booker.rs"
name = "booker" name = "booker"
[dependencies] [dependencies]
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
chrono = { version = "0.4", default-features = false, features = ["clock", "std"]} chrono = { version = "0.4", default-features = false, features = ["clock", "std"]}

View file

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use chrono::NaiveDate; use chrono::NaiveDate;
use sixtyfps::SharedString; use slint::SharedString;
sixtyfps::sixtyfps!(import { Booker } from "booker.slint";); slint::slint!(import { Booker } from "booker.slint";);
pub fn main() { pub fn main() {
let booker = Booker::new(); let booker = Booker::new();

View file

@ -15,10 +15,10 @@ path = "main.rs"
name = "gallery" name = "gallery"
[dependencies] [dependencies]
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../api/rs/build" } slint-build = { path = "../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,5 +2,5 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
fn main() { fn main() {
sixtyfps_build::compile("gallery.slint").unwrap(); slint_build::compile("gallery.slint").unwrap();
} }

View file

@ -6,7 +6,7 @@
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::include_modules!(); slint::include_modules!();
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] #[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() { pub fn main() {

View file

@ -14,11 +14,11 @@ path = "main.rs"
name = "imagefilter" name = "imagefilter"
[dependencies] [dependencies]
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
image = { version = "0.23.12", default-features = false, features = [ "png" ] } image = { version = "0.23.12", default-features = false, features = [ "png" ] }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../api/rs/build" } slint-build = { path = "../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -1,13 +1,13 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use sixtyfps::SharedString; use slint::SharedString;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::sixtyfps! { slint::slint! {
import { Slider, HorizontalBox, VerticalBox, GroupBox, ComboBox } from "std-widgets.slint"; import { Slider, HorizontalBox, VerticalBox, GroupBox, ComboBox } from "std-widgets.slint";
export MainWindow := Window { export MainWindow := Window {
@ -57,7 +57,7 @@ struct Filter {
struct Filters(Vec<Filter>); struct Filters(Vec<Filter>);
impl sixtyfps::Model for Filters { impl slint::Model for Filters {
type Data = SharedString; type Data = SharedString;
fn row_count(&self) -> usize { fn row_count(&self) -> usize {
@ -68,7 +68,7 @@ impl sixtyfps::Model for Filters {
self.0.get(row).map(|x| x.name.clone()) self.0.get(row).map(|x| x.name.clone())
} }
fn model_tracker(&self) -> &dyn sixtyfps::ModelTracker { fn model_tracker(&self) -> &dyn slint::ModelTracker {
&() &()
} }
} }
@ -92,8 +92,8 @@ pub fn main() {
image::open(&cat_path).expect("Error loading cat image").into_rgba8() image::open(&cat_path).expect("Error loading cat image").into_rgba8()
}; };
main_window.set_original_image(sixtyfps::Image::from_rgba8( main_window.set_original_image(slint::Image::from_rgba8(
sixtyfps::SharedPixelBuffer::clone_from_slice( slint::SharedPixelBuffer::clone_from_slice(
source_image.as_raw(), source_image.as_raw(),
source_image.width(), source_image.width(),
source_image.height(), source_image.height(),
@ -140,12 +140,12 @@ pub fn main() {
]); ]);
let filters = Rc::new(filters); let filters = Rc::new(filters);
main_window.set_filters(sixtyfps::ModelRc::from(filters.clone())); main_window.set_filters(slint::ModelRc::from(filters.clone()));
main_window.on_filter_image(move |filter_index| { main_window.on_filter_image(move |filter_index| {
let filter_fn = filters.0[filter_index as usize].apply_function; let filter_fn = filters.0[filter_index as usize].apply_function;
let filtered_image = filter_fn(&source_image); let filtered_image = filter_fn(&source_image);
sixtyfps::Image::from_rgba8(sixtyfps::SharedPixelBuffer::clone_from_slice( slint::Image::from_rgba8(sixtyfps::SharedPixelBuffer::clone_from_slice(
filtered_image.as_raw(), filtered_image.as_raw(),
filtered_image.width(), filtered_image.width(),
filtered_image.height(), filtered_image.height(),

View file

@ -15,10 +15,10 @@ name = "memory"
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../api/rs/build" } slint-build = { path = "../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -1,14 +1,14 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use sixtyfps::{Model, Timer, VecModel}; use slint::{Model, Timer, VecModel};
use std::rc::Rc; use std::rc::Rc;
use std::time::Duration; use std::time::Duration;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::sixtyfps! { slint::slint! {
import { MainWindow } from "memory.slint"; import { MainWindow } from "memory.slint";
} }

View file

@ -14,11 +14,11 @@ path = "main.rs"
name = "plotter" name = "plotter"
[dependencies] [dependencies]
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
plotters = { version = "0.3.1", default-features = false, features = ["bitmap_backend", "surface_series"] } plotters = { version = "0.3.1", default-features = false, features = ["bitmap_backend", "surface_series"] }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../api/rs/build" } slint-build = { path = "../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use plotters::prelude::*; use plotters::prelude::*;
use sixtyfps::SharedPixelBuffer; use slint::SharedPixelBuffer;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
@ -10,7 +10,7 @@ use wasm_bindgen::prelude::*;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
mod wasm_backend; mod wasm_backend;
sixtyfps::sixtyfps! { slint::slint! {
import { MainWindow } from "plotter.slint"; import { MainWindow } from "plotter.slint";
} }
@ -23,7 +23,7 @@ fn pdf(x: f64, y: f64) -> f64 {
A * (-x * x / 2.0 / SDX / SDX - y * y / 2.0 / SDY / SDY).exp() A * (-x * x / 2.0 / SDX / SDX - y * y / 2.0 / SDY / SDY).exp()
} }
fn render_plot(pitch: f32) -> sixtyfps::Image { fn render_plot(pitch: f32) -> slint::Image {
let mut pixel_buffer = SharedPixelBuffer::new(640, 480); let mut pixel_buffer = SharedPixelBuffer::new(640, 480);
let size = (pixel_buffer.width(), pixel_buffer.height()); let size = (pixel_buffer.width(), pixel_buffer.height());
@ -66,7 +66,7 @@ fn render_plot(pitch: f32) -> sixtyfps::Image {
drop(chart); drop(chart);
drop(root); drop(root);
sixtyfps::Image::from_rgb8(pixel_buffer) slint::Image::from_rgb8(pixel_buffer)
} }
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] #[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]

View file

@ -15,11 +15,12 @@ path = "main.rs"
name = "printerdemo" name = "printerdemo"
[dependencies] [dependencies]
sixtyfps = { path = "../../../api/rs/slint" } slint = { path = "../../../api/rs/slint" }
chrono = { version = "0.4", default-features = false, features = ["clock", "std"]} chrono = { version = "0.4", default-features = false, features = ["clock", "std"]}
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../../api/rs/build" } slint-build = { path = "../../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,5 +2,5 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
fn main() { fn main() {
sixtyfps_build::compile("../ui/printerdemo.slint").unwrap(); slint_build::compile("../ui/printerdemo.slint").unwrap();
} }

View file

@ -4,13 +4,13 @@
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
use sixtyfps::Model; use slint::Model;
use std::rc::Rc; use std::rc::Rc;
sixtyfps::include_modules!(); slint::include_modules!();
/// Returns the current time formated as a string /// Returns the current time formated as a string
fn current_time() -> sixtyfps::SharedString { fn current_time() -> slint::SharedString {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
return chrono::Local::now().format("%H:%M:%S %d/%m/%Y").to_string().into(); return chrono::Local::now().format("%H:%M:%S %d/%m/%Y").to_string().into();
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
@ -18,12 +18,12 @@ fn current_time() -> sixtyfps::SharedString {
} }
struct PrinterQueueData { struct PrinterQueueData {
data: Rc<sixtyfps::VecModel<PrinterQueueItem>>, data: Rc<slint::VecModel<PrinterQueueItem>>,
print_progress_timer: sixtyfps::Timer, print_progress_timer: slint::Timer,
} }
impl PrinterQueueData { impl PrinterQueueData {
fn push_job(&self, title: sixtyfps::SharedString) { fn push_job(&self, title: slint::SharedString) {
self.data.push(PrinterQueueItem { self.data.push(PrinterQueueItem {
status: "WAITING...".into(), status: "WAITING...".into(),
progress: 0, progress: 0,
@ -44,17 +44,17 @@ pub fn main() {
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
let main_window = MainWindow::new(); let main_window = MainWindow::new();
main_window.set_ink_levels(sixtyfps::VecModel::from_slice(&[ main_window.set_ink_levels(slint::VecModel::from_slice(&[
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 255, 255), level: 0.40 }, InkLevel { color: slint::Color::from_rgb_u8(0, 255, 255), level: 0.40 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(255, 0, 255), level: 0.20 }, InkLevel { color: slint::Color::from_rgb_u8(255, 0, 255), level: 0.20 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(255, 255, 0), level: 0.50 }, InkLevel { color: slint::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 0, 0), level: 0.80 }, InkLevel { color: slint::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
])); ]));
let default_queue: Vec<PrinterQueueItem> = let default_queue: Vec<PrinterQueueItem> =
main_window.global::<PrinterQueue>().get_printer_queue().iter().collect(); main_window.global::<PrinterQueue>().get_printer_queue().iter().collect();
let printer_queue = Rc::new(PrinterQueueData { let printer_queue = Rc::new(PrinterQueueData {
data: Rc::new(sixtyfps::VecModel::from(default_queue)), data: Rc::new(slint::VecModel::from(default_queue)),
print_progress_timer: Default::default(), print_progress_timer: Default::default(),
}); });
main_window.global::<PrinterQueue>().set_printer_queue(printer_queue.data.clone().into()); main_window.global::<PrinterQueue>().set_printer_queue(printer_queue.data.clone().into());
@ -76,7 +76,7 @@ pub fn main() {
let printer_queue_weak = Rc::downgrade(&printer_queue); let printer_queue_weak = Rc::downgrade(&printer_queue);
printer_queue.print_progress_timer.start( printer_queue.print_progress_timer.start(
sixtyfps::TimerMode::Repeated, slint::TimerMode::Repeated,
std::time::Duration::from_secs(1), std::time::Duration::from_secs(1),
move || { move || {
if let Some(printer_queue) = printer_queue_weak.upgrade() { if let Some(printer_queue) = printer_queue_weak.upgrade() {

View file

@ -2,7 +2,7 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
// import "sixtyfps"; // import "slint";
require("slint"); require("slint");
// import * as demo from "../ui/printerdemo.slint"; // import * as demo from "../ui/printerdemo.slint";
let demo = require("../ui/printerdemo.slint"); let demo = require("../ui/printerdemo.slint");

View file

@ -15,10 +15,10 @@ path = "main.rs"
name = "printerdemo_old" name = "printerdemo_old"
[dependencies] [dependencies]
sixtyfps = { path = "../../../api/rs/slint" } slint = { path = "../../../api/rs/slint" }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../../api/rs/build" } slint-build = { path = "../../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,5 +2,5 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
fn main() { fn main() {
sixtyfps_build::compile("../ui/printerdemo.slint").unwrap(); slint_build::compile("../ui/printerdemo.slint").unwrap();
} }

View file

@ -4,7 +4,7 @@
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::include_modules!(); slint::include_modules!();
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] #[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() { pub fn main() {
@ -14,11 +14,11 @@ pub fn main() {
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
let main_window = MainWindow::new(); let main_window = MainWindow::new();
main_window.set_ink_levels(sixtyfps::VecModel::from_slice(&[ main_window.set_ink_levels(slint::VecModel::from_slice(&[
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 255, 255), level: 0.40 }, InkLevel { color: slint::Color::from_rgb_u8(0, 255, 255), level: 0.40 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(255, 0, 255), level: 0.20 }, InkLevel { color: slint::Color::from_rgb_u8(255, 0, 255), level: 0.20 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(255, 255, 0), level: 0.50 }, InkLevel { color: slint::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 0, 0), level: 0.80 }, InkLevel { color: slint::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
])); ]));
let main_weak = main_window.as_weak(); let main_weak = main_window.as_weak();
@ -34,7 +34,7 @@ pub fn main() {
let main_window = main_weak.upgrade().unwrap(); let main_window = main_weak.upgrade().unwrap();
let fax_number = main_window.get_fax_number().to_string(); let fax_number = main_window.get_fax_number().to_string();
println!("Sending a fax to {}", fax_number); println!("Sending a fax to {}", fax_number);
main_window.set_fax_number(sixtyfps::SharedString::default()); main_window.set_fax_number(slint::SharedString::default());
}); });
main_window.on_quit(move || { main_window.on_quit(move || {

View file

@ -2,5 +2,5 @@
This is an example that shows how to embed a dynamically loaded .slint into a Qt (QWidgets) application This is an example that shows how to embed a dynamically loaded .slint into a Qt (QWidgets) application
The trick is that it uses the C++ `sixtyfps::interpreter::ComponentInstance::qwidget` and embed The trick is that it uses the C++ `slint::interpreter::ComponentInstance::qwidget` and embed
that widget in a Qt application. that widget in a Qt application.

View file

@ -15,10 +15,10 @@ name = "slide_puzzle"
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"
sixtyfps = { path = "../../api/rs/slint" } slint = { path = "../../api/rs/slint" }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../api/rs/build" } slint-build = { path = "../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,5 +2,5 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
fn main() { fn main() {
sixtyfps_build::compile("slide_puzzle.slint").unwrap(); slint_build::compile("slide_puzzle.slint").unwrap();
} }

View file

@ -1,14 +1,14 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use sixtyfps::Model; use slint::Model;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::include_modules!(); slint::include_modules!();
fn shuffle() -> Vec<i8> { fn shuffle() -> Vec<i8> {
fn is_solvable(positions: &[i8]) -> bool { fn is_solvable(positions: &[i8]) -> bool {
@ -36,13 +36,13 @@ fn shuffle() -> Vec<i8> {
} }
struct AppState { struct AppState {
pieces: Rc<sixtyfps::VecModel<Piece>>, pieces: Rc<slint::VecModel<Piece>>,
main_window: sixtyfps::Weak<MainWindow>, main_window: slint::Weak<MainWindow>,
/// An array of 16 values which represent a 4x4 matrix containing the piece number in that /// An array of 16 values which represent a 4x4 matrix containing the piece number in that
/// position. -1 is no piece. /// position. -1 is no piece.
positions: Vec<i8>, positions: Vec<i8>,
auto_play_timer: sixtyfps::Timer, auto_play_timer: slint::Timer,
kick_animation_timer: sixtyfps::Timer, kick_animation_timer: slint::Timer,
/// The speed in the x and y direction for the associated tile /// The speed in the x and y direction for the associated tile
speed_for_kick_animation: [(f32, f32); 15], speed_for_kick_animation: [(f32, f32); 15],
finished: bool, finished: bool,
@ -171,7 +171,7 @@ pub fn main() {
let main_window = MainWindow::new(); let main_window = MainWindow::new();
let state = Rc::new(RefCell::new(AppState { let state = Rc::new(RefCell::new(AppState {
pieces: Rc::new(sixtyfps::VecModel::<Piece>::from(vec![Piece::default(); 15])), pieces: Rc::new(slint::VecModel::<Piece>::from(vec![Piece::default(); 15])),
main_window: main_window.as_weak(), main_window: main_window.as_weak(),
positions: vec![], positions: vec![],
auto_play_timer: Default::default(), auto_play_timer: Default::default(),
@ -192,7 +192,7 @@ pub fn main() {
if !state_copy.borrow_mut().piece_clicked(p as i8) { if !state_copy.borrow_mut().piece_clicked(p as i8) {
let state_weak = Rc::downgrade(&state_copy); let state_weak = Rc::downgrade(&state_copy);
state_copy.borrow().kick_animation_timer.start( state_copy.borrow().kick_animation_timer.start(
sixtyfps::TimerMode::Repeated, slint::TimerMode::Repeated,
std::time::Duration::from_millis(16), std::time::Duration::from_millis(16),
move || { move || {
if let Some(state) = state_weak.upgrade() { if let Some(state) = state_weak.upgrade() {
@ -215,7 +215,7 @@ pub fn main() {
if enabled { if enabled {
let state_weak = Rc::downgrade(&state_copy); let state_weak = Rc::downgrade(&state_copy);
state_copy.borrow().auto_play_timer.start( state_copy.borrow().auto_play_timer.start(
sixtyfps::TimerMode::Repeated, slint::TimerMode::Repeated,
std::time::Duration::from_millis(200), std::time::Duration::from_millis(200),
move || { move || {
if let Some(state) = state_weak.upgrade() { if let Some(state) = state_weak.upgrade() {

View file

@ -2,7 +2,7 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
// import "sixtyfps"; // import "slint";
let slint = require("slint"); let slint = require("slint");
// import * as demo from "../ui/todo.slint"; // import * as demo from "../ui/todo.slint";
let demo = require("../ui/todo.slint"); let demo = require("../ui/todo.slint");

View file

@ -15,10 +15,10 @@ path = "main.rs"
name = "todo" name = "todo"
[dependencies] [dependencies]
sixtyfps = { path = "../../../api/rs/slint" } slint = { path = "../../../api/rs/slint" }
[build-dependencies] [build-dependencies]
sixtyfps-build = { path = "../../../api/rs/build" } slint-build = { path = "../../../api/rs/build" }
# Remove the `#wasm#` to uncomment the wasm build. # Remove the `#wasm#` to uncomment the wasm build.
# This is commented out by default because we don't want to build it as a library by default # This is commented out by default because we don't want to build it as a library by default

View file

@ -2,5 +2,5 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
fn main() { fn main() {
sixtyfps_build::compile("../ui/todo.slint").unwrap(); slint_build::compile("../ui/todo.slint").unwrap();
} }

View file

@ -1,13 +1,13 @@
// Copyright © SixtyFPS GmbH <info@sixtyfps.io> // Copyright © SixtyFPS GmbH <info@sixtyfps.io>
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
use sixtyfps::Model; use slint::Model;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
sixtyfps::include_modules!(); slint::include_modules!();
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] #[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() { pub fn main() {
@ -16,7 +16,7 @@ pub fn main() {
#[cfg(all(debug_assertions, target_arch = "wasm32"))] #[cfg(all(debug_assertions, target_arch = "wasm32"))]
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
let todo_model = Rc::new(sixtyfps::VecModel::<TodoItem>::from(vec![ let todo_model = Rc::new(slint::VecModel::<TodoItem>::from(vec![
TodoItem { checked: true, title: "Implement the .slint file".into() }, TodoItem { checked: true, title: "Implement the .slint file".into() },
TodoItem { checked: true, title: "Do the Rust part".into() }, TodoItem { checked: true, title: "Do the Rust part".into() },
TodoItem { checked: false, title: "Make the C++ code".into() }, TodoItem { checked: false, title: "Make the C++ code".into() },

View file

@ -156,7 +156,7 @@ cpp! {{
QCoreApplication::setAttribute(Qt::AA_PluginApplication, true); QCoreApplication::setAttribute(Qt::AA_PluginApplication, true);
} }
static int argc = 1; static int argc = 1;
static char argv[] = "sixtyfps"; static char argv[] = "Slint";
static char *argv2[] = { argv }; static char *argv2[] = { argv };
// Leak the QApplication, otherwise it crashes on exit // Leak the QApplication, otherwise it crashes on exit
// (because the QGuiApplication destructor access some Q_GLOBAL_STATIC which are already gone) // (because the QGuiApplication destructor access some Q_GLOBAL_STATIC which are already gone)

View file

@ -16,8 +16,8 @@ fn main() {
// has set the DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE env variable. // has set the DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE env variable.
// We then write a file in the build directory with the default style that depends on the // We then write a file in the build directory with the default style that depends on the
// Qt availability // Qt availability
// 4a. When using the sixtyfps-build crate from a build script, it will be able to read this file // 4a. When using the slint-build crate from a build script, it will be able to read this file
// from `sixtyfps_build::compile_with_config` // from `slint_build::compile_with_config`
// 4b. Same when using the `sixtyfps!` macro, // 4b. Same when using the `sixtyfps!` macro,
let has_native_style = std::env::var("DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE") let has_native_style = std::env::var("DEP_slint_backend_qt_internal_SUPPORTS_NATIVE_STYLE")
@ -29,7 +29,7 @@ fn main() {
// <target_dir>/build/slint-backend-selector-internal-1fe5c4ab61eb0584/out // <target_dir>/build/slint-backend-selector-internal-1fe5c4ab61eb0584/out
// and we want to write to a common directory, so write in the build/ dir // and we want to write to a common directory, so write in the build/ dir
let target_path = let target_path =
Path::new(&out_dir).parent().unwrap().parent().unwrap().join("SIXTYFPS_DEFAULT_STYLE.txt"); Path::new(&out_dir).parent().unwrap().parent().unwrap().join("SLINT_DEFAULT_STYLE.txt");
std::fs::write(target_path, if has_native_style { b"native\n" as &[u8] } else { b"fluent\n" }) std::fs::write(target_path, if has_native_style { b"native\n" as &[u8] } else { b"fluent\n" })
.unwrap(); .unwrap();
} }

View file

@ -161,7 +161,7 @@ WindowItem := _ {
property <length> height: native_output; property <length> height: native_output;
property <color> background; // StyleMetrics.window_background set in apply_default_properties_from_style property <color> background; // StyleMetrics.window_background set in apply_default_properties_from_style
property <color> color <=> background; property <color> color <=> background;
property <string> title: "SixtyFPS Window"; property <string> title: "Slint Window";
property <bool> no-frame; property <bool> no-frame;
property <string> default-font-family; property <string> default-font-family;
property <length> default-font-size; property <length> default-font-size;
@ -268,7 +268,7 @@ MoveTo := _ {
property <float> x; property <float> x;
property <float> y; property <float> y;
//-rust_type_constructor:sixtyfps::re_exports::PathElement::MoveTo(PathMoveTo{{}}) //-rust_type_constructor:slint::re_exports::PathElement::MoveTo(PathMoveTo{{}})
//-cpp_type:slint::private_api::PathMoveTo //-cpp_type:slint::private_api::PathMoveTo
//-is_non_item_type //-is_non_item_type
} }
@ -277,7 +277,7 @@ LineTo := _ {
property <float> x; property <float> x;
property <float> y; property <float> y;
//-rust_type_constructor:sixtyfps::re_exports::PathElement::LineTo(PathLineTo{{}}) //-rust_type_constructor:slint::re_exports::PathElement::LineTo(PathLineTo{{}})
//-cpp_type:slint::private_api::PathLineTo //-cpp_type:slint::private_api::PathLineTo
//-is_non_item_type //-is_non_item_type
} }
@ -291,7 +291,7 @@ ArcTo := _ {
property <bool> large_arc; property <bool> large_arc;
property <bool> sweep; property <bool> sweep;
//-rust_type_constructor:sixtyfps::re_exports::PathElement::ArcTo(PathArcTo{{}}) //-rust_type_constructor:slint::re_exports::PathElement::ArcTo(PathArcTo{{}})
//-cpp_type:slint::private_api::PathArcTo //-cpp_type:slint::private_api::PathArcTo
//-is_non_item_type //-is_non_item_type
} }
@ -304,7 +304,7 @@ CubicTo := _ {
property <float> x; property <float> x;
property <float> y; property <float> y;
//-rust_type_constructor:sixtyfps::re_exports::PathElement::CubicTo(PathCubicTo{{}}) //-rust_type_constructor:slint::re_exports::PathElement::CubicTo(PathCubicTo{{}})
//-cpp_type:slint::private_api::PathCubicTo //-cpp_type:slint::private_api::PathCubicTo
//-is_non_item_type //-is_non_item_type
} }
@ -315,13 +315,13 @@ QuadraticTo := _ {
property <float> x; property <float> x;
property <float> y; property <float> y;
//-rust_type_constructor:sixtyfps::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}}) //-rust_type_constructor:slint::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}})
//-cpp_type:slint::private_api::PathQuadraticTo //-cpp_type:slint::private_api::PathQuadraticTo
//-is_non_item_type //-is_non_item_type
} }
Close := _ { Close := _ {
//-rust_type_constructor:sixtyfps::re_exports::PathElement::Close //-rust_type_constructor:slint::re_exports::PathElement::Close
//-cpp_type:slint::private_api::PathClose //-cpp_type:slint::private_api::PathClose
//-is_non_item_type //-is_non_item_type
//-is_non_item_type //-is_non_item_type

View file

@ -38,8 +38,8 @@ fn ident(ident: &str) -> proc_macro2::Ident {
impl quote::ToTokens for Orientation { impl quote::ToTokens for Orientation {
fn to_tokens(&self, tokens: &mut TokenStream) { fn to_tokens(&self, tokens: &mut TokenStream) {
let tks = match self { let tks = match self {
Orientation::Horizontal => quote!(sixtyfps::re_exports::Orientation::Horizontal), Orientation::Horizontal => quote!(slint::re_exports::Orientation::Horizontal),
Orientation::Vertical => quote!(sixtyfps::re_exports::Orientation::Vertical), Orientation::Vertical => quote!(slint::re_exports::Orientation::Vertical),
}; };
tokens.extend(tks); tokens.extend(tks);
} }
@ -49,9 +49,9 @@ impl quote::ToTokens for crate::embedded_resources::PixelFormat {
fn to_tokens(&self, tokens: &mut TokenStream) { fn to_tokens(&self, tokens: &mut TokenStream) {
use crate::embedded_resources::PixelFormat::*; use crate::embedded_resources::PixelFormat::*;
let tks = match self { let tks = match self {
Rgb => quote!(sixtyfps::re_exports::PixelFormat::Rgb), Rgb => quote!(slint::re_exports::PixelFormat::Rgb),
Rgba => quote!(sixtyfps::re_exports::PixelFormat::Rgba), Rgba => quote!(slint::re_exports::PixelFormat::Rgba),
AlphaMap(_) => quote!(sixtyfps::re_exports::PixelFormat::AlphaMap), AlphaMap(_) => quote!(slint::re_exports::PixelFormat::AlphaMap),
}; };
tokens.extend(tks); tokens.extend(tks);
} }
@ -61,15 +61,15 @@ fn rust_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
match ty { match ty {
Type::Int32 => Some(quote!(i32)), Type::Int32 => Some(quote!(i32)),
Type::Float32 => Some(quote!(f32)), Type::Float32 => Some(quote!(f32)),
Type::String => Some(quote!(sixtyfps::re_exports::SharedString)), Type::String => Some(quote!(slint::re_exports::SharedString)),
Type::Color => Some(quote!(sixtyfps::re_exports::Color)), Type::Color => Some(quote!(slint::re_exports::Color)),
Type::Duration => Some(quote!(i64)), Type::Duration => Some(quote!(i64)),
Type::Angle => Some(quote!(f32)), Type::Angle => Some(quote!(f32)),
Type::PhysicalLength => Some(quote!(f32)), Type::PhysicalLength => Some(quote!(f32)),
Type::LogicalLength => Some(quote!(f32)), Type::LogicalLength => Some(quote!(f32)),
Type::Percent => Some(quote!(f32)), Type::Percent => Some(quote!(f32)),
Type::Bool => Some(quote!(bool)), Type::Bool => Some(quote!(bool)),
Type::Image => Some(quote!(sixtyfps::re_exports::Image)), Type::Image => Some(quote!(slint::re_exports::Image)),
Type::Struct { fields, name: None, .. } => { Type::Struct { fields, name: None, .. } => {
let elem = fields.values().map(rust_type).collect::<Option<Vec<_>>>()?; let elem = fields.values().map(rust_type).collect::<Option<Vec<_>>>()?;
// This will produce a tuple // This will produce a tuple
@ -78,13 +78,13 @@ fn rust_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
Type::Struct { name: Some(name), .. } => Some(struct_name_to_tokens(name)), Type::Struct { name: Some(name), .. } => Some(struct_name_to_tokens(name)),
Type::Array(o) => { Type::Array(o) => {
let inner = rust_type(o)?; let inner = rust_type(o)?;
Some(quote!(sixtyfps::re_exports::ModelRc<#inner>)) Some(quote!(slint::re_exports::ModelRc<#inner>))
} }
Type::Enumeration(e) => { Type::Enumeration(e) => {
let e = ident(&e.name); let e = ident(&e.name);
Some(quote!(sixtyfps::re_exports::#e)) Some(quote!(slint::re_exports::#e))
} }
Type::Brush => Some(quote!(sixtyfps::Brush)), Type::Brush => Some(quote!(slint::Brush)),
Type::LayoutCache => Some(quote!(SharedVector<f32>)), Type::LayoutCache => Some(quote!(SharedVector<f32>)),
_ => None, _ => None,
} }
@ -122,7 +122,7 @@ pub fn generate(doc: &Document) -> TokenStream {
let compo = generate_public_component(&llr); let compo = generate_public_component(&llr);
let compo_id = public_component_id(&llr.item_tree.root); let compo_id = public_component_id(&llr.item_tree.root);
let compo_module = format_ident!("sixtyfps_generated_{}", compo_id); let compo_module = format_ident!("slint_generated{}", compo_id);
let version_check = format_ident!( let version_check = format_ident!(
"VersionCheck_{}_{}_{}", "VersionCheck_{}_{}_{}",
env!("CARGO_PKG_VERSION_MAJOR"), env!("CARGO_PKG_VERSION_MAJOR"),
@ -150,17 +150,17 @@ pub fn generate(doc: &Document) -> TokenStream {
crate::embedded_resources::EmbeddedResourcesKind::TextureData(crate::embedded_resources::Texture { data, format, rect, total_size: crate::embedded_resources::Size{width, height} }) => { crate::embedded_resources::EmbeddedResourcesKind::TextureData(crate::embedded_resources::Texture { data, format, rect, total_size: crate::embedded_resources::Size{width, height} }) => {
let (r_x, r_y, r_w, r_h) = (rect.x(), rect.y(), rect.width(), rect.height()); let (r_x, r_y, r_w, r_h) = (rect.x(), rect.y(), rect.width(), rect.height());
let color = if let crate::embedded_resources::PixelFormat::AlphaMap([r, g, b]) = format { let color = if let crate::embedded_resources::PixelFormat::AlphaMap([r, g, b]) = format {
quote!(sixtyfps::re_exports::Color::from_rgb_u8(#r, #g, #b)) quote!(slint::re_exports::Color::from_rgb_u8(#r, #g, #b))
} else { } else {
quote!(sixtyfps::re_exports::Color::from_argb_encoded(0)) quote!(slint::re_exports::Color::from_argb_encoded(0))
}; };
quote!( quote!(
const #symbol: sixtyfps::re_exports::ImageInner = sixtyfps::re_exports::ImageInner::StaticTextures { const #symbol: slint::re_exports::ImageInner = slint::re_exports::ImageInner::StaticTextures {
size: sixtyfps::re_exports::IntSize::new(#width as _, #height as _), size: slint::re_exports::IntSize::new(#width as _, #height as _),
data: Slice::from_slice(&[#(#data),*]), data: Slice::from_slice(&[#(#data),*]),
textures: Slice::from_slice(&[ textures: Slice::from_slice(&[
sixtyfps::re_exports::StaticTexture { slint::re_exports::StaticTexture {
rect: sixtyfps::re_exports::euclid::rect(#r_x as _, #r_y as _, #r_w as _, #r_h as _), rect: slint::re_exports::euclid::rect(#r_x as _, #r_y as _, #r_w as _, #r_h as _),
format: #format, format: #format,
color: #color, color: #color,
index: 0, index: 0,
@ -182,16 +182,16 @@ pub fn generate(doc: &Document) -> TokenStream {
#[allow(clippy::erasing_op)] #[allow(clippy::erasing_op)]
#[allow(clippy::approx_constant)] // We may get those from .slint inputs! #[allow(clippy::approx_constant)] // We may get those from .slint inputs!
mod #compo_module { mod #compo_module {
use sixtyfps::re_exports::*; use slint::re_exports::*;
#(#structs)* #(#structs)*
#(#globals)* #(#globals)*
#(#sub_compos)* #(#sub_compos)*
#compo #compo
#(#resource_symbols)* #(#resource_symbols)*
const _THE_SAME_VERSION_MUST_BE_USED_FOR_THE_COMPILER_AND_THE_RUNTIME : sixtyfps::#version_check = sixtyfps::#version_check; const _THE_SAME_VERSION_MUST_BE_USED_FOR_THE_COMPILER_AND_THE_RUNTIME : slint::#version_check = slint::#version_check;
} }
pub use #compo_module::{#compo_id #(,#structs_ids)* #(,#globals_ids)* }; pub use #compo_module::{#compo_id #(,#structs_ids)* #(,#globals_ids)* };
pub use sixtyfps::{ComponentHandle, Global}; pub use slint::{ComponentHandle, Global};
} }
} }
@ -221,7 +221,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
quote!( quote!(
#component #component
pub struct #public_component_id(vtable::VRc<sixtyfps::re_exports::ComponentVTable, #inner_component_id>); pub struct #public_component_id(vtable::VRc<slint::re_exports::ComponentVTable, #inner_component_id>);
impl #public_component_id { impl #public_component_id {
pub fn new() -> Self { pub fn new() -> Self {
@ -231,29 +231,29 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
#property_and_callback_accessors #property_and_callback_accessors
} }
impl From<#public_component_id> for vtable::VRc<sixtyfps::re_exports::ComponentVTable, #inner_component_id> { impl From<#public_component_id> for vtable::VRc<slint::re_exports::ComponentVTable, #inner_component_id> {
fn from(value: #public_component_id) -> Self { fn from(value: #public_component_id) -> Self {
value.0 value.0
} }
} }
impl sixtyfps::ComponentHandle for #public_component_id { impl slint::ComponentHandle for #public_component_id {
type Inner = #inner_component_id; type Inner = #inner_component_id;
fn as_weak(&self) -> sixtyfps::Weak<Self> { fn as_weak(&self) -> slint::Weak<Self> {
sixtyfps::Weak::new(&self.0) slint::Weak::new(&self.0)
} }
fn clone_strong(&self) -> Self { fn clone_strong(&self) -> Self {
Self(self.0.clone()) Self(self.0.clone())
} }
fn from_inner(inner: vtable::VRc<sixtyfps::re_exports::ComponentVTable, #inner_component_id>) -> Self { fn from_inner(inner: vtable::VRc<slint::re_exports::ComponentVTable, #inner_component_id>) -> Self {
Self(inner) Self(inner)
} }
fn run(&self) { fn run(&self) {
self.show(); self.show();
sixtyfps::run_event_loop(); slint::run_event_loop();
self.hide(); self.hide();
} }
@ -265,17 +265,17 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
self.window().hide() self.window().hide()
} }
fn window(&self) -> &sixtyfps::Window { fn window(&self) -> &slint::Window {
vtable::VRc::as_pin_ref(&self.0).get_ref().window.get().unwrap() vtable::VRc::as_pin_ref(&self.0).get_ref().window.get().unwrap()
} }
fn global<'a, T: sixtyfps::Global<'a, Self>>(&'a self) -> T { fn global<'a, T: slint::Global<'a, Self>>(&'a self) -> T {
T::get(&self) T::get(&self)
} }
} }
struct #global_container_id { struct #global_container_id {
#(#global_names : ::core::pin::Pin<sixtyfps::re_exports::Rc<#global_types>>,)* #(#global_names : ::core::pin::Pin<slint::re_exports::Rc<#global_types>>,)*
} }
impl Default for #global_container_id { impl Default for #global_container_id {
fn default() -> Self { fn default() -> Self {
@ -321,7 +321,7 @@ fn handle_property_init(
let tokens_for_expression = compile_expression(&binding_expression.expression, &ctx2); let tokens_for_expression = compile_expression(&binding_expression.expression, &ctx2);
init.push(quote!({ init.push(quote!({
#[allow(unreachable_code, unused)] #[allow(unreachable_code, unused)]
sixtyfps::internal::set_callback_handler(#rust_property, &self_rc, { slint::internal::set_callback_handler(#rust_property, &self_rc, {
move |self_rc, args| { move |self_rc, args| {
#init_self_pin_ref #init_self_pin_ref
(#tokens_for_expression) as _ (#tokens_for_expression) as _
@ -357,7 +357,7 @@ fn handle_property_init(
let is_state_info = matches!(prop_type, Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo")); let is_state_info = matches!(prop_type, Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo"));
if is_state_info { if is_state_info {
quote! { { quote! { {
sixtyfps::internal::set_property_state_binding(#rust_property, &self_rc, #binding_tokens); slint::internal::set_property_state_binding(#rust_property, &self_rc, #binding_tokens);
} } } }
} else { } else {
match &binding_expression.animation { match &binding_expression.animation {
@ -365,13 +365,13 @@ fn handle_property_init(
let anim = compile_expression(anim, ctx); let anim = compile_expression(anim, ctx);
quote! { { quote! { {
#init_self_pin_ref #init_self_pin_ref
sixtyfps::internal::set_animated_property_binding(#rust_property, &self_rc, #binding_tokens, #anim); slint::internal::set_animated_property_binding(#rust_property, &self_rc, #binding_tokens, #anim);
} } } }
} }
Some(llr::Animation::Transition(anim)) => { Some(llr::Animation::Transition(anim)) => {
let anim = compile_expression(anim, ctx); let anim = compile_expression(anim, ctx);
quote! { quote! {
sixtyfps::internal::set_animated_property_binding_for_transition( slint::internal::set_animated_property_binding_for_transition(
#rust_property, &self_rc, #binding_tokens, move |self_rc| { #rust_property, &self_rc, #binding_tokens, move |self_rc| {
#init_self_pin_ref #init_self_pin_ref
#anim #anim
@ -381,7 +381,7 @@ fn handle_property_init(
} }
None => { None => {
quote! { { quote! { {
sixtyfps::internal::set_property_binding(#rust_property, &self_rc, #binding_tokens); slint::internal::set_property_binding(#rust_property, &self_rc, #binding_tokens);
} } } }
} }
} }
@ -436,7 +436,7 @@ fn public_api(
#[allow(dead_code)] #[allow(dead_code)]
pub fn #getter_ident(&self) -> #rust_property_type { pub fn #getter_ident(&self) -> #rust_property_type {
#[allow(unused_imports)] #[allow(unused_imports)]
use sixtyfps::re_exports::*; use slint::re_exports::*;
let _self = #self_init; let _self = #self_init;
#prop.get() #prop.get()
} }
@ -447,7 +447,7 @@ fn public_api(
#[allow(dead_code)] #[allow(dead_code)]
pub fn #setter_ident(&self, value: #rust_property_type) { pub fn #setter_ident(&self, value: #rust_property_type) {
#[allow(unused_imports)] #[allow(unused_imports)]
use sixtyfps::re_exports::*; use slint::re_exports::*;
let _self = #self_init; let _self = #self_init;
#set_value #set_value
} }
@ -510,7 +510,7 @@ fn generate_sub_component(
} }
item_names.push(ident(&item.name)); item_names.push(ident(&item.name));
item_types.push(ident(&item.ty.class_name)); item_types.push(ident(&item.ty.class_name));
#[cfg(sixtyfps_debug_property)] #[cfg(slint_debug_property)]
for (prop, info) in &item.ty.properties { for (prop, info) in &item.ty.properties {
if info.ty.is_property_type() && !prop.starts_with("viewport") && prop != "commands" { if info.ty.is_property_type() && !prop.starts_with("viewport") && prop != "commands" {
let name = format!("{}::{}.{}", component.name, item.name, prop); let name = format!("{}::{}.{}", component.name, item.name, prop);
@ -536,12 +536,12 @@ fn generate_sub_component(
let mut model = compile_expression(&repeated.model, &ctx); let mut model = compile_expression(&repeated.model, &ctx);
if repeated.model.ty(&ctx) == Type::Bool { if repeated.model.ty(&ctx) == Type::Bool {
model = quote!(sixtyfps::re_exports::ModelRc::new(#model as bool)) model = quote!(slint::re_exports::ModelRc::new(#model as bool))
} }
init.push(quote! { init.push(quote! {
_self.#repeater_id.set_model_binding({ _self.#repeater_id.set_model_binding({
let self_weak = sixtyfps::re_exports::VRcMapped::downgrade(&self_rc); let self_weak = slint::re_exports::VRcMapped::downgrade(&self_rc);
move || { move || {
let self_rc = self_weak.upgrade().unwrap(); let self_rc = self_weak.upgrade().unwrap();
let _self = self_rc.as_pin_ref(); let _self = self_rc.as_pin_ref();
@ -625,7 +625,7 @@ fn generate_sub_component(
sub_component_types.push(sub_component_id); sub_component_types.push(sub_component_id);
} }
#[cfg(sixtyfps_debug_property)] #[cfg(slint_debug_property)]
builder.init.push(quote!( builder.init.push(quote!(
#(self_rc.#declared_property_vars.debug_name.replace( #(self_rc.#declared_property_vars.debug_name.replace(
concat!(stringify!(#inner_component_id), ".", stringify!(#declared_property_vars)).into());)* concat!(stringify!(#inner_component_id), ".", stringify!(#declared_property_vars)).into());)*
@ -651,7 +651,7 @@ fn generate_sub_component(
let parent_component_type = parent_ctx.iter().map(|parent| { let parent_component_type = parent_ctx.iter().map(|parent| {
let parent_component_id = self::inner_component_id(parent.ctx.current_sub_component.unwrap()); let parent_component_id = self::inner_component_id(parent.ctx.current_sub_component.unwrap());
quote!(sixtyfps::re_exports::VWeakMapped::<sixtyfps::re_exports::ComponentVTable, #parent_component_id>) quote!(slint::re_exports::VWeakMapped::<slint::re_exports::ComponentVTable, #parent_component_id>)
}); });
init.extend(component.init_code.iter().map(|e| compile_expression(e, &ctx))); init.extend(component.init_code.iter().map(|e| compile_expression(e, &ctx)));
@ -664,30 +664,30 @@ fn generate_sub_component(
core::ptr::eq(&root.item_tree.root as *const _, component as *const _).then(|| quote!(pub)); core::ptr::eq(&root.item_tree.root as *const _, component as *const _).then(|| quote!(pub));
quote!( quote!(
#[derive(sixtyfps::re_exports::FieldOffsets, Default)] #[derive(slint::re_exports::FieldOffsets, Default)]
#[const_field_offset(sixtyfps::re_exports::const_field_offset)] #[const_field_offset(slint::re_exports::const_field_offset)]
#[repr(C)] #[repr(C)]
#[pin] #[pin]
#visibility #visibility
struct #inner_component_id { struct #inner_component_id {
#(#item_names : sixtyfps::re_exports::#item_types,)* #(#item_names : slint::re_exports::#item_types,)*
#(#sub_component_names : #sub_component_types,)* #(#sub_component_names : #sub_component_types,)*
#(#declared_property_vars : sixtyfps::re_exports::Property<#declared_property_types>,)* #(#declared_property_vars : slint::re_exports::Property<#declared_property_types>,)*
#(#declared_callbacks : sixtyfps::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)* #(#declared_callbacks : slint::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
#(#repeated_element_names : sixtyfps::re_exports::Repeater<#repeated_element_components>,)* #(#repeated_element_names : slint::re_exports::Repeater<#repeated_element_components>,)*
self_weak : sixtyfps::re_exports::OnceCell<sixtyfps::re_exports::VWeakMapped<sixtyfps::re_exports::ComponentVTable, #inner_component_id>>, self_weak : slint::re_exports::OnceCell<slint::re_exports::VWeakMapped<slint::re_exports::ComponentVTable, #inner_component_id>>,
#(parent : #parent_component_type,)* #(parent : #parent_component_type,)*
// FIXME: Do we really need a window all the time? // FIXME: Do we really need a window all the time?
window: sixtyfps::re_exports::OnceCell<sixtyfps::Window>, window: slint::re_exports::OnceCell<slint::Window>,
root : sixtyfps::re_exports::OnceCell<sixtyfps::re_exports::VWeak<sixtyfps::re_exports::ComponentVTable, #root_component_id>>, root : slint::re_exports::OnceCell<slint::re_exports::VWeak<slint::re_exports::ComponentVTable, #root_component_id>>,
tree_index: ::core::cell::Cell<u32>, tree_index: ::core::cell::Cell<u32>,
tree_index_of_first_child: ::core::cell::Cell<u32>, tree_index_of_first_child: ::core::cell::Cell<u32>,
#extra_fields #extra_fields
} }
impl #inner_component_id { impl #inner_component_id {
pub fn init(self_rc: sixtyfps::re_exports::VRcMapped<sixtyfps::re_exports::ComponentVTable, Self>, pub fn init(self_rc: slint::re_exports::VRcMapped<slint::re_exports::ComponentVTable, Self>,
root : &sixtyfps::re_exports::VRc<sixtyfps::re_exports::ComponentVTable, #root_component_id>, root : &slint::re_exports::VRc<slint::re_exports::ComponentVTable, #root_component_id>,
tree_index: u32, tree_index_of_first_child: u32) { tree_index: u32, tree_index_of_first_child: u32) {
#![allow(unused)] #![allow(unused)]
let _self = self_rc.as_pin_ref(); let _self = self_rc.as_pin_ref();
@ -702,11 +702,11 @@ fn generate_sub_component(
fn visit_dynamic_children( fn visit_dynamic_children(
self: ::core::pin::Pin<&Self>, self: ::core::pin::Pin<&Self>,
dyn_index: usize, dyn_index: usize,
order: sixtyfps::re_exports::TraversalOrder, order: slint::re_exports::TraversalOrder,
visitor: sixtyfps::re_exports::ItemVisitorRefMut visitor: slint::re_exports::ItemVisitorRefMut
) -> sixtyfps::re_exports::VisitChildrenResult { ) -> slint::re_exports::VisitChildrenResult {
#![allow(unused)] #![allow(unused)]
use sixtyfps::re_exports::*; use slint::re_exports::*;
let _self = self; let _self = self;
match dyn_index { match dyn_index {
#(#repeated_visit_branch)* #(#repeated_visit_branch)*
@ -714,13 +714,13 @@ fn generate_sub_component(
} }
} }
fn layout_info(self: ::core::pin::Pin<&Self>, orientation: sixtyfps::re_exports::Orientation) -> sixtyfps::re_exports::LayoutInfo { fn layout_info(self: ::core::pin::Pin<&Self>, orientation: slint::re_exports::Orientation) -> slint::re_exports::LayoutInfo {
#![allow(unused)] #![allow(unused)]
use sixtyfps::re_exports::*; use slint::re_exports::*;
let _self = self; let _self = self;
match orientation { match orientation {
sixtyfps::re_exports::Orientation::Horizontal => #layout_info_h, slint::re_exports::Orientation::Horizontal => #layout_info_h,
sixtyfps::re_exports::Orientation::Vertical => #layout_info_v, slint::re_exports::Orientation::Vertical => #layout_info_v,
} }
} }
} }
@ -792,7 +792,7 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
let aliases = global.aliases.iter().map(|name| ident(name)); let aliases = global.aliases.iter().map(|name| ident(name));
quote!( quote!(
pub struct #public_component_id<'a>(&'a ::core::pin::Pin<sixtyfps::re_exports::Rc<#inner_component_id>>); pub struct #public_component_id<'a>(&'a ::core::pin::Pin<slint::re_exports::Rc<#inner_component_id>>);
impl<'a> #public_component_id<'a> { impl<'a> #public_component_id<'a> {
#property_and_callback_accessors #property_and_callback_accessors
@ -800,7 +800,7 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
#(pub type #aliases<'a> = #public_component_id<'a>;)* #(pub type #aliases<'a> = #public_component_id<'a>;)*
impl<'a> sixtyfps::Global<'a, #root_component_id> for #public_component_id<'a> { impl<'a> slint::Global<'a, #root_component_id> for #public_component_id<'a> {
fn get(component: &'a #root_component_id) -> Self { fn get(component: &'a #root_component_id) -> Self {
Self(&component.0 .globals.#global_id) Self(&component.0 .globals.#global_id)
} }
@ -809,18 +809,18 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
}); });
quote!( quote!(
#[derive(sixtyfps::re_exports::FieldOffsets, Default)] #[derive(slint::re_exports::FieldOffsets, Default)]
#[const_field_offset(sixtyfps::re_exports::const_field_offset)] #[const_field_offset(slint::re_exports::const_field_offset)]
#[repr(C)] #[repr(C)]
#[pin] #[pin]
struct #inner_component_id { struct #inner_component_id {
#(#declared_property_vars: sixtyfps::re_exports::Property<#declared_property_types>,)* #(#declared_property_vars: slint::re_exports::Property<#declared_property_types>,)*
#(#declared_callbacks: sixtyfps::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)* #(#declared_callbacks: slint::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
} }
impl #inner_component_id { impl #inner_component_id {
fn new() -> ::core::pin::Pin<sixtyfps::re_exports::Rc<Self>> { fn new() -> ::core::pin::Pin<slint::re_exports::Rc<Self>> {
let self_rc = sixtyfps::re_exports::Rc::pin(Self::default()); let self_rc = slint::re_exports::Rc::pin(Self::default());
let _self = self_rc.as_ref(); let _self = self_rc.as_ref();
#(#init)* #(#init)*
self_rc self_rc
@ -841,7 +841,7 @@ fn generate_item_tree(
let inner_component_id = self::inner_component_id(&sub_tree.root); let inner_component_id = self::inner_component_id(&sub_tree.root);
let parent_component_type = parent_ctx.iter().map(|parent| { let parent_component_type = parent_ctx.iter().map(|parent| {
let parent_component_id = self::inner_component_id(parent.ctx.current_sub_component.unwrap()); let parent_component_id = self::inner_component_id(parent.ctx.current_sub_component.unwrap());
quote!(sixtyfps::re_exports::VWeakMapped::<sixtyfps::re_exports::ComponentVTable, #parent_component_id>) quote!(slint::re_exports::VWeakMapped::<slint::re_exports::ComponentVTable, #parent_component_id>)
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let root_token = if parent_ctx.is_some() { let root_token = if parent_ctx.is_some() {
quote!(&parent.upgrade().unwrap().root.get().unwrap().upgrade().unwrap()) quote!(&parent.upgrade().unwrap().root.get().unwrap().upgrade().unwrap())
@ -850,7 +850,7 @@ fn generate_item_tree(
}; };
let maybe_create_window = parent_ctx.is_none().then(|| { let maybe_create_window = parent_ctx.is_none().then(|| {
quote!( quote!(
_self.window.set(sixtyfps::create_window().into()); _self.window.set(slint::create_window().into());
_self.window.get().unwrap().window_handle().set_component(&VRc::into_dyn(self_rc.clone())); _self.window.get().unwrap().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
) )
}); });
@ -874,7 +874,7 @@ fn generate_item_tree(
sub_component = &sub_component.sub_components[*i].ty; sub_component = &sub_component.sub_components[*i].ty;
} }
item_tree_array.push(quote!( item_tree_array.push(quote!(
sixtyfps::re_exports::ItemTreeNode::DynamicTree { slint::re_exports::ItemTreeNode::DynamicTree {
index: #repeater_index, index: #repeater_index,
parent_index: #parent_index, parent_index: #parent_index,
} }
@ -883,7 +883,7 @@ fn generate_item_tree(
let item = &component.items[node.item_index]; let item = &component.items[node.item_index];
let flick = item let flick = item
.is_flickable_viewport .is_flickable_viewport
.then(|| quote!(+ sixtyfps::re_exports::Flickable::FIELD_OFFSETS.viewport)); .then(|| quote!(+ slint::re_exports::Flickable::FIELD_OFFSETS.viewport));
let field = access_component_field_offset( let field = access_component_field_offset(
&self::inner_component_id(component), &self::inner_component_id(component),
@ -893,7 +893,7 @@ fn generate_item_tree(
let children_count = node.children.len() as u32; let children_count = node.children.len() as u32;
let children_index = children_offset as u32; let children_index = children_offset as u32;
item_tree_array.push(quote!( item_tree_array.push(quote!(
sixtyfps::re_exports::ItemTreeNode::Item{ slint::re_exports::ItemTreeNode::Item{
item: VOffset::new(#path #field #flick), item: VOffset::new(#path #field #flick),
children_count: #children_count, children_count: #children_count,
children_index: #children_index, children_index: #children_index,
@ -910,51 +910,51 @@ fn generate_item_tree(
impl #inner_component_id { impl #inner_component_id {
pub fn new(#(parent: #parent_component_type)*) pub fn new(#(parent: #parent_component_type)*)
-> vtable::VRc<sixtyfps::re_exports::ComponentVTable, Self> -> vtable::VRc<slint::re_exports::ComponentVTable, Self>
{ {
#![allow(unused)] #![allow(unused)]
use sixtyfps::re_exports::*; use slint::re_exports::*;
let mut _self = Self::default(); let mut _self = Self::default();
#(_self.parent = parent.clone() as #parent_component_type;)* #(_self.parent = parent.clone() as #parent_component_type;)*
let self_rc = VRc::new(_self); let self_rc = VRc::new(_self);
let _self = self_rc.as_pin_ref(); let _self = self_rc.as_pin_ref();
#maybe_create_window; #maybe_create_window;
sixtyfps::re_exports::init_component_items(_self, Self::item_tree(), #root_token.window.get().unwrap().window_handle()); slint::re_exports::init_component_items(_self, Self::item_tree(), #root_token.window.get().unwrap().window_handle());
Self::init(sixtyfps::re_exports::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1); Self::init(slint::re_exports::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1);
self_rc self_rc
} }
fn item_tree() -> &'static [sixtyfps::re_exports::ItemTreeNode<Self>] { fn item_tree() -> &'static [slint::re_exports::ItemTreeNode<Self>] {
use sixtyfps::re_exports::*; use slint::re_exports::*;
ComponentVTable_static!(static VT for #inner_component_id); ComponentVTable_static!(static VT for #inner_component_id);
// FIXME: ideally this should be a const, but we can't because of the pointer to the vtable // FIXME: ideally this should be a const, but we can't because of the pointer to the vtable
static ITEM_TREE : sixtyfps::re_exports::OnceBox< static ITEM_TREE : slint::re_exports::OnceBox<
[sixtyfps::re_exports::ItemTreeNode<#inner_component_id>; #item_tree_array_len] [slint::re_exports::ItemTreeNode<#inner_component_id>; #item_tree_array_len]
> = sixtyfps::re_exports::OnceBox::new(); > = slint::re_exports::OnceBox::new();
&*ITEM_TREE.get_or_init(|| Box::new([#(#item_tree_array),*])) &*ITEM_TREE.get_or_init(|| Box::new([#(#item_tree_array),*]))
} }
} }
impl sixtyfps::re_exports::PinnedDrop for #inner_component_id { impl slint::re_exports::PinnedDrop for #inner_component_id {
fn drop(self: core::pin::Pin<&mut #inner_component_id>) { fn drop(self: core::pin::Pin<&mut #inner_component_id>) {
sixtyfps::re_exports::free_component_item_graphics_resources(self.as_ref(), Self::item_tree(), self.window.get().unwrap().window_handle()); slint::re_exports::free_component_item_graphics_resources(self.as_ref(), Self::item_tree(), self.window.get().unwrap().window_handle());
} }
} }
impl sixtyfps::re_exports::WindowHandleAccess for #inner_component_id { impl slint::re_exports::WindowHandleAccess for #inner_component_id {
fn window_handle(&self) -> &sixtyfps::re_exports::Rc<sixtyfps::re_exports::Window> { fn window_handle(&self) -> &slint::re_exports::Rc<slint::re_exports::Window> {
self.window.get().unwrap().window_handle() self.window.get().unwrap().window_handle()
} }
} }
impl sixtyfps::re_exports::Component for #inner_component_id { impl slint::re_exports::Component for #inner_component_id {
fn visit_children_item(self: ::core::pin::Pin<&Self>, index: isize, order: sixtyfps::re_exports::TraversalOrder, visitor: sixtyfps::re_exports::ItemVisitorRefMut) fn visit_children_item(self: ::core::pin::Pin<&Self>, index: isize, order: slint::re_exports::TraversalOrder, visitor: slint::re_exports::ItemVisitorRefMut)
-> sixtyfps::re_exports::VisitChildrenResult -> slint::re_exports::VisitChildrenResult
{ {
use sixtyfps::re_exports::*; use slint::re_exports::*;
return sixtyfps::re_exports::visit_item_tree(self, &VRcMapped::origin(&self.as_ref().self_weak.get().unwrap().upgrade().unwrap()), Self::item_tree(), index, order, visitor, visit_dynamic); return slint::re_exports::visit_item_tree(self, &VRcMapped::origin(&self.as_ref().self_weak.get().unwrap().upgrade().unwrap()), Self::item_tree(), index, order, visitor, visit_dynamic);
#[allow(unused)] #[allow(unused)]
fn visit_dynamic(_self: ::core::pin::Pin<&#inner_component_id>, order: sixtyfps::re_exports::TraversalOrder, visitor: ItemVisitorRefMut, dyn_index: usize) -> VisitChildrenResult { fn visit_dynamic(_self: ::core::pin::Pin<&#inner_component_id>, order: slint::re_exports::TraversalOrder, visitor: ItemVisitorRefMut, dyn_index: usize) -> VisitChildrenResult {
_self.visit_dynamic_children(dyn_index, order, visitor) _self.visit_dynamic_children(dyn_index, order, visitor)
} }
} }
@ -967,21 +967,21 @@ fn generate_item_tree(
} }
} }
fn parent_item(self: ::core::pin::Pin<&Self>, index: usize, result: &mut sixtyfps::re_exports::ItemWeak) { fn parent_item(self: ::core::pin::Pin<&Self>, index: usize, result: &mut slint::re_exports::ItemWeak) {
if index == 0 { if index == 0 {
#( #(
if let Some(parent) = self.parent.clone().upgrade().map(|sc| VRcMapped::origin(&sc)) { if let Some(parent) = self.parent.clone().upgrade().map(|sc| VRcMapped::origin(&sc)) {
*result = sixtyfps::re_exports::ItemRc::new(parent, #parent_item_index).parent_item(); *result = slint::re_exports::ItemRc::new(parent, #parent_item_index).parent_item();
} }
)* )*
return; return;
} }
let parent_index = Self::item_tree()[index].parent_index(); let parent_index = Self::item_tree()[index].parent_index();
let self_rc = sixtyfps::re_exports::VRcMapped::origin(&self.self_weak.get().unwrap().upgrade().unwrap()); let self_rc = slint::re_exports::VRcMapped::origin(&self.self_weak.get().unwrap().upgrade().unwrap());
*result = ItemRc::new(self_rc, parent_index).downgrade(); *result = ItemRc::new(self_rc, parent_index).downgrade();
} }
fn layout_info(self: ::core::pin::Pin<&Self>, orientation: sixtyfps::re_exports::Orientation) -> sixtyfps::re_exports::LayoutInfo { fn layout_info(self: ::core::pin::Pin<&Self>, orientation: slint::re_exports::Orientation) -> slint::re_exports::LayoutInfo {
self.layout_info(orientation) self.layout_info(orientation)
} }
} }
@ -1020,9 +1020,9 @@ fn generate_repeated_component(
fn listview_layout( fn listview_layout(
self: core::pin::Pin<&Self>, self: core::pin::Pin<&Self>,
offset_y: &mut f32, offset_y: &mut f32,
viewport_width: core::pin::Pin<&sixtyfps::re_exports::Property<f32>>, viewport_width: core::pin::Pin<&slint::re_exports::Property<f32>>,
) { ) {
use sixtyfps::re_exports::*; use slint::re_exports::*;
let _self = self; let _self = self;
let vp_w = viewport_width.get(); let vp_w = viewport_width.get();
#p_y.set(*offset_y); #p_y.set(*offset_y);
@ -1036,10 +1036,10 @@ fn generate_repeated_component(
} else { } else {
// TODO: we could generate this code only if we know that this component is in a box layout // TODO: we could generate this code only if we know that this component is in a box layout
quote! { quote! {
fn box_layout_data(self: ::core::pin::Pin<&Self>, o: sixtyfps::re_exports::Orientation) fn box_layout_data(self: ::core::pin::Pin<&Self>, o: slint::re_exports::Orientation)
-> sixtyfps::re_exports::BoxLayoutCellData -> slint::re_exports::BoxLayoutCellData
{ {
use sixtyfps::re_exports::*; use slint::re_exports::*;
BoxLayoutCellData { constraint: self.as_ref().layout_info(o) } BoxLayoutCellData { constraint: self.as_ref().layout_info(o) }
} }
} }
@ -1063,7 +1063,7 @@ fn generate_repeated_component(
quote!( quote!(
#component #component
impl sixtyfps::re_exports::RepeatedComponent for #inner_component_id { impl slint::re_exports::RepeatedComponent for #inner_component_id {
type Data = #data_type; type Data = #data_type;
fn update(&self, _index: usize, _data: Self::Data) { fn update(&self, _index: usize, _data: Self::Data) {
let self_rc = self.self_weak.get().unwrap().upgrade().unwrap(); let self_rc = self.self_weak.get().unwrap().upgrade().unwrap();
@ -1135,7 +1135,7 @@ fn access_member(reference: &llr::PropertyReference, ctx: &EvaluationContext) ->
let item_ty = ident(&sub_component.items[item_index].ty.class_name); let item_ty = ident(&sub_component.items[item_index].ty.class_name);
let flick = sub_component.items[item_index] let flick = sub_component.items[item_index]
.is_flickable_viewport .is_flickable_viewport
.then(|| quote!(+ sixtyfps::re_exports::Flickable::FIELD_OFFSETS.viewport)); .then(|| quote!(+ slint::re_exports::Flickable::FIELD_OFFSETS.viewport));
quote!((#compo_path #item_field #flick + #item_ty::FIELD_OFFSETS.#property_name).apply_pin(#path)) quote!((#compo_path #item_field #flick + #item_ty::FIELD_OFFSETS.#property_name).apply_pin(#path))
} }
} }
@ -1261,25 +1261,25 @@ fn access_item_rc(pr: &llr::PropertyReference, ctx: &EvaluationContext) -> Token
fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream { fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream {
match expr { match expr {
Expression::StringLiteral(s) => quote!(sixtyfps::re_exports::SharedString::from(#s)), Expression::StringLiteral(s) => quote!(slint::re_exports::SharedString::from(#s)),
Expression::NumberLiteral(n) => quote!(#n), Expression::NumberLiteral(n) => quote!(#n),
Expression::BoolLiteral(b) => quote!(#b), Expression::BoolLiteral(b) => quote!(#b),
Expression::Cast { from, to } => { Expression::Cast { from, to } => {
let f = compile_expression(&*from, ctx); let f = compile_expression(&*from, ctx);
match (from.ty(ctx), to) { match (from.ty(ctx), to) {
(from, Type::String) if from.as_unit_product().is_some() => { (from, Type::String) if from.as_unit_product().is_some() => {
quote!(sixtyfps::re_exports::SharedString::from( quote!(slint::re_exports::SharedString::from(
sixtyfps::re_exports::format!("{}", #f).as_str() slint::re_exports::format!("{}", #f).as_str()
)) ))
} }
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => { (Type::Float32, Type::Model) | (Type::Int32, Type::Model) => {
quote!(sixtyfps::re_exports::ModelRc::new(#f as usize)) quote!(slint::re_exports::ModelRc::new(#f as usize))
} }
(Type::Float32, Type::Color) => { (Type::Float32, Type::Color) => {
quote!(sixtyfps::re_exports::Color::from_argb_encoded(#f as u32)) quote!(slint::re_exports::Color::from_argb_encoded(#f as u32))
} }
(Type::Color, Type::Brush) => { (Type::Color, Type::Brush) => {
quote!(sixtyfps::Brush::SolidColor(#f)) quote!(slint::Brush::SolidColor(#f))
} }
(Type::Brush, Type::Color) => { (Type::Brush, Type::Color) => {
quote!(#f.color()) quote!(#f.color())
@ -1324,7 +1324,7 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
unreachable!() unreachable!()
} }
}; };
quote!(sixtyfps::re_exports::PathData::Elements(sixtyfps::re_exports::SharedVector::<_>::from_slice(&[#((#path_elements).into()),*]))) quote!(slint::re_exports::PathData::Elements(slint::re_exports::SharedVector::<_>::from_slice(&[#((#path_elements).into()),*])))
} }
(Type::Struct { .. }, Type::PathData) (Type::Struct { .. }, Type::PathData)
if matches!( if matches!(
@ -1341,10 +1341,10 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
unreachable!() unreachable!()
} }
}; };
quote!(sixtyfps::re_exports::PathData::Events(sixtyfps::re_exports::SharedVector::<_>::from_slice(&#events), sixtyfps::re_exports::SharedVector::<_>::from_slice(&#points))) quote!(slint::re_exports::PathData::Events(slint::re_exports::SharedVector::<_>::from_slice(&#events), slint::re_exports::SharedVector::<_>::from_slice(&#points)))
} }
(Type::String, Type::PathData) => { (Type::String, Type::PathData) => {
quote!(sixtyfps::re_exports::PathData::Commands(#f)) quote!(slint::re_exports::PathData::Commands(#f))
} }
_ => f, _ => f,
} }
@ -1499,24 +1499,24 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
} }
Expression::ImageReference { resource_ref, .. } => match resource_ref { Expression::ImageReference { resource_ref, .. } => match resource_ref {
crate::expression_tree::ImageReference::None => { crate::expression_tree::ImageReference::None => {
quote!(sixtyfps::re_exports::Image::default()) quote!(slint::re_exports::Image::default())
} }
crate::expression_tree::ImageReference::AbsolutePath(path) => { crate::expression_tree::ImageReference::AbsolutePath(path) => {
quote!(sixtyfps::re_exports::Image::load_from_path(::std::path::Path::new(#path)).unwrap()) quote!(slint::re_exports::Image::load_from_path(::std::path::Path::new(#path)).unwrap())
} }
crate::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => { crate::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id); let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
let format = proc_macro2::Literal::byte_string(extension.as_bytes()); let format = proc_macro2::Literal::byte_string(extension.as_bytes());
quote!( quote!(
sixtyfps::re_exports::Image::from( slint::re_exports::Image::from(
sixtyfps::re_exports::ImageInner::EmbeddedData{ data: #symbol.into(), format: Slice::from_slice(#format) } slint::re_exports::ImageInner::EmbeddedData{ data: #symbol.into(), format: Slice::from_slice(#format) }
) )
) )
} }
crate::expression_tree::ImageReference::EmbeddedTexture { resource_id } => { crate::expression_tree::ImageReference::EmbeddedTexture { resource_id } => {
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id); let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
quote!( quote!(
sixtyfps::re_exports::Image::from(#symbol) slint::re_exports::Image::from(#symbol)
) )
} }
}, },
@ -1536,9 +1536,9 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
let val = values.iter().map(|e| compile_expression(e, ctx)); let val = values.iter().map(|e| compile_expression(e, ctx));
if *as_model { if *as_model {
let rust_element_ty = rust_type(element_ty).unwrap(); let rust_element_ty = rust_type(element_ty).unwrap();
quote!(sixtyfps::re_exports::ModelRc::new( quote!(slint::re_exports::ModelRc::new(
sixtyfps::re_exports::VecModel::<#rust_element_ty>::from( slint::re_exports::VecModel::<#rust_element_ty>::from(
sixtyfps::re_exports::vec![#(#val as _),*] slint::re_exports::vec![#(#val as _),*]
) )
)) ))
} else { } else {
@ -1585,26 +1585,26 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
quote!(#name) quote!(#name)
} }
Expression::EasingCurve(EasingCurve::Linear) => { Expression::EasingCurve(EasingCurve::Linear) => {
quote!(sixtyfps::re_exports::EasingCurve::Linear) quote!(slint::re_exports::EasingCurve::Linear)
} }
Expression::EasingCurve(EasingCurve::CubicBezier(a, b, c, d)) => { Expression::EasingCurve(EasingCurve::CubicBezier(a, b, c, d)) => {
quote!(sixtyfps::re_exports::EasingCurve::CubicBezier([#a, #b, #c, #d])) quote!(slint::re_exports::EasingCurve::CubicBezier([#a, #b, #c, #d]))
} }
Expression::LinearGradient { angle, stops } => { Expression::LinearGradient { angle, stops } => {
let angle = compile_expression(angle, ctx); let angle = compile_expression(angle, ctx);
let stops = stops.iter().map(|(color, stop)| { let stops = stops.iter().map(|(color, stop)| {
let color = compile_expression(color, ctx); let color = compile_expression(color, ctx);
let position = compile_expression(stop, ctx); let position = compile_expression(stop, ctx);
quote!(sixtyfps::re_exports::GradientStop{ color: #color, position: #position as _ }) quote!(slint::re_exports::GradientStop{ color: #color, position: #position as _ })
}); });
quote!(sixtyfps::Brush::LinearGradient( quote!(slint::Brush::LinearGradient(
sixtyfps::re_exports::LinearGradientBrush::new(#angle as _, [#(#stops),*].iter().cloned()) slint::re_exports::LinearGradientBrush::new(#angle as _, [#(#stops),*].iter().cloned())
)) ))
} }
Expression::EnumerationValue(value) => { Expression::EnumerationValue(value) => {
let base_ident = ident(&value.enumeration.name); let base_ident = ident(&value.enumeration.name);
let value_ident = ident(&value.to_string()); let value_ident = ident(&value.to_string());
quote!(sixtyfps::re_exports::#base_ident::#value_ident) quote!(slint::re_exports::#base_ident::#value_ident)
} }
Expression::ReturnStatement(expr) => { Expression::ReturnStatement(expr) => {
let return_expr = expr.as_ref().map(|expr| compile_expression(expr, ctx)); let return_expr = expr.as_ref().map(|expr| compile_expression(expr, ctx));
@ -1647,8 +1647,8 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
}; };
quote! { quote! {
let mut #cells_variable = [#(#cells),*]; let mut #cells_variable = [#(#cells),*];
sixtyfps::re_exports::reorder_dialog_button_layout(&mut #cells_variable, &#roles); slint::re_exports::reorder_dialog_button_layout(&mut #cells_variable, &#roles);
let #cells_variable = sixtyfps::re_exports::Slice::from_slice(&#cells_variable); let #cells_variable = slint::re_exports::Slice::from_slice(&#cells_variable);
} }
} }
} }
@ -1708,7 +1708,7 @@ fn compile_builtin_function_call(
} }
BuiltinFunction::RegisterCustomFontByPath => { BuiltinFunction::RegisterCustomFontByPath => {
if let [Expression::StringLiteral(path)] = arguments { if let [Expression::StringLiteral(path)] = arguments {
quote!(sixtyfps::register_font_from_path(&std::path::PathBuf::from(#path));) quote!(slint::register_font_from_path(&std::path::PathBuf::from(#path));)
} else { } else {
panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments) panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments)
} }
@ -1717,7 +1717,7 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments { if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _; let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id); let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
quote!(sixtyfps::register_font_from_memory(#symbol.into());) quote!(slint::register_font_from_memory(#symbol.into());)
} else { } else {
panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments) panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments)
} }
@ -1777,7 +1777,7 @@ fn compile_builtin_function_call(
let g: u8 = (#g as u32).max(0).min(255) as u8; let g: u8 = (#g as u32).max(0).min(255) as u8;
let b: u8 = (#b as u32).max(0).min(255) as u8; let b: u8 = (#b as u32).max(0).min(255) as u8;
let a: u8 = (255. * (#a as f32)).max(0.).min(255.) as u8; let a: u8 = (255. * (#a as f32)).max(0.).min(255.) as u8;
sixtyfps::re_exports::Color::from_argb_u8(a, r, g, b) slint::re_exports::Color::from_argb_u8(a, r, g, b)
}) })
} }
} }
@ -1786,7 +1786,7 @@ fn compile_builtin_function_call(
/// Return a TokenStream for a name (as in [`Type::Struct::name`]) /// Return a TokenStream for a name (as in [`Type::Struct::name`])
fn struct_name_to_tokens(name: &str) -> TokenStream { fn struct_name_to_tokens(name: &str) -> TokenStream {
// the name match the C++ signature so we need to change that to the rust namespace // the name match the C++ signature so we need to change that to the rust namespace
let mut name = name.replace("slint::private_api::", "sixtyfps::re_exports::").replace('-', "_"); let mut name = name.replace("slint::private_api::", "slint::re_exports::").replace('-', "_");
if !name.contains("::") { if !name.contains("::") {
name.insert_str(0, "r#") name.insert_str(0, "r#")
} }
@ -1843,15 +1843,15 @@ fn box_layout_function(
let ri = repeated_indices.as_ref().map(|ri| quote!(let mut #ri = [0u32; 2 * #repeater_idx];)); let ri = repeated_indices.as_ref().map(|ri| quote!(let mut #ri = [0u32; 2 * #repeater_idx];));
let ri2 = let ri2 =
repeated_indices.map(|ri| quote!(let #ri = sixtyfps::re_exports::Slice::from_slice(&#ri);)); repeated_indices.map(|ri| quote!(let #ri = slint::re_exports::Slice::from_slice(&#ri);));
let cells_variable = ident(cells_variable); let cells_variable = ident(cells_variable);
let sub_expression = compile_expression(sub_expression, ctx); let sub_expression = compile_expression(sub_expression, ctx);
quote! { { quote! { {
#ri #ri
let mut items_vec = sixtyfps::re_exports::Vec::with_capacity(#fixed_count #repeated_count); let mut items_vec = slint::re_exports::Vec::with_capacity(#fixed_count #repeated_count);
#(#push_code)* #(#push_code)*
let #cells_variable = sixtyfps::re_exports::Slice::from_slice(&items_vec); let #cells_variable = slint::re_exports::Slice::from_slice(&items_vec);
#ri2 #ri2
#sub_expression #sub_expression
} } } }

View file

@ -75,12 +75,12 @@ impl<'a> TypeLoader<'a> {
.style .style
.as_ref() .as_ref()
.map(Cow::from) .map(Cow::from)
.or_else(|| std::env::var("SIXTYFPS_STYLE").map(Cow::from).ok()) .or_else(|| std::env::var("SLINT_STYLE").map(Cow::from).ok())
.unwrap_or_else(|| { .unwrap_or_else(|| {
let is_wasm = cfg!(target_arch = "wasm32") let is_wasm = cfg!(target_arch = "wasm32")
|| std::env::var("TARGET").map_or(false, |t| t.starts_with("wasm")); || std::env::var("TARGET").map_or(false, |t| t.starts_with("wasm"));
if !is_wasm { if !is_wasm {
diag.push_diagnostic_with_span("SIXTYFPS_STYLE not defined, defaulting to 'fluent', see https://github.com/sixtyfpsui/sixtyfps/issues/83 for more info".to_owned(), diag.push_diagnostic_with_span("SLINT_STYLE not defined, defaulting to 'fluent', see https://github.com/sixtyfpsui/sixtyfps/issues/83 for more info".to_owned(),
Default::default(), Default::default(),
crate::diagnostics::DiagnosticLevel::Warning crate::diagnostics::DiagnosticLevel::Warning
); );

View file

@ -66,7 +66,7 @@ wasm-bindgen = { version = "0.2" }
web_sys = { version = "0.3", package = "web-sys", features=["console", "CanvasRenderingContext2d", "TextMetrics", "HtmlSpanElement"] } web_sys = { version = "0.3", package = "web-sys", features=["console", "CanvasRenderingContext2d", "TextMetrics", "HtmlSpanElement"] }
[dev-dependencies] [dev-dependencies]
sixtyfps = { version = "=0.2.0", path = "../../api/rs/slint", default-features = false, features = ["std"] } slint = { version = "=0.2.0", path = "../../api/rs/slint", default-features = false, features = ["std"] }
slint-backend-testing-internal = { path="../backends/testing" } slint-backend-testing-internal = { path="../backends/testing" }
image = { version = "0.23.14", default-features = false, features = [ "png" ] } image = { version = "0.23.14", default-features = false, features = [ "png" ] }

View file

@ -50,7 +50,7 @@ impl crate::window::WindowHandleAccess for Window {
/// it and modifies it from Rust code: /// it and modifies it from Rust code:
/// ```rust /// ```rust
/// # slint_backend_testing_internal::init(); /// # slint_backend_testing_internal::init();
/// sixtyfps::sixtyfps!{ /// slint::slint!{
/// export global Palette := { /// export global Palette := {
/// property<color> foreground-color; /// property<color> foreground-color;
/// property<color> background-color; /// property<color> background-color;
@ -66,10 +66,10 @@ impl crate::window::WindowHandleAccess for Window {
/// } /// }
/// } /// }
/// let app = App::new(); /// let app = App::new();
/// app.global::<Palette>().set_background_color(sixtyfps::Color::from_rgb_u8(0, 0, 0)); /// app.global::<Palette>().set_background_color(slint::Color::from_rgb_u8(0, 0, 0));
/// ///
/// // alternate way to access the global singleton: /// // alternate way to access the global singleton:
/// Palette::get(&app).set_foreground_color(sixtyfps::Color::from_rgb_u8(255, 255, 255)); /// Palette::get(&app).set_foreground_color(slint::Color::from_rgb_u8(255, 255, 255));
/// ``` /// ```
/// ///
/// See also the [language reference for global singletons](docs/langref/index.html#global-singletons) for more information. /// See also the [language reference for global singletons](docs/langref/index.html#global-singletons) for more information.
@ -203,7 +203,7 @@ mod weak_handle {
/// # Example /// # Example
/// ```rust /// ```rust
/// # slint_backend_testing_internal::init(); /// # slint_backend_testing_internal::init();
/// sixtyfps::sixtyfps! { MyApp := Window { property <int> foo; /* ... */ } } /// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
/// let handle = MyApp::new(); /// let handle = MyApp::new();
/// let handle_weak = handle.as_weak(); /// let handle_weak = handle.as_weak();
/// let thread = std::thread::spawn(move || { /// let thread = std::thread::spawn(move || {
@ -253,7 +253,7 @@ pub use weak_handle::*;
/// ///
/// # Example /// # Example
/// ```rust /// ```rust
/// sixtyfps::sixtyfps! { MyApp := Window { property <int> foo; /* ... */ } } /// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
/// # slint_backend_testing_internal::init(); /// # slint_backend_testing_internal::init();
/// let handle = MyApp::new(); /// let handle = MyApp::new();
/// let handle_weak = handle.as_weak(); /// let handle_weak = handle.as_weak();
@ -262,7 +262,7 @@ pub use weak_handle::*;
/// let foo = 42; /// let foo = 42;
/// // now forward the data to the main thread using invoke_from_event_loop /// // now forward the data to the main thread using invoke_from_event_loop
/// let handle_copy = handle_weak.clone(); /// let handle_copy = handle_weak.clone();
/// sixtyfps::invoke_from_event_loop(move || handle_copy.unwrap().set_foo(foo)); /// slint::invoke_from_event_loop(move || handle_copy.unwrap().set_foo(foo));
/// }); /// });
/// # thread.join().unwrap(); return; // don't run the event loop in examples /// # thread.join().unwrap(); return; // don't run the event loop in examples
/// handle.run(); /// handle.run();
@ -271,6 +271,6 @@ pub fn invoke_from_event_loop(func: impl FnOnce() + Send + 'static) {
if let Some(backend) = crate::backend::instance() { if let Some(backend) = crate::backend::instance() {
backend.post_event(alloc::boxed::Box::new(func)) backend.post_event(alloc::boxed::Box::new(func))
} else { } else {
panic!("sixtyfps::invoke_from_event_loop() must be called after the SixtyFPS backend is initialized.") panic!("slint::invoke_from_event_loop() must be called after the Slint backend is initialized.")
} }
} }

View file

@ -389,7 +389,7 @@ impl Image {
ImageInner::AbsoluteFilePath(_) | ImageInner::EmbeddedData { .. } => { ImageInner::AbsoluteFilePath(_) | ImageInner::EmbeddedData { .. } => {
match crate::backend::instance() { match crate::backend::instance() {
Some(backend) => backend.image_size(self), Some(backend) => backend.image_size(self),
None => panic!("sixtyfps::Image::size() called too early (before a graphics backend was chosen). You need to create a component first."), None => panic!("slint::Image::size() called too early (before a graphics backend was chosen). You need to create a component first."),
} }
}, },
ImageInner::EmbeddedImage(buffer) => buffer.size(), ImageInner::EmbeddedImage(buffer) => buffer.size(),

View file

@ -43,13 +43,13 @@ pub enum TimerMode {
/// ## Example /// ## Example
/// ```rust,no_run /// ```rust,no_run
/// # slint_backend_testing_internal::init(); /// # slint_backend_testing_internal::init();
/// use sixtyfps::{Timer, TimerMode}; /// use slint::{Timer, TimerMode};
/// let timer = Timer::default(); /// let timer = Timer::default();
/// timer.start(TimerMode::Repeated, std::time::Duration::from_millis(200), move || { /// timer.start(TimerMode::Repeated, std::time::Duration::from_millis(200), move || {
/// println!("This will be printed every 200ms."); /// println!("This will be printed every 200ms.");
/// }); /// });
/// // ... more initialization ... /// // ... more initialization ...
/// sixtyfps::run_event_loop(); /// slint::run_event_loop();
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
pub struct Timer { pub struct Timer {
@ -93,7 +93,7 @@ impl Timer {
/// ## Example /// ## Example
/// ```rust /// ```rust
/// # slint_backend_testing_internal::init(); /// # slint_backend_testing_internal::init();
/// use sixtyfps::Timer; /// use slint::Timer;
/// Timer::single_shot(std::time::Duration::from_millis(200), move || { /// Timer::single_shot(std::time::Duration::from_millis(200), move || {
/// println!("This will be printed after 200ms."); /// println!("This will be printed after 200ms.");
/// }); /// });

View file

@ -688,7 +688,7 @@ pub async fn load(
Result<Rc<ComponentDescription<'_>>, ()>, Result<Rc<ComponentDescription<'_>>, ()>,
slint_compiler_internal::diagnostics::BuildDiagnostics, slint_compiler_internal::diagnostics::BuildDiagnostics,
) { ) {
if compiler_config.style.is_none() && std::env::var("SIXTYFPS_STYLE").is_err() { if compiler_config.style.is_none() && std::env::var("SLINT_STYLE").is_err() {
// Defaults to native if it exists: // Defaults to native if it exists:
compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE { compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE {
"native".to_owned() "native".to_owned()

View file

@ -680,7 +680,7 @@ pub enum DiagnosticLevel {
/// Diagnostic describes the aspects of either a warning or an error, along /// Diagnostic describes the aspects of either a warning or an error, along
/// with its location and a description. Diagnostics are typically returned by /// with its location and a description. Diagnostics are typically returned by
/// sixtyfps::interpreter::ComponentCompiler::diagnostics() in a vector. /// slint::interpreter::ComponentCompiler::diagnostics() in a vector.
#[derive(Clone)] #[derive(Clone)]
#[repr(C)] #[repr(C)]
pub struct Diagnostic { pub struct Diagnostic {
@ -839,7 +839,7 @@ pub unsafe extern "C" fn slint_interpreter_component_compiler_build_from_path(
/// PropertyDescriptor is a simple structure that's used to describe a property declared in .slint /// PropertyDescriptor is a simple structure that's used to describe a property declared in .slint
/// code. It is returned from in a vector from /// code. It is returned from in a vector from
/// sixtyfps::interpreter::ComponentDefinition::properties(). /// slint::interpreter::ComponentDefinition::properties().
#[derive(Clone)] #[derive(Clone)]
#[repr(C)] #[repr(C)]
pub struct PropertyDescriptor { pub struct PropertyDescriptor {

View file

@ -7,8 +7,8 @@
* `Value::Array` was removed and [`Value::Model`] needs to be used instead. * `Value::Array` was removed and [`Value::Model`] needs to be used instead.
* `CallCallbackError` was renamed to [`InvokeCallbackError`]. * `CallCallbackError` was renamed to [`InvokeCallbackError`].
* `WeakComponentInstance` was removed. Use `sixtyfps::Weak<sixtyfps::interpreter::ComponentInstance>` instead. * `WeakComponentInstance` was removed. Use `slint::Weak<sixtyfps::interpreter::ComponentInstance>` instead.
You might need to `use sixtyfps::ComponentHandle;` in your code to bring the trait into scope. You might need to `use slint::ComponentHandle;` in your code to bring the trait into scope.
*/ */

View file

@ -29,9 +29,9 @@ TestCase := Rectangle {
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_sub_text(), sixtyfps::SharedString::from("ABC")); assert_eq!(instance.get_sub_text(), slint::SharedString::from("ABC"));
instance.set_public_alias(sixtyfps::SharedString::from("EFG")); instance.set_public_alias(slint::SharedString::from("EFG"));
assert_eq!(instance.get_sub_text(), sixtyfps::SharedString::from("EFG")); assert_eq!(instance.get_sub_text(), slint::SharedString::from("EFG"));
``` ```

View file

@ -24,9 +24,9 @@ let instance = TestCase::new();
assert_eq!(instance.get_val(), 1.); assert_eq!(instance.get_val(), 1.);
instance.set_cond(true); instance.set_cond(true);
assert_eq!(instance.get_val(), 1.); assert_eq!(instance.get_val(), 1.);
sixtyfps::testing::mock_elapsed_time(500); slint::testing::mock_elapsed_time(500);
assert_eq!(instance.get_val(), 0.5); assert_eq!(instance.get_val(), 0.5);
sixtyfps::testing::mock_elapsed_time(500); slint::testing::mock_elapsed_time(500);
assert_eq!(instance.get_val(), 0.); assert_eq!(instance.get_val(), 0.);
``` ```

View file

@ -28,7 +28,7 @@ TestCase := Rectangle {
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_prop_a(), 1); assert_eq!(instance.get_prop_a(), 1);
assert_eq!(instance.get_prop_b(), 2); assert_eq!(instance.get_prop_b(), 2);
assert_eq!(instance.get_prop_text(), sixtyfps::SharedString::from("world")); assert_eq!(instance.get_prop_text(), slint::SharedString::from("world"));
``` ```
```cpp ```cpp

View file

@ -57,30 +57,30 @@ TestCase := Rectangle {
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hello")); assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hello")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text()); assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text());
assert_eq!(instance.get_othercomp_t(), sixtyfps::SharedString::from("real value")); assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value"));
assert_eq!(instance.get_othercomp_get_text(), sixtyfps::SharedString::from("real value")); assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value"));
instance.set_text1(sixtyfps::SharedString::from("Text1New")); instance.set_text1(slint::SharedString::from("Text1New"));
instance.set_text2(sixtyfps::SharedString::from("Text2New")); instance.set_text2(slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Text1New")); assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Text1New")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New"));
instance.invoke_set_ti1(sixtyfps::SharedString::from("Hallo")); instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
instance.invoke_set_ti2(sixtyfps::SharedString::from("Bonjour")); instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Bonjour")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Bonjour")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_othercomp_some_value(), 42); assert_eq!(instance.get_othercomp_some_value(), 42);
assert_eq!(instance.get_othercomp_some_value_alias(), 42); assert_eq!(instance.get_othercomp_some_value_alias(), 42);

View file

@ -60,30 +60,30 @@ TestCase := Rectangle {
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hello")); assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hello")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Blah")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Blah"));
assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text()); assert_eq!(instance.get_othercomp_t(), instance.get_othercomp_get_text());
assert_eq!(instance.get_othercomp_t(), sixtyfps::SharedString::from("real value")); assert_eq!(instance.get_othercomp_t(), slint::SharedString::from("real value"));
assert_eq!(instance.get_othercomp_get_text(), sixtyfps::SharedString::from("real value")); assert_eq!(instance.get_othercomp_get_text(), slint::SharedString::from("real value"));
instance.set_text1(sixtyfps::SharedString::from("Text1New")); instance.set_text1(slint::SharedString::from("Text1New"));
instance.set_text2(sixtyfps::SharedString::from("Text2New")); instance.set_text2(slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Text1New")); assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Text1New")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Text2New"));
instance.invoke_set_ti1(sixtyfps::SharedString::from("Hallo")); instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
instance.invoke_set_ti2(sixtyfps::SharedString::from("Bonjour")); instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New")); assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo")); assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Bonjour")); assert_eq!(instance.get_ti2_text(), slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Bonjour")); assert_eq!(instance.get_text_item_text(), slint::SharedString::from("Bonjour"));
assert_eq!(instance.get_othercomp_some_value(), 42); assert_eq!(instance.get_othercomp_some_value(), 42);
assert_eq!(instance.get_othercomp_some_value_alias(), 42); assert_eq!(instance.get_othercomp_some_value_alias(), 42);

View file

@ -40,17 +40,17 @@ assert_eq!(instance.get_hello(), 40);
assert_eq!(instance.get_binding_dep(), 100); assert_eq!(instance.get_binding_dep(), 100);
// Half the animation // Half the animation
sixtyfps::testing::mock_elapsed_time(600); slint::testing::mock_elapsed_time(600);
assert_eq!(instance.get_hello(), 50); assert_eq!(instance.get_hello(), 50);
assert_eq!(instance.get_binding_dep(), 125); assert_eq!(instance.get_binding_dep(), 125);
// Remaining half // Remaining half
sixtyfps::testing::mock_elapsed_time(600); slint::testing::mock_elapsed_time(600);
assert_eq!(instance.get_hello(), 60); assert_eq!(instance.get_hello(), 60);
assert_eq!(instance.get_binding_dep(), 150); assert_eq!(instance.get_binding_dep(), 150);
sixtyfps::testing::mock_elapsed_time(100); slint::testing::mock_elapsed_time(100);
assert_eq!(instance.get_hello(), 60); assert_eq!(instance.get_hello(), 60);
assert_eq!(instance.get_binding_dep(), 150); assert_eq!(instance.get_binding_dep(), 150);
@ -58,7 +58,7 @@ assert_eq!(instance.get_binding_dep(), 150);
// querying the value (because te dirty event should cause the animation to start) // querying the value (because te dirty event should cause the animation to start)
instance.set_condition(true); instance.set_condition(true);
instance.set_hello(30); instance.set_hello(30);
sixtyfps::testing::mock_elapsed_time(600); slint::testing::mock_elapsed_time(600);
assert_eq!(instance.get_hello(), 45); assert_eq!(instance.get_hello(), 45);
assert_eq!(instance.get_binding_dep(), 125); assert_eq!(instance.get_binding_dep(), 125);

View file

@ -36,12 +36,12 @@ TestCase := Rectangle {
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 70., 5.); slint::testing::send_mouse_click(&instance, 70., 5.);
sixtyfps::testing::send_mouse_click(&instance, 85., 55.); slint::testing::send_mouse_click(&instance, 85., 55.);
assert_eq!(instance.get_result(), 345); assert_eq!(instance.get_result(), 345);
instance.set_xx(0.); instance.set_xx(0.);
sixtyfps::testing::send_mouse_click(&instance, 5., 10.); slint::testing::send_mouse_click(&instance, 5., 10.);
sixtyfps::testing::send_mouse_click(&instance, 5., 60.); slint::testing::send_mouse_click(&instance, 5., 60.);
assert_eq!(instance.get_result(), 685); assert_eq!(instance.get_result(), 685);
``` ```

View file

@ -22,7 +22,7 @@ assert_eq(instance.get_value(), 1);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_value(), 1); assert_eq!(instance.get_value(), 1);
``` ```

View file

@ -24,12 +24,12 @@ instance.on_test_func({
move |a| weak.upgrade().unwrap().get_some_value() * a move |a| weak.upgrade().unwrap().get_some_value() * a
}); });
assert_eq!(instance.get_test_prop(), 4 + 16); assert_eq!(instance.get_test_prop(), 4 + 16);
assert_eq!(instance.get_test_prop2(), sixtyfps::SharedString::from("hello=50")); assert_eq!(instance.get_test_prop2(), slint::SharedString::from("hello=50"));
instance.set_some_value(2); instance.set_some_value(2);
assert_eq!(instance.get_test_prop(), 4 + 4); assert_eq!(instance.get_test_prop(), 4 + 4);
assert_eq!(instance.get_test_prop2(), sixtyfps::SharedString::from("hello=44")); assert_eq!(instance.get_test_prop2(), slint::SharedString::from("hello=44"));
assert_eq!(instance.invoke_test_func2("xxx".into(), 1), sixtyfps::SharedString::from("xxx=3")); assert_eq!(instance.invoke_test_func2("xxx".into(), 1), slint::SharedString::from("xxx=3"));
``` ```
```cpp ```cpp

View file

@ -101,12 +101,12 @@ assert_eq(instance.get_touch_error(), 0);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 38., 5.); slint::testing::send_mouse_click(&instance, 38., 5.);
assert_eq!(instance.get_touch1(), 0); assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_value(), 10); assert_eq!(instance.get_value(), 10);
assert_eq!(instance.get_touch_error(), 0); assert_eq!(instance.get_touch_error(), 0);
sixtyfps::testing::send_mouse_click(&instance, 95., 5.); slint::testing::send_mouse_click(&instance, 95., 5.);
assert_eq!(instance.get_touch1(), 1); assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_value(), 10); assert_eq!(instance.get_value(), 10);
assert_eq!(instance.get_touch_error(), 0); assert_eq!(instance.get_touch_error(), 0);

View file

@ -32,7 +32,7 @@ assert(instance.get_combo_has_focus());
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert!(!instance.get_combo_has_focus()); assert!(!instance.get_combo_has_focus());
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert!(instance.get_combo_has_focus()); assert!(instance.get_combo_has_focus());
``` ```

View file

@ -49,15 +49,15 @@ assert(!instance.get_hover());
``` ```
```rust ```rust
use sixtyfps::Model; use slint::Model;
let instance = TestCase::new(); let instance = TestCase::new();
let vec_model = std::rc::Rc::new(sixtyfps::VecModel::from(vec![1i32, 2i32])); let vec_model = std::rc::Rc::new(slint::VecModel::from(vec![1i32, 2i32]));
instance.set_model(vec_model.clone().into()); instance.set_model(vec_model.clone().into());
instance.on_clicked(move || dbg!(vec_model.remove(vec_model.row_count() - 1))); instance.on_clicked(move || dbg!(vec_model.remove(vec_model.row_count() - 1)));
sixtyfps::testing::send_mouse_click(&instance, 95., 5.); slint::testing::send_mouse_click(&instance, 95., 5.);
assert_eq!(instance.get_model().row_count(), 1); assert_eq!(instance.get_model().row_count(), 1);
assert!(instance.get_hover()); assert!(instance.get_hover());
sixtyfps::testing::send_mouse_click(&instance, 95., 5.); slint::testing::send_mouse_click(&instance, 95., 5.);
assert_eq!(instance.get_model().row_count(), 0); assert_eq!(instance.get_model().row_count(), 0);
assert!(!instance.get_hover()); assert!(!instance.get_hover());
``` ```

View file

@ -17,7 +17,7 @@ slint::testing::send_mouse_click(&instance, 5., 5.);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
``` ```
*/ */

View file

@ -36,8 +36,8 @@ assert_eq(instance.get_result(), 99);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 295., 295.); slint::testing::send_mouse_click(&instance, 295., 295.);
assert_eq!(instance.get_result(), 99); assert_eq!(instance.get_result(), 99);
``` ```
*/ */

View file

@ -65,7 +65,7 @@ assert(instance.get_all_ok());
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert!(instance.get_all_ok()); assert!(instance.get_all_ok());
``` ```

View file

@ -44,7 +44,7 @@ assert_eq(instance.get_value(), "Green");
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 205.); slint::testing::send_mouse_click(&instance, 5., 205.);
assert_eq!(instance.get_value(), "Green"); assert_eq!(instance.get_value(), "Green");
``` ```

View file

@ -94,25 +94,25 @@ assert_eq(instance.get_pointer_event_test(), "downleftclickupleft");
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
// does not click on anything // does not click on anything
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_touch1(), 0); assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
assert_eq!(instance.get_touch3(), 0); assert_eq!(instance.get_touch3(), 0);
// click on second one // click on second one
sixtyfps::testing::send_mouse_click(&instance, 101., 101.); slint::testing::send_mouse_click(&instance, 101., 101.);
assert_eq!(instance.get_touch1(), 0); assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 1); assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 0); assert_eq!(instance.get_touch3(), 0);
// click on first one only // click on first one only
sixtyfps::testing::send_mouse_click(&instance, 108., 108.); slint::testing::send_mouse_click(&instance, 108., 108.);
assert_eq!(instance.get_touch1(), 1); assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 1); assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 0); assert_eq!(instance.get_touch3(), 0);
// click on the third // click on the third
sixtyfps::testing::send_mouse_click(&instance, 106., 103.); slint::testing::send_mouse_click(&instance, 106., 103.);
assert_eq!(instance.get_touch1(), 1); assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 1); assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 1); assert_eq!(instance.get_touch3(), 1);

View file

@ -31,13 +31,13 @@ assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212")); assert_eq!(instance.get_s1(), slint::SharedString::from("hello1212"));
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1")); assert_eq!(instance.get_s2(), slint::SharedString::from("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242")); assert_eq!(instance.get_s1(), slint::SharedString::from("hello4242"));
instance.invoke_foo(); instance.invoke_foo();
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42")); assert_eq!(instance.get_s3(), slint::SharedString::from("x42x42"));
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx")); assert_eq!(instance.get_s4(), slint::SharedString::from("ayoxxx"));
``` ```
```js ```js

View file

@ -30,13 +30,13 @@ assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212")); assert_eq!(instance.get_s1(), slint::SharedString::from("hello1212"));
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1")); assert_eq!(instance.get_s2(), slint::SharedString::from("10hello5.1"));
instance.set_a(42); instance.set_a(42);
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242")); assert_eq!(instance.get_s1(), slint::SharedString::from("hello4242"));
instance.invoke_foo(); instance.invoke_foo();
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42")); assert_eq!(instance.get_s3(), slint::SharedString::from("x42x42"));
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx")); assert_eq!(instance.get_s4(), slint::SharedString::from("ayoxxx"));
``` ```
```js ```js

View file

@ -40,7 +40,7 @@ TestCase := Rectangle {
/* /*
```rust ```rust
let ctrl_modifier = sixtyfps::re_exports::KeyboardModifiers { let ctrl_modifier = slint::re_exports::KeyboardModifiers {
control: true, control: true,
..Default::default() ..Default::default()
}; };
@ -50,13 +50,13 @@ let instance = TestCase::new();
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused()); assert!(instance.get_input2_focused());
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Hello"); slint::testing::send_keyboard_string_sequence(&instance, "Hello");
assert_eq!(instance.get_input2_text(), "Hello"); assert_eq!(instance.get_input2_text(), "Hello");
assert_eq!(instance.get_input1_text(), ""); assert_eq!(instance.get_input1_text(), "");
assert_eq!(instance.get_recieved(), ""); assert_eq!(instance.get_recieved(), "");
sixtyfps::testing::set_current_keyboard_modifiers(&instance, ctrl_modifier); slint::testing::set_current_keyboard_modifiers(&instance, ctrl_modifier);
sixtyfps::testing::send_keyboard_string_sequence(&instance, "ß"); slint::testing::send_keyboard_string_sequence(&instance, "ß");
assert_eq!(instance.get_input2_text(), "Hello"); assert_eq!(instance.get_input2_text(), "Hello");
assert_eq!(instance.get_input1_text(), ""); assert_eq!(instance.get_input1_text(), "");
assert_eq!(instance.get_recieved(), "ß"); assert_eq!(instance.get_recieved(), "ß");

View file

@ -55,8 +55,8 @@ TestCase := Window {
/* /*
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 50., 50.); slint::testing::send_mouse_click(&instance, 50., 50.);
sixtyfps::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__"); slint::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__");
assert_eq!(instance.get_r1(), "__afghij__"); assert_eq!(instance.get_r1(), "__afghij__");
assert_eq!(instance.get_r2(), "__abfghij__"); assert_eq!(instance.get_r2(), "__abfghij__");
assert_eq!(instance.get_r3(), "__abcfghij__"); assert_eq!(instance.get_r3(), "__abcfghij__");

View file

@ -28,19 +28,19 @@ let instance = TestCase::new();
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
sixtyfps::testing::send_mouse_click(&instance, 150., 100.); slint::testing::send_mouse_click(&instance, 150., 100.);
assert!(instance.get_input1_focused()); assert!(instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 1"); slint::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
assert_eq!(instance.get_input1_text(), "Only for field 1"); assert_eq!(instance.get_input1_text(), "Only for field 1");
assert_eq!(instance.get_input2_text(), ""); assert_eq!(instance.get_input2_text(), "");
sixtyfps::testing::send_mouse_click(&instance, 150., 300.); slint::testing::send_mouse_click(&instance, 150., 300.);
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused()); assert!(instance.get_input2_focused());
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 2"); slint::testing::send_keyboard_string_sequence(&instance, "Only for field 2");
assert_eq!(instance.get_input1_text(), "Only for field 1"); assert_eq!(instance.get_input1_text(), "Only for field 1");
assert_eq!(instance.get_input2_text(), "Only for field 2"); assert_eq!(instance.get_input2_text(), "Only for field 2");
``` ```

View file

@ -28,15 +28,15 @@ let instance = TestCase::new();
assert!(instance.get_input1_focused()); assert!(instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
sixtyfps::testing::send_keyboard_string_sequence(&instance, "Only for field 1"); slint::testing::send_keyboard_string_sequence(&instance, "Only for field 1");
assert_eq!(instance.get_input1_text(), "Only for field 1"); assert_eq!(instance.get_input1_text(), "Only for field 1");
assert_eq!(instance.get_input2_text(), ""); assert_eq!(instance.get_input2_text(), "");
sixtyfps::testing::send_mouse_click(&instance, 150., 100.); slint::testing::send_mouse_click(&instance, 150., 100.);
assert!(instance.get_input1_focused()); assert!(instance.get_input1_focused());
assert!(!instance.get_input2_focused()); assert!(!instance.get_input2_focused());
sixtyfps::testing::send_mouse_click(&instance, 150., 300.); slint::testing::send_mouse_click(&instance, 150., 300.);
assert!(!instance.get_input1_focused()); assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused()); assert!(instance.get_input2_focused());
``` ```

View file

@ -91,28 +91,28 @@ assert_eq!(instance.get_test(), true);
assert_eq!(instance.get_el1clip(), false); assert_eq!(instance.get_el1clip(), false);
// clip, outside // clip, outside
sixtyfps::testing::send_mouse_click(&instance, 37., 27.); slint::testing::send_mouse_click(&instance, 37., 27.);
assert_eq!(instance.get_touch1(), 0, "a. touch1"); assert_eq!(instance.get_touch1(), 0, "a. touch1");
assert_eq!(instance.get_touch2(), 0, "a. touch2"); assert_eq!(instance.get_touch2(), 0, "a. touch2");
// clip, inside // clip, inside
sixtyfps::testing::send_mouse_click(&instance, 37., 33.); slint::testing::send_mouse_click(&instance, 37., 33.);
assert_eq!(instance.get_touch1(), 0, "b. touch1"); assert_eq!(instance.get_touch1(), 0, "b. touch1");
assert_eq!(instance.get_touch2(), 1, "b. touch2"); assert_eq!(instance.get_touch2(), 1, "b. touch2");
// no-clip, outside // no-clip, outside
sixtyfps::testing::send_mouse_click(&instance, 17., 7.); slint::testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 1, "c. touch1"); assert_eq!(instance.get_touch1(), 1, "c. touch1");
assert_eq!(instance.get_touch2(), 1, "c. touch2"); assert_eq!(instance.get_touch2(), 1, "c. touch2");
// no-clip, inside // no-clip, inside
sixtyfps::testing::send_mouse_click(&instance, 17., 13.); slint::testing::send_mouse_click(&instance, 17., 13.);
assert_eq!(instance.get_touch1(), 2, "d. touch1"); assert_eq!(instance.get_touch1(), 2, "d. touch1");
assert_eq!(instance.get_touch2(), 1, "d. touch2"); assert_eq!(instance.get_touch2(), 1, "d. touch2");
// now clip also el1 // now clip also el1
instance.set_el1clip(true); instance.set_el1clip(true);
sixtyfps::testing::send_mouse_click(&instance, 17., 7.); slint::testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 2, "e. touch1"); assert_eq!(instance.get_touch1(), 2, "e. touch1");
assert_eq!(instance.get_touch2(), 1, "e. touch2"); assert_eq!(instance.get_touch2(), 1, "e. touch2");
``` ```

View file

@ -87,29 +87,29 @@ assert_eq!(instance.get_test(), true);
assert_eq!(instance.get_el1visible(), true); assert_eq!(instance.get_el1visible(), true);
// el2 !visible, outside // el2 !visible, outside
sixtyfps::testing::send_mouse_click(&instance, 37., 27.); slint::testing::send_mouse_click(&instance, 37., 27.);
assert_eq!(instance.get_touch1(), 0); assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
// el2 !visible, inside // el2 !visible, inside
sixtyfps::testing::send_mouse_click(&instance, 37., 33.); slint::testing::send_mouse_click(&instance, 37., 33.);
assert_eq!(instance.get_touch1(), 0); assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
// el1 visible, outside // el1 visible, outside
sixtyfps::testing::send_mouse_click(&instance, 17., 7.); slint::testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 1); assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
// el1 visible, inside // el1 visible, inside
sixtyfps::testing::send_mouse_click(&instance, 17., 13.); slint::testing::send_mouse_click(&instance, 17., 13.);
assert_eq!(instance.get_touch1(), 2); assert_eq!(instance.get_touch1(), 2);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
// now makes el invisible // now makes el invisible
instance.set_el1visible(false); instance.set_el1visible(false);
sixtyfps::testing::send_mouse_click(&instance, 17., 7.); slint::testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 2); assert_eq!(instance.get_touch1(), 2);
assert_eq!(instance.get_touch2(), 0); assert_eq!(instance.get_touch2(), 0);
``` ```

View file

@ -70,7 +70,7 @@ assert(instance.get_rect5_pos_ok());
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 95.); slint::testing::send_mouse_click(&instance, 5., 95.);
assert!(instance.get_rect1_pos_ok()); assert!(instance.get_rect1_pos_ok());
assert!(instance.get_rect2_pos_ok()); assert!(instance.get_rect2_pos_ok());
assert!(instance.get_rect3_pos_ok()); assert!(instance.get_rect3_pos_ok());

View file

@ -69,7 +69,7 @@ assert(instance.get_rect5_pos_ok());
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 95.); slint::testing::send_mouse_click(&instance, 5., 95.);
assert!(instance.get_rect1_pos_ok()); assert!(instance.get_rect1_pos_ok());
assert!(instance.get_rect2_pos_ok()); assert!(instance.get_rect2_pos_ok());
assert!(instance.get_rect3_pos_ok()); assert!(instance.get_rect3_pos_ok());

View file

@ -45,13 +45,13 @@ assert_eq(instance.get_value(), 1+1+2);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout slint::testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
sixtyfps::testing::send_mouse_click(&instance, 190., 190.); slint::testing::send_mouse_click(&instance, 190., 190.);
assert_eq!(instance.get_value(), 1+1); assert_eq!(instance.get_value(), 1+1);
sixtyfps::testing::send_mouse_click(&instance, 5., 290.); slint::testing::send_mouse_click(&instance, 5., 290.);
assert_eq!(instance.get_value(), 1+1+2); assert_eq!(instance.get_value(), 1+1+2);
``` ```

View file

@ -50,13 +50,13 @@ assert_eq(instance.get_value(), 9);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_value(), -10); assert_eq!(instance.get_value(), -10);
sixtyfps::testing::send_mouse_click(&instance, 25., 25.); slint::testing::send_mouse_click(&instance, 25., 25.);
assert_eq!(instance.get_value(), 8); assert_eq!(instance.get_value(), 8);
sixtyfps::testing::send_mouse_click(&instance, 45., 15.); slint::testing::send_mouse_click(&instance, 45., 15.);
assert_eq!(instance.get_value(), 9); assert_eq!(instance.get_value(), 9);
``` ```

View file

@ -23,7 +23,7 @@ slint::testing::send_mouse_click(&instance, 5., 5.);
```rust ```rust
let instance = HelloWorld::new(); let instance = HelloWorld::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
``` ```
*/ */

View file

@ -51,13 +51,13 @@ assert_eq(instance.get_last_clicked(), 1);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 455.); slint::testing::send_mouse_click(&instance, 5., 455.);
assert_eq!(instance.get_last_clicked(), 0); assert_eq!(instance.get_last_clicked(), 0);
sixtyfps::testing::send_mouse_click(&instance, 5., 305.); slint::testing::send_mouse_click(&instance, 5., 305.);
assert_eq!(instance.get_last_clicked(), 11); assert_eq!(instance.get_last_clicked(), 11);
sixtyfps::testing::send_mouse_click(&instance, 5., 295.); slint::testing::send_mouse_click(&instance, 5., 295.);
assert_eq!(instance.get_last_clicked(), 3); assert_eq!(instance.get_last_clicked(), 3);
sixtyfps::testing::send_mouse_click(&instance, 5., 95.); slint::testing::send_mouse_click(&instance, 5., 95.);
assert_eq!(instance.get_last_clicked(), 1); assert_eq!(instance.get_last_clicked(), 1);
``` ```

View file

@ -62,17 +62,17 @@ assert_eq(instance.get_last_clicked(), 1);
let instance = TestCase::new(); let instance = TestCase::new();
// aim at the padding // aim at the padding
sixtyfps::testing::send_mouse_click(&instance, 5., 100.); slint::testing::send_mouse_click(&instance, 5., 100.);
assert_eq!(instance.get_last_clicked(), 0); assert_eq!(instance.get_last_clicked(), 0);
sixtyfps::testing::send_mouse_click(&instance, 5., 455.); slint::testing::send_mouse_click(&instance, 5., 455.);
assert_eq!(instance.get_last_clicked(), 0); assert_eq!(instance.get_last_clicked(), 0);
sixtyfps::testing::send_mouse_click(&instance, 5., 305.); slint::testing::send_mouse_click(&instance, 5., 305.);
assert_eq!(instance.get_last_clicked(), 11); assert_eq!(instance.get_last_clicked(), 11);
sixtyfps::testing::send_mouse_click(&instance, 5., 295.); slint::testing::send_mouse_click(&instance, 5., 295.);
assert_eq!(instance.get_last_clicked(), 3); assert_eq!(instance.get_last_clicked(), 3);
sixtyfps::testing::send_mouse_click(&instance, 5., 95.); slint::testing::send_mouse_click(&instance, 5., 95.);
assert_eq!(instance.get_last_clicked(), 1); assert_eq!(instance.get_last_clicked(), 1);
``` ```

View file

@ -46,13 +46,13 @@ assert_eq(instance.get_last_clicked(), 31);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 95.); slint::testing::send_mouse_click(&instance, 5., 95.);
assert_eq!(instance.get_last_clicked(), 11); assert_eq!(instance.get_last_clicked(), 11);
sixtyfps::testing::send_mouse_click(&instance, 105., 205.); slint::testing::send_mouse_click(&instance, 105., 205.);
assert_eq!(instance.get_last_clicked(), 23); assert_eq!(instance.get_last_clicked(), 23);
sixtyfps::testing::send_mouse_click(&instance, 95., 195.); slint::testing::send_mouse_click(&instance, 95., 195.);
assert_eq!(instance.get_last_clicked(), 12); assert_eq!(instance.get_last_clicked(), 12);
sixtyfps::testing::send_mouse_click(&instance, 295., 56.); slint::testing::send_mouse_click(&instance, 295., 56.);
assert_eq!(instance.get_last_clicked(), 31); assert_eq!(instance.get_last_clicked(), 31);
``` ```

View file

@ -51,7 +51,7 @@ assert(instance.get_check_ok());
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 1., 1.); slint::testing::send_mouse_click(&instance, 1., 1.);
assert!(instance.get_check_ok()); assert!(instance.get_check_ok());
``` ```

View file

@ -34,9 +34,9 @@ assert_eq(instance.get_last_clicked(), 2);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_last_clicked(), 0); assert_eq!(instance.get_last_clicked(), 0);
sixtyfps::testing::send_mouse_click(&instance, 15., 145.); slint::testing::send_mouse_click(&instance, 15., 145.);
assert_eq!(instance.get_last_clicked(), 1); assert_eq!(instance.get_last_clicked(), 1);
sixtyfps::testing::send_mouse_click(&instance, 15., 155.); slint::testing::send_mouse_click(&instance, 15., 155.);
assert_eq!(instance.get_last_clicked(), 2); assert_eq!(instance.get_last_clicked(), 2);
``` ```

View file

@ -69,7 +69,7 @@ assert_eq(uint32_t(instance.get_materialized_rect_max_width()), uint32_t(std::nu
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_materialized_max_height(), 300); assert_eq!(instance.get_materialized_max_height(), 300);
assert_eq!(instance.get_materialized_min_width(), 50); assert_eq!(instance.get_materialized_min_width(), 50);
assert_eq!(instance.get_materialized_min_height(), 25); assert_eq!(instance.get_materialized_min_height(), 25);

View file

@ -94,28 +94,28 @@ assert_eq(instance.get_value(), 2);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_value(), 0); assert_eq!(instance.get_value(), 0);
sixtyfps::testing::send_mouse_click(&instance, 5., 52.); slint::testing::send_mouse_click(&instance, 5., 52.);
assert_eq!(instance.get_value(), 2); assert_eq!(instance.get_value(), 2);
sixtyfps::testing::send_mouse_click(&instance, 5., 30.); slint::testing::send_mouse_click(&instance, 5., 30.);
assert_eq!(instance.get_value(), 1); assert_eq!(instance.get_value(), 1);
sixtyfps::testing::send_mouse_click(&instance, 5., 80.); slint::testing::send_mouse_click(&instance, 5., 80.);
assert_eq!(instance.get_value(), 4); assert_eq!(instance.get_value(), 4);
instance.set_cond(false); instance.set_cond(false);
sixtyfps::testing::send_mouse_click(&instance, 5., 35.); slint::testing::send_mouse_click(&instance, 5., 35.);
assert_eq!(instance.get_value(), 1); assert_eq!(instance.get_value(), 1);
sixtyfps::testing::send_mouse_click(&instance, 5., 30.); slint::testing::send_mouse_click(&instance, 5., 30.);
assert_eq!(instance.get_value(), 0); assert_eq!(instance.get_value(), 0);
sixtyfps::testing::send_mouse_click(&instance, 5., 67.); slint::testing::send_mouse_click(&instance, 5., 67.);
assert_eq!(instance.get_value(), 4); assert_eq!(instance.get_value(), 4);
instance.set_cond(true); instance.set_cond(true);
sixtyfps::testing::send_mouse_click(&instance, 5., 70.); slint::testing::send_mouse_click(&instance, 5., 70.);
assert_eq!(instance.get_value(), 2); assert_eq!(instance.get_value(), 2);

View file

@ -35,15 +35,15 @@ assert_eq(instance.get_hello_world(), "world");
```rust ```rust
use sixtyfps::Model; use slint::Model;
let instance = TestCase::new(); let instance = TestCase::new();
assert_eq!(instance.get_num_ints(), 5); assert_eq!(instance.get_num_ints(), 5);
assert_eq!(instance.get_n(), 4); assert_eq!(instance.get_n(), 4);
assert_eq!(instance.get_third_int(), 3); assert_eq!(instance.get_third_int(), 3);
let model: std::rc::Rc<sixtyfps::VecModel<i32>> = std::rc::Rc::new(vec![1, 2, 3, 4, 5, 6, 7].into()); let model: std::rc::Rc<slint::VecModel<i32>> = std::rc::Rc::new(vec![1, 2, 3, 4, 5, 6, 7].into());
instance.set_ints(sixtyfps::ModelRc::from(model.clone())); instance.set_ints(slint::ModelRc::from(model.clone()));
assert_eq!(instance.get_num_ints(), 7); assert_eq!(instance.get_num_ints(), 7);
assert_eq!(instance.get_third_int(), 3); assert_eq!(instance.get_third_int(), 3);
model.push(8); model.push(8);
@ -51,7 +51,7 @@ assert_eq!(instance.get_num_ints(), 8);
model.set_row_data(2, 100); model.set_row_data(2, 100);
assert_eq!(instance.get_third_int(), 100); assert_eq!(instance.get_third_int(), 100);
assert_eq!(instance.get_hello_world(), sixtyfps::SharedString::from("world")); assert_eq!(instance.get_hello_world(), slint::SharedString::from("world"));
``` ```
```js ```js

View file

@ -105,13 +105,13 @@ assert_eq(instance.get_value(), 3000+13+42);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_value(), 1010); assert_eq!(instance.get_value(), 1010);
sixtyfps::testing::send_mouse_click(&instance, 15., 15.); slint::testing::send_mouse_click(&instance, 15., 15.);
assert_eq!(instance.get_value(), 2013); assert_eq!(instance.get_value(), 2013);
sixtyfps::testing::send_mouse_click(&instance, 5., 15.); slint::testing::send_mouse_click(&instance, 5., 15.);
assert_eq!(instance.get_value(), 3000+13+42); assert_eq!(instance.get_value(), 3000+13+42);
``` ```

View file

@ -50,15 +50,15 @@ assert_eq(instance.get_top_level(), 92);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 42); assert_eq!(instance.get_top_level(), 42);
instance.set_cond1(true); instance.set_cond1(true);
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 92); assert_eq!(instance.get_top_level(), 92);
instance.set_cond1(false); instance.set_cond1(false);
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 92); assert_eq!(instance.get_top_level(), 92);
``` ```

View file

@ -50,15 +50,15 @@ assert_eq(instance.get_top_level(), 92);
```rust ```rust
let instance = TestCase::new(); let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 42); assert_eq!(instance.get_top_level(), 42);
instance.set_cond1(true); instance.set_cond1(true);
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 92); assert_eq!(instance.get_top_level(), 92);
instance.set_cond1(false); instance.set_cond1(false);
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_top_level(), 92); assert_eq!(instance.get_top_level(), 92);
``` ```

View file

@ -58,14 +58,14 @@ let instance = TestCase::new();
// Send an initial click to traverse the item tree and force a listview // Send an initial click to traverse the item tree and force a listview
// layout. // layout.
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_viewport_height(), 100.); assert_eq!(instance.get_viewport_height(), 100.);
// Trigger the mouse area to change the model // Trigger the mouse area to change the model
sixtyfps::testing::send_mouse_click(&instance, 5., 55.); slint::testing::send_mouse_click(&instance, 5., 55.);
// Send a second click to force an item tree traversal and listview update // Send a second click to force an item tree traversal and listview update
sixtyfps::testing::send_mouse_click(&instance, 5., 5.); slint::testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_viewport_height(), 200.); assert_eq!(instance.get_viewport_height(), 200.);
``` ```

Some files were not shown because too many files have changed in this diff Show more