mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Rename rust API
This commit is contained in:
parent
8d1c852e89
commit
cc3994b58d
128 changed files with 631 additions and 627 deletions
|
@ -11,7 +11,7 @@ image = "ghcr.io/sixtyfpsui/sixtyfps/riscv64gc-unknown-linux-gnu"
|
|||
[build.env]
|
||||
passthrough = [
|
||||
"SLINT_NO_QT",
|
||||
"SIXTYFPS_STYLE",
|
||||
"SIXTYFPS_TEST_FILTER",
|
||||
"SIXTYFPS_INTERPRETER_ERROR_WHITELIST",
|
||||
"SLINT_STYLE",
|
||||
"SLINT_TEST_FILTER",
|
||||
"SLINT_INTERPRETER_ERROR_WHITELIST",
|
||||
]
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
[package]
|
||||
name = "sixtyfps-build"
|
||||
name = "slint-build"
|
||||
version = "0.2.0"
|
||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||
edition = "2021"
|
||||
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"
|
||||
homepage = "https://sixtyfps.io"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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.
|
||||
|
||||
The main entry point of this crate is the [`compile()`] function
|
||||
|
@ -17,25 +17,25 @@ In your Cargo.toml:
|
|||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = "0.1.6"
|
||||
slint = "0.2.0"
|
||||
...
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = "0.1.6"
|
||||
slint-build = "0.2.0"
|
||||
```
|
||||
|
||||
In the `build.rs` file:
|
||||
|
||||
```ignore
|
||||
fn main() {
|
||||
sixtyfps_build::compile("ui/hello.slint").unwrap();
|
||||
slint_build::compile("ui/hello.slint").unwrap();
|
||||
}
|
||||
```
|
||||
|
||||
Then in your main file
|
||||
|
||||
```ignore
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
fn main() {
|
||||
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 generated code.
|
||||
/// ```ignore
|
||||
/// sixtyfps::include_modules!();
|
||||
/// slint::include_modules!();
|
||||
/// ```
|
||||
///
|
||||
/// 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
|
||||
/// 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.
|
||||
pub fn compile(path: impl AsRef<std::path::Path>) -> Result<(), CompileError> {
|
||||
compile_with_config(path, CompilerConfiguration::default())
|
||||
|
@ -206,10 +206,10 @@ pub fn compile_with_config(
|
|||
};
|
||||
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| {
|
||||
// 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,
|
||||
// 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.
|
||||
|
@ -238,7 +238,7 @@ pub fn compile_with_config(
|
|||
.join(
|
||||
path.file_stem()
|
||||
.map(Path::new)
|
||||
.unwrap_or_else(|| Path::new("sixtyfps_out"))
|
||||
.unwrap_or_else(|| Path::new("slint_out"))
|
||||
.with_extension("rs"),
|
||||
);
|
||||
|
||||
|
@ -267,8 +267,8 @@ pub fn compile_with_config(
|
|||
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(())
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
[package]
|
||||
name = "sixtyfps-macros"
|
||||
name = "slint-macros"
|
||||
version = "0.2.0"
|
||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||
edition = "2021"
|
||||
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"
|
||||
homepage = "https://sixtyfps.io"
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
/*!
|
||||
|
||||
**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.
|
||||
You should use the `sixtyfps` crate instead.
|
||||
This crate should **not be used directly** by applications using Slint.
|
||||
You should use the `slint` crate instead.
|
||||
|
||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||
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
|
||||
/// 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.
|
||||
#[proc_macro]
|
||||
pub fn sixtyfps(stream: TokenStream) -> TokenStream {
|
||||
pub fn slint(stream: TokenStream) -> TokenStream {
|
||||
let token_iter = stream.into_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 =
|
||||
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.
|
||||
// It is in the target/xxx/build directory
|
||||
let target_path = match std::env::var_os("OUT_DIR") {
|
||||
|
@ -349,7 +349,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
|
|||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("SIXTYFPS_DEFAULT_STYLE.txt"),
|
||||
.join("SLINT_DEFAULT_STYLE.txt"),
|
||||
),
|
||||
None => {
|
||||
// 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| {
|
||||
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);});
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
[package]
|
||||
name = "sixtyfps"
|
||||
name = "slint"
|
||||
version = "0.2.0"
|
||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||
edition = "2021"
|
||||
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
|
||||
description = "SixtyFPS Rust API"
|
||||
description = "Slint Rust API"
|
||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||
homepage = "https://sixtyfps.io"
|
||||
categories = ["gui", "rendering::engine"]
|
||||
|
@ -48,16 +48,16 @@ wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]
|
|||
|
||||
|
||||
[dependencies]
|
||||
slint-core-internal = { version = "=0.2.0", path="../../internal/core", default-features = false }
|
||||
sixtyfps-macros = { version = "=0.2.0", path = "../rs/macros" }
|
||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||
slint-core-internal = { version = "=0.2.0", path="../../../internal/core", default-features = false }
|
||||
slint-macros = { version = "=0.2.0", path = "../macros" }
|
||||
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" }
|
||||
vtable = { version = "0.1.5", path = "../../helper_crates/vtable" }
|
||||
const-field-offset = { version = "0.1.2", path = "../../../helper_crates/const-field-offset" }
|
||||
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"] }
|
||||
pin-weak = { version = "1.1", default-features = false }
|
||||
document-features = { version = "0.1.0", path = "../../helper_crates/document-features" }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = [ "--html-in-header", "docs/resources/slint-docs-preview.html", "--html-in-header", "docs/resources/slint-docs-highlight.html" ]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# SixtyFPS-rs
|
||||
# Slint
|
||||
|
||||
[](https://crates.io/crates/sixtyfps)
|
||||
[](https://docs.rs/sixtyfps)
|
||||
|
||||
# A Rust UI toolkit
|
||||
|
||||
[SixtyFPS](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](https://sixtyfps.io/) is a UI toolkit that supports different programming languages.
|
||||
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/.
|
||||
|
||||
|
@ -22,13 +22,13 @@ In your `Cargo.toml` add:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
sixtyfps = "0.1.6"
|
||||
slint = "0.2.0"
|
||||
```
|
||||
|
||||
And in your `main.rs`:
|
||||
|
||||
```rust
|
||||
sixtyfps::sixtyfps!{
|
||||
slint::slint!{
|
||||
HelloWorld := Window {
|
||||
Text {
|
||||
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.
|
||||
|
||||
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
|
||||
cargo install cargo-generate
|
||||
|
|
|
@ -8,8 +8,8 @@ This should work:
|
|||
|
||||
```
|
||||
mod x {
|
||||
use sixtyfps::*;
|
||||
sixtyfps!{ Hello := Rectangle { } }
|
||||
use slint::*;
|
||||
slint!{ Hello := Rectangle { } }
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -17,8 +17,8 @@ But his not:
|
|||
|
||||
```compile_fail
|
||||
mod x {
|
||||
use sixtyfps::*;
|
||||
sixtyfps!{ Hello : = Rectangle { } }
|
||||
use slint::*;
|
||||
slint!{ Hello : = Rectangle { } }
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#![cfg(doc)]
|
||||
/*!
|
||||
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)
|
||||
of what is generated from the `.slint` file
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
// 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
|
||||
[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 already familiar with SixtyFPS, the following topics provide related information.
|
||||
If you are new to Slint, start with the [Walk-through tutorial](https://sixtyfps.io/docs/tutorial/rust).
|
||||
If you are already familiar with Slint, the following topics provide related information.
|
||||
|
||||
## 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:
|
||||
|
||||
```rust
|
||||
sixtyfps::sixtyfps!{
|
||||
slint::slint!{
|
||||
HelloWorld := Window {
|
||||
Text {
|
||||
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
|
||||
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
|
||||
[package]
|
||||
|
@ -68,25 +68,25 @@ build = "build.rs"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = "0.1.6"
|
||||
slint = "0.1.6"
|
||||
...
|
||||
|
||||
[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
|
||||
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`:
|
||||
|
||||
```ignore
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
fn main() {
|
||||
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
|
||||
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.
|
||||
|
||||
For example, if you have
|
||||
|
@ -198,7 +198,7 @@ The following struct would be generated:
|
|||
#[derive(Default, Clone, Debug, PartialEq)]
|
||||
struct MyStruct {
|
||||
foo : i32,
|
||||
bar: sixtyfps::SharedString,
|
||||
bar: slint::SharedString,
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -235,7 +235,7 @@ compile_error!(
|
|||
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::graphics::{
|
||||
|
@ -248,7 +248,7 @@ pub use slint_core_internal::sharedvector::SharedVector;
|
|||
pub use slint_core_internal::string::SharedString;
|
||||
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
|
||||
/// font.
|
||||
#[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)
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// font.
|
||||
#[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
|
||||
/// 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_rules! include_modules {
|
||||
() => {
|
||||
include!(env!("SIXTYFPS_INCLUDE_GENERATED"));
|
||||
include!(env!("SLINT_INCLUDE_GENERATED"));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ to the [`ModelNotify`] instance that you previously used in `attach_peer`:
|
|||
Old code:
|
||||
|
||||
```rust,ignore
|
||||
fn attach_peer(&self, peer: sixtyfps::ModelPeer) {
|
||||
fn attach_peer(&self, peer: slint::ModelPeer) {
|
||||
self.model_notify.attach_peer(peer);
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use ::sixtyfps::sixtyfps;
|
||||
use ::slint::slint;
|
||||
|
||||
#[test]
|
||||
fn simple_window() {
|
||||
sixtyfps!(X := Window{});
|
||||
slint!(X := Window{});
|
||||
X::new();
|
||||
}
|
||||
#[test]
|
||||
fn empty_stuff() {
|
||||
sixtyfps!();
|
||||
sixtyfps!(struct Hei := { abcd: bool });
|
||||
slint!();
|
||||
slint!(struct Hei := { abcd: bool });
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ name = "memory_tutorial_game_logic_in_rust"
|
|||
path = "main_game_logic_in_rust.rs"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../../../api/rs/slint" }
|
||||
slint = { path = "../../../../api/rs/slint" }
|
||||
rand = "0.8"
|
||||
|
|
|
@ -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.
|
||||
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`.
|
||||
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
|
||||
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.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
|
||||
let main_window = MainWindow::new();
|
||||
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
|||
|
||||
// ANCHOR: game_logic
|
||||
// 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());
|
||||
|
||||
let main_window_weak = main_window.as_weak();
|
||||
|
@ -40,7 +40,7 @@ fn main() {
|
|||
let main_window = main_window_weak.unwrap();
|
||||
main_window.set_disable_tiles(true);
|
||||
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);
|
||||
t1.image_visible = false;
|
||||
tiles_model.set_row_data(t1_idx, t1);
|
||||
|
@ -54,7 +54,8 @@ fn main() {
|
|||
main_window.run();
|
||||
// ANCHOR_END: game_logic
|
||||
}
|
||||
sixtyfps::sixtyfps! {
|
||||
|
||||
slint::slint! {
|
||||
struct TileData := {
|
||||
image: image,
|
||||
image_visible: bool,
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
fn main() {
|
||||
MainWindow::new().run();
|
||||
}
|
||||
sixtyfps::sixtyfps! {
|
||||
|
||||
slint::slint! {
|
||||
MainWindow := Window {
|
||||
Text {
|
||||
text: "hello world";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
fn main() {
|
||||
MainWindow::new().run();
|
||||
}
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
// ANCHOR: tile
|
||||
MemoryTile := Rectangle {
|
||||
width: 64px;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
fn main() {
|
||||
MainWindow::new().run();
|
||||
}
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
// ANCHOR: tile_data
|
||||
|
||||
// Added:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
fn main() {
|
||||
MainWindow::new().run();
|
||||
}
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
// ANCHOR: tile
|
||||
MemoryTile := Rectangle {
|
||||
callback clicked;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#[allow(dead_code)]
|
||||
// ANCHOR: tiles
|
||||
fn main() {
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
|
||||
let main_window = MainWindow::new();
|
||||
|
||||
|
@ -19,13 +19,14 @@ fn main() {
|
|||
tiles.shuffle(&mut rng);
|
||||
|
||||
// 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.run();
|
||||
}
|
||||
|
||||
// ANCHOR_END: tiles
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
struct TileData := {
|
||||
image: image,
|
||||
image_visible: bool,
|
||||
|
|
|
@ -14,5 +14,5 @@ path = "booker.rs"
|
|||
name = "booker"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
chrono = { version = "0.4", default-features = false, features = ["clock", "std"]}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
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() {
|
||||
let booker = Booker::new();
|
||||
|
|
|
@ -15,10 +15,10 @@ path = "main.rs"
|
|||
name = "gallery"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../api/rs/build" }
|
||||
slint-build = { path = "../../api/rs/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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
fn main() {
|
||||
sixtyfps_build::compile("gallery.slint").unwrap();
|
||||
slint_build::compile("gallery.slint").unwrap();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||
pub fn main() {
|
||||
|
|
|
@ -14,11 +14,11 @@ path = "main.rs"
|
|||
name = "imagefilter"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
image = { version = "0.23.12", default-features = false, features = [ "png" ] }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../api/rs/build" }
|
||||
slint-build = { path = "../../api/rs/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
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use sixtyfps::SharedString;
|
||||
use slint::SharedString;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
import { Slider, HorizontalBox, VerticalBox, GroupBox, ComboBox } from "std-widgets.slint";
|
||||
|
||||
export MainWindow := Window {
|
||||
|
@ -57,7 +57,7 @@ struct Filter {
|
|||
|
||||
struct Filters(Vec<Filter>);
|
||||
|
||||
impl sixtyfps::Model for Filters {
|
||||
impl slint::Model for Filters {
|
||||
type Data = SharedString;
|
||||
|
||||
fn row_count(&self) -> usize {
|
||||
|
@ -68,7 +68,7 @@ impl sixtyfps::Model for Filters {
|
|||
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()
|
||||
};
|
||||
|
||||
main_window.set_original_image(sixtyfps::Image::from_rgba8(
|
||||
sixtyfps::SharedPixelBuffer::clone_from_slice(
|
||||
main_window.set_original_image(slint::Image::from_rgba8(
|
||||
slint::SharedPixelBuffer::clone_from_slice(
|
||||
source_image.as_raw(),
|
||||
source_image.width(),
|
||||
source_image.height(),
|
||||
|
@ -140,12 +140,12 @@ pub fn main() {
|
|||
]);
|
||||
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| {
|
||||
let filter_fn = filters.0[filter_index as usize].apply_function;
|
||||
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.width(),
|
||||
filtered_image.height(),
|
||||
|
|
|
@ -15,10 +15,10 @@ name = "memory"
|
|||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../api/rs/build" }
|
||||
slint-build = { path = "../../api/rs/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
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// 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::time::Duration;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::slint! {
|
||||
import { MainWindow } from "memory.slint";
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ path = "main.rs"
|
|||
name = "plotter"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
plotters = { version = "0.3.1", default-features = false, features = ["bitmap_backend", "surface_series"] }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../api/rs/build" }
|
||||
slint-build = { path = "../../api/rs/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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use plotters::prelude::*;
|
||||
use sixtyfps::SharedPixelBuffer;
|
||||
use slint::SharedPixelBuffer;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -10,7 +10,7 @@ use wasm_bindgen::prelude::*;
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
mod wasm_backend;
|
||||
|
||||
sixtyfps::sixtyfps! {
|
||||
slint::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()
|
||||
}
|
||||
|
||||
fn render_plot(pitch: f32) -> sixtyfps::Image {
|
||||
fn render_plot(pitch: f32) -> slint::Image {
|
||||
let mut pixel_buffer = SharedPixelBuffer::new(640, 480);
|
||||
let size = (pixel_buffer.width(), pixel_buffer.height());
|
||||
|
||||
|
@ -66,7 +66,7 @@ fn render_plot(pitch: f32) -> sixtyfps::Image {
|
|||
drop(chart);
|
||||
drop(root);
|
||||
|
||||
sixtyfps::Image::from_rgb8(pixel_buffer)
|
||||
slint::Image::from_rgb8(pixel_buffer)
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||
|
|
|
@ -15,11 +15,12 @@ path = "main.rs"
|
|||
name = "printerdemo"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../../api/rs/slint" }
|
||||
slint = { path = "../../../api/rs/slint" }
|
||||
|
||||
chrono = { version = "0.4", default-features = false, features = ["clock", "std"]}
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../../api/rs/build" }
|
||||
slint-build = { path = "../../../api/rs/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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
fn main() {
|
||||
sixtyfps_build::compile("../ui/printerdemo.slint").unwrap();
|
||||
slint_build::compile("../ui/printerdemo.slint").unwrap();
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
use std::rc::Rc;
|
||||
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
|
||||
/// Returns the current time formated as a string
|
||||
fn current_time() -> sixtyfps::SharedString {
|
||||
fn current_time() -> slint::SharedString {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
return chrono::Local::now().format("%H:%M:%S %d/%m/%Y").to_string().into();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
@ -18,12 +18,12 @@ fn current_time() -> sixtyfps::SharedString {
|
|||
}
|
||||
|
||||
struct PrinterQueueData {
|
||||
data: Rc<sixtyfps::VecModel<PrinterQueueItem>>,
|
||||
print_progress_timer: sixtyfps::Timer,
|
||||
data: Rc<slint::VecModel<PrinterQueueItem>>,
|
||||
print_progress_timer: slint::Timer,
|
||||
}
|
||||
|
||||
impl PrinterQueueData {
|
||||
fn push_job(&self, title: sixtyfps::SharedString) {
|
||||
fn push_job(&self, title: slint::SharedString) {
|
||||
self.data.push(PrinterQueueItem {
|
||||
status: "WAITING...".into(),
|
||||
progress: 0,
|
||||
|
@ -44,17 +44,17 @@ pub fn main() {
|
|||
console_error_panic_hook::set_once();
|
||||
|
||||
let main_window = MainWindow::new();
|
||||
main_window.set_ink_levels(sixtyfps::VecModel::from_slice(&[
|
||||
InkLevel { color: sixtyfps::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: sixtyfps::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
|
||||
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
|
||||
main_window.set_ink_levels(slint::VecModel::from_slice(&[
|
||||
InkLevel { color: slint::Color::from_rgb_u8(0, 255, 255), level: 0.40 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(255, 0, 255), level: 0.20 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
|
||||
]));
|
||||
|
||||
let default_queue: Vec<PrinterQueueItem> =
|
||||
main_window.global::<PrinterQueue>().get_printer_queue().iter().collect();
|
||||
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(),
|
||||
});
|
||||
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);
|
||||
printer_queue.print_progress_timer.start(
|
||||
sixtyfps::TimerMode::Repeated,
|
||||
slint::TimerMode::Repeated,
|
||||
std::time::Duration::from_secs(1),
|
||||
move || {
|
||||
if let Some(printer_queue) = printer_queue_weak.upgrade() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
// import "sixtyfps";
|
||||
// import "slint";
|
||||
require("slint");
|
||||
// import * as demo from "../ui/printerdemo.slint";
|
||||
let demo = require("../ui/printerdemo.slint");
|
||||
|
|
|
@ -15,10 +15,10 @@ path = "main.rs"
|
|||
name = "printerdemo_old"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../../api/rs/slint" }
|
||||
slint = { path = "../../../api/rs/slint" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../../api/rs/build" }
|
||||
slint-build = { path = "../../../api/rs/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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
fn main() {
|
||||
sixtyfps_build::compile("../ui/printerdemo.slint").unwrap();
|
||||
slint_build::compile("../ui/printerdemo.slint").unwrap();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||
pub fn main() {
|
||||
|
@ -14,11 +14,11 @@ pub fn main() {
|
|||
console_error_panic_hook::set_once();
|
||||
|
||||
let main_window = MainWindow::new();
|
||||
main_window.set_ink_levels(sixtyfps::VecModel::from_slice(&[
|
||||
InkLevel { color: sixtyfps::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: sixtyfps::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
|
||||
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
|
||||
main_window.set_ink_levels(slint::VecModel::from_slice(&[
|
||||
InkLevel { color: slint::Color::from_rgb_u8(0, 255, 255), level: 0.40 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(255, 0, 255), level: 0.20 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(255, 255, 0), level: 0.50 },
|
||||
InkLevel { color: slint::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
|
||||
]));
|
||||
|
||||
let main_weak = main_window.as_weak();
|
||||
|
@ -34,7 +34,7 @@ pub fn main() {
|
|||
let main_window = main_weak.upgrade().unwrap();
|
||||
let fax_number = main_window.get_fax_number().to_string();
|
||||
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 || {
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
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.
|
||||
|
|
|
@ -15,10 +15,10 @@ name = "slide_puzzle"
|
|||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
sixtyfps = { path = "../../api/rs/slint" }
|
||||
slint = { path = "../../api/rs/slint" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../api/rs/build" }
|
||||
slint-build = { path = "../../api/rs/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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
fn main() {
|
||||
sixtyfps_build::compile("slide_puzzle.slint").unwrap();
|
||||
slint_build::compile("slide_puzzle.slint").unwrap();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
|
||||
fn shuffle() -> Vec<i8> {
|
||||
fn is_solvable(positions: &[i8]) -> bool {
|
||||
|
@ -36,13 +36,13 @@ fn shuffle() -> Vec<i8> {
|
|||
}
|
||||
|
||||
struct AppState {
|
||||
pieces: Rc<sixtyfps::VecModel<Piece>>,
|
||||
main_window: sixtyfps::Weak<MainWindow>,
|
||||
pieces: Rc<slint::VecModel<Piece>>,
|
||||
main_window: slint::Weak<MainWindow>,
|
||||
/// An array of 16 values which represent a 4x4 matrix containing the piece number in that
|
||||
/// position. -1 is no piece.
|
||||
positions: Vec<i8>,
|
||||
auto_play_timer: sixtyfps::Timer,
|
||||
kick_animation_timer: sixtyfps::Timer,
|
||||
auto_play_timer: slint::Timer,
|
||||
kick_animation_timer: slint::Timer,
|
||||
/// The speed in the x and y direction for the associated tile
|
||||
speed_for_kick_animation: [(f32, f32); 15],
|
||||
finished: bool,
|
||||
|
@ -171,7 +171,7 @@ pub fn main() {
|
|||
|
||||
let main_window = MainWindow::new();
|
||||
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(),
|
||||
positions: vec![],
|
||||
auto_play_timer: Default::default(),
|
||||
|
@ -192,7 +192,7 @@ pub fn main() {
|
|||
if !state_copy.borrow_mut().piece_clicked(p as i8) {
|
||||
let state_weak = Rc::downgrade(&state_copy);
|
||||
state_copy.borrow().kick_animation_timer.start(
|
||||
sixtyfps::TimerMode::Repeated,
|
||||
slint::TimerMode::Repeated,
|
||||
std::time::Duration::from_millis(16),
|
||||
move || {
|
||||
if let Some(state) = state_weak.upgrade() {
|
||||
|
@ -215,7 +215,7 @@ pub fn main() {
|
|||
if enabled {
|
||||
let state_weak = Rc::downgrade(&state_copy);
|
||||
state_copy.borrow().auto_play_timer.start(
|
||||
sixtyfps::TimerMode::Repeated,
|
||||
slint::TimerMode::Repeated,
|
||||
std::time::Duration::from_millis(200),
|
||||
move || {
|
||||
if let Some(state) = state_weak.upgrade() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
// import "sixtyfps";
|
||||
// import "slint";
|
||||
let slint = require("slint");
|
||||
// import * as demo from "../ui/todo.slint";
|
||||
let demo = require("../ui/todo.slint");
|
||||
|
|
|
@ -15,10 +15,10 @@ path = "main.rs"
|
|||
name = "todo"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../../api/rs/slint" }
|
||||
slint = { path = "../../../api/rs/slint" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-build = { path = "../../../api/rs/build" }
|
||||
slint-build = { path = "../../../api/rs/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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
fn main() {
|
||||
sixtyfps_build::compile("../ui/todo.slint").unwrap();
|
||||
slint_build::compile("../ui/todo.slint").unwrap();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
sixtyfps::include_modules!();
|
||||
slint::include_modules!();
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||
pub fn main() {
|
||||
|
@ -16,7 +16,7 @@ pub fn main() {
|
|||
#[cfg(all(debug_assertions, target_arch = "wasm32"))]
|
||||
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: "Do the Rust part".into() },
|
||||
TodoItem { checked: false, title: "Make the C++ code".into() },
|
||||
|
|
|
@ -156,7 +156,7 @@ cpp! {{
|
|||
QCoreApplication::setAttribute(Qt::AA_PluginApplication, true);
|
||||
}
|
||||
static int argc = 1;
|
||||
static char argv[] = "sixtyfps";
|
||||
static char argv[] = "Slint";
|
||||
static char *argv2[] = { argv };
|
||||
// Leak the QApplication, otherwise it crashes on exit
|
||||
// (because the QGuiApplication destructor access some Q_GLOBAL_STATIC which are already gone)
|
||||
|
|
|
@ -16,8 +16,8 @@ fn main() {
|
|||
// 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
|
||||
// Qt availability
|
||||
// 4a. When using the sixtyfps-build crate from a build script, it will be able to read this file
|
||||
// from `sixtyfps_build::compile_with_config`
|
||||
// 4a. When using the slint-build crate from a build script, it will be able to read this file
|
||||
// from `slint_build::compile_with_config`
|
||||
// 4b. Same when using the `sixtyfps!` macro,
|
||||
|
||||
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
|
||||
// and we want to write to a common directory, so write in the build/ dir
|
||||
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" })
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ WindowItem := _ {
|
|||
property <length> height: native_output;
|
||||
property <color> background; // StyleMetrics.window_background set in apply_default_properties_from_style
|
||||
property <color> color <=> background;
|
||||
property <string> title: "SixtyFPS Window";
|
||||
property <string> title: "Slint Window";
|
||||
property <bool> no-frame;
|
||||
property <string> default-font-family;
|
||||
property <length> default-font-size;
|
||||
|
@ -268,7 +268,7 @@ MoveTo := _ {
|
|||
property <float> x;
|
||||
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
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ LineTo := _ {
|
|||
property <float> x;
|
||||
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
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ ArcTo := _ {
|
|||
property <bool> large_arc;
|
||||
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
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ CubicTo := _ {
|
|||
property <float> x;
|
||||
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
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
@ -315,13 +315,13 @@ QuadraticTo := _ {
|
|||
property <float> x;
|
||||
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
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
Close := _ {
|
||||
//-rust_type_constructor:sixtyfps::re_exports::PathElement::Close
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::Close
|
||||
//-cpp_type:slint::private_api::PathClose
|
||||
//-is_non_item_type
|
||||
//-is_non_item_type
|
||||
|
|
|
@ -38,8 +38,8 @@ fn ident(ident: &str) -> proc_macro2::Ident {
|
|||
impl quote::ToTokens for Orientation {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let tks = match self {
|
||||
Orientation::Horizontal => quote!(sixtyfps::re_exports::Orientation::Horizontal),
|
||||
Orientation::Vertical => quote!(sixtyfps::re_exports::Orientation::Vertical),
|
||||
Orientation::Horizontal => quote!(slint::re_exports::Orientation::Horizontal),
|
||||
Orientation::Vertical => quote!(slint::re_exports::Orientation::Vertical),
|
||||
};
|
||||
tokens.extend(tks);
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ impl quote::ToTokens for crate::embedded_resources::PixelFormat {
|
|||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
use crate::embedded_resources::PixelFormat::*;
|
||||
let tks = match self {
|
||||
Rgb => quote!(sixtyfps::re_exports::PixelFormat::Rgb),
|
||||
Rgba => quote!(sixtyfps::re_exports::PixelFormat::Rgba),
|
||||
AlphaMap(_) => quote!(sixtyfps::re_exports::PixelFormat::AlphaMap),
|
||||
Rgb => quote!(slint::re_exports::PixelFormat::Rgb),
|
||||
Rgba => quote!(slint::re_exports::PixelFormat::Rgba),
|
||||
AlphaMap(_) => quote!(slint::re_exports::PixelFormat::AlphaMap),
|
||||
};
|
||||
tokens.extend(tks);
|
||||
}
|
||||
|
@ -61,15 +61,15 @@ fn rust_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
|
|||
match ty {
|
||||
Type::Int32 => Some(quote!(i32)),
|
||||
Type::Float32 => Some(quote!(f32)),
|
||||
Type::String => Some(quote!(sixtyfps::re_exports::SharedString)),
|
||||
Type::Color => Some(quote!(sixtyfps::re_exports::Color)),
|
||||
Type::String => Some(quote!(slint::re_exports::SharedString)),
|
||||
Type::Color => Some(quote!(slint::re_exports::Color)),
|
||||
Type::Duration => Some(quote!(i64)),
|
||||
Type::Angle => Some(quote!(f32)),
|
||||
Type::PhysicalLength => Some(quote!(f32)),
|
||||
Type::LogicalLength => Some(quote!(f32)),
|
||||
Type::Percent => Some(quote!(f32)),
|
||||
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, .. } => {
|
||||
let elem = fields.values().map(rust_type).collect::<Option<Vec<_>>>()?;
|
||||
// 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::Array(o) => {
|
||||
let inner = rust_type(o)?;
|
||||
Some(quote!(sixtyfps::re_exports::ModelRc<#inner>))
|
||||
Some(quote!(slint::re_exports::ModelRc<#inner>))
|
||||
}
|
||||
Type::Enumeration(e) => {
|
||||
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>)),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ pub fn generate(doc: &Document) -> TokenStream {
|
|||
|
||||
let compo = generate_public_component(&llr);
|
||||
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!(
|
||||
"VersionCheck_{}_{}_{}",
|
||||
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} }) => {
|
||||
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 {
|
||||
quote!(sixtyfps::re_exports::Color::from_rgb_u8(#r, #g, #b))
|
||||
quote!(slint::re_exports::Color::from_rgb_u8(#r, #g, #b))
|
||||
} else {
|
||||
quote!(sixtyfps::re_exports::Color::from_argb_encoded(0))
|
||||
quote!(slint::re_exports::Color::from_argb_encoded(0))
|
||||
};
|
||||
quote!(
|
||||
const #symbol: sixtyfps::re_exports::ImageInner = sixtyfps::re_exports::ImageInner::StaticTextures {
|
||||
size: sixtyfps::re_exports::IntSize::new(#width as _, #height as _),
|
||||
const #symbol: slint::re_exports::ImageInner = slint::re_exports::ImageInner::StaticTextures {
|
||||
size: slint::re_exports::IntSize::new(#width as _, #height as _),
|
||||
data: Slice::from_slice(&[#(#data),*]),
|
||||
textures: Slice::from_slice(&[
|
||||
sixtyfps::re_exports::StaticTexture {
|
||||
rect: sixtyfps::re_exports::euclid::rect(#r_x as _, #r_y as _, #r_w as _, #r_h as _),
|
||||
slint::re_exports::StaticTexture {
|
||||
rect: slint::re_exports::euclid::rect(#r_x as _, #r_y as _, #r_w as _, #r_h as _),
|
||||
format: #format,
|
||||
color: #color,
|
||||
index: 0,
|
||||
|
@ -182,16 +182,16 @@ pub fn generate(doc: &Document) -> TokenStream {
|
|||
#[allow(clippy::erasing_op)]
|
||||
#[allow(clippy::approx_constant)] // We may get those from .slint inputs!
|
||||
mod #compo_module {
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
#(#structs)*
|
||||
#(#globals)*
|
||||
#(#sub_compos)*
|
||||
#compo
|
||||
#(#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 sixtyfps::{ComponentHandle, Global};
|
||||
pub use slint::{ComponentHandle, Global};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
|
||||
quote!(
|
||||
#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 {
|
||||
pub fn new() -> Self {
|
||||
|
@ -231,29 +231,29 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
#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 {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl sixtyfps::ComponentHandle for #public_component_id {
|
||||
impl slint::ComponentHandle for #public_component_id {
|
||||
type Inner = #inner_component_id;
|
||||
fn as_weak(&self) -> sixtyfps::Weak<Self> {
|
||||
sixtyfps::Weak::new(&self.0)
|
||||
fn as_weak(&self) -> slint::Weak<Self> {
|
||||
slint::Weak::new(&self.0)
|
||||
}
|
||||
|
||||
fn clone_strong(&self) -> Self {
|
||||
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)
|
||||
}
|
||||
|
||||
fn run(&self) {
|
||||
self.show();
|
||||
sixtyfps::run_event_loop();
|
||||
slint::run_event_loop();
|
||||
self.hide();
|
||||
}
|
||||
|
||||
|
@ -265,17 +265,17 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
|
|||
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()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
fn default() -> Self {
|
||||
|
@ -321,7 +321,7 @@ fn handle_property_init(
|
|||
let tokens_for_expression = compile_expression(&binding_expression.expression, &ctx2);
|
||||
init.push(quote!({
|
||||
#[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| {
|
||||
#init_self_pin_ref
|
||||
(#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"));
|
||||
if is_state_info {
|
||||
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 {
|
||||
match &binding_expression.animation {
|
||||
|
@ -365,13 +365,13 @@ fn handle_property_init(
|
|||
let anim = compile_expression(anim, ctx);
|
||||
quote! { {
|
||||
#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)) => {
|
||||
let anim = compile_expression(anim, ctx);
|
||||
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| {
|
||||
#init_self_pin_ref
|
||||
#anim
|
||||
|
@ -381,7 +381,7 @@ fn handle_property_init(
|
|||
}
|
||||
None => {
|
||||
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)]
|
||||
pub fn #getter_ident(&self) -> #rust_property_type {
|
||||
#[allow(unused_imports)]
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
let _self = #self_init;
|
||||
#prop.get()
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ fn public_api(
|
|||
#[allow(dead_code)]
|
||||
pub fn #setter_ident(&self, value: #rust_property_type) {
|
||||
#[allow(unused_imports)]
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
let _self = #self_init;
|
||||
#set_value
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ fn generate_sub_component(
|
|||
}
|
||||
item_names.push(ident(&item.name));
|
||||
item_types.push(ident(&item.ty.class_name));
|
||||
#[cfg(sixtyfps_debug_property)]
|
||||
#[cfg(slint_debug_property)]
|
||||
for (prop, info) in &item.ty.properties {
|
||||
if info.ty.is_property_type() && !prop.starts_with("viewport") && prop != "commands" {
|
||||
let name = format!("{}::{}.{}", component.name, item.name, prop);
|
||||
|
@ -536,12 +536,12 @@ fn generate_sub_component(
|
|||
|
||||
let mut model = compile_expression(&repeated.model, &ctx);
|
||||
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! {
|
||||
_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 || {
|
||||
let self_rc = self_weak.upgrade().unwrap();
|
||||
let _self = self_rc.as_pin_ref();
|
||||
|
@ -625,7 +625,7 @@ fn generate_sub_component(
|
|||
sub_component_types.push(sub_component_id);
|
||||
}
|
||||
|
||||
#[cfg(sixtyfps_debug_property)]
|
||||
#[cfg(slint_debug_property)]
|
||||
builder.init.push(quote!(
|
||||
#(self_rc.#declared_property_vars.debug_name.replace(
|
||||
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_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)));
|
||||
|
@ -664,30 +664,30 @@ fn generate_sub_component(
|
|||
core::ptr::eq(&root.item_tree.root as *const _, component as *const _).then(|| quote!(pub));
|
||||
|
||||
quote!(
|
||||
#[derive(sixtyfps::re_exports::FieldOffsets, Default)]
|
||||
#[const_field_offset(sixtyfps::re_exports::const_field_offset)]
|
||||
#[derive(slint::re_exports::FieldOffsets, Default)]
|
||||
#[const_field_offset(slint::re_exports::const_field_offset)]
|
||||
#[repr(C)]
|
||||
#[pin]
|
||||
#visibility
|
||||
struct #inner_component_id {
|
||||
#(#item_names : sixtyfps::re_exports::#item_types,)*
|
||||
#(#item_names : slint::re_exports::#item_types,)*
|
||||
#(#sub_component_names : #sub_component_types,)*
|
||||
#(#declared_property_vars : sixtyfps::re_exports::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks : sixtyfps::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
#(#repeated_element_names : sixtyfps::re_exports::Repeater<#repeated_element_components>,)*
|
||||
self_weak : sixtyfps::re_exports::OnceCell<sixtyfps::re_exports::VWeakMapped<sixtyfps::re_exports::ComponentVTable, #inner_component_id>>,
|
||||
#(#declared_property_vars : slint::re_exports::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks : slint::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
#(#repeated_element_names : slint::re_exports::Repeater<#repeated_element_components>,)*
|
||||
self_weak : slint::re_exports::OnceCell<slint::re_exports::VWeakMapped<slint::re_exports::ComponentVTable, #inner_component_id>>,
|
||||
#(parent : #parent_component_type,)*
|
||||
// FIXME: Do we really need a window all the time?
|
||||
window: sixtyfps::re_exports::OnceCell<sixtyfps::Window>,
|
||||
root : sixtyfps::re_exports::OnceCell<sixtyfps::re_exports::VWeak<sixtyfps::re_exports::ComponentVTable, #root_component_id>>,
|
||||
window: slint::re_exports::OnceCell<slint::Window>,
|
||||
root : slint::re_exports::OnceCell<slint::re_exports::VWeak<slint::re_exports::ComponentVTable, #root_component_id>>,
|
||||
tree_index: ::core::cell::Cell<u32>,
|
||||
tree_index_of_first_child: ::core::cell::Cell<u32>,
|
||||
#extra_fields
|
||||
}
|
||||
|
||||
impl #inner_component_id {
|
||||
pub fn init(self_rc: sixtyfps::re_exports::VRcMapped<sixtyfps::re_exports::ComponentVTable, Self>,
|
||||
root : &sixtyfps::re_exports::VRc<sixtyfps::re_exports::ComponentVTable, #root_component_id>,
|
||||
pub fn init(self_rc: slint::re_exports::VRcMapped<slint::re_exports::ComponentVTable, Self>,
|
||||
root : &slint::re_exports::VRc<slint::re_exports::ComponentVTable, #root_component_id>,
|
||||
tree_index: u32, tree_index_of_first_child: u32) {
|
||||
#![allow(unused)]
|
||||
let _self = self_rc.as_pin_ref();
|
||||
|
@ -702,11 +702,11 @@ fn generate_sub_component(
|
|||
fn visit_dynamic_children(
|
||||
self: ::core::pin::Pin<&Self>,
|
||||
dyn_index: usize,
|
||||
order: sixtyfps::re_exports::TraversalOrder,
|
||||
visitor: sixtyfps::re_exports::ItemVisitorRefMut
|
||||
) -> sixtyfps::re_exports::VisitChildrenResult {
|
||||
order: slint::re_exports::TraversalOrder,
|
||||
visitor: slint::re_exports::ItemVisitorRefMut
|
||||
) -> slint::re_exports::VisitChildrenResult {
|
||||
#![allow(unused)]
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
let _self = self;
|
||||
match dyn_index {
|
||||
#(#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)]
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
let _self = self;
|
||||
match orientation {
|
||||
sixtyfps::re_exports::Orientation::Horizontal => #layout_info_h,
|
||||
sixtyfps::re_exports::Orientation::Vertical => #layout_info_v,
|
||||
slint::re_exports::Orientation::Horizontal => #layout_info_h,
|
||||
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));
|
||||
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> {
|
||||
#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>;)*
|
||||
|
||||
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 {
|
||||
Self(&component.0 .globals.#global_id)
|
||||
}
|
||||
|
@ -809,18 +809,18 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
|
|||
});
|
||||
|
||||
quote!(
|
||||
#[derive(sixtyfps::re_exports::FieldOffsets, Default)]
|
||||
#[const_field_offset(sixtyfps::re_exports::const_field_offset)]
|
||||
#[derive(slint::re_exports::FieldOffsets, Default)]
|
||||
#[const_field_offset(slint::re_exports::const_field_offset)]
|
||||
#[repr(C)]
|
||||
#[pin]
|
||||
struct #inner_component_id {
|
||||
#(#declared_property_vars: sixtyfps::re_exports::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks: sixtyfps::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
#(#declared_property_vars: slint::re_exports::Property<#declared_property_types>,)*
|
||||
#(#declared_callbacks: slint::re_exports::Callback<(#(#declared_callbacks_types,)*), #declared_callbacks_ret>,)*
|
||||
}
|
||||
|
||||
impl #inner_component_id {
|
||||
fn new() -> ::core::pin::Pin<sixtyfps::re_exports::Rc<Self>> {
|
||||
let self_rc = sixtyfps::re_exports::Rc::pin(Self::default());
|
||||
fn new() -> ::core::pin::Pin<slint::re_exports::Rc<Self>> {
|
||||
let self_rc = slint::re_exports::Rc::pin(Self::default());
|
||||
let _self = self_rc.as_ref();
|
||||
#(#init)*
|
||||
self_rc
|
||||
|
@ -841,7 +841,7 @@ fn generate_item_tree(
|
|||
let inner_component_id = self::inner_component_id(&sub_tree.root);
|
||||
let parent_component_type = parent_ctx.iter().map(|parent| {
|
||||
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<_>>();
|
||||
let root_token = if parent_ctx.is_some() {
|
||||
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(|| {
|
||||
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()));
|
||||
)
|
||||
});
|
||||
|
@ -874,7 +874,7 @@ fn generate_item_tree(
|
|||
sub_component = &sub_component.sub_components[*i].ty;
|
||||
}
|
||||
item_tree_array.push(quote!(
|
||||
sixtyfps::re_exports::ItemTreeNode::DynamicTree {
|
||||
slint::re_exports::ItemTreeNode::DynamicTree {
|
||||
index: #repeater_index,
|
||||
parent_index: #parent_index,
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ fn generate_item_tree(
|
|||
let item = &component.items[node.item_index];
|
||||
let flick = item
|
||||
.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(
|
||||
&self::inner_component_id(component),
|
||||
|
@ -893,7 +893,7 @@ fn generate_item_tree(
|
|||
let children_count = node.children.len() as u32;
|
||||
let children_index = children_offset as u32;
|
||||
item_tree_array.push(quote!(
|
||||
sixtyfps::re_exports::ItemTreeNode::Item{
|
||||
slint::re_exports::ItemTreeNode::Item{
|
||||
item: VOffset::new(#path #field #flick),
|
||||
children_count: #children_count,
|
||||
children_index: #children_index,
|
||||
|
@ -910,51 +910,51 @@ fn generate_item_tree(
|
|||
|
||||
impl #inner_component_id {
|
||||
pub fn new(#(parent: #parent_component_type)*)
|
||||
-> vtable::VRc<sixtyfps::re_exports::ComponentVTable, Self>
|
||||
-> vtable::VRc<slint::re_exports::ComponentVTable, Self>
|
||||
{
|
||||
#![allow(unused)]
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
let mut _self = Self::default();
|
||||
#(_self.parent = parent.clone() as #parent_component_type;)*
|
||||
let self_rc = VRc::new(_self);
|
||||
let _self = self_rc.as_pin_ref();
|
||||
#maybe_create_window;
|
||||
sixtyfps::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);
|
||||
slint::re_exports::init_component_items(_self, Self::item_tree(), #root_token.window.get().unwrap().window_handle());
|
||||
Self::init(slint::re_exports::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1);
|
||||
self_rc
|
||||
}
|
||||
|
||||
fn item_tree() -> &'static [sixtyfps::re_exports::ItemTreeNode<Self>] {
|
||||
use sixtyfps::re_exports::*;
|
||||
fn item_tree() -> &'static [slint::re_exports::ItemTreeNode<Self>] {
|
||||
use slint::re_exports::*;
|
||||
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
|
||||
static ITEM_TREE : sixtyfps::re_exports::OnceBox<
|
||||
[sixtyfps::re_exports::ItemTreeNode<#inner_component_id>; #item_tree_array_len]
|
||||
> = sixtyfps::re_exports::OnceBox::new();
|
||||
static ITEM_TREE : slint::re_exports::OnceBox<
|
||||
[slint::re_exports::ItemTreeNode<#inner_component_id>; #item_tree_array_len]
|
||||
> = slint::re_exports::OnceBox::new();
|
||||
&*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>) {
|
||||
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 {
|
||||
fn window_handle(&self) -> &sixtyfps::re_exports::Rc<sixtyfps::re_exports::Window> {
|
||||
impl slint::re_exports::WindowHandleAccess for #inner_component_id {
|
||||
fn window_handle(&self) -> &slint::re_exports::Rc<slint::re_exports::Window> {
|
||||
self.window.get().unwrap().window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
impl sixtyfps::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)
|
||||
-> sixtyfps::re_exports::VisitChildrenResult
|
||||
impl slint::re_exports::Component for #inner_component_id {
|
||||
fn visit_children_item(self: ::core::pin::Pin<&Self>, index: isize, order: slint::re_exports::TraversalOrder, visitor: slint::re_exports::ItemVisitorRefMut)
|
||||
-> slint::re_exports::VisitChildrenResult
|
||||
{
|
||||
use sixtyfps::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);
|
||||
use slint::re_exports::*;
|
||||
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)]
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -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 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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -1020,9 +1020,9 @@ fn generate_repeated_component(
|
|||
fn listview_layout(
|
||||
self: core::pin::Pin<&Self>,
|
||||
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 vp_w = viewport_width.get();
|
||||
#p_y.set(*offset_y);
|
||||
|
@ -1036,10 +1036,10 @@ fn generate_repeated_component(
|
|||
} else {
|
||||
// TODO: we could generate this code only if we know that this component is in a box layout
|
||||
quote! {
|
||||
fn box_layout_data(self: ::core::pin::Pin<&Self>, o: sixtyfps::re_exports::Orientation)
|
||||
-> sixtyfps::re_exports::BoxLayoutCellData
|
||||
fn box_layout_data(self: ::core::pin::Pin<&Self>, o: slint::re_exports::Orientation)
|
||||
-> slint::re_exports::BoxLayoutCellData
|
||||
{
|
||||
use sixtyfps::re_exports::*;
|
||||
use slint::re_exports::*;
|
||||
BoxLayoutCellData { constraint: self.as_ref().layout_info(o) }
|
||||
}
|
||||
}
|
||||
|
@ -1063,7 +1063,7 @@ fn generate_repeated_component(
|
|||
quote!(
|
||||
#component
|
||||
|
||||
impl sixtyfps::re_exports::RepeatedComponent for #inner_component_id {
|
||||
impl slint::re_exports::RepeatedComponent for #inner_component_id {
|
||||
type Data = #data_type;
|
||||
fn update(&self, _index: usize, _data: Self::Data) {
|
||||
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 flick = sub_component.items[item_index]
|
||||
.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))
|
||||
}
|
||||
}
|
||||
|
@ -1261,25 +1261,25 @@ fn access_item_rc(pr: &llr::PropertyReference, ctx: &EvaluationContext) -> Token
|
|||
|
||||
fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream {
|
||||
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::BoolLiteral(b) => quote!(#b),
|
||||
Expression::Cast { from, to } => {
|
||||
let f = compile_expression(&*from, ctx);
|
||||
match (from.ty(ctx), to) {
|
||||
(from, Type::String) if from.as_unit_product().is_some() => {
|
||||
quote!(sixtyfps::re_exports::SharedString::from(
|
||||
sixtyfps::re_exports::format!("{}", #f).as_str()
|
||||
quote!(slint::re_exports::SharedString::from(
|
||||
slint::re_exports::format!("{}", #f).as_str()
|
||||
))
|
||||
}
|
||||
(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) => {
|
||||
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) => {
|
||||
quote!(sixtyfps::Brush::SolidColor(#f))
|
||||
quote!(slint::Brush::SolidColor(#f))
|
||||
}
|
||||
(Type::Brush, Type::Color) => {
|
||||
quote!(#f.color())
|
||||
|
@ -1324,7 +1324,7 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
|
|||
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)
|
||||
if matches!(
|
||||
|
@ -1341,10 +1341,10 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
|
|||
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) => {
|
||||
quote!(sixtyfps::re_exports::PathData::Commands(#f))
|
||||
quote!(slint::re_exports::PathData::Commands(#f))
|
||||
}
|
||||
_ => f,
|
||||
}
|
||||
|
@ -1499,24 +1499,24 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
|
|||
}
|
||||
Expression::ImageReference { resource_ref, .. } => match resource_ref {
|
||||
crate::expression_tree::ImageReference::None => {
|
||||
quote!(sixtyfps::re_exports::Image::default())
|
||||
quote!(slint::re_exports::Image::default())
|
||||
}
|
||||
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 } => {
|
||||
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
|
||||
let format = proc_macro2::Literal::byte_string(extension.as_bytes());
|
||||
quote!(
|
||||
sixtyfps::re_exports::Image::from(
|
||||
sixtyfps::re_exports::ImageInner::EmbeddedData{ data: #symbol.into(), format: Slice::from_slice(#format) }
|
||||
slint::re_exports::Image::from(
|
||||
slint::re_exports::ImageInner::EmbeddedData{ data: #symbol.into(), format: Slice::from_slice(#format) }
|
||||
)
|
||||
)
|
||||
}
|
||||
crate::expression_tree::ImageReference::EmbeddedTexture { resource_id } => {
|
||||
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
|
||||
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));
|
||||
if *as_model {
|
||||
let rust_element_ty = rust_type(element_ty).unwrap();
|
||||
quote!(sixtyfps::re_exports::ModelRc::new(
|
||||
sixtyfps::re_exports::VecModel::<#rust_element_ty>::from(
|
||||
sixtyfps::re_exports::vec![#(#val as _),*]
|
||||
quote!(slint::re_exports::ModelRc::new(
|
||||
slint::re_exports::VecModel::<#rust_element_ty>::from(
|
||||
slint::re_exports::vec![#(#val as _),*]
|
||||
)
|
||||
))
|
||||
} else {
|
||||
|
@ -1585,26 +1585,26 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
|
|||
quote!(#name)
|
||||
}
|
||||
Expression::EasingCurve(EasingCurve::Linear) => {
|
||||
quote!(sixtyfps::re_exports::EasingCurve::Linear)
|
||||
quote!(slint::re_exports::EasingCurve::Linear)
|
||||
}
|
||||
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 } => {
|
||||
let angle = compile_expression(angle, ctx);
|
||||
let stops = stops.iter().map(|(color, stop)| {
|
||||
let color = compile_expression(color, 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(
|
||||
sixtyfps::re_exports::LinearGradientBrush::new(#angle as _, [#(#stops),*].iter().cloned())
|
||||
quote!(slint::Brush::LinearGradient(
|
||||
slint::re_exports::LinearGradientBrush::new(#angle as _, [#(#stops),*].iter().cloned())
|
||||
))
|
||||
}
|
||||
Expression::EnumerationValue(value) => {
|
||||
let base_ident = ident(&value.enumeration.name);
|
||||
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) => {
|
||||
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! {
|
||||
let mut #cells_variable = [#(#cells),*];
|
||||
sixtyfps::re_exports::reorder_dialog_button_layout(&mut #cells_variable, &#roles);
|
||||
let #cells_variable = sixtyfps::re_exports::Slice::from_slice(&#cells_variable);
|
||||
slint::re_exports::reorder_dialog_button_layout(&mut #cells_variable, &#roles);
|
||||
let #cells_variable = slint::re_exports::Slice::from_slice(&#cells_variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1708,7 +1708,7 @@ fn compile_builtin_function_call(
|
|||
}
|
||||
BuiltinFunction::RegisterCustomFontByPath => {
|
||||
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 {
|
||||
panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments)
|
||||
}
|
||||
|
@ -1717,7 +1717,7 @@ fn compile_builtin_function_call(
|
|||
if let [Expression::NumberLiteral(resource_id)] = &arguments {
|
||||
let resource_id: usize = *resource_id as _;
|
||||
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 {
|
||||
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 b: u8 = (#b as u32).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`])
|
||||
fn struct_name_to_tokens(name: &str) -> TokenStream {
|
||||
// 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("::") {
|
||||
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 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 sub_expression = compile_expression(sub_expression, ctx);
|
||||
|
||||
quote! { {
|
||||
#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)*
|
||||
let #cells_variable = sixtyfps::re_exports::Slice::from_slice(&items_vec);
|
||||
let #cells_variable = slint::re_exports::Slice::from_slice(&items_vec);
|
||||
#ri2
|
||||
#sub_expression
|
||||
} }
|
||||
|
|
|
@ -75,12 +75,12 @@ impl<'a> TypeLoader<'a> {
|
|||
.style
|
||||
.as_ref()
|
||||
.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(|| {
|
||||
let is_wasm = cfg!(target_arch = "wasm32")
|
||||
|| std::env::var("TARGET").map_or(false, |t| t.starts_with("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(),
|
||||
crate::diagnostics::DiagnosticLevel::Warning
|
||||
);
|
||||
|
|
|
@ -66,7 +66,7 @@ wasm-bindgen = { version = "0.2" }
|
|||
web_sys = { version = "0.3", package = "web-sys", features=["console", "CanvasRenderingContext2d", "TextMetrics", "HtmlSpanElement"] }
|
||||
|
||||
[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" }
|
||||
|
||||
image = { version = "0.23.14", default-features = false, features = [ "png" ] }
|
||||
|
|
|
@ -50,7 +50,7 @@ impl crate::window::WindowHandleAccess for Window {
|
|||
/// it and modifies it from Rust code:
|
||||
/// ```rust
|
||||
/// # slint_backend_testing_internal::init();
|
||||
/// sixtyfps::sixtyfps!{
|
||||
/// slint::slint!{
|
||||
/// export global Palette := {
|
||||
/// property<color> foreground-color;
|
||||
/// property<color> background-color;
|
||||
|
@ -66,10 +66,10 @@ impl crate::window::WindowHandleAccess for Window {
|
|||
/// }
|
||||
/// }
|
||||
/// 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:
|
||||
/// 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.
|
||||
|
@ -203,7 +203,7 @@ mod weak_handle {
|
|||
/// # Example
|
||||
/// ```rust
|
||||
/// # 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_weak = handle.as_weak();
|
||||
/// let thread = std::thread::spawn(move || {
|
||||
|
@ -253,7 +253,7 @@ pub use weak_handle::*;
|
|||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// sixtyfps::sixtyfps! { MyApp := Window { property <int> foo; /* ... */ } }
|
||||
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
|
||||
/// # slint_backend_testing_internal::init();
|
||||
/// let handle = MyApp::new();
|
||||
/// let handle_weak = handle.as_weak();
|
||||
|
@ -262,7 +262,7 @@ pub use weak_handle::*;
|
|||
/// let foo = 42;
|
||||
/// // now forward the data to the main thread using invoke_from_event_loop
|
||||
/// 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
|
||||
/// handle.run();
|
||||
|
@ -271,6 +271,6 @@ pub fn invoke_from_event_loop(func: impl FnOnce() + Send + 'static) {
|
|||
if let Some(backend) = crate::backend::instance() {
|
||||
backend.post_event(alloc::boxed::Box::new(func))
|
||||
} 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.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -389,7 +389,7 @@ impl Image {
|
|||
ImageInner::AbsoluteFilePath(_) | ImageInner::EmbeddedData { .. } => {
|
||||
match crate::backend::instance() {
|
||||
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(),
|
||||
|
|
|
@ -43,13 +43,13 @@ pub enum TimerMode {
|
|||
/// ## Example
|
||||
/// ```rust,no_run
|
||||
/// # slint_backend_testing_internal::init();
|
||||
/// use sixtyfps::{Timer, TimerMode};
|
||||
/// use slint::{Timer, TimerMode};
|
||||
/// let timer = Timer::default();
|
||||
/// timer.start(TimerMode::Repeated, std::time::Duration::from_millis(200), move || {
|
||||
/// println!("This will be printed every 200ms.");
|
||||
/// });
|
||||
/// // ... more initialization ...
|
||||
/// sixtyfps::run_event_loop();
|
||||
/// slint::run_event_loop();
|
||||
/// ```
|
||||
#[derive(Default)]
|
||||
pub struct Timer {
|
||||
|
@ -93,7 +93,7 @@ impl Timer {
|
|||
/// ## Example
|
||||
/// ```rust
|
||||
/// # slint_backend_testing_internal::init();
|
||||
/// use sixtyfps::Timer;
|
||||
/// use slint::Timer;
|
||||
/// Timer::single_shot(std::time::Duration::from_millis(200), move || {
|
||||
/// println!("This will be printed after 200ms.");
|
||||
/// });
|
||||
|
|
|
@ -688,7 +688,7 @@ pub async fn load(
|
|||
Result<Rc<ComponentDescription<'_>>, ()>,
|
||||
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:
|
||||
compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE {
|
||||
"native".to_owned()
|
||||
|
|
|
@ -680,7 +680,7 @@ pub enum DiagnosticLevel {
|
|||
|
||||
/// Diagnostic describes the aspects of either a warning or an error, along
|
||||
/// 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)]
|
||||
#[repr(C)]
|
||||
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
|
||||
/// code. It is returned from in a vector from
|
||||
/// sixtyfps::interpreter::ComponentDefinition::properties().
|
||||
/// slint::interpreter::ComponentDefinition::properties().
|
||||
#[derive(Clone)]
|
||||
#[repr(C)]
|
||||
pub struct PropertyDescriptor {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
* `Value::Array` was removed and [`Value::Model`] needs to be used instead.
|
||||
* `CallCallbackError` was renamed to [`InvokeCallbackError`].
|
||||
* `WeakComponentInstance` was removed. Use `sixtyfps::Weak<sixtyfps::interpreter::ComponentInstance>` instead.
|
||||
You might need to `use sixtyfps::ComponentHandle;` in your code to bring the trait into scope.
|
||||
* `WeakComponentInstance` was removed. Use `slint::Weak<sixtyfps::interpreter::ComponentInstance>` instead.
|
||||
You might need to `use slint::ComponentHandle;` in your code to bring the trait into scope.
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ TestCase := Rectangle {
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_sub_text(), sixtyfps::SharedString::from("ABC"));
|
||||
instance.set_public_alias(sixtyfps::SharedString::from("EFG"));
|
||||
assert_eq!(instance.get_sub_text(), sixtyfps::SharedString::from("EFG"));
|
||||
assert_eq!(instance.get_sub_text(), slint::SharedString::from("ABC"));
|
||||
instance.set_public_alias(slint::SharedString::from("EFG"));
|
||||
assert_eq!(instance.get_sub_text(), slint::SharedString::from("EFG"));
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ let instance = TestCase::new();
|
|||
assert_eq!(instance.get_val(), 1.);
|
||||
instance.set_cond(true);
|
||||
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);
|
||||
sixtyfps::testing::mock_elapsed_time(500);
|
||||
slint::testing::mock_elapsed_time(500);
|
||||
assert_eq!(instance.get_val(), 0.);
|
||||
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@ TestCase := Rectangle {
|
|||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_prop_a(), 1);
|
||||
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
|
||||
|
|
|
@ -57,30 +57,30 @@ TestCase := Rectangle {
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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(), sixtyfps::SharedString::from("real value"));
|
||||
assert_eq!(instance.get_othercomp_get_text(), sixtyfps::SharedString::from("real value"));
|
||||
assert_eq!(instance.get_othercomp_t(), slint::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_text2(sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New"));
|
||||
instance.set_text1(slint::SharedString::from("Text1New"));
|
||||
instance.set_text2(slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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_ti2(sixtyfps::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Bonjour"));
|
||||
instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
|
||||
instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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_alias(), 42);
|
||||
|
|
|
@ -60,30 +60,30 @@ TestCase := Rectangle {
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Blah"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hello"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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(), sixtyfps::SharedString::from("real value"));
|
||||
assert_eq!(instance.get_othercomp_get_text(), sixtyfps::SharedString::from("real value"));
|
||||
assert_eq!(instance.get_othercomp_t(), slint::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_text2(sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Text2New"));
|
||||
instance.set_text1(slint::SharedString::from("Text1New"));
|
||||
instance.set_text2(slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Text1New"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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_ti2(sixtyfps::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text1(), sixtyfps::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_text2(), sixtyfps::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), sixtyfps::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_ti2_text(), sixtyfps::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text_item_text(), sixtyfps::SharedString::from("Bonjour"));
|
||||
instance.invoke_set_ti1(slint::SharedString::from("Hallo"));
|
||||
instance.invoke_set_ti2(slint::SharedString::from("Bonjour"));
|
||||
assert_eq!(instance.get_text1(), slint::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_text2(), slint::SharedString::from("Text2New"));
|
||||
assert_eq!(instance.get_ti1_text(), slint::SharedString::from("Hallo"));
|
||||
assert_eq!(instance.get_ti2_text(), slint::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_alias(), 42);
|
||||
|
|
|
@ -40,17 +40,17 @@ assert_eq!(instance.get_hello(), 40);
|
|||
assert_eq!(instance.get_binding_dep(), 100);
|
||||
|
||||
// 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_binding_dep(), 125);
|
||||
|
||||
|
||||
// Remaining half
|
||||
sixtyfps::testing::mock_elapsed_time(600);
|
||||
slint::testing::mock_elapsed_time(600);
|
||||
assert_eq!(instance.get_hello(), 60);
|
||||
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_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)
|
||||
instance.set_condition(true);
|
||||
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_binding_dep(), 125);
|
||||
|
||||
|
|
|
@ -36,12 +36,12 @@ TestCase := Rectangle {
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
sixtyfps::testing::send_mouse_click(&instance, 70., 5.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 85., 55.);
|
||||
slint::testing::send_mouse_click(&instance, 70., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 85., 55.);
|
||||
assert_eq!(instance.get_result(), 345);
|
||||
instance.set_xx(0.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 10.);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 60.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 10.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 60.);
|
||||
assert_eq!(instance.get_result(), 685);
|
||||
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ assert_eq(instance.get_value(), 1);
|
|||
|
||||
```rust
|
||||
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);
|
||||
|
||||
```
|
||||
|
|
|
@ -24,12 +24,12 @@ instance.on_test_func({
|
|||
move |a| weak.upgrade().unwrap().get_some_value() * a
|
||||
});
|
||||
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);
|
||||
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
|
||||
|
|
|
@ -101,12 +101,12 @@ assert_eq(instance.get_touch_error(), 0);
|
|||
|
||||
```rust
|
||||
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_value(), 10);
|
||||
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_value(), 10);
|
||||
assert_eq!(instance.get_touch_error(), 0);
|
||||
|
|
|
@ -32,7 +32,7 @@ assert(instance.get_combo_has_focus());
|
|||
```rust
|
||||
let instance = TestCase::new();
|
||||
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());
|
||||
```
|
||||
|
||||
|
|
|
@ -49,15 +49,15 @@ assert(!instance.get_hover());
|
|||
```
|
||||
|
||||
```rust
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
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.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!(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!(!instance.get_hover());
|
||||
```
|
||||
|
|
|
@ -17,7 +17,7 @@ slint::testing::send_mouse_click(&instance, 5., 5.);
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
```
|
||||
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -36,8 +36,8 @@ assert_eq(instance.get_result(), 99);
|
|||
|
||||
```rust
|
||||
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);
|
||||
```
|
||||
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -65,7 +65,7 @@ assert(instance.get_all_ok());
|
|||
|
||||
```rust
|
||||
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());
|
||||
```
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ assert_eq(instance.get_value(), "Green");
|
|||
|
||||
```rust
|
||||
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");
|
||||
```
|
||||
|
||||
|
|
|
@ -94,25 +94,25 @@ assert_eq(instance.get_pointer_event_test(), "downleftclickupleft");
|
|||
```rust
|
||||
let instance = TestCase::new();
|
||||
// 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_touch2(), 0);
|
||||
assert_eq!(instance.get_touch3(), 0);
|
||||
|
||||
// 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_touch2(), 1);
|
||||
assert_eq!(instance.get_touch3(), 0);
|
||||
|
||||
// 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_touch2(), 1);
|
||||
assert_eq!(instance.get_touch3(), 0);
|
||||
|
||||
// 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_touch2(), 1);
|
||||
assert_eq!(instance.get_touch3(), 1);
|
||||
|
|
|
@ -31,13 +31,13 @@ assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212"));
|
||||
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1"));
|
||||
assert_eq!(instance.get_s1(), slint::SharedString::from("hello1212"));
|
||||
assert_eq!(instance.get_s2(), slint::SharedString::from("10hello5.1"));
|
||||
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();
|
||||
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42"));
|
||||
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx"));
|
||||
assert_eq!(instance.get_s3(), slint::SharedString::from("x42x42"));
|
||||
assert_eq!(instance.get_s4(), slint::SharedString::from("ayoxxx"));
|
||||
```
|
||||
|
||||
```js
|
||||
|
|
|
@ -30,13 +30,13 @@ assert_eq(instance.get_s4(), slint::SharedString("ayoxxx"));
|
|||
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212"));
|
||||
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1"));
|
||||
assert_eq!(instance.get_s1(), slint::SharedString::from("hello1212"));
|
||||
assert_eq!(instance.get_s2(), slint::SharedString::from("10hello5.1"));
|
||||
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();
|
||||
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42"));
|
||||
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx"));
|
||||
assert_eq!(instance.get_s3(), slint::SharedString::from("x42x42"));
|
||||
assert_eq!(instance.get_s4(), slint::SharedString::from("ayoxxx"));
|
||||
```
|
||||
|
||||
```js
|
||||
|
|
|
@ -40,7 +40,7 @@ TestCase := Rectangle {
|
|||
|
||||
/*
|
||||
```rust
|
||||
let ctrl_modifier = sixtyfps::re_exports::KeyboardModifiers {
|
||||
let ctrl_modifier = slint::re_exports::KeyboardModifiers {
|
||||
control: true,
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -50,13 +50,13 @@ let instance = TestCase::new();
|
|||
assert!(!instance.get_input1_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_input1_text(), "");
|
||||
assert_eq!(instance.get_recieved(), "");
|
||||
|
||||
sixtyfps::testing::set_current_keyboard_modifiers(&instance, ctrl_modifier);
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "ß");
|
||||
slint::testing::set_current_keyboard_modifiers(&instance, ctrl_modifier);
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "ß");
|
||||
assert_eq!(instance.get_input2_text(), "Hello");
|
||||
assert_eq!(instance.get_input1_text(), "");
|
||||
assert_eq!(instance.get_recieved(), "ß");
|
||||
|
|
|
@ -55,8 +55,8 @@ TestCase := Window {
|
|||
/*
|
||||
```rust
|
||||
let instance = TestCase::new();
|
||||
sixtyfps::testing::send_mouse_click(&instance, 50., 50.);
|
||||
sixtyfps::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__");
|
||||
slint::testing::send_mouse_click(&instance, 50., 50.);
|
||||
slint::testing::send_keyboard_string_sequence(&instance, "__abcdefghij__");
|
||||
assert_eq!(instance.get_r1(), "__afghij__");
|
||||
assert_eq!(instance.get_r2(), "__abfghij__");
|
||||
assert_eq!(instance.get_r3(), "__abcfghij__");
|
||||
|
|
|
@ -28,19 +28,19 @@ let instance = TestCase::new();
|
|||
assert!(!instance.get_input1_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_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_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_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_input2_text(), "Only for field 2");
|
||||
```
|
||||
|
|
|
@ -28,15 +28,15 @@ let instance = TestCase::new();
|
|||
assert!(instance.get_input1_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_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_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_input2_focused());
|
||||
```
|
||||
|
|
|
@ -91,28 +91,28 @@ assert_eq!(instance.get_test(), true);
|
|||
assert_eq!(instance.get_el1clip(), false);
|
||||
|
||||
// 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_touch2(), 0, "a. touch2");
|
||||
|
||||
// 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_touch2(), 1, "b. touch2");
|
||||
|
||||
// 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_touch2(), 1, "c. touch2");
|
||||
|
||||
// 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_touch2(), 1, "d. touch2");
|
||||
|
||||
// now clip also el1
|
||||
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_touch2(), 1, "e. touch2");
|
||||
```
|
||||
|
|
|
@ -87,29 +87,29 @@ assert_eq!(instance.get_test(), true);
|
|||
assert_eq!(instance.get_el1visible(), true);
|
||||
|
||||
// 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_touch2(), 0);
|
||||
|
||||
// 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_touch2(), 0);
|
||||
|
||||
|
||||
// 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_touch2(), 0);
|
||||
|
||||
// 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_touch2(), 0);
|
||||
|
||||
// now makes el invisible
|
||||
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_touch2(), 0);
|
||||
```
|
||||
|
|
|
@ -70,7 +70,7 @@ assert(instance.get_rect5_pos_ok());
|
|||
|
||||
```rust
|
||||
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_rect2_pos_ok());
|
||||
assert!(instance.get_rect3_pos_ok());
|
||||
|
|
|
@ -69,7 +69,7 @@ assert(instance.get_rect5_pos_ok());
|
|||
|
||||
```rust
|
||||
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_rect2_pos_ok());
|
||||
assert!(instance.get_rect3_pos_ok());
|
||||
|
|
|
@ -45,13 +45,13 @@ assert_eq(instance.get_value(), 1+1+2);
|
|||
|
||||
```rust
|
||||
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);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 290.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 290.);
|
||||
assert_eq!(instance.get_value(), 1+1+2);
|
||||
|
||||
```
|
||||
|
|
|
@ -50,13 +50,13 @@ assert_eq(instance.get_value(), 9);
|
|||
```rust
|
||||
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);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 25., 25.);
|
||||
slint::testing::send_mouse_click(&instance, 25., 25.);
|
||||
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);
|
||||
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ slint::testing::send_mouse_click(&instance, 5., 5.);
|
|||
|
||||
```rust
|
||||
let instance = HelloWorld::new();
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
```
|
||||
|
||||
*/
|
||||
|
|
|
@ -51,13 +51,13 @@ assert_eq(instance.get_last_clicked(), 1);
|
|||
```rust
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 305.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 305.);
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 95.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 95.);
|
||||
assert_eq!(instance.get_last_clicked(), 1);
|
||||
```
|
||||
|
||||
|
|
|
@ -62,17 +62,17 @@ assert_eq(instance.get_last_clicked(), 1);
|
|||
let instance = TestCase::new();
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 455.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 455.);
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 295.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 295.);
|
||||
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);
|
||||
```
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@ assert_eq(instance.get_last_clicked(), 31);
|
|||
```rust
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 105., 205.);
|
||||
slint::testing::send_mouse_click(&instance, 105., 205.);
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 295., 56.);
|
||||
slint::testing::send_mouse_click(&instance, 295., 56.);
|
||||
assert_eq!(instance.get_last_clicked(), 31);
|
||||
|
||||
```
|
||||
|
|
|
@ -51,7 +51,7 @@ assert(instance.get_check_ok());
|
|||
|
||||
```rust
|
||||
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());
|
||||
```
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ assert_eq(instance.get_last_clicked(), 2);
|
|||
```rust
|
||||
let instance = TestCase::new();
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 155.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 155.);
|
||||
assert_eq!(instance.get_last_clicked(), 2);
|
||||
```
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ assert_eq(uint32_t(instance.get_materialized_rect_max_width()), uint32_t(std::nu
|
|||
|
||||
```rust
|
||||
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_min_width(), 50);
|
||||
assert_eq!(instance.get_materialized_min_height(), 25);
|
||||
|
|
|
@ -94,28 +94,28 @@ assert_eq(instance.get_value(), 2);
|
|||
```rust
|
||||
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);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 52.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 52.);
|
||||
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);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 80.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 80.);
|
||||
assert_eq!(instance.get_value(), 4);
|
||||
|
||||
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);
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 30.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 30.);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
|
|
@ -35,15 +35,15 @@ assert_eq(instance.get_hello_world(), "world");
|
|||
|
||||
|
||||
```rust
|
||||
use sixtyfps::Model;
|
||||
use slint::Model;
|
||||
let instance = TestCase::new();
|
||||
|
||||
assert_eq!(instance.get_num_ints(), 5);
|
||||
assert_eq!(instance.get_n(), 4);
|
||||
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());
|
||||
instance.set_ints(sixtyfps::ModelRc::from(model.clone()));
|
||||
let model: std::rc::Rc<slint::VecModel<i32>> = std::rc::Rc::new(vec![1, 2, 3, 4, 5, 6, 7].into());
|
||||
instance.set_ints(slint::ModelRc::from(model.clone()));
|
||||
assert_eq!(instance.get_num_ints(), 7);
|
||||
assert_eq!(instance.get_third_int(), 3);
|
||||
model.push(8);
|
||||
|
@ -51,7 +51,7 @@ assert_eq!(instance.get_num_ints(), 8);
|
|||
model.set_row_data(2, 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
|
||||
|
|
|
@ -105,13 +105,13 @@ assert_eq(instance.get_value(), 3000+13+42);
|
|||
```rust
|
||||
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);
|
||||
|
||||
sixtyfps::testing::send_mouse_click(&instance, 15., 15.);
|
||||
slint::testing::send_mouse_click(&instance, 15., 15.);
|
||||
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);
|
||||
|
||||
```
|
||||
|
|
|
@ -50,15 +50,15 @@ assert_eq(instance.get_top_level(), 92);
|
|||
```rust
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
```
|
||||
|
||||
|
|
|
@ -50,15 +50,15 @@ assert_eq(instance.get_top_level(), 92);
|
|||
```rust
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
```
|
||||
|
||||
|
|
|
@ -58,14 +58,14 @@ let instance = TestCase::new();
|
|||
|
||||
// Send an initial click to traverse the item tree and force a listview
|
||||
// layout.
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq!(instance.get_viewport_height(), 100.);
|
||||
|
||||
// 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
|
||||
sixtyfps::testing::send_mouse_click(&instance, 5., 5.);
|
||||
slint::testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq!(instance.get_viewport_height(), 200.);
|
||||
```
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue