Merge remote-tracking branch 'origin/wip/rename'

Conflicts:
	examples/opengl_underlay/index.html
	examples/opengl_underlay/main.cpp
This commit is contained in:
Olivier Goffart 2022-02-08 07:29:41 +01:00
commit 91e107150e
766 changed files with 5403 additions and 4877 deletions

View file

@ -2,7 +2,7 @@
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
cmake_minimum_required(VERSION 3.19)
project(SixtyFPS HOMEPAGE_URL "https://sixtyfps.io/" LANGUAGES CXX)
project(Slint HOMEPAGE_URL "https://sixtyfps.io/" LANGUAGES CXX)
include(FeatureSummary)
include(CMakeDependentOption)
@ -19,30 +19,30 @@ list(PREPEND CMAKE_MODULE_PATH ${Corrosion_SOURCE_DIR}/cmake)
find_package(Rust 1.56 REQUIRED MODULE)
corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Cargo.toml"
CRATES sixtyfps-compiler sixtyfps-cpp)
CRATES slint-compiler slint-cpp)
set_property(
TARGET sixtyfps-cpp
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
SIXTYFPS_GENERATED_INCLUDE_DIR="${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
SLINT_GENERATED_INCLUDE_DIR="${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
)
set_property(
TARGET sixtyfps-compiler
TARGET slint-compiler
PROPERTY CORROSION_USE_HOST_BUILD 1
)
add_library(SixtyFPS INTERFACE)
add_library(SixtyFPS::SixtyFPS ALIAS SixtyFPS)
target_link_libraries(SixtyFPS INTERFACE sixtyfps-cpp)
target_compile_features(SixtyFPS INTERFACE cxx_std_20)
add_library(Slint INTERFACE)
add_library(Slint::Slint ALIAS Slint)
target_link_libraries(Slint INTERFACE slint-cpp)
target_compile_features(Slint INTERFACE cxx_std_20)
function(define_cargo_feature cargo-feature description default)
# turn foo-bar into SIXTYFPS_FEATURE_FOO_BAR
# turn foo-bar into SLINT_FEATURE_FOO_BAR
string(TOUPPER "${cargo-feature}" cmake_option)
string(REPLACE "-" "_" cmake_option "${cmake_option}")
set(cmake_option "SIXTYFPS_FEATURE_${cmake_option}")
set(cmake_option "SLINT_FEATURE_${cmake_option}")
option("${cmake_option}" "${description}" ${default})
if(${cmake_option})
list(APPEND features ${cargo-feature})
@ -52,10 +52,10 @@ function(define_cargo_feature cargo-feature description default)
endfunction()
function(define_cargo_dependent_feature cargo-feature description default depends_condition)
# turn foo-bar into SIXTYFPS_FEATURE_FOO_BAR
# turn foo-bar into SLINT_FEATURE_FOO_BAR
string(TOUPPER "${cargo-feature}" cmake_option)
string(REPLACE "-" "_" cmake_option "${cmake_option}")
set(cmake_option "SIXTYFPS_FEATURE_${cmake_option}")
set(cmake_option "SLINT_FEATURE_${cmake_option}")
cmake_dependent_option("${cmake_option}" "${description}" ${default} ${depends_condition} OFF)
if(${cmake_option})
list(APPEND features ${cargo-feature})
@ -66,148 +66,148 @@ endfunction()
# Features that are mapped to features in the Rust crate. These and their
# defaults need to be kept in sync with the Rust bit.
define_cargo_feature(interpreter "Enable support for the SixtyFPS interpeter to load .60 files at run-time" ON)
define_cargo_feature(interpreter "Enable support for the Slint interpeter to load .slint files at run-time" ON)
define_cargo_feature(backend-gl "Enable OpenGL ES 2.0 based rendering backend" ON)
define_cargo_dependent_feature(x11 "Enable X11 support when using GL backend" ON SIXTYFPS_FEATURE_BACKEND_GL OFF)
define_cargo_dependent_feature(wayland "Enable Wayland support when using the GL backend" OFF SIXTYFPS_FEATURE_BACKEND_GL OFF)
define_cargo_dependent_feature(x11 "Enable X11 support when using GL backend" ON SLINT_FEATURE_BACKEND_GL OFF)
define_cargo_dependent_feature(wayland "Enable Wayland support when using the GL backend" OFF SLINT_FEATURE_BACKEND_GL OFF)
define_cargo_feature(backend-qt "Enable Qt based rendering backend" ON)
set_property(
TARGET sixtyfps-cpp
TARGET slint-cpp
PROPERTY CORROSION_FEATURES
${features}
)
set_property(
TARGET sixtyfps-cpp
TARGET slint-cpp
PROPERTY CORROSION_NO_DEFAULT_FEATURES
${features}
)
if (SIXTYFPS_FEATURE_BACKEND_QT)
if (SLINT_FEATURE_BACKEND_QT)
# For the CMake build don't rely on qmake being in PATH but use CMake to locate Qt. This
# means usually CMAKE_PREFIX_PATH is set.
find_package(Qt6 6.0 QUIET COMPONENTS Core Widgets)
if (NOT TARGET Qt::qmake)
find_package(Qt5 5.15 QUIET COMPONENTS Core Widgets)
endif()
endif (SIXTYFPS_FEATURE_BACKEND_QT)
endif (SLINT_FEATURE_BACKEND_QT)
if (TARGET Qt::qmake)
set_property(
TARGET sixtyfps-cpp
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
QMAKE=$<TARGET_PROPERTY:Qt::qmake,LOCATION>
)
set(SIXTYFPS_STYLE_DEFAULT "native")
set(SLINT_STYLE_DEFAULT "native")
else()
set_property(
TARGET sixtyfps-cpp
TARGET slint-cpp
APPEND
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
SIXTYFPS_NO_QT=1
SLINT_NO_QT=1
)
set(SIXTYFPS_STYLE_DEFAULT "fluent")
set(SLINT_STYLE_DEFAULT "fluent")
endif()
set(SIXTYFPS_STYLE ${SIXTYFPS_STYLE_DEFAULT} CACHE STRING "The SixtyFPS widget style" FORCE)
set(SLINT_STYLE ${SLINT_STYLE_DEFAULT} CACHE STRING "The Slint widget style" FORCE)
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
foreach(header IN LISTS api_headers)
set_property(TARGET SixtyFPS APPEND PROPERTY PUBLIC_HEADER include/${header})
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER include/${header})
endforeach()
set(generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_backend_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_generated_public.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/sixtyfps_interpreter_generated_public.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_backend_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_generated_public.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_generated_public.h
)
foreach(header IN LISTS generated_headers)
set_property(TARGET SixtyFPS APPEND PROPERTY PUBLIC_HEADER ${header})
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
endforeach()
target_include_directories(SixtyFPS INTERFACE
target_include_directories(Slint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/sixtyfps>
$<INSTALL_INTERFACE:include/slint>
)
add_executable(SixtyFPS::sixtyfps-compiler ALIAS sixtyfps-compiler)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SixtyFPSMacro.cmake)
add_executable(Slint::slint-compiler ALIAS slint-compiler)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake)
export(TARGETS SixtyFPS sixtyfps-cpp
NAMESPACE SixtyFPS:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/SixtyFPS/SixtyFPSTargets.cmake")
install(EXPORT SixtyFPSTargets NAMESPACE SixtyFPS:: DESTINATION lib/cmake/SixtyFPS)
install(TARGETS SixtyFPS sixtyfps-cpp
EXPORT SixtyFPSTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/sixtyfps)
export(TARGETS Slint slint-cpp
NAMESPACE Slint:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/Slint/SlintTargets.cmake")
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
install(TARGETS Slint slint-cpp
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(FILES $<TARGET_FILE:sixtyfps-cpp-shared> TYPE LIB)
install(FILES $<TARGET_FILE:slint-cpp-shared> TYPE LIB)
if(WIN32)
install(FILES $<TARGET_LINKER_FILE:sixtyfps-cpp-shared> TYPE LIB)
install(FILES $<TARGET_LINKER_FILE:slint-cpp-shared> TYPE LIB)
# Copy the dll to the top-level bin directory, where the examples will
# will also be located, so that they can find the dll.
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG)
set(config_subdir_genex "$<CONFIG>/")
endif()
add_custom_target(SixtyFPS_dll_convenience ALL DEPENDS sixtyfps-cpp-shared
add_custom_target(Slint_dll_convenience ALL DEPENDS slint-cpp-shared
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:sixtyfps-cpp-shared>
${CMAKE_BINARY_DIR}/bin/${config_subdir_genex}$<TARGET_FILE_NAME:sixtyfps-cpp-shared>)
$<TARGET_FILE:slint-cpp-shared>
${CMAKE_BINARY_DIR}/bin/${config_subdir_genex}$<TARGET_FILE_NAME:slint-cpp-shared>)
endif()
install(PROGRAMS $<TARGET_FILE:sixtyfps-compiler> TYPE BIN)
install(PROGRAMS $<TARGET_FILE:slint-compiler> TYPE BIN)
set(SIXTYFPS_LIB_PROPERTIES "")
set(SLINT_LIB_PROPERTIES "")
foreach(prop
IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE
IMPORTED_LOCATION_RELWITHDEBINFO IMPORTED_LOCATION_MINSIZEREL
IMPORTED_IMPLIB IMPORTED_IMPLIB_DEBUG IMPORTED_IMPLIB_RELEASE
IMPORTED_IMPLIB_RELWITHDEBINFO IMPORTED_IMPLIB_MINSIZEREL)
get_target_property(value sixtyfps-cpp-shared ${prop})
get_target_property(value slint-cpp-shared ${prop})
if(value)
get_filename_component(value ${value} NAME)
list(APPEND SIXTYFPS_LIB_PROPERTIES ${prop} "\${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${value}")
list(APPEND SLINT_LIB_PROPERTIES ${prop} "\${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${value}")
endif()
endforeach()
configure_package_config_file("cmake/SixtyFPSConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SixtyFPS/SixtyFPSConfig.cmake" INSTALL_DESTINATION lib/cmake/SixtyFPS)
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SixtyFPS/SixtyFPSConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake
VERSION 0.2.0
COMPATIBILITY SameMinorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SixtyFPS/SixtyFPSConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SixtyFPS/SixtyFPSConfigVersion.cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/SixtyFPSMacro.cmake"
DESTINATION lib/cmake/SixtyFPS
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfigVersion.cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake"
DESTINATION lib/cmake/Slint
)
option(SIXTYFPS_PACKAGE_BUNDLE_QT "Internal setting to install Qt binary in the packages" OFF)
if(SIXTYFPS_PACKAGE_BUNDLE_QT)
option(SLINT_PACKAGE_BUNDLE_QT "Internal setting to install Qt binary in the packages" OFF)
if(SLINT_PACKAGE_BUNDLE_QT)
if(WIN32)
find_package(Qt6 6.0 COMPONENTS Core Gui Widgets Svg)
install(
@ -234,10 +234,10 @@ if(SIXTYFPS_PACKAGE_BUNDLE_QT)
include(InstallRequiredSystemLibraries)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} TYPE LIB)
endif()
endif(SIXTYFPS_PACKAGE_BUNDLE_QT)
endif(SLINT_PACKAGE_BUNDLE_QT)
set(CPACK_PACKAGE_NAME "SixtyFPS-cpp")
set(CPACK_PACKAGE_VENDOR "SixtyFPS")
set(CPACK_PACKAGE_NAME "Slint-cpp")
set(CPACK_PACKAGE_VENDOR "Slint")
set(CPACK_VERBATIM_VARIABLES true)
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 2)
@ -264,9 +264,9 @@ if(BUILD_TESTING)
find_package(Threads REQUIRED)
macro(sixtyfps_test NAME)
macro(slint_test NAME)
add_executable(test_${NAME} tests/${NAME}.cpp)
target_link_libraries(test_${NAME} PRIVATE SixtyFPS Catch2::Catch2)
target_link_libraries(test_${NAME} PRIVATE Slint Catch2::Catch2)
target_compile_definitions(test_${NAME} PRIVATE
SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
)
@ -286,11 +286,11 @@ if(BUILD_TESTING)
target_compile_options(test_${NAME} PRIVATE -Wno-maybe-uninitialized)
endif()
endmacro(sixtyfps_test)
sixtyfps_test(datastructures)
if(SIXTYFPS_FEATURE_INTERPRETER)
sixtyfps_test(interpreter)
endmacro(slint_test)
slint_test(datastructures)
if(SLINT_FEATURE_INTERPRETER)
slint_test(interpreter)
endif()
sixtyfps_test(eventloop)
slint_test(eventloop)
target_link_libraries(test_eventloop PRIVATE Threads::Threads)
endif()

View file

@ -2,18 +2,18 @@
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
[package]
name = "sixtyfps-cpp"
name = "slint-cpp"
version = "0.2.0"
authors = ["SixtyFPS <info@sixtyfps.io>"]
authors = ["Slint Developers <info@slint-ui.com>"]
edition = "2021"
build = "build.rs"
license = "(GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)"
description = "SixtyFPS C++ integration"
description = "Slint C++ integration"
repository = "https://github.com/sixtyfpsui/sixtyfps"
homepage = "https://sixtyfps.io"
publish = false
# prefix used to convey path to generated includes to the C++ test driver
links = "sixtyfps_cpp"
links = "slint_cpp"
[lib]
path = "lib.rs"
@ -22,20 +22,20 @@ crate-type = ["lib", "cdylib"]
# Note, these features need to be kept in sync (along with their defaults) in
# the C++ crate's CMakeLists.txt
[features]
backend-gl = ["sixtyfps-rendering-backend-selector/sixtyfps-rendering-backend-gl"]
backend-qt = ["sixtyfps-rendering-backend-selector/sixtyfps-rendering-backend-qt"]
interpreter = ["sixtyfps-interpreter"]
testing = ["sixtyfps-rendering-backend-testing"] # Enable some function used by the integration tests
wayland = ["sixtyfps-rendering-backend-selector/wayland"]
x11 = ["sixtyfps-rendering-backend-selector/x11"]
backend-gl = ["i-slint-backend-selector/i-slint-backend-gl"]
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt"]
interpreter = ["slint-interpreter"]
testing = ["i-slint-backend-testing"] # Enable some function used by the integration tests
wayland = ["i-slint-backend-selector/wayland"]
x11 = ["i-slint-backend-selector/x11"]
default = ["backend-gl", "x11", "backend-qt"]
[dependencies]
sixtyfps-corelib = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
sixtyfps-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
sixtyfps-rendering-backend-selector = { version = "=0.2.0", path="../../internal/backends/selector" }
sixtyfps-rendering-backend-testing = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
i-slint-backend-selector = { version = "=0.2.0", path="../../internal/backends/selector" }
i-slint-backend-testing = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
i-slint-core = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
slint-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
[build-dependencies]
anyhow = "1.0"

View file

@ -1,25 +1,25 @@
# SixtyFPS-cpp
# Slint-cpp
## A C++ UI toolkit
[SixtyFPS](https://sixtyfps.io/) is a UI toolkit that supports different programming languages.
SixtyFPS.cpp is the C++ API to interact with a SixtyFPS UI from C++.
[Slint](https://sixtyfps.io/) is a UI toolkit that supports different programming languages.
Slint.cpp is the C++ API to interact with a Slint UI from C++.
The complete C++ documentation can be viewed online at https://sixtyfps.io/docs/cpp/.
If you are new to SixtyFPS, you might also consider going through our [Walk-through tutorial](https://sixtyfps.io/docs/tutorial/cpp).
If you are new to Slint, you might also consider going through our [Walk-through tutorial](https://sixtyfps.io/docs/tutorial/cpp).
## Installing or Building SixtyFPS
## Installing or Building Slint
SixtyFPS comes with a CMake integration that automates the compilation step of the `.60` markup language files and
Slint comes with a CMake integration that automates the compilation step of the `.slint` markup language files and
offers a CMake target for convenient linkage.
*Note*: We recommend using the Ninja generator of CMake for the most efficient build and `.60` dependency tracking.
*Note*: We recommend using the Ninja generator of CMake for the most efficient build and `.slint` dependency tracking.
You can select the CMake Ninja backend by passing `-GNinja` or setting the `CMAKE_GENERATOR` environment variable to `Ninja`.
### Building from Sources
The recommended and most flexible way to use the C++ API is to build SixtyFPS from sources.
The recommended and most flexible way to use the C++ API is to build Slint from sources.
First you need to install the prerequisites:
@ -28,31 +28,31 @@ First you need to install the prerequisites:
* **[cmake](https://cmake.org/download/)** (3.19 or newer)
* A C++ compiler that supports C++20 (e.g., **MSVC 2019 16.6** on Windows)
You can include SixtyFPS in your CMake project using CMake's `FetchContent` feature. Insert the following snippet into your
You can include Slint in your CMake project using CMake's `FetchContent` feature. Insert the following snippet into your
`CMakeLists.txt` to make CMake download the latest release, compile it and make the CMake integration available:
```cmake
include(FetchContent)
FetchContent_Declare(
SixtyFPS
Slint
GIT_REPOSITORY https://github.com/sixtyfpsui/sixtyfps.git
GIT_TAG v0.1.6
SOURCE_SUBDIR api/sixtyfps-cpp
SOURCE_SUBDIR api/cpp
)
FetchContent_MakeAvailable(SixtyFPS)
FetchContent_MakeAvailable(Slint)
```
If you prefer to treat SixtyFPS as an external CMake package, then you can also build SixtyFPS from source like a regular
CMake project, install it into a prefix directory of your choice and use `find_package(SixtyFPS)` in your `CMakeLists.txt`.
If you prefer to treat Slint as an external CMake package, then you can also build Slint from source like a regular
CMake project, install it into a prefix directory of your choice and use `find_package(Slint)` in your `CMakeLists.txt`.
#### Cross-compiling
It is possible to cross-compile SixtyFPS to a different target architecture when building with CMake. In order to complete
It is possible to cross-compile Slint to a different target architecture when building with CMake. In order to complete
that, you need to make sure that your CMake setup is ready for cross-compilation. You can find more information about
how to set this up in the [upstream CMake documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling).
If you are building against a Yocto SDK, it is sufficient to source the SDK's environment setup file.
Since SixtyFPS is implemented using the Rust programming language, you need to determine which Rust target
Since Slint is implemented using the Rust programming language, you need to determine which Rust target
matches the target architecture that you're compiling to. Please consult the [upstream Rust documentation](https://doc.rust-lang.org/nightly/rustc/platform-support.html) to find the correct target name. Now you need to install the Rust toolchain:
```sh
@ -60,7 +60,7 @@ rustup target add <target-name>
```
Then you're ready to invoke CMake and you need to add `-DRust_CARGO_TARGET=<target name>` to the CMake command line.
This ensures that the SixtyFPS library is built for the correct architecture.
This ensures that the Slint library is built for the correct architecture.
For example if you are building against an embedded Linux Yocto SDK targeting an ARM64 board, the following commands
show how to compile:
@ -75,28 +75,28 @@ Set up the environment and build:
```sh
. /path/to/yocto/sdk/environment-setup-cortexa53-crypto-poky-linux
cd sixtyfps
cd slint
mkdir build
cd build
cmake -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/sixtyfps/install/path ..
cmake -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/slint/install/path ..
cmake --build .
cmake --install .
```
### Binary Packages
We also provide binary packages of SixtyFPS for use with C++, which eliminates the need to have Rust installed in your development environment.
We also provide binary packages of Slint for use with C++, which eliminates the need to have Rust installed in your development environment.
You can download one of our pre-built binaries for Linux or Windows on x86-64 architectures:
1. Open <https://github.com/sixtyfpsui/sixtyfps/releases>
2. Click on the latest release
3. From "Assets" download either `sixtyfps-cpp-XXX-Linux-x86_64.tar.gz` for a Linux x86-64 archive
or `sixtyfps-cpp-XXX-win64.exe` for a Windows x86-64 installer. ("XXX" refers to the version of the latest release)
3. From "Assets" download either `slint-cpp-XXX-Linux-x86_64.tar.gz` for a Linux x86-64 archive
or `slint-cpp-XXX-win64.exe` for a Windows x86-64 installer. ("XXX" refers to the version of the latest release)
4. Uncompress the downloaded archive or run the installer.
After extracting the artifact or running the installer, you can place the `lib` sub-directory into your `CMAKE_PREFIX_PATH` and `find_package(SixtyFPS)` should succeed in locating the package.
After extracting the artifact or running the installer, you can place the `lib` sub-directory into your `CMAKE_PREFIX_PATH` and `find_package(Slint)` should succeed in locating the package.
## Usage via CMake
@ -106,33 +106,33 @@ A typical example looks like this:
cmake_minimum_required(VERSION 3.19)
project(my_application LANGUAGES CXX)
# Note: Use find_package(SixtyFPS) instead of the following three commands, if you prefer the package
# Note: Use find_package(Slint) instead of the following three commands, if you prefer the package
# approach.
include(FetchContent)
FetchContent_Declare(
SixtyFPS
Slint
GIT_REPOSITORY https://github.com/sixtyfpsui/sixtyfps.git
GIT_TAG v0.1.6
SOURCE_SUBDIR api/sixtyfps-cpp
SOURCE_SUBDIR api/cpp
)
FetchContent_MakeAvailable(SixtyFPS)
FetchContent_MakeAvailable(Slint)
add_executable(my_application main.cpp)
target_link_libraries(my_application PRIVATE SixtyFPS::SixtyFPS)
sixtyfps_target_60_sources(my_application my_application_ui.60)
target_link_libraries(my_application PRIVATE Slint::Slint)
slint_target_sources(my_application my_application_ui.slint)
```
The `sixtyfps_target_60_sources` cmake command allows you to add .60 files to your build. Finally it is
necessary to link your executable or library against the `SixtyFPS::SixtyFPS` target.
The `slint_target_sources` cmake command allows you to add .slint files to your build. Finally it is
necessary to link your executable or library against the `Slint::Slint` target.
## Tutorial
Let's make a UI for a todo list application using the SixtyFPS UI description language.
Let's make a UI for a todo list application using the Slint UI description language.
Hopefully this should be self explanatory. Check out the documentation of the language for help
```60
// file: my_application_ui.60
import { CheckBox, Button, ListView, LineEdit } from "sixtyfps_widgets.60";
```slint
// file: my_application_ui.slint
import { CheckBox, Button, ListView, LineEdit } from "std-widgets.slint";
export struct TodoItem := {
title: string,
@ -175,34 +175,34 @@ export MainWindow := Window {
}
```
We can compile this code using the `sixtyfps-compiler` binary:
We can compile this code using the `slint-compiler` binary:
```sh
sixtyfps-compiler my_application_ui.60 > my_application_ui.h
slint-compiler my_application_ui.slint > my_application_ui.h
```
Note: You would usually not type this command yourself, this is done automatically by the build system.
(that's what the `sixtyfps_target_60_sources` cmake function does)
(that's what the `slint_target_sources` cmake function does)
This will generate a `my_application_ui.h` header file. It basically contains the following code
(edited for brevity)
```C++
#include <sixtyfps.h>
#include <slint.h>
struct TodoItem {
bool checked;
sixtyfps::SharedString title;
slint::SharedString title;
};
struct MainWindow {
public:
inline auto create () -> sixtyfps::ComponentHandle<MainWindow>;
inline auto create () -> slint::ComponentHandle<MainWindow>;
inline auto get_todo_model () const -> std::shared_ptr<sixtyfps::Model<TodoItem>>;
inline void set_todo_model (const std::shared_ptr<sixtyfps::Model<TodoItem>> &value) const;
inline auto get_todo_model () const -> std::shared_ptr<slint::Model<TodoItem>>;
inline void set_todo_model (const std::shared_ptr<slint::Model<TodoItem>> &value) const;
inline void invoke_todo_added (sixtyfps::SharedString arg_0) const;
inline void invoke_todo_added (slint::SharedString arg_0) const;
template<typename Functor> inline void on_todo_added (Functor && callback_handler) const;
//...
@ -220,14 +220,14 @@ int main() {
auto todo_app = MainWindow::create();
// let's create a model:
auto todo_model = std::make_shared<sixtyfps::VectorModel<TodoItem>>(std::vector {
auto todo_model = std::make_shared<slint::VectorModel<TodoItem>>(std::vector {
TodoItem { false, "Write documentation" },
});
// set the model as the model of our view
todo_app->set_todo_model(todo_model);
// let's connect our "add" button to add an item in the model
todo_app->on_todo_added([todo_model](const sixtyfps::SharedString &s) {
todo_app->on_todo_added([todo_model](const slint::SharedString &s) {
todo_model->push_back(TodoItem { false, s} );
});
@ -241,4 +241,4 @@ That's it.
For more details, check the [Online documentation](https://sixtyfps.io/docs/cpp) and the full
[Walk-through tutorial](https://sixtyfps.io/docs/tutorial/cpp).
We also have a [Getting Started Template](https://github.com/sixtyfpsui/sixtyfps-cpp-template) repository with
the code of a minimal C++ application using SixtyFPS that can be used as a starting point to your program.
the code of a minimal C++ application using Slint that can be used as a starting point to your program.

View file

@ -13,7 +13,7 @@ fn main() -> Result<(), anyhow::Error> {
manifest_dir.to_string_lossy()
));
let output_dir = std::env::var_os("SIXTYFPS_GENERATED_INCLUDE_DIR").unwrap_or_else(|| {
let output_dir = std::env::var_os("SLINT_GENERATED_INCLUDE_DIR").unwrap_or_else(|| {
Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("generated_include").into()
});
let output_dir = Path::new(&output_dir);

View file

@ -25,7 +25,7 @@ fn default_config() -> cbindgen::Config {
cbindgen::Config {
pragma_once: true,
include_version: true,
namespaces: Some(vec!["sixtyfps".into(), "cbindgen_private".into()]),
namespaces: Some(vec!["slint".into(), "cbindgen_private".into()]),
line_length: 100,
tab_width: 4,
// Note: we might need to switch to C if we need to generate bindings for language that needs C headers
@ -46,8 +46,8 @@ fn default_config() -> cbindgen::Config {
..Default::default()
},
defines: [
("target_pointer_width = 64".into(), "SIXTYFPS_TARGET_64".into()),
("target_pointer_width = 32".into(), "SIXTYFPS_TARGET_32".into()),
("target_pointer_width = 64".into(), "SLINT_TARGET_64".into()),
("target_pointer_width = 32".into(), "SLINT_TARGET_32".into()),
]
.iter()
.cloned()
@ -59,21 +59,21 @@ fn default_config() -> cbindgen::Config {
fn gen_item_declarations(items: &[&str]) -> String {
format!(
r#"
namespace sixtyfps::private_api {{
#define SIXTYFPS_DECL_ITEM(ItemName) \
namespace slint::private_api {{
#define SLINT_DECL_ITEM(ItemName) \
extern const cbindgen_private::ItemVTable ItemName##VTable; \
extern SIXTYFPS_DLL_IMPORT const cbindgen_private::ItemVTable* sixtyfps_get_##ItemName##VTable();
extern SLINT_DLL_IMPORT const cbindgen_private::ItemVTable* slint_get_##ItemName##VTable();
extern "C" {{
{}
}}
#undef SIXTYFPS_DECL_ITEM
#undef SLINT_DECL_ITEM
}}
"#,
items
.iter()
.map(|item_name| format!("SIXTYFPS_DECL_ITEM({});", item_name))
.map(|item_name| format!("SLINT_DECL_ITEM({});", item_name))
.collect::<Vec<_>>()
.join("\n")
)
@ -140,14 +140,14 @@ fn gen_corelib(
"PathData",
"PathElement",
"Brush",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
"slint_new_path_elements",
"slint_new_path_events",
"Property",
"Slice",
"PropertyHandleOpaque",
"Callback",
"sixtyfps_property_listener_scope_evaluate",
"sixtyfps_property_listener_scope_is_dirty",
"slint_property_listener_scope_evaluate",
"slint_property_listener_scope_is_dirty",
"PropertyTrackerOpaque",
"CallbackOpaque",
"WindowRc",
@ -156,10 +156,10 @@ fn gen_corelib(
"PointerEventArg",
"PointArg",
"Point",
"sixtyfps_color_brighter",
"sixtyfps_color_darker",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_color_brighter",
"slint_color_darker",
"slint_image_size",
"slint_image_path",
"TimerMode", // included in generated_public.h
"IntSize", // included in generated_public.h
"RenderingState", // included in generated_public.h
@ -185,18 +185,18 @@ fn gen_corelib(
.with_config(string_config)
.with_src(crate_dir.join("string.rs"))
.with_src(crate_dir.join("slice.rs"))
.with_after_include("namespace sixtyfps { struct SharedString; }")
.with_after_include("namespace slint { struct SharedString; }")
.generate()
.context("Unable to generate bindings for sixtyfps_string_internal.h")?
.write_to_file(include_dir.join("sixtyfps_string_internal.h"));
.context("Unable to generate bindings for slint_string_internal.h")?
.write_to_file(include_dir.join("slint_string_internal.h"));
cbindgen::Builder::new()
.with_config(config.clone())
.with_src(crate_dir.join("sharedvector.rs"))
.with_after_include("namespace sixtyfps { template<typename T> struct SharedVector; }")
.with_after_include("namespace slint { template<typename T> struct SharedVector; }")
.generate()
.context("Unable to generate bindings for sixtyfps_sharedvector_internal.h")?
.write_to_file(include_dir.join("sixtyfps_sharedvector_internal.h"));
.context("Unable to generate bindings for slint_sharedvector_internal.h")?
.write_to_file(include_dir.join("slint_sharedvector_internal.h"));
let mut properties_config = config.clone();
properties_config.export.exclude.clear();
@ -212,10 +212,10 @@ fn gen_corelib(
.with_config(properties_config)
.with_src(crate_dir.join("properties.rs"))
.with_src(crate_dir.join("callbacks.rs"))
.with_after_include("namespace sixtyfps { class Color; class Brush; }")
.with_after_include("namespace slint { class Color; class Brush; }")
.generate()
.context("Unable to generate bindings for sixtyfps_properties_internal.h")?
.write_to_file(include_dir.join("sixtyfps_properties_internal.h"));
.context("Unable to generate bindings for slint_properties_internal.h")?
.write_to_file(include_dir.join("slint_properties_internal.h"));
for (rust_types, extra_excluded_types, internal_header) in [
(
@ -223,59 +223,50 @@ fn gen_corelib(
"ImageInner",
"Image",
"Size",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_image_size",
"slint_image_path",
"SharedPixelBuffer",
"SharedImageBuffer",
],
vec!["Color"],
"sixtyfps_image_internal.h",
"slint_image_internal.h",
),
(
vec!["Color", "sixtyfps_color_brighter", "sixtyfps_color_darker"],
vec!["Color", "slint_color_brighter", "slint_color_darker"],
vec![],
"sixtyfps_color_internal.h",
"slint_color_internal.h",
),
(
vec![
"PathData",
"PathElement",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
],
vec!["PathData", "PathElement", "slint_new_path_elements", "slint_new_path_events"],
vec![],
"sixtyfps_pathdata_internal.h",
),
(
vec!["Brush", "LinearGradient", "GradientStop"],
vec!["Color"],
"sixtyfps_brush_internal.h",
"slint_pathdata_internal.h",
),
(vec!["Brush", "LinearGradient", "GradientStop"], vec!["Color"], "slint_brush_internal.h"),
]
.iter()
{
let mut special_config = config.clone();
special_config.export.include = rust_types.iter().map(|s| s.to_string()).collect();
special_config.export.exclude = [
"sixtyfps_visit_item_tree",
"sixtyfps_windowrc_drop",
"sixtyfps_windowrc_clone",
"sixtyfps_windowrc_show",
"sixtyfps_windowrc_hide",
"sixtyfps_windowrc_get_scale_factor",
"sixtyfps_windowrc_set_scale_factor",
"sixtyfps_windowrc_free_graphics_resources",
"sixtyfps_windowrc_set_focus_item",
"sixtyfps_windowrc_set_component",
"sixtyfps_windowrc_show_popup",
"sixtyfps_windowrc_set_rendering_notifier",
"sixtyfps_windowrc_request_redraw",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
"sixtyfps_color_brighter",
"sixtyfps_color_darker",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_visit_item_tree",
"slint_windowrc_drop",
"slint_windowrc_clone",
"slint_windowrc_show",
"slint_windowrc_hide",
"slint_windowrc_get_scale_factor",
"slint_windowrc_set_scale_factor",
"slint_windowrc_free_graphics_resources",
"slint_windowrc_set_focus_item",
"slint_windowrc_set_component",
"slint_windowrc_show_popup",
"slint_windowrc_set_rendering_notifier",
"slint_windowrc_request_redraw",
"slint_new_path_elements",
"slint_new_path_events",
"slint_color_brighter",
"slint_color_darker",
"slint_image_size",
"slint_image_path",
"IntSize",
]
.iter()
@ -295,9 +286,9 @@ fn gen_corelib(
special_config.structure.derive_eq = true;
special_config.structure.derive_neq = true;
// Put the rust type in a deeper "types" namespace, so the use of same type in for example generated
// Property<> fields uses the public `sixtyfps::Blah` type
// Property<> fields uses the public `slint::Blah` type
special_config.namespaces =
Some(vec!["sixtyfps".into(), "cbindgen_private".into(), "types".into()]);
Some(vec!["slint".into(), "cbindgen_private".into(), "types".into()]);
private_exported_types.extend(special_config.export.include.iter().cloned());
@ -319,7 +310,7 @@ fn gen_corelib(
// Generate a header file with some public API (enums, etc.)
let mut public_config = config.clone();
public_config.namespaces = Some(vec!["sixtyfps".into()]);
public_config.namespaces = Some(vec!["slint".into()]);
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
// Previously included types are now excluded (to avoid duplicates)
public_config.export.exclude = private_exported_types.into_iter().collect();
@ -348,23 +339,23 @@ fn gen_corelib(
.with_src(crate_dir.join("api.rs"))
.with_after_include(format!(
r"
/// This macro expands to the to the numeric value of the major version of SixtyFPS you're
/// This macro expands to the to the numeric value of the major version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 1.
#define SIXTYFPS_VERSION_MAJOR {}
/// This macro expands to the to the numeric value of the minor version of SixtyFPS you're
#define SLINT_VERSION_MAJOR {}
/// This macro expands to the to the numeric value of the minor version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 5.
#define SIXTYFPS_VERSION_MINOR {}
/// This macro expands to the to the numeric value of the patch version of SixtyFPS you're
#define SLINT_VERSION_MINOR {}
/// This macro expands to the to the numeric value of the patch version of Slint you're
/// developing against. For example if you're using version 1.5.2, this macro will expand to 2.
#define SIXTYFPS_VERSION_PATCH {}
#define SLINT_VERSION_PATCH {}
",
env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MINOR"),
env!("CARGO_PKG_VERSION_PATCH"),
))
.generate()
.context("Unable to generate bindings for sixtyfps_generated_public.h")?
.write_to_file(include_dir.join("sixtyfps_generated_public.h"));
.context("Unable to generate bindings for slint_generated_public.h")?
.write_to_file(include_dir.join("slint_generated_public.h"));
config.export.body.insert(
"ItemTreeNode".to_owned(),
@ -400,23 +391,23 @@ fn gen_corelib(
cbindgen::Builder::new()
.with_config(config)
.with_src(crate_dir.join("lib.rs"))
.with_include("sixtyfps_config.h")
.with_include("slint_config.h")
.with_include("vtable.h")
.with_include("sixtyfps_string.h")
.with_include("sixtyfps_sharedvector.h")
.with_include("sixtyfps_properties.h")
.with_include("sixtyfps_callbacks.h")
.with_include("sixtyfps_color.h")
.with_include("sixtyfps_image.h")
.with_include("sixtyfps_pathdata.h")
.with_include("sixtyfps_brush.h")
.with_include("sixtyfps_generated_public.h")
.with_include("slint_string.h")
.with_include("slint_sharedvector.h")
.with_include("slint_properties.h")
.with_include("slint_callbacks.h")
.with_include("slint_color.h")
.with_include("slint_image.h")
.with_include("slint_pathdata.h")
.with_include("slint_brush.h")
.with_include("slint_generated_public.h")
.with_after_include(
r"
namespace sixtyfps {
namespace slint {
namespace private_api { class WindowRc; }
namespace cbindgen_private {
using sixtyfps::private_api::WindowRc;
using slint::private_api::WindowRc;
using namespace vtable;
struct KeyEvent; struct PointerEvent;
using private_api::Property;
@ -428,7 +419,7 @@ namespace sixtyfps {
.with_trailer(gen_item_declarations(&items))
.generate()
.expect("Unable to generate bindings")
.write_to_file(include_dir.join("sixtyfps_internal.h"));
.write_to_file(include_dir.join("slint_internal.h"));
Ok(())
}
@ -470,11 +461,11 @@ fn gen_backend_qt(
cbindgen::Builder::new()
.with_config(config)
.with_crate(crate_dir)
.with_include("sixtyfps_internal.h")
.with_include("slint_internal.h")
.with_trailer(gen_item_declarations(&items))
.generate()
.context("Unable to generate bindings for sixtyfps_qt_internal.h")?
.write_to_file(include_dir.join("sixtyfps_qt_internal.h"));
.context("Unable to generate bindings for slint_qt_internal.h")?
.write_to_file(include_dir.join("slint_qt_internal.h"));
Ok(())
}
@ -493,10 +484,10 @@ fn gen_backend(
cbindgen::Builder::new()
.with_config(config)
.with_crate(crate_dir)
.with_header("#include <sixtyfps_internal.h>")
.with_header("#include <slint_internal.h>")
.generate()
.context("Unable to generate bindings for sixtyfps_backend_internal.h")?
.write_to_file(include_dir.join("sixtyfps_backend_internal.h"));
.context("Unable to generate bindings for slint_backend_internal.h")?
.write_to_file(include_dir.join("slint_backend_internal.h"));
Ok(())
}
@ -524,7 +515,7 @@ fn gen_interpreter(
// Generate a header file with some public API (enums, etc.)
let mut public_config = config.clone();
public_config.namespaces = Some(vec!["sixtyfps".into(), "interpreter".into()]);
public_config.namespaces = Some(vec!["slint".into(), "interpreter".into()]);
public_config.export.item_types = vec![cbindgen::ItemType::Enums, cbindgen::ItemType::Structs];
public_config.export.exclude = IntoIterator::into_iter([
@ -545,32 +536,32 @@ fn gen_interpreter(
.with_config(public_config)
.with_crate(crate_dir.clone())
.generate()
.context("Unable to generate bindings for sixtyfps_interpreter_generated_public.h")?
.write_to_file(include_dir.join("sixtyfps_interpreter_generated_public.h"));
.context("Unable to generate bindings for slint_interpreter_generated_public.h")?
.write_to_file(include_dir.join("slint_interpreter_generated_public.h"));
cbindgen::Builder::new()
.with_config(config)
.with_crate(crate_dir)
.with_include("sixtyfps_internal.h")
.with_include("sixtyfps_interpreter_generated_public.h")
.with_include("slint_internal.h")
.with_include("slint_interpreter_generated_public.h")
.with_after_include(
r"
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
struct Value;
using sixtyfps::interpreter::ValueType;
using sixtyfps::interpreter::PropertyDescriptor;
using sixtyfps::interpreter::Diagnostic;
using slint::interpreter::ValueType;
using slint::interpreter::PropertyDescriptor;
using slint::interpreter::Diagnostic;
}",
)
.generate()
.context("Unable to generate bindings for sixtyfps_interpreter_internal.h")?
.write_to_file(include_dir.join("sixtyfps_interpreter_internal.h"));
.context("Unable to generate bindings for slint_interpreter_internal.h")?
.write_to_file(include_dir.join("slint_interpreter_internal.h"));
Ok(())
}
/// Generate the headers.
/// `root_dir` is the root directory of the sixtyfps git repo
/// `root_dir` is the root directory of the slint git repo
/// `include_dir` is the output directory
/// Returns the list of all paths that contain dependencies to the generated output. If you call this
/// function from build.rs, feed each entry to stdout prefixed with `cargo:rerun-if-changed=`.

View file

@ -1,25 +0,0 @@
# Copyright © SixtyFPS GmbH <info@sixtyfps.io>
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
@PACKAGE_INIT@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
add_library(sixtyfps-cpp-shared SHARED IMPORTED)
set_target_properties(sixtyfps-cpp-shared PROPERTIES @SIXTYFPS_LIB_PROPERTIES@)
add_executable(SixtyFPS::sixtyfps-compiler IMPORTED GLOBAL)
set_target_properties(SixtyFPS::sixtyfps-compiler PROPERTIES IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_BINDIR@/sixtyfps-compiler${CMAKE_EXECUTABLE_SUFFIX}")
set(_IMPORT_PREFIX)
include("${CMAKE_CURRENT_LIST_DIR}/SixtyFPSTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SixtyFPSMacro.cmake")
set(SIXTYFPS_STYLE @SIXTYFPS_STYLE_DEFAULT@ CACHE STRING "The SixtyFPS widget style")

View file

@ -1,41 +0,0 @@
# Copyright © SixtyFPS GmbH <info@sixtyfps.io>
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
function(SIXTYFPS_TARGET_60_SOURCES target)
foreach (it IN ITEMS ${ARGN})
get_filename_component(_60_BASE_NAME ${it} NAME_WE)
get_filename_component(_60_ABSOLUTE ${it} REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(CMAKE_GENERATOR STREQUAL "Ninja")
# this code is inspired from the llvm source
# https://github.com/llvm/llvm-project/blob/a00290ed10a6b4e9f6e9be44ceec367562f270c6/llvm/cmake/modules/TableGen.cmake#L13
file(RELATIVE_PATH _60_BASE_NAME_REL ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h
COMMAND SixtyFPS::sixtyfps-compiler ${_60_ABSOLUTE}
-o ${_60_BASE_NAME_REL}.h --depfile ${_60_BASE_NAME_REL}.d
--style ${SIXTYFPS_STYLE}
DEPENDS SixtyFPS::sixtyfps-compiler ${_60_ABSOLUTE}
COMMENT "Generating ${_60_BASE_NAME}.h"
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.d
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else(CMAKE_GENERATOR STREQUAL "Ninja")
get_filename_component(_60_DIR ${_60_ABSOLUTE} DIRECTORY )
file(GLOB ALL_60S "${_60_DIR}/*.60")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h
COMMAND SixtyFPS::sixtyfps-compiler ${_60_ABSOLUTE}
-o ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h
--style ${SIXTYFPS_STYLE}
DEPENDS SixtyFPS::sixtyfps-compiler ${_60_ABSOLUTE} ${ALL_60S}
COMMENT "Generating ${_60_BASE_NAME}.h"
)
endif(CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h)
endforeach()
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endfunction()

View file

@ -0,0 +1,25 @@
# Copyright © SixtyFPS GmbH <info@sixtyfps.io>
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
@PACKAGE_INIT@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
add_library(slint-cpp-shared SHARED IMPORTED)
set_target_properties(slint-cpp-shared PROPERTIES @SLINT_LIB_PROPERTIES@)
add_executable(Slint::slint-compiler IMPORTED GLOBAL)
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION "${_IMPORT_PREFIX}/@CMAKE_INSTALL_BINDIR@/slint-compiler${CMAKE_EXECUTABLE_SUFFIX}")
set(_IMPORT_PREFIX)
include("${CMAKE_CURRENT_LIST_DIR}/SlintTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
set(SLINT_STYLE @SLINT_STYLE_DEFAULT@ CACHE STRING "The Slint widget style")

View file

@ -0,0 +1,41 @@
# Copyright © SixtyFPS GmbH <info@sixtyfps.io>
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
function(SLINT_TARGET_SOURCES target)
foreach (it IN ITEMS ${ARGN})
get_filename_component(_SLINT_BASE_NAME ${it} NAME_WE)
get_filename_component(_SLINT_ABSOLUTE ${it} REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(CMAKE_GENERATOR STREQUAL "Ninja")
# this code is inspired from the llvm source
# https://github.com/llvm/llvm-project/blob/a00290ed10a6b4e9f6e9be44ceec367562f270c6/llvm/cmake/modules/TableGen.cmake#L13
file(RELATIVE_PATH _SLINT_BASE_NAME_REL ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.h
COMMAND Slint::slint-compiler ${_SLINT_ABSOLUTE}
-o ${_SLINT_BASE_NAME_REL}.h --depfile ${_SLINT_BASE_NAME_REL}.d
--style ${SLINT_STYLE}
DEPENDS Slint::slint-compiler ${_SLINT_ABSOLUTE}
COMMENT "Generating ${_SLINT_BASE_NAME}.h"
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.d
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else(CMAKE_GENERATOR STREQUAL "Ninja")
get_filename_component(_SLINT_DIR ${_SLINT_ABSOLUTE} DIRECTORY )
file(GLOB ALL_SLINTS "${_SLINT_DIR}/*.slint")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.h
COMMAND Slint::slint-compiler ${_SLINT_ABSOLUTE}
-o ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.h
--style ${SLINT_STYLE}
DEPENDS Slint::slint-compiler ${_SLINT_ABSOLUTE} ${ALL_SLINTS}
COMMENT "Generating ${_SLINT_BASE_NAME}.h"
)
endif(CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.h)
endforeach()
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endfunction()

View file

@ -17,4 +17,4 @@ myst_parser = "*"
sphinx-markdown-tables = "*"
[requires]
python_version = "3.8"
python_version = "3"

View file

@ -1,6 +1,6 @@
{% extends "!layout.html" %}
{% block scripts %}
{{ super() }}
{% include "../../../../docs/resources/sixtyfps-docs-preview.html" %}
{% include "../../../../docs/resources/sixtyfps-docs-highlight.html" %}
{% endblock %}
{% include "../../../../docs/resources/slint-docs-preview.html" %}
{% include "../../../../docs/resources/slint-docs-highlight.html" %}
{% endblock %}

View file

@ -1,31 +1,31 @@
# Installing or Building with CMake
SixtyFPS comes with a CMake integration that automates the compilation step of the `.60` markup language files and
Slint comes with a CMake integration that automates the compilation step of the `.slint` markup language files and
offers a CMake target for convenient linkage.
*Note*: We recommend using the Ninja generator of CMake for the most efficient build and `.60` dependency tracking.
*Note*: We recommend using the Ninja generator of CMake for the most efficient build and `.slint` dependency tracking.
You can select the CMake Ninja backend by passing `-GNinja` or setting the `CMAKE_GENERATOR` environment variable to `Ninja`.
## Binary Packages
We also provide binary packages of SixtyFPS for use with C++, which eliminates the need to have Rust installed in your development environment.
We also provide binary packages of Slint for use with C++, which eliminates the need to have Rust installed in your development environment.
You can download one of our pre-built binaries for Linux or Windows on x86-64 architectures:
1. Open <https://github.com/sixtyfpsui/sixtyfps/releases>
2. Click on the latest release
3. From "Assets" download either `sixtyfps-cpp-XXX-Linux-x86_64.tar.gz` for a Linux archive
or `sixtyfps-cpp-XXX-win64.exe` for a Windows installer. ("XXX" refers to the version of the latest release)
3. From "Assets" download either `slint-cpp-XXX-Linux-x86_64.tar.gz` for a Linux archive
or `slint-cpp-XXX-win64.exe` for a Windows installer. ("XXX" refers to the version of the latest release)
4. Uncompress the downloaded archive or run the installer.
After extracting the artifact or running the installer, you can place the `lib` sub-directory into your `CMAKE_PREFIX_PATH` and `find_package(SixtyFPS)` should succeed in locating the package.
After extracting the artifact or running the installer, you can place the `lib` sub-directory into your `CMAKE_PREFIX_PATH` and `find_package(Slint)` should succeed in locating the package.
In the next section you will learn how to use the installed library in your application
and load `.60` UI files.
and load `.slint` UI files.
## Building from Sources
The recommended and most flexible way to use the C++ API is to build SixtyFPS from sources.
The recommended and most flexible way to use the C++ API is to build Slint from sources.
First you need to install the prerequisites:
@ -35,49 +35,49 @@ First you need to install the prerequisites:
* **[cmake](https://cmake.org/download/)** (3.19 or newer)
* A C++ compiler that supports C++20 (e.g., **MSVC 2019 16.6** on Windows)
You can include SixtyFPS in your CMake project using CMake's [`FetchContent`](https://cmake.org/cmake/help/latest/module/FetchContent.html) feature.
You can include Slint in your CMake project using CMake's [`FetchContent`](https://cmake.org/cmake/help/latest/module/FetchContent.html) feature.
Insert the following snippet into your `CMakeLists.txt` to make CMake download the latest release, compile it and make the CMake integration available:
```cmake
include(FetchContent)
FetchContent_Declare(
SixtyFPS
Slint
GIT_REPOSITORY https://github.com/sixtyfpsui/sixtyfps.git
GIT_TAG v0.1.6
SOURCE_SUBDIR api/cpp
)
FetchContent_MakeAvailable(SixtyFPS)
FetchContent_MakeAvailable(Slint)
```
If you prefer to treat SixtyFPS as an external CMake package, then you can also build SixtyFPS from source like a regular
CMake project, install it into a prefix directory of your choice and use `find_package(SixtyFPS)` in your `CMakeLists.txt`.
If you prefer to treat Slint as an external CMake package, then you can also build Slint from source like a regular
CMake project, install it into a prefix directory of your choice and use `find_package(Slint)` in your `CMakeLists.txt`.
### Features
The SixtyFPS run-time library supports different features that can be toggled. You might want to enable a feature that is
The Slint run-time library supports different features that can be toggled. You might want to enable a feature that is
not enabled by default but that is revelant for you, or you may want to disable a feature that you know you do not need and
therefore reduce the size of the resulting library.
The CMake configure step offers CMake options for various feature that are all prefixed with `SIXTYFPS_FEATURE_`. For example
you can enable support for the Wayland windowing system on Linux by enabling the `SIXTYFPS_FEATURE_WAYLAND` feature. There are
The CMake configure step offers CMake options for various feature that are all prefixed with `SLINT_FEATURE_`. For example
you can enable support for the Wayland windowing system on Linux by enabling the `SLINT_FEATURE_WAYLAND` feature. There are
different ways of toggling CMake options. For example on the command line using the `-D` parameter:
`cmake -DSIXTYFPS_FEATURE_WAYLAND=ON ...`
`cmake -DSLINT_FEATURE_WAYLAND=ON ...`
Alternatively, after the configure step you can use `cmake-gui` or `ccmake` on the build directory for a list of all features
and their description.
This works when compiling SixtyFPS as a package, using `cmake --build` and `cmake --install`, or when including SixtyFPS
This works when compiling Slint as a package, using `cmake --build` and `cmake --install`, or when including Slint
using `FetchContent`.
### Cross-compiling
It is possible to cross-compile SixtyFPS to a different target architecture when building with CMake. In order to complete
It is possible to cross-compile Slint to a different target architecture when building with CMake. In order to complete
that, you need to make sure that your CMake setup is ready for cross-compilation. You can find more information about
how to set this up in the [upstream CMake documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling).
If you are building against a Yocto SDK, it is sufficient to source the SDK's environment setup file.
Since SixtyFPS is implemented using the Rust programming language, you need to determine which Rust target
Since Slint is implemented using the Rust programming language, you need to determine which Rust target
matches the target architecture that you're compiling to. Please consult the [upstream Rust documentation](https://doc.rust-lang.org/nightly/rustc/platform-support.html) to find the correct target name. Now you need to install the Rust toolchain:
```sh
@ -85,7 +85,7 @@ rustup target add <target-name>
```
Then you're ready to invoke CMake and you need to add `-DRust_CARGO_TARGET=<target name>` to the CMake command line.
This ensures that the SixtyFPS library is built for the correct architecture.
This ensures that the Slint library is built for the correct architecture.
For example if you are building against an embedded Linux Yocto SDK targeting an ARM64 board, the following commands
show how to compile:
@ -103,10 +103,10 @@ Set up the environment and build:
<!-- cSpell:disable -->
```sh
. /path/to/yocto/sdk/environment-setup-cortexa53-crypto-poky-linux
cd sixtyfps
cd slint
mkdir build
cd build
cmake -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/sixtyfps/install/path ..
cmake -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/slint/install/path ..
cmake --build .
cmake --install .
```

View file

@ -21,14 +21,14 @@ import textwrap
# -- Project information -----------------------------------------------------
project = "SixtyFPS C++"
project = "Slint C++"
copyright = "2021, info@sixtyfps.io"
author = "info@sixtyfps.io"
# The full version, including alpha/beta/rc tags
version = "0.2.0"
cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
cpp_index_common_prefix = ["slint::", "slint::interpreter::"]
# -- General configuration ---------------------------------------------------
@ -37,8 +37,8 @@ cpp_index_common_prefix = ["sixtyfps::", "sixtyfps::interpreter::"]
# ones.
extensions = ["breathe", "myst_parser", "exhale", "sphinx_markdown_tables"]
breathe_projects = {"SixtyFPS": "./docs/xml"}
breathe_default_project = "SixtyFPS"
breathe_projects = {"Slint": "./docs/xml"}
breathe_default_project = "Slint"
exhale_args = {
"containmentFolder": "./api",
@ -47,21 +47,21 @@ exhale_args = {
"afterTitleDescription": textwrap.dedent(
"""
The following sections present the C++ API Reference. All types are
within the :ref:`sixtyfps<namespace_sixtyfps>` namespace and are accessible by including
the :code:`sixtyfps.h` header file.
within the :ref:`slint<namespace_slint>` namespace and are accessible by including
the :code:`slint.h` header file.
If you choose to load :code:`.60` files dynamically at run-time, then
you can use the classes in :ref:`sixtyfps::interpreter<namespace_sixtyfps__interpreter>`, starting at
:cpp:class:`sixtyfps::interpreter::ComponentCompiler`. You need to include
the :code:`sixtyfps_interpreter.h` header file.
If you choose to load :code:`.slint` files dynamically at run-time, then
you can use the classes in :ref:`slint::interpreter<namespace_slint__interpreter>`, starting at
:cpp:class:`slint::interpreter::ComponentCompiler`. You need to include
the :code:`slint_interpreter.h` header file.
"""
),
"doxygenStripFromPath": "..",
"createTreeView": True,
"exhaleExecutesDoxygen": True,
"exhaleDoxygenStdin": """INPUT = ../../api/cpp/include generated_include
EXCLUDE_SYMBOLS = sixtyfps::cbindgen_private* sixtyfps::private_api* vtable* SIXTYFPS_DECL_ITEM
EXCLUDE = ../../api/cpp/include/vtable.h ../../api/cpp/include/sixtyfps_testing.h
EXCLUDE_SYMBOLS = slint::cbindgen_private* slint::private_api* vtable* SLINT_DECL_ITEM
EXCLUDE = ../../api/cpp/include/vtable.h ../../api/cpp/include/slint_testing.h
ENABLE_PREPROCESSING = YES
PREDEFINED += DOXYGEN
WARN_AS_ERROR = YES""",
@ -103,7 +103,7 @@ html_static_path = ["_static"]
html_show_sourcelink = False
html_logo = "logo.drawio.svg"
html_logo = "https://slint-ui.com/logo/slint-logo-small-light.svg"
myst_enable_extensions = [
"html_image",

View file

@ -8,11 +8,11 @@ This guide lists all API incompatible changes between major versions and describ
In version 0.2.0 we have increased the minimum version of C++. You need to have a C++ compiler installed that supports C++ 20 or newer.
If you are building SixtyFPS from source, you need to make sure that your Rust installation is up-to-date. If you have installed Rust using `rustup`, then you can upgrade to the latest Version of Rust by running `rustup update`.
If you are building Slint from source, you need to make sure that your Rust installation is up-to-date. If you have installed Rust using `rustup`, then you can upgrade to the latest Version of Rust by running `rustup update`.
### CMakeLists.txt
- When using `FetchContent`, the `SOURCE_SUBDIR` has changed from `api/sixtyfps-cpp` to `api/cpp`
- When using `FetchContent`, the `SOURCE_SUBDIR` has changed from `api/sixtyfps-cpp` to `api/cpp`
### Models
@ -43,7 +43,7 @@ if (value.has_value()) {
#### Callbacks
Callbacks declared in `.60` markup can be invoked from C++ using {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_callback()` or {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_global_callback()`. The arguments to the callback at invocation time used to require the use of `sixtyfps::Slice` type. This was changed to use the C++ 20 [`std::span`](https://en.cppreference.com/w/cpp/container/span) type, for easier passing.
Callbacks declared in `.slint` markup can be invoked from C++ using {cpp:func}`slint::interpreter::ComponentInstance::invoke_callback()` or {cpp:func}`slint::interpreter::ComponentInstance::invoke_global_callback()`. The arguments to the callback at invocation time used to require the use of `sixtyfps::Slice` type. This was changed to use the C++ 20 [`std::span`](https://en.cppreference.com/w/cpp/container/span) type, for easier passing.
Old code:
@ -55,10 +55,19 @@ instance->invoke_callback("foo", sixtyfps::Slice{ args, 2 });
New code:
```cpp
sixtyfps::Value args[] = { SharedString("Hello"), 42. };
slint::Value args[] = { SharedString("Hello"), 42. };
instance->invoke_callback("foo", args);
```
#### Models
The `Value::Type::Array` has been replaced by `Value::Type::Model`
### CMake Interface
The CMake interface has changed mostly in terms of renaming `SixtyFPS` to `Slint`:
* `find_package(SixtyFPS)` becomes `find_package(Slint)`.
* The `SixtyFPS::SixtyFPS` CMake target was renamed to `Slint::Slint`.
* The `sixtyfps_target_60_sources` CMake command was renamed to `slint_target_sources`.

View file

@ -1,16 +1,16 @@
# Generated code
The SixtyFPS compiler called by the build system will generate a header file for the root `.60`
The Slint compiler called by the build system will generate a header file for the root `.slint`
file. This header file will contain a `class` with the same name as the component.
This class will have the following public member functions:
* A `create` constructor function and a destructor.
* A `show` function, which will show the component on the screen. Note that in order to render
and react to user input, it's still necessary to spin the event loop, by calling {cpp:func}`sixtyfps::run_event_loop()`
and react to user input, it's still necessary to spin the event loop, by calling {cpp:func}`slint::run_event_loop()`
or using the convenience `fun` function in this class.
* A `hide` function, which de-registers the component from the windowing system.
* A `window` function that provides access to the {cpp:class}`sixtyfps::Window`, allow for further customization
* A `window` function that provides access to the {cpp:class}`slint::Window`, allow for further customization
towards the windowing system.
* A `run` convenience function, which will show the component and starts the event loop.
* for each properties:
@ -22,20 +22,20 @@ This class will have the following public member functions:
for this callback. the functor must accept the type parameter of the callback
* A `global` function, to provide access to any exported global singletons.
The class is instantiated with the `create` function, which returns the type wrapped in {cpp:class}`sixtyfps::ComponentHandle`.
This is a smart pointer that owns the actual instance and keeps it alive as long as at least one {cpp:class}`sixtyfps::ComponentHandle`
The class is instantiated with the `create` function, which returns the type wrapped in {cpp:class}`slint::ComponentHandle`.
This is a smart pointer that owns the actual instance and keeps it alive as long as at least one {cpp:class}`slint::ComponentHandle`
is in scope, similar to `std::shared_ptr<T>`.
For more complex UIs it is common to supply data in the form of an abstract data model, that is used with
[`for` - `in`](markdown/langref.md#repetition) repetitions or [`ListView`](markdown/widgets.md#listview) elements in the `.60` language.
All models in C++ are sub-classes of the {cpp:class}`sixtyfps::Model` and you can sub-class it yourself. For convenience,
the {cpp:class}`sixtyfps::VectorModel` provides an implementation that is backed by a `std::vector<T>`.
[`for` - `in`](markdown/langref.md#repetition) repetitions or [`ListView`](markdown/widgets.md#listview) elements in the `.slint` language.
All models in C++ are sub-classes of the {cpp:class}`slint::Model` and you can sub-class it yourself. For convenience,
the {cpp:class}`slint::VectorModel` provides an implementation that is backed by a `std::vector<T>`.
## Example
Let's assume we have this code in our `.60` file
Let's assume we have this code in our `.slint` file
```60
```slint
SampleComponent := Window {
property<int> counter;
property<string> user_name;
@ -49,20 +49,20 @@ This will generate a header with the following contents (edited for documentatio
```cpp
#include <array>
#include <limits>
#include <sixtyfps.h>
#include <slint.h>
class SampleComponent {
public:
/// Constructor function
inline auto create () -> sixtyfps::ComponentHandle<MainWindow>;
inline auto create () -> slint::ComponentHandle<MainWindow>;
/// Destructor
inline ~SampleComponent ();
/// Show this component, and runs the event loop
inline void run () const;
/// Show the window that renders this component. Call `sixtyfps::run_event_loop()`
/// Show the window that renders this component. Call `slint::run_event_loop()`
/// to continuously render the contents and react to user input.
inline void show () const;
@ -75,9 +75,9 @@ public:
inline void set_counter (const int &value) const;
/// Getter for the `user_name` property
inline sixtyfps::SharedString get_user_name () const;
inline slint::SharedString get_user_name () const;
/// Setter for the `user_name` property
inline void set_user_name (const sixtyfps::SharedString &value) const;
inline void set_user_name (const slint::SharedString &value) const;
/// Call this function to call the `hello` callback
inline void invoke_hello () const;
@ -95,14 +95,14 @@ private:
## Global Singletons
In `.60` files it is possible to declare [singletons that are globally available](markdown/langref.md#global-singletons).
In `.slint` files it is possible to declare [singletons that are globally available](markdown/langref.md#global-singletons).
You can access them from to your C++ code by exporting them and using the `global()` getter function in the
C++ class generated for your entry component. Each global singleton creates a class that has getter/setter functions
for properties and callbacks, similar to API that's created for your `.60` component, as demonstrated in the previous section.
for properties and callbacks, similar to API that's created for your `.slint` component, as demonstrated in the previous section.
For example the following `.60` markup defines a global `Logic` singleton that's also exported:
For example the following `.slint` markup defines a global `Logic` singleton that's also exported:
```60,ignore
```slint,ignore
export global Logic := {
callback to_uppercase(string) -> string;
}

View file

@ -1,11 +1,11 @@
# Getting Started
Once SixtyFPS is built, you can use it in your CMake application or library target in two steps:
Once Slint is built, you can use it in your CMake application or library target in two steps:
1. Associate the `.60` files that you'd like to use by calling the `sixtyfps_target_60_sources` cmake command. The first parameter is
your application (or library) CMake target, and the parameters following are the names of the `.60` files. This will result in the
`.60` files to be compiled into C++ source code.
2. The generated C++ source code also needs the SixtyFPS run-time library. This dependency is satisfied by linking `SixtyFPS::SixtyFPS`
1. Associate the `.slint` files that you'd like to use by calling the `slint_target_sources` cmake command. The first parameter is
your application (or library) CMake target, and the parameters following are the names of the `.slint` files. This will result in the
`.slint` files to be compiled into C++ source code.
2. The generated C++ source code also needs the Slint run-time library. This dependency is satisfied by linking `Slint::Slint`
into your target with the `target_link_libraries` command.
A typical example looks like this:
@ -14,25 +14,25 @@ A typical example looks like this:
cmake_minimum_required(VERSION 3.19)
project(my_application LANGUAGES CXX)
# Note: Use find_package(SixtyFPS) instead of the following three commands,
# Note: Use find_package(Slint) instead of the following three commands,
# if you prefer the package approach.
include(FetchContent)
FetchContent_Declare(
SixtyFPS
Slint
GIT_REPOSITORY https://github.com/sixtyfpsui/sixtyfps.git
GIT_TAG v0.1.6
SOURCE_SUBDIR api/cpp
)
FetchContent_MakeAvailable(SixtyFPS)
FetchContent_MakeAvailable(Slint)
add_executable(my_application main.cpp)
sixtyfps_target_60_sources(my_application my_application_ui.60)
target_link_libraries(my_application PRIVATE SixtyFPS::SixtyFPS)
slint_target_sources(my_application my_application_ui.slint)
target_link_libraries(my_application PRIVATE Slint::Slint)
```
Suppose `my_application_ui.60` was a "Hello World" like this:
Suppose `my_application_ui.slint` was a "Hello World" like this:
```60,ignore
```slint,ignore
HelloWorld := Window {
width: 400px;
height: 400px;
@ -65,17 +65,17 @@ int main(int argc, char **argv)
}
```
This works because the SixtyFPS compiler translated `my_application_ui.60` to C++ code, in the `my_application_ui.h`
This works because the Slint compiler translated `my_application_ui.slint` to C++ code, in the `my_application_ui.h`
header file. That generated code has a C++ class that corresponds to the `HelloWorld` element and has API to create
the ui, read or write properties or set callbacks. You can learn more about how this API looks like in general in the
[](generated_code.md) section.
## Tutorial
For an in-depth walk-through, you may be interested in reading our walk-through <a href="../tutorial/cpp">SixtyFPS Memory Game Tutorial Tutorial</a>.
It will guide you through the `.60` mark-up language and the C++ API by building a little memory game.
For an in-depth walk-through, you may be interested in reading our walk-through <a href="../tutorial/cpp">Slint Memory Game Tutorial Tutorial</a>.
It will guide you through the `.slint` mark-up language and the C++ API by building a little memory game.
## Template
You can clone the [Template Repository](https://github.com/sixtyfpsui/sixtyfps-cpp-template) repository with
the code of a minimal C++ application using SixtyFPS that can be used as a starting point to your program.
the code of a minimal C++ application using Slint that can be used as a starting point to your program.

View file

@ -1,9 +1,9 @@
.. Copyright © SixtyFPS GmbH <info@sixtyfps.io>
.. SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
.. SixtyFPS C++ documentation master file
.. Slint C++ documentation master file
Welcome to SixtyFPS C++'s documentation!
Welcome to Slint C++'s documentation!
========================================
.. toctree::
@ -18,7 +18,7 @@ Welcome to SixtyFPS C++'s documentation!
.. toctree::
:maxdepth: 2
:hidden:
:caption: C++ / .60 Integration
:caption: C++ / .slint Integration
Overview <overview.md>
@ -49,17 +49,17 @@ Welcome to SixtyFPS C++'s documentation!
:target: https://github.com/sixtyfpsui/sixtyfps/discussions
:alt: GitHub Discussions
`SixtyFPS <https://sixtyfps.io/>`_ is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications.
SixtyFPS C++ is the C++ API to interact with a SixtyFPS UI from C++.
`Slint <https://slint-ui.com/>`_ is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications.
Slint C++ is the C++ API to interact with a Slint UI from C++.
The .60 Markup Language
The .slint Markup Language
=======================
SixtyFPS comes with a markup language that is specifically designed for user interfaces. This language provides a
Slint comes with a markup language that is specifically designed for user interfaces. This language provides a
powerful way to describe graphical elements, their placement, and the flow of data through the different states. It is a familiar syntax to describe the hierarchy
of elements and property bindings. Here's the obligatory "Hello World":
.. code-block:: 60-no-preview
.. code-block:: slint-no-preview
HelloWorld := Window {
width: 400px;
@ -78,19 +78,19 @@ Check out the `language reference <markdown/langref.html>`_ for more details.
Architecture
============
An application is composed of the business logic written in C++ and the `.60` user interface design markup, which
An application is composed of the business logic written in C++ and the `.slint` user interface design markup, which
is compiled to native code.
.. image:: https://sixtyfps.io/resources/architecture.drawio.svg
.. image:: https://slint-ui.com/resources/architecture.drawio.svg
:alt: Architecture Overview
Developing
==========
You can create and edit `.60` files using our `SixtyFPS Visual Studio Code Extension <https://marketplace.visualstudio.com/items?itemName=SixtyFPS.sixtyfps-vscode>`_,
You can create and edit `.slint` files using our `Slint Visual Studio Code Extension <https://marketplace.visualstudio.com/items?itemName=Slint.slint>`_,
which features syntax highlighting and live design preview.
For a quick edit and preview cycle, you can also use the :code:`sixtyfps-viewer` command line tool, which can be installed using :code:`cargo install sixtyfps-viewer`,
if you have `Cargo <https://marketplace.visualstudio.com/items?itemName=SixtyFPS.sixtyfps-vscode>`_ installed.
For a quick edit and preview cycle, you can also use the :code:`slint-viewer` command line tool, which can be installed using :code:`cargo install slint-viewer`,
if you have `Cargo <https://marketplace.visualstudio.com/items?itemName=Slint.slint>`_ installed.
In the next section you will learn how to install the SixtyFPS C++ library and the CMake build system integration.
In the next section you will learn how to install the Slint C++ library and the CMake build system integration.

View file

@ -1,7 +1,7 @@
.. Copyright © SixtyFPS GmbH <info@sixtyfps.io>
.. SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
The .60 UI Design Language
The .slint UI Design Language
==========================
.. toctree::

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,3 +0,0 @@
Copyright © SixtyFPS GmbH <info@sixtyfps.io>
SPDX-License-Identifier: CC-BY-ND-4.0

View file

@ -1,56 +1,56 @@
# Overview
The following two sections explain how you can integrate your `.60` designs into your
C++ application. The entry point is a `.60` file that contains your primary component
The following two sections explain how you can integrate your `.slint` designs into your
C++ application. The entry point is a `.slint` file that contains your primary component
that you instantiate from C++.
There are two ways in that you can instantiate your `.60` designs in your C++ application,
There are two ways in that you can instantiate your `.slint` designs in your C++ application,
either by compiling them ahead of time or by dynamically loading them at run-time.
Once instantiated you feed data into it, for example by setting properties, populating
data models or setting up callbacks that are invoked when the user activates certain elements.
## Compiled `.60` designs
## Compiled `.slint` designs
You can choose to compile a `.60` file to C++, which provides the best performance
You can choose to compile a `.slint` file to C++, which provides the best performance
and lowest memory consumption.
The `sixtyfps_target_60_sources` cmake command makes the translation automatic
The `slint_target_sources` cmake command makes the translation automatic
and [generated code](generated_code.md) has an API that allows setting and getting
property values, etc. That API will use types from the {ref}`sixtyfps <namespace_sixtyfps>`
namespace, for example {cpp:class}`sixtyfps::SharedString` or {cpp:class}`sixtyfps::Color`.
property values, etc. That API will use types from the {ref}`slint <namespace_slint>`
namespace, for example {cpp:class}`slint::SharedString` or {cpp:class}`slint::Color`.
## Run-time interpreted `.60` designs
## Run-time interpreted `.slint` designs
Instead of compiling `.60` designs to C++, you can also choose to dynamically load `.60`
Instead of compiling `.slint` designs to C++, you can also choose to dynamically load `.slint`
files at run-time. This is slower than compiling them ahead of time and requires more memory,
however it provides more flexibility in your application design.
The entry point to loading a `.60` file is the {cpp:class}`sixtyfps::interpreter::ComponentCompiler`
class in the {ref}`sixtyfps::interpreter <namespace_sixtyfps__interpreter>` namespace.
The entry point to loading a `.slint` file is the {cpp:class}`slint::interpreter::ComponentCompiler`
class in the {ref}`slint::interpreter <namespace_slint__interpreter>` namespace.
With the help of {cpp:class}`sixtyfps::interpreter::ComponentCompiler` you create a {cpp:class}`sixtyfps::interpreter::ComponentDefinition`,
With the help of {cpp:class}`slint::interpreter::ComponentCompiler` you create a {cpp:class}`slint::interpreter::ComponentDefinition`,
which provides you with information about properties and callbacks that are common to all instances. The
{cpp:func}`sixtyfps::interpreter::ComponentDefinition::create()` function creates new instances, which
are wrapped in {cpp:class}`sixtyfps::ComponentHandle`. This is a smart pointer that owns the actual instance
and keeps it alive as long as at least one {cpp:class}`sixtyfps::ComponentHandle` is in scope, similar to `std::shared_ptr<T>`.
{cpp:func}`slint::interpreter::ComponentDefinition::create()` function creates new instances, which
are wrapped in {cpp:class}`slint::ComponentHandle`. This is a smart pointer that owns the actual instance
and keeps it alive as long as at least one {cpp:class}`slint::ComponentHandle` is in scope, similar to `std::shared_ptr<T>`.
All property values in `.60` are mapped to {cpp:class}`sixtyfps::interpreter::Value` in C++. This is a
All property values in `.slint` are mapped to {cpp:class}`slint::interpreter::Value` in C++. This is a
polymorphic data type that can hold different kinds of values, such as numbers, strings or even data models.
For more complex UIs it is common to supply data in the form of an abstract data model, that is used with
[`for` - `in`](markdown/langref.md#repetition) repetitions or [`ListView`](markdown/widgets.md#listview) elements in the `.60` language.
All models in C++ with the interpreter API are sub-classes of the {cpp:class}`sixtyfps::Model` where the template
parameter is {cpp:class}`sixtyfps::interpreter::Value`. Therefore to provide your own data model, you can subclass
`sixtyfps::Model<sixtyfps::interpreter::Value>`.
[`for` - `in`](markdown/langref.md#repetition) repetitions or [`ListView`](markdown/widgets.md#listview) elements in the `.slint` language.
All models in C++ with the interpreter API are sub-classes of the {cpp:class}`slint::Model` where the template
parameter is {cpp:class}`slint::interpreter::Value`. Therefore to provide your own data model, you can subclass
`slint::Model<slint::interpreter::Value>`.
In `.60` files it is possible to declare [singletons that are globally available](markdown/langref.md#global-singletons).
In `.slint` files it is possible to declare [singletons that are globally available](markdown/langref.md#global-singletons).
You can access them from to your C++ code by exporting them and using the getter and setter functions on
{cpp:class}`sixtyfps::interpreter::ComponentInstance` to change properties and callbacks:
{cpp:class}`slint::interpreter::ComponentInstance` to change properties and callbacks:
1. {cpp:func}`sixtyfps::interpreter::ComponentInstance::set_global_property()`
1. {cpp:func}`sixtyfps::interpreter::ComponentInstance::get_global_property()`
1. {cpp:func}`sixtyfps::interpreter::ComponentInstance::set_global_callback()`
1. {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_global_callback()`
1. {cpp:func}`slint::interpreter::ComponentInstance::set_global_property()`
1. {cpp:func}`slint::interpreter::ComponentInstance::get_global_property()`
1. {cpp:func}`slint::interpreter::ComponentInstance::set_global_callback()`
1. {cpp:func}`slint::interpreter::ComponentInstance::invoke_global_callback()`

View file

@ -1,17 +1,17 @@
# Type Mappings
The types used for properties in `.60` design markup each translate to specific types in C++.
The types used for properties in `.slint` design markup each translate to specific types in C++.
The follow table summarizes the entire mapping:
| `.60` Type | C++ Type | Note |
| `.slint` Type | C++ Type | Note |
| --- | --- | --- |
| `int` | `int` | |
| `float` | `float` | |
| `bool` | `bool` | |
| `string` | [`sixtyfps::SharedString`](api/structsixtyfps_1_1_shared_string.html) | A reference-counted string type that uses UTF-8 encoding and can be easily converted to a std::string_view or a const char *. |
| `color` | [`sixtyfps::Color`](api/classsixtyfps_1_1_color.html) | |
| `brush` | [`sixtyfps::Brush`](api/classsixtyfps_1_1_brush.html) | |
| `image` | [`sixtyfps::Image`](api/structsixtyfps_1_1_image.html) | |
| `string` | [`slint::SharedString`](api/structslint_1_1_shared_string.html) | A reference-counted string type that uses UTF-8 encoding and can be easily converted to a std::string_view or a const char *. |
| `color` | [`slint::Color`](api/classslint_1_1_color.html) | |
| `brush` | [`slint::Brush`](api/classslint_1_1_brush.html) | |
| `image` | [`slint::Image`](api/structslint_1_1_image.html) | |
| `physical_length` | `float` | The unit are physical pixels. |
| `length` | `float` | At run-time, logical lengths are automatically translated to physical pixels using the device pixel ratio. |
| `duration` | `std::int64_t` | At run-time, durations are always represented as signed 64-bit integers with millisecond precision. |
@ -20,12 +20,12 @@ The follow table summarizes the entire mapping:
## Structures
For user-defined structures in the .60 code, a `class` of the same name is generated with data member
For user-defined structures in the .slint code, a `class` of the same name is generated with data member
in lexicographic order.
For example, if you have this structure in the .60 file
For example, if you have this structure in the .slint file
```60,ignore
```slint,ignore
export struct MyStruct := {
foo: int,
bar: string,
@ -37,7 +37,7 @@ It would result in the following type being generated:
```cpp
class MyStruct {
public:
sixtyfps::SharedString bar;
slint::SharedString bar;
int foo;
};
```

View file

@ -19,23 +19,23 @@
#include <condition_variable>
#include <span>
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
// Workaround https://github.com/eqrion/cbindgen/issues/43
struct ComponentVTable;
struct ItemVTable;
}
#include "sixtyfps_internal.h"
#include "sixtyfps_backend_internal.h"
#include "sixtyfps_qt_internal.h"
#include "slint_internal.h"
#include "slint_backend_internal.h"
#include "slint_qt_internal.h"
/// \rst
/// The :code:`sixtyfps` namespace is the primary entry point into the SixtyFPS C++ API.
/// The :code:`slint` namespace is the primary entry point into the Slint C++ API.
/// All available types are in this namespace.
///
/// See the :doc:`Overview <../overview>` documentation for the C++ integration how
/// to load :code:`.60` designs.
/// to load :code:`.slint` designs.
/// \endrst
namespace sixtyfps {
namespace slint {
// Bring opaque structure in scope
namespace private_api {
@ -60,7 +60,7 @@ using cbindgen_private::StandardListViewItem;
/// thread is indeed called from the main thread, or abort the program otherwise
///
/// Most API should be called from the main thread. When using thread one must
/// use sixtyfps::invoke_from_event_loop
/// use slint::invoke_from_event_loop
inline void assert_main_thread()
{
#ifndef NDEBUG
@ -70,7 +70,7 @@ inline void assert_main_thread()
"thread."
<< std::endl;
std::cerr << "Most API should be called from the main thread. When using thread one must "
"use sixtyfps::invoke_from_event_loop."
"use slint::invoke_from_event_loop."
<< std::endl;
std::abort();
}
@ -81,12 +81,12 @@ class WindowRc
{
public:
explicit WindowRc(cbindgen_private::WindowRcOpaque adopted_inner) : inner(adopted_inner) { }
WindowRc() { cbindgen_private::sixtyfps_windowrc_init(&inner); }
~WindowRc() { cbindgen_private::sixtyfps_windowrc_drop(&inner); }
WindowRc() { cbindgen_private::slint_windowrc_init(&inner); }
~WindowRc() { cbindgen_private::slint_windowrc_drop(&inner); }
WindowRc(const WindowRc &other)
{
assert_main_thread();
cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
}
WindowRc(WindowRc &&) = delete;
WindowRc &operator=(WindowRc &&) = delete;
@ -94,35 +94,35 @@ public:
{
assert_main_thread();
if (this != &other) {
cbindgen_private::sixtyfps_windowrc_drop(&inner);
cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
cbindgen_private::slint_windowrc_drop(&inner);
cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
}
return *this;
}
void show() const { sixtyfps_windowrc_show(&inner); }
void hide() const { sixtyfps_windowrc_hide(&inner); }
void show() const { slint_windowrc_show(&inner); }
void hide() const { slint_windowrc_hide(&inner); }
float scale_factor() const { return sixtyfps_windowrc_get_scale_factor(&inner); }
void set_scale_factor(float value) const { sixtyfps_windowrc_set_scale_factor(&inner, value); }
float scale_factor() const { return slint_windowrc_get_scale_factor(&inner); }
void set_scale_factor(float value) const { slint_windowrc_set_scale_factor(&inner, value); }
template<typename Component, typename ItemTree>
void free_graphics_resources(Component *c, ItemTree items) const
{
cbindgen_private::sixtyfps_component_free_item_graphics_resources(
cbindgen_private::slint_component_free_item_graphics_resources(
vtable::VRef<ComponentVTable> { &Component::static_vtable, c }, items, &inner);
}
void set_focus_item(const ComponentRc &component_rc, uintptr_t item_index)
{
cbindgen_private::ItemRc item_rc { component_rc, item_index };
cbindgen_private::sixtyfps_windowrc_set_focus_item(&inner, &item_rc);
cbindgen_private::slint_windowrc_set_focus_item(&inner, &item_rc);
}
template<typename Component, typename ItemTree>
void init_items(Component *c, ItemTree items) const
{
cbindgen_private::sixtyfps_component_init_items(
cbindgen_private::slint_component_init_items(
vtable::VRef<ComponentVTable> { &Component::static_vtable, c }, items, &inner);
}
@ -130,7 +130,7 @@ public:
void set_component(const Component &c) const
{
auto self_rc = c.self_weak.lock().value().into_dyn();
sixtyfps_windowrc_set_component(&inner, &self_rc);
slint_windowrc_set_component(&inner, &self_rc);
}
template<typename Component, typename Parent>
@ -138,7 +138,7 @@ public:
cbindgen_private::ItemRc parent_item) const
{
auto popup = Component::create(parent_component).into_dyn();
cbindgen_private::sixtyfps_windowrc_show_popup(&inner, &popup, p, &parent_item);
cbindgen_private::slint_windowrc_show_popup(&inner, &popup, p, &parent_item);
}
template<typename F>
@ -148,7 +148,7 @@ public:
(*reinterpret_cast<F *>(data))(state, graphics_api);
};
SetRenderingNotifierError err;
if (cbindgen_private::sixtyfps_windowrc_set_rendering_notifier(
if (cbindgen_private::slint_windowrc_set_rendering_notifier(
&inner, actual_cb,
[](void *user_data) { delete reinterpret_cast<F *>(user_data); },
new F(std::move(callback)), &err)) {
@ -158,7 +158,7 @@ public:
}
}
void request_redraw() const { cbindgen_private::sixtyfps_windowrc_request_redraw(&inner); }
void request_redraw() const { cbindgen_private::slint_windowrc_request_redraw(&inner); }
private:
cbindgen_private::WindowRcOpaque inner;
@ -221,10 +221,9 @@ inline vtable::Layout drop_in_place(ComponentRef component)
// so we have a relocation to a function that returns the address we seek. That
// relocation will be resolved to the locally linked stub library, the implementation of
// which will be patched.
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) \
sixtyfps::private_api::sixtyfps_get_##VTableName()
# define SLINT_GET_ITEM_VTABLE(VTableName) slint::private_api::slint_get_##VTableName()
# else
# define SIXTYFPS_GET_ITEM_VTABLE(VTableName) (&sixtyfps::private_api::VTableName)
# define SLINT_GET_ITEM_VTABLE(VTableName) (&slint::private_api::VTableName)
# endif
#endif // !defined(DOXYGEN)
@ -245,7 +244,7 @@ class ComponentWeakHandle;
/// The component handle is like a shared pointer to a component in the generated code.
/// In order to get a component, use `T::create()` where T is the name of the component
/// in the .60 file. This give you a `ComponentHandle<T>`
/// in the .slint file. This give you a `ComponentHandle<T>`
template<typename T>
class ComponentHandle
{
@ -368,10 +367,10 @@ struct Timer
/// the destructor of the timer is called.
///
/// This is a convenience function and equivalent to calling
/// `start(sixtyfps::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
/// `start(slint::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
template<typename F>
Timer(std::chrono::milliseconds interval, F callback)
: id(cbindgen_private::sixtyfps_timer_start(
: id(cbindgen_private::slint_timer_start(
-1, TimerMode::Repeated, interval.count(),
[](void *data) { (*reinterpret_cast<F *>(data))(); }, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); }))
@ -379,7 +378,7 @@ struct Timer
}
Timer(const Timer &) = delete;
Timer &operator=(const Timer &) = delete;
~Timer() { cbindgen_private::sixtyfps_timer_destroy(id); }
~Timer() { cbindgen_private::slint_timer_destroy(id); }
/// Starts the timer with the given \a mode and \a interval, in order for the \a callback to
/// called when the timer fires. If the timer has been started previously and not fired yet,
@ -387,27 +386,27 @@ struct Timer
template<typename F>
void start(TimerMode mode, std::chrono::milliseconds interval, F callback)
{
id = cbindgen_private::sixtyfps_timer_start(
id = cbindgen_private::slint_timer_start(
id, mode, interval.count(), [](void *data) { (*reinterpret_cast<F *>(data))(); },
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
/// Stops the previously started timer. Does nothing if the timer has never been started. A
/// stopped timer cannot be restarted with restart() -- instead you need to call start().
void stop() { cbindgen_private::sixtyfps_timer_stop(id); }
void stop() { cbindgen_private::slint_timer_stop(id); }
/// Restarts the timer. If the timer was previously started by calling [`Self::start()`]
/// with a duration and callback, then the time when the callback will be next invoked
/// is re-calculated to be in the specified duration relative to when this function is called.
///
/// Does nothing if the timer was never started.
void restart() { cbindgen_private::sixtyfps_timer_restart(id); }
void restart() { cbindgen_private::slint_timer_restart(id); }
/// Returns true if the timer is running; false otherwise.
bool running() const { return cbindgen_private::sixtyfps_timer_running(id); }
bool running() const { return cbindgen_private::slint_timer_running(id); }
/// Call the callback after the given duration.
template<typename F>
static void single_shot(std::chrono::milliseconds duration, F callback)
{
cbindgen_private::sixtyfps_timer_singleshot(
cbindgen_private::slint_timer_singleshot(
duration.count(), [](void *data) { (*reinterpret_cast<F *>(data))(); },
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -437,14 +436,14 @@ inline SharedVector<float> solve_box_layout(const cbindgen_private::BoxLayoutDat
SharedVector<float> result;
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr),
repeater_indexes.len };
cbindgen_private::sixtyfps_solve_box_layout(&data, ri, &result);
cbindgen_private::slint_solve_box_layout(&data, ri, &result);
return result;
}
inline SharedVector<float> solve_grid_layout(const cbindgen_private::GridLayoutData &data)
{
SharedVector<float> result;
cbindgen_private::sixtyfps_solve_grid_layout(&data, &result);
cbindgen_private::slint_solve_grid_layout(&data, &result);
return result;
}
@ -452,7 +451,7 @@ inline cbindgen_private::LayoutInfo
grid_layout_info(cbindgen_private::Slice<cbindgen_private::GridLayoutCellData> cells, float spacing,
const cbindgen_private::Padding &padding)
{
return cbindgen_private::sixtyfps_grid_layout_info(cells, spacing, &padding);
return cbindgen_private::slint_grid_layout_info(cells, spacing, &padding);
}
inline cbindgen_private::LayoutInfo
@ -460,14 +459,14 @@ box_layout_info(cbindgen_private::Slice<cbindgen_private::BoxLayoutCellData> cel
const cbindgen_private::Padding &padding,
cbindgen_private::LayoutAlignment alignment)
{
return cbindgen_private::sixtyfps_box_layout_info(cells, spacing, &padding, alignment);
return cbindgen_private::slint_box_layout_info(cells, spacing, &padding, alignment);
}
inline cbindgen_private::LayoutInfo
box_layout_info_ortho(cbindgen_private::Slice<cbindgen_private::BoxLayoutCellData> cells,
const cbindgen_private::Padding &padding)
{
return cbindgen_private::sixtyfps_box_layout_info_ortho(cells, &padding);
return cbindgen_private::slint_box_layout_info_ortho(cells, &padding);
}
inline SharedVector<float> solve_path_layout(const cbindgen_private::PathLayoutData &data,
@ -476,7 +475,7 @@ inline SharedVector<float> solve_path_layout(const cbindgen_private::PathLayoutD
SharedVector<float> result;
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr),
repeater_indexes.len };
cbindgen_private::sixtyfps_solve_path_layout(&data, ri, &result);
cbindgen_private::slint_solve_path_layout(&data, ri, &result);
return result;
}
@ -512,7 +511,7 @@ auto access_array_index(const M &model, int index)
/// \rst
/// A Model is providing Data for |Repetition|_ repetitions or |ListView|_ elements of the
/// :code:`.60` language
/// :code:`.slint` language
/// \endrst
template<typename ModelData>
class Model
@ -859,29 +858,28 @@ public:
#if !defined(DOXYGEN)
cbindgen_private::Flickable::Flickable()
{
sixtyfps_flickable_data_init(&data);
slint_flickable_data_init(&data);
}
cbindgen_private::Flickable::~Flickable()
{
sixtyfps_flickable_data_free(&data);
slint_flickable_data_free(&data);
}
cbindgen_private::NativeStyleMetrics::NativeStyleMetrics()
{
sixtyfps_native_style_metrics_init(this);
slint_native_style_metrics_init(this);
}
cbindgen_private::NativeStyleMetrics::~NativeStyleMetrics()
{
sixtyfps_native_style_metrics_deinit(this);
slint_native_style_metrics_deinit(this);
}
#endif // !defined(DOXYGEN)
namespace private_api {
// Code generated by SixtyFPS <= 0.1.5 uses this enum with VersionCheckHelper
enum class [[deprecated]] VersionCheck { Major = SIXTYFPS_VERSION_MAJOR,
Minor = SIXTYFPS_VERSION_MINOR,
Patch = SIXTYFPS_VERSION_PATCH };
// Code generated by Slint <= 0.1.5 uses this enum with VersionCheckHelper
enum class [[deprecated]] VersionCheck { Major = SLINT_VERSION_MAJOR, Minor = SLINT_VERSION_MINOR,
Patch = SLINT_VERSION_PATCH };
template<int Major, int Minor, int Patch>
struct VersionCheckHelper
{
@ -894,16 +892,16 @@ struct VersionCheckHelper
inline void run_event_loop()
{
private_api::assert_main_thread();
cbindgen_private::sixtyfps_run_event_loop();
cbindgen_private::slint_run_event_loop();
}
/// Schedules the main event loop for termination. This function is meant
/// to be called from callbacks triggered by the UI. After calling the function,
/// it will return immediately and once control is passed back to the event loop,
/// the initial call to sixtyfps::run_event_loop() will return.
/// the initial call to slint::run_event_loop() will return.
inline void quit_event_loop()
{
cbindgen_private::sixtyfps_quit_event_loop();
cbindgen_private::slint_quit_event_loop();
}
/// Adds the specified functor to an internal queue, notifies the event loop to wake up.
@ -912,7 +910,7 @@ inline void quit_event_loop()
/// running the event loop. The provided functors will only be invoked from the thread
/// that started the event loop.
///
/// You can use this to set properties or use any other SixtyFPS APIs from other threads,
/// You can use this to set properties or use any other Slint APIs from other threads,
/// by collecting the code in a functor and queuing it up for invocation within the event loop.
///
/// The following example assumes that a status message received from a network thread is
@ -927,10 +925,10 @@ inline void quit_event_loop()
/// auto ui = NetworkStatusUI::create();
/// ui->set_status_label("Pending");
///
/// sixtyfps::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
/// slint::ComponentWeakHandle<NetworkStatusUI> weak_ui_handle(ui);
/// std::thread network_thread([=]{
/// std::string message = read_message_blocking_from_network();
/// sixtyfps::invoke_from_event_loop([&]() {
/// slint::invoke_from_event_loop([&]() {
/// if (auto ui = weak_ui_handle.lock()) {
/// ui->set_status_label(message);
/// }
@ -946,7 +944,7 @@ inline void quit_event_loop()
template<typename Functor>
void invoke_from_event_loop(Functor f)
{
cbindgen_private::sixtyfps_post_event(
cbindgen_private::slint_post_event(
[](void *data) { (*reinterpret_cast<Functor *>(data))(); }, new Functor(std::move(f)),
[](void *data) { delete reinterpret_cast<Functor *>(data); });
}
@ -954,7 +952,7 @@ void invoke_from_event_loop(Functor f)
/// Blocking version of invoke_from_event_loop()
///
/// Just like invoke_from_event_loop(), this will run the specified functor from the thread running
/// the sixtyfps event loop. But it will block until the execution of the functor is finished,
/// the slint event loop. But it will block until the execution of the functor is finished,
/// and return that value.
///
/// This function must be called from a different thread than the thread that runs the event loop
@ -974,7 +972,7 @@ void invoke_from_event_loop(Functor f)
///
/// std::thread worker_thread([ui]{
/// while (...) {
/// auto message = sixtyfps::blocking_invoke_from_event_loop([ui]() {
/// auto message = slint::blocking_invoke_from_event_loop([ui]() {
/// return ui->get_message();
/// }
/// do_something(message);
@ -1029,7 +1027,7 @@ namespace private_api {
inline std::optional<SharedString> register_font_from_path(const SharedString &path)
{
SharedString maybe_err;
cbindgen_private::sixtyfps_register_font_from_path(&path, &maybe_err);
cbindgen_private::slint_register_font_from_path(&path, &maybe_err);
if (!maybe_err.empty()) {
return maybe_err;
} else {
@ -1042,8 +1040,8 @@ inline std::optional<SharedString> register_font_from_path(const SharedString &p
inline std::optional<SharedString> register_font_from_data(const uint8_t *data, std::size_t len)
{
SharedString maybe_err;
cbindgen_private::sixtyfps_register_font_from_data({ const_cast<uint8_t *>(data), len },
&maybe_err);
cbindgen_private::slint_register_font_from_data({ const_cast<uint8_t *>(data), len },
&maybe_err);
if (!maybe_err.empty()) {
return maybe_err;
} else {
@ -1053,4 +1051,4 @@ inline std::optional<SharedString> register_font_from_data(const uint8_t *data,
}
} // namespace sixtyfps
} // namespace slint

View file

@ -3,11 +3,11 @@
#pragma once
#include <string_view>
#include "sixtyfps_color.h"
#include "sixtyfps_brush_internal.h"
#include "sixtyfps_string.h"
#include "slint_color.h"
#include "slint_brush_internal.h"
#include "slint_string.h"
namespace sixtyfps {
namespace slint {
namespace private_api {
@ -47,7 +47,7 @@ public:
private:
cbindgen_private::types::LinearGradientBrush inner;
friend class sixtyfps::Brush;
friend class slint::Brush;
static SharedVector<private_api::GradientStop>
make_linear_gradient(float angle, const GradientStop *firstStop, int stopCount)

View file

@ -3,25 +3,25 @@
#pragma once
#include <tuple>
#include "sixtyfps_properties_internal.h"
#include "slint_properties_internal.h"
namespace sixtyfps::private_api {
namespace slint::private_api {
/// A Callback stores a function pointer with no parameters and no return value.
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
/// used to implement callbacks in the `.60` language.
/// used to implement callbacks in the `.slint` language.
template<typename = void()>
struct Callback;
/// A Callback stores a function pointer with \a Arg parameters and a return value of type \a Ret.
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
/// used to implement callbacks in the `.60` language.
/// used to implement callbacks in the `.slint` language.
template<typename Ret, typename... Arg>
struct Callback<Ret(Arg...)>
{
/// Constructs an empty callback that contains no handler.
Callback() { cbindgen_private::sixtyfps_callback_init(&inner); }
Callback() { cbindgen_private::slint_callback_init(&inner); }
/// Destructs the callback.
~Callback() { cbindgen_private::sixtyfps_callback_drop(&inner); }
~Callback() { cbindgen_private::slint_callback_drop(&inner); }
Callback(const Callback &) = delete;
Callback(Callback &&) = delete;
Callback &operator=(const Callback &) = delete;
@ -30,7 +30,7 @@ struct Callback<Ret(Arg...)>
template<typename F>
void set_handler(F binding) const
{
cbindgen_private::sixtyfps_callback_set_handler(
cbindgen_private::slint_callback_set_handler(
&inner,
[](void *user_data, const void *arg, void *ret) {
*reinterpret_cast<Ret *>(ret) =
@ -47,7 +47,7 @@ struct Callback<Ret(Arg...)>
{
Ret r {};
Tuple tuple { arg... };
cbindgen_private::sixtyfps_callback_call(&inner, &tuple, &r);
cbindgen_private::slint_callback_call(&inner, &tuple, &r);
return r;
}
@ -58,14 +58,14 @@ private:
/// A Callback stores a function pointer with \a Arg parameters and no return value.
/// It's possible to set that pointer via set_handler() and it can be invoked via call(). This is
/// used to implement callbacks in the `.60` language.
/// used to implement callbacks in the `.slint` language.
template<typename... Arg>
struct Callback<void(Arg...)>
{
/// Constructs an empty callback that contains no handler.
Callback() { cbindgen_private::sixtyfps_callback_init(&inner); }
Callback() { cbindgen_private::slint_callback_init(&inner); }
/// Destructs the callback.
~Callback() { cbindgen_private::sixtyfps_callback_drop(&inner); }
~Callback() { cbindgen_private::slint_callback_drop(&inner); }
Callback(const Callback &) = delete;
Callback(Callback &&) = delete;
Callback &operator=(const Callback &) = delete;
@ -74,7 +74,7 @@ struct Callback<void(Arg...)>
template<typename F>
void set_handler(F binding) const
{
cbindgen_private::sixtyfps_callback_set_handler(
cbindgen_private::slint_callback_set_handler(
&inner,
[](void *user_data, const void *arg, void *) {
std::apply(*reinterpret_cast<F *>(user_data),
@ -88,7 +88,7 @@ struct Callback<void(Arg...)>
void call(const Arg &...arg) const
{
Tuple tuple { arg... };
cbindgen_private::sixtyfps_callback_call(&inner, &tuple, reinterpret_cast<void *>(0x1));
cbindgen_private::slint_callback_call(&inner, &tuple, reinterpret_cast<void *>(0x1));
}
private:
@ -109,4 +109,4 @@ struct CallbackSignatureHelper<void, R>
template<typename A, typename R = void>
using CallbackHelper = Callback<typename CallbackSignatureHelper<A, R>::Result>;
} // namespace sixtyfps
} // namespace slint

View file

@ -3,12 +3,12 @@
#pragma once
#include "sixtyfps_color_internal.h"
#include "sixtyfps_properties.h"
#include "slint_color_internal.h"
#include "slint_properties.h"
#include <stdint.h>
namespace sixtyfps {
namespace slint {
namespace private_api {
class LinearGradientBrush;
@ -37,7 +37,7 @@ struct RgbaColor
RgbaColor(const Color &col);
};
/// Color represents a color in the SixtyFPS run-time, represented using 8-bit channels for
/// Color represents a color in the Slint run-time, represented using 8-bit channels for
/// red, green, blue and the alpha (opacity).
class Color
{
@ -175,14 +175,14 @@ private:
inline Color Color::brighter(float factor) const
{
Color result;
cbindgen_private::types::sixtyfps_color_brighter(&inner, factor, &result.inner);
cbindgen_private::types::slint_color_brighter(&inner, factor, &result.inner);
return result;
}
inline Color Color::darker(float factor) const
{
Color result;
cbindgen_private::types::sixtyfps_color_darker(&inner, factor, &result.inner);
cbindgen_private::types::slint_color_darker(&inner, factor, &result.inner);
return result;
}
@ -223,10 +223,10 @@ inline void
Property<Color>::set_animated_value(const Color &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
cbindgen_private::slint_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
}
} // namespace private_api
} // namespace sixtyfps
} // namespace slint

View file

@ -6,21 +6,21 @@
#include <cstdint>
#if UINTPTR_MAX == 0xFFFFFFFF
# define SIXTYFPS_TARGET_32
# define SLINT_TARGET_32
#elif UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu
# define SIXTYFPS_TARGET_64
# define SLINT_TARGET_64
#endif
#if !defined(DOXYGEN)
# if defined(_MSC_VER)
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
# define SLINT_DLL_IMPORT __declspec(dllimport)
# elif defined(__GNUC__)
# if defined(_WIN32) || defined(_WIN64)
# define SIXTYFPS_DLL_IMPORT __declspec(dllimport)
# define SLINT_DLL_IMPORT __declspec(dllimport)
# else
# define SIXTYFPS_DLL_IMPORT __attribute__((visibility("default")))
# define SLINT_DLL_IMPORT __attribute__((visibility("default")))
# endif
# else
# define SIXTYFPS_DLL_IMPORT
# define SLINT_DLL_IMPORT
# endif
#endif // !defined(DOXYGEN)

View file

@ -3,12 +3,12 @@
#pragma once
#include <string_view>
#include "sixtyfps_generated_public.h"
#include "sixtyfps_image_internal.h"
#include "sixtyfps_string.h"
#include "sixtyfps_sharedvector.h"
#include "slint_generated_public.h"
#include "slint_image_internal.h"
#include "slint_string.h"
#include "slint_sharedvector.h"
namespace sixtyfps {
namespace slint {
/// An image type that can be displayed by the Image element
struct Image
@ -33,12 +33,12 @@ public:
*/
/// Returns the size of the Image in pixels.
IntSize size() const { return cbindgen_private::types::sixtyfps_image_size(&data); }
IntSize size() const { return cbindgen_private::types::slint_image_size(&data); }
/// Returns the path of the image on disk, if it was constructed via Image::load_from_path().
std::optional<sixtyfps::SharedString> path() const
std::optional<slint::SharedString> path() const
{
if (auto *str = cbindgen_private::types::sixtyfps_image_path(&data)) {
if (auto *str = cbindgen_private::types::slint_image_path(&data)) {
return *str;
} else {
return {};

View file

@ -3,21 +3,21 @@
#pragma once
#include "sixtyfps.h"
#include "slint.h"
#include "sixtyfps_interpreter_internal.h"
#include "slint_interpreter_internal.h"
#include <optional>
#if !defined(DOXYGEN)
# define SIXTYFPS_QT_INTEGRATION // In the future, should be defined by cmake only if this is
// enabled
# define SLINT_QT_INTEGRATION // In the future, should be defined by cmake only if this is
// enabled
#endif
#ifdef SIXTYFPS_QT_INTEGRATION
#ifdef SLINT_QT_INTEGRATION
class QWidget;
#endif
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
// This has to stay opaque, but VRc don't compile if it is just forward declared
struct ErasedComponentBox : vtable::Dyn
{
@ -27,23 +27,23 @@ struct ErasedComponentBox : vtable::Dyn
};
}
/// The types in this namespace allow you to load a .60 file at runtime and show its UI.
/// The types in this namespace allow you to load a .slint file at runtime and show its UI.
///
/// You only need to use them if you do not want to use pre-compiled .60 code, which is
/// the normal way to use SixtyFPS.
/// You only need to use them if you do not want to use pre-compiled .slint code, which is
/// the normal way to use Slint.
///
/// The entry point for this namespace is the \ref ComponentCompiler, which you can
/// use to create \ref ComponentDefinition instances with the
/// \ref ComponentCompiler::build_from_source() or \ref ComponentCompiler::build_from_path()
/// functions.
namespace sixtyfps::interpreter {
namespace slint::interpreter {
class Value;
/// This type represents a runtime instance of structure in `.60`.
/// This type represents a runtime instance of structure in `.slint`.
///
/// This can either be an instance of a name structure introduced
/// with the `struct` keyword in the .60 file, or an anonymous struct
/// with the `struct` keyword in the .slint file, or an anonymous struct
/// written with the `{ key: value, }` notation.
///
/// It can be constructed with the range constructor or initializer lst,
@ -54,26 +54,26 @@ struct Struct
public:
/// Constructs a new empty struct. You can add fields with set_field() and
/// read them with get_field().
Struct() { cbindgen_private::sixtyfps_interpreter_struct_new(&inner); }
Struct() { cbindgen_private::slint_interpreter_struct_new(&inner); }
/// Creates a new Struct as a copy from \a other. All fields are copied as well.
Struct(const Struct &other)
{
cbindgen_private::sixtyfps_interpreter_struct_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_struct_clone(&other.inner, &inner);
}
/// Creates a new Struct by moving all fields from \a other into this struct.
Struct(Struct &&other)
{
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_struct_new(&other.inner);
cbindgen_private::slint_interpreter_struct_new(&other.inner);
}
/// Assigns all the fields of \a other to this struct.
Struct &operator=(const Struct &other)
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner);
sixtyfps_interpreter_struct_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_struct_destructor(&inner);
slint_interpreter_struct_clone(&other.inner, &inner);
return *this;
}
/// Moves all the fields of \a other to this struct.
@ -81,13 +81,13 @@ public:
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner);
cbindgen_private::slint_interpreter_struct_destructor(&inner);
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_struct_new(&other.inner);
cbindgen_private::slint_interpreter_struct_new(&other.inner);
return *this;
}
/// Destroys this struct.
~Struct() { cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner); }
~Struct() { cbindgen_private::slint_interpreter_struct_destructor(&inner); }
/// Creates a new struct with the fields of the std::initializer_list given by args.
inline Struct(std::initializer_list<std::pair<std::string_view, Value>> args);
@ -159,11 +159,11 @@ public:
iterator() = default;
void next()
{
auto next = cbindgen_private::sixtyfps_interpreter_struct_iterator_next(&inner);
auto next = cbindgen_private::slint_interpreter_struct_iterator_next(&inner);
v = reinterpret_cast<const Value *>(next.v);
k = std::string_view(reinterpret_cast<char *>(next.k.ptr), next.k.len);
if (!v) {
cbindgen_private::sixtyfps_interpreter_struct_iterator_destructor(&inner);
cbindgen_private::slint_interpreter_struct_iterator_destructor(&inner);
}
}
@ -172,7 +172,7 @@ public:
~iterator()
{
if (v) {
cbindgen_private::sixtyfps_interpreter_struct_iterator_destructor(&inner);
cbindgen_private::slint_interpreter_struct_iterator_destructor(&inner);
}
}
// FIXME I believe iterators are supposed to be copy constructible
@ -201,7 +201,7 @@ public:
/// Returns an iterator over the fields of the struct.
iterator begin() const
{
return iterator(cbindgen_private::sixtyfps_interpreter_struct_make_iter(&inner));
return iterator(cbindgen_private::slint_interpreter_struct_make_iter(&inner));
}
/// Returns an iterator that when compared with an iterator returned by begin() can be
/// used to detect when all fields have been visited.
@ -216,18 +216,18 @@ public:
inline void set_field(std::string_view name, const Value &value);
/// \private
Struct(const sixtyfps::cbindgen_private::StructOpaque &other)
Struct(const slint::cbindgen_private::StructOpaque &other)
{
cbindgen_private::sixtyfps_interpreter_struct_clone(&other, &inner);
cbindgen_private::slint_interpreter_struct_clone(&other, &inner);
}
private:
using StructOpaque = sixtyfps::cbindgen_private::StructOpaque;
using StructOpaque = slint::cbindgen_private::StructOpaque;
StructOpaque inner;
friend class Value;
};
/// This is a dynamically typed value used in the SixtyFPS interpreter.
/// This is a dynamically typed value used in the Slint interpreter.
/// It can hold a value of different types, and you should use the
/// different overloaded constructors and the to_xxx() functions to access the
//// value within.
@ -235,10 +235,10 @@ private:
/// It is also possible to query the type the value holds by calling the Value::type()
/// function.
///
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
/// Note that models are only represented in one direction: You can create a slint::Model<Value>
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
/// property in your .60 code that was declared to be either an array (`property <[sometype]> foo;`)
/// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
/// property in your .slint code that was declared to be either an array (`property <[sometype]>
/// foo;`) or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
/// dynamic and accept models implemented in C++.
///
/// ```
@ -246,30 +246,30 @@ private:
///
/// Value some_value = ...;
/// // Check if the value has a string
/// if (std::optional<sixtyfps::SharedString> string_value = some_value.to_string())
/// if (std::optional<slint::SharedString> string_value = some_value.to_string())
/// do_something(*string_value); // Extract the string by de-referencing
/// ```
class Value
{
public:
/// Constructs a new value of type Value::Type::Void.
Value() { cbindgen_private::sixtyfps_interpreter_value_new(&inner); }
Value() { cbindgen_private::slint_interpreter_value_new(&inner); }
/// Constructs a new value by copying \a other.
Value(const Value &other) { sixtyfps_interpreter_value_clone(&other.inner, &inner); }
Value(const Value &other) { slint_interpreter_value_clone(&other.inner, &inner); }
/// Constructs a new value by moving \a other to this.
Value(Value &&other)
{
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_value_new(&other.inner);
cbindgen_private::slint_interpreter_value_new(&other.inner);
}
/// Assigns the value \a other to this.
Value &operator=(const Value &other)
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_value_destructor(&inner);
sixtyfps_interpreter_value_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_value_destructor(&inner);
slint_interpreter_value_clone(&other.inner, &inner);
return *this;
}
/// Moves the value \a other to this.
@ -277,13 +277,13 @@ public:
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_value_destructor(&inner);
cbindgen_private::slint_interpreter_value_destructor(&inner);
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_value_new(&other.inner);
cbindgen_private::slint_interpreter_value_new(&other.inner);
return *this;
}
/// Destroys the value.
~Value() { cbindgen_private::sixtyfps_interpreter_value_destructor(&inner); }
~Value() { cbindgen_private::slint_interpreter_value_destructor(&inner); }
/// A convenience alias for the value type enum.
using Type = ValueType;
@ -294,7 +294,7 @@ public:
/// Type::Double, otherwise an empty optional is returned.
std::optional<double> to_number() const
{
if (auto *number = cbindgen_private::sixtyfps_interpreter_value_to_number(&inner)) {
if (auto *number = cbindgen_private::slint_interpreter_value_to_number(&inner)) {
return *number;
} else {
return {};
@ -303,9 +303,9 @@ public:
/// Returns a std::optional that contains a string if the type of this Value is
/// Type::String, otherwise an empty optional is returned.
std::optional<sixtyfps::SharedString> to_string() const
std::optional<slint::SharedString> to_string() const
{
if (auto *str = cbindgen_private::sixtyfps_interpreter_value_to_string(&inner)) {
if (auto *str = cbindgen_private::slint_interpreter_value_to_string(&inner)) {
return *str;
} else {
return {};
@ -316,7 +316,7 @@ public:
/// Type::Bool, otherwise an empty optional is returned.
std::optional<bool> to_bool() const
{
if (auto *b = cbindgen_private::sixtyfps_interpreter_value_to_bool(&inner)) {
if (auto *b = cbindgen_private::slint_interpreter_value_to_bool(&inner)) {
return *b;
} else {
return {};
@ -327,13 +327,13 @@ public:
/// Type::Model, otherwise an empty optional is returned.
///
/// The vector will be constructed by serializing all the elements of the model.
inline std::optional<sixtyfps::SharedVector<Value>> to_array() const;
inline std::optional<slint::SharedVector<Value>> to_array() const;
/// Returns a std::optional that contains a brush if the type of this Value is
/// Type::Brush, otherwise an empty optional is returned.
std::optional<sixtyfps::Brush> to_brush() const
std::optional<slint::Brush> to_brush() const
{
if (auto *brush = cbindgen_private::sixtyfps_interpreter_value_to_brush(&inner)) {
if (auto *brush = cbindgen_private::slint_interpreter_value_to_brush(&inner)) {
return *brush;
} else {
return {};
@ -344,7 +344,7 @@ public:
/// Type::Struct, otherwise an empty optional is returned.
std::optional<Struct> to_struct() const
{
if (auto *opaque_struct = cbindgen_private::sixtyfps_interpreter_value_to_struct(&inner)) {
if (auto *opaque_struct = cbindgen_private::slint_interpreter_value_to_struct(&inner)) {
return Struct(*opaque_struct);
} else {
return {};
@ -355,7 +355,7 @@ public:
/// Type::Image, otherwise an empty optional is returned.
std::optional<Image> to_image() const
{
if (auto *img = cbindgen_private::sixtyfps_interpreter_value_to_image(&inner)) {
if (auto *img = cbindgen_private::slint_interpreter_value_to_image(&inner)) {
return *reinterpret_cast<const Image *>(img);
} else {
return {};
@ -365,47 +365,44 @@ public:
// template<typename T> std::optional<T> get() const;
/// Constructs a new Value that holds the double \a value.
Value(double value) { cbindgen_private::sixtyfps_interpreter_value_new_double(value, &inner); }
Value(double value) { cbindgen_private::slint_interpreter_value_new_double(value, &inner); }
/// Constructs a new Value that holds the string \a str.
Value(const SharedString &str)
{
cbindgen_private::sixtyfps_interpreter_value_new_string(&str, &inner);
cbindgen_private::slint_interpreter_value_new_string(&str, &inner);
}
/// Constructs a new Value that holds the boolean \a b.
Value(bool b) { cbindgen_private::sixtyfps_interpreter_value_new_bool(b, &inner); }
Value(bool b) { cbindgen_private::slint_interpreter_value_new_bool(b, &inner); }
/// Constructs a new Value that holds the value vector \a v as a model.
inline Value(const SharedVector<Value> &v);
/// Constructs a new Value that holds the value model \a m.
Value(const std::shared_ptr<sixtyfps::Model<Value>> &m);
Value(const std::shared_ptr<slint::Model<Value>> &m);
/// Constructs a new Value that holds the brush \a b.
Value(const sixtyfps::Brush &brush)
Value(const slint::Brush &brush)
{
cbindgen_private::sixtyfps_interpreter_value_new_brush(&brush, &inner);
cbindgen_private::slint_interpreter_value_new_brush(&brush, &inner);
}
/// Constructs a new Value that holds the Struct \a struc.
Value(const Struct &struc)
{
cbindgen_private::sixtyfps_interpreter_value_new_struct(&struc.inner, &inner);
cbindgen_private::slint_interpreter_value_new_struct(&struc.inner, &inner);
}
/// Constructs a new Value that holds the Image \a img.
Value(const Image &img)
{
cbindgen_private::sixtyfps_interpreter_value_new_image(&img, &inner);
}
Value(const Image &img) { cbindgen_private::slint_interpreter_value_new_image(&img, &inner); }
/// Returns the type the variant holds.
Type type() const { return cbindgen_private::sixtyfps_interpreter_value_type(&inner); }
Type type() const { return cbindgen_private::slint_interpreter_value_type(&inner); }
/// Returns true if \a and \b hold values of the same type and the underlying vales are equal.
friend bool operator==(const Value &a, const Value &b)
{
return cbindgen_private::sixtyfps_interpreter_value_eq(&a.inner, &b.inner);
return cbindgen_private::slint_interpreter_value_eq(&a.inner, &b.inner);
}
private:
inline Value(const void *) = delete; // Avoid that for example Value("foo") turns to Value(bool)
using ValueOpaque = sixtyfps::cbindgen_private::ValueOpaque;
using ValueOpaque = slint::cbindgen_private::ValueOpaque;
ValueOpaque inner;
friend struct Struct;
friend class ComponentInstance;
@ -413,53 +410,53 @@ private:
explicit Value(ValueOpaque &inner) : inner(inner) { }
};
inline Value::Value(const sixtyfps::SharedVector<Value> &array)
inline Value::Value(const slint::SharedVector<Value> &array)
{
cbindgen_private::sixtyfps_interpreter_value_new_array_model(
&reinterpret_cast<const sixtyfps::SharedVector<ValueOpaque> &>(array), &inner);
cbindgen_private::slint_interpreter_value_new_array_model(
&reinterpret_cast<const slint::SharedVector<ValueOpaque> &>(array), &inner);
}
inline std::optional<sixtyfps::SharedVector<Value>> Value::to_array() const
inline std::optional<slint::SharedVector<Value>> Value::to_array() const
{
sixtyfps::SharedVector<Value> array;
if (cbindgen_private::sixtyfps_interpreter_value_to_array(
&inner, &reinterpret_cast<sixtyfps::SharedVector<ValueOpaque> &>(array))) {
slint::SharedVector<Value> array;
if (cbindgen_private::slint_interpreter_value_to_array(
&inner, &reinterpret_cast<slint::SharedVector<ValueOpaque> &>(array))) {
return array;
} else {
return {};
}
}
inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
{
using cbindgen_private::ModelAdaptorVTable;
using vtable::VRef;
struct ModelWrapper : private_api::AbstractRepeaterView
{
std::shared_ptr<sixtyfps::Model<Value>> model;
std::shared_ptr<slint::Model<Value>> model;
cbindgen_private::ModelNotifyOpaque notify;
// This kind of mean that the rust code has ownership of "this" until the drop function is
// called
std::shared_ptr<AbstractRepeaterView> self;
~ModelWrapper() { cbindgen_private::sixtyfps_interpreter_model_notify_destructor(&notify); }
~ModelWrapper() { cbindgen_private::slint_interpreter_model_notify_destructor(&notify); }
void row_added(int index, int count) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_added(&notify, index, count);
cbindgen_private::slint_interpreter_model_notify_row_added(&notify, index, count);
}
void row_changed(int index) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_changed(&notify, index);
cbindgen_private::slint_interpreter_model_notify_row_changed(&notify, index);
}
void row_removed(int index, int count) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_removed(&notify, index, count);
cbindgen_private::slint_interpreter_model_notify_row_removed(&notify, index, count);
}
};
auto wrapper = std::make_shared<ModelWrapper>();
wrapper->model = model;
wrapper->self = wrapper;
cbindgen_private::sixtyfps_interpreter_model_notify_new(&wrapper->notify);
cbindgen_private::slint_interpreter_model_notify_new(&wrapper->notify);
model->attach_peer(wrapper);
auto row_count = [](VRef<ModelAdaptorVTable> self) -> uintptr_t {
@ -470,7 +467,7 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
reinterpret_cast<ModelWrapper *>(self.instance)->model->row_data(int(row));
if (v.has_value()) {
*out = v->inner;
cbindgen_private::sixtyfps_interpreter_value_new(&v->inner);
cbindgen_private::slint_interpreter_value_new(&v->inner);
return true;
}
return false;
@ -489,7 +486,7 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
static const ModelAdaptorVTable vt { row_count, row_data, set_row_data, get_notify, drop };
vtable::VBox<ModelAdaptorVTable> wrap { &vt, wrapper.get() };
cbindgen_private::sixtyfps_interpreter_value_new_model(wrap, &inner);
cbindgen_private::slint_interpreter_value_new_model(wrap, &inner);
}
inline Struct::Struct(std::initializer_list<std::pair<std::string_view, Value>> args)
@ -503,7 +500,7 @@ inline std::optional<Value> Struct::get_field(std::string_view name) const
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(name.data())),
name.size()
};
if (auto *value = cbindgen_private::sixtyfps_interpreter_struct_get_field(&inner, name_view)) {
if (auto *value = cbindgen_private::slint_interpreter_struct_get_field(&inner, name_view)) {
return *reinterpret_cast<const Value *>(value);
} else {
return {};
@ -515,7 +512,7 @@ inline void Struct::set_field(std::string_view name, const Value &value)
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(name.data())),
name.size()
};
cbindgen_private::sixtyfps_interpreter_struct_set_field(&inner, name_view, &value.inner);
cbindgen_private::slint_interpreter_struct_set_field(&inner, name_view, &value.inner);
}
/// The ComponentInstance represents a running instance of a component.
@ -536,7 +533,7 @@ class ComponentInstance : vtable::Dyn
// ComponentHandle<ComponentInstance> is in fact a VRc<ComponentVTable, ErasedComponentBox>
const cbindgen_private::ErasedComponentBox *inner() const
{
sixtyfps::private_api::assert_main_thread();
slint::private_api::assert_main_thread();
return reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(this);
}
@ -544,43 +541,43 @@ public:
/// Marks the window of this component to be shown on the screen. This registers
/// the window with the windowing system. In order to react to events from the windowing system,
/// such as draw requests or mouse/touch input, it is still necessary to spin the event loop,
/// using sixtyfps::run_event_loop().
/// using slint::run_event_loop().
void show() const
{
cbindgen_private::sixtyfps_interpreter_component_instance_show(inner(), true);
cbindgen_private::slint_interpreter_component_instance_show(inner(), true);
}
/// Marks the window of this component to be hidden on the screen. This de-registers
/// the window from the windowing system and it will not receive any further events.
void hide() const
{
cbindgen_private::sixtyfps_interpreter_component_instance_show(inner(), false);
cbindgen_private::slint_interpreter_component_instance_show(inner(), false);
}
/// Returns the Window associated with this component. The window API can be used
/// to control different aspects of the integration into the windowing system,
/// such as the position on the screen.
const sixtyfps::Window &window()
const slint::Window &window()
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win_ptr);
return *reinterpret_cast<const sixtyfps::Window *>(win_ptr);
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
return *reinterpret_cast<const slint::Window *>(win_ptr);
}
/// This is a convenience function that first calls show(), followed by
/// sixtyfps::run_event_loop() and hide().
/// slint::run_event_loop() and hide().
void run() const
{
show();
cbindgen_private::sixtyfps_run_event_loop();
cbindgen_private::slint_run_event_loop();
hide();
}
#if defined(SIXTYFPS_QT_INTEGRATION) || defined(DOXYGEN)
#if defined(SLINT_QT_INTEGRATION) || defined(DOXYGEN)
/// Return a QWidget for this instance.
/// This function is only available if the qt graphical backend was compiled in, and
/// it may return nullptr if the Qt backend is not used at runtime.
QWidget *qwidget() const
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget(
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::slint_qt_get_widget(
reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr)));
return wid;
}
@ -591,39 +588,39 @@ public:
/// For example, if the component has a `property <string> hello;`,
/// we can set this property
/// ```
/// instance->set_property("hello", sixtyfps::SharedString("world"));
/// instance->set_property("hello", slint::SharedString("world"));
/// ```
///
/// Returns true if the property was correctly set. Returns false if the property
/// could not be set because it either do not exist (was not declared in .60) or if
/// could not be set because it either do not exist (was not declared in .slint) or if
/// the value is not of the proper type for the property's type.
bool set_property(std::string_view name, const Value &value) const
{
using namespace cbindgen_private;
return sixtyfps_interpreter_component_instance_set_property(
inner(), sixtyfps::private_api::string_to_slice(name), &value.inner);
return slint_interpreter_component_instance_set_property(
inner(), slint::private_api::string_to_slice(name), &value.inner);
}
/// Returns the value behind a property declared in .60.
/// Returns the value behind a property declared in .slint.
std::optional<Value> get_property(std::string_view name) const
{
using namespace cbindgen_private;
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_get_property(
inner(), sixtyfps::private_api::string_to_slice(name), &out)) {
if (slint_interpreter_component_instance_get_property(
inner(), slint::private_api::string_to_slice(name), &out)) {
return Value(out);
} else {
return {};
}
}
/// Invoke the specified callback declared in .60 with the given arguments
/// Invoke the specified callback declared in .slint with the given arguments
///
/// Example: imagine the .60 file contains the given callback declaration:
/// Example: imagine the .slint file contains the given callback declaration:
/// ```
/// callback foo(string, int) -> string;
/// ```
/// Then one can call it with this function
/// ```
/// sixtyfps::Value args[] = { SharedString("Hello"), 42. };
/// slint::Value args[] = { SharedString("Hello"), 42. };
/// instance->invoke_callback("foo", { args, 2 });
/// ```
///
@ -637,8 +634,8 @@ public:
reinterpret_cast<const ValueOpaque *>(args.data())),
args.size() };
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_invoke_callback(
inner(), sixtyfps::private_api::string_to_slice(name), args_view, &out)) {
if (slint_interpreter_component_instance_invoke_callback(
inner(), slint::private_api::string_to_slice(name), args_view, &out)) {
return Value(out);
} else {
return {};
@ -653,7 +650,7 @@ public:
/// The \a callback parameter is a functor which takes as argument a slice of Value
/// and must return a Value.
///
/// Example: imagine the .60 file contains the given callback declaration:
/// Example: imagine the .slint file contains the given callback declaration:
/// ```
/// callback foo(string, int) -> string;
/// ```
@ -676,8 +673,8 @@ public:
Value r = (*reinterpret_cast<F *>(data))(args_view);
new (ret) Value(std::move(r));
};
return cbindgen_private::sixtyfps_interpreter_component_instance_set_callback(
inner(), sixtyfps::private_api::string_to_slice(name), actual_cb,
return cbindgen_private::slint_interpreter_component_instance_set_callback(
inner(), slint::private_api::string_to_slice(name), actual_cb,
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -690,15 +687,15 @@ public:
/// ```
///
/// Returns true if the property was correctly set. Returns false if the property
/// could not be set because it either does not exist (was not declared in .60) or if
/// could not be set because it either does not exist (was not declared in .slint) or if
/// the value is not of the correct type for the property's type.
bool set_global_property(std::string_view global, std::string_view prop_name,
const Value &value) const
{
using namespace cbindgen_private;
return sixtyfps_interpreter_component_instance_set_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &value.inner);
return slint_interpreter_component_instance_set_global_property(
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(prop_name), &value.inner);
}
/// Returns the value behind a property in an exported global singleton.
std::optional<Value> get_global_property(std::string_view global,
@ -706,9 +703,9 @@ public:
{
using namespace cbindgen_private;
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_get_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &out)) {
if (slint_interpreter_component_instance_get_global_property(
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(prop_name), &out)) {
return Value(out);
} else {
return {};
@ -717,8 +714,8 @@ public:
/// Like `set_callback()` but on a callback in the specified exported global singleton.
///
/// Example: imagine the .60 file contains the given global:
/// ```60
/// Example: imagine the .slint file contains the given global:
/// ```slint
/// export global Logic := {
/// callback to_uppercase(string) -> string;
/// }
@ -741,9 +738,9 @@ public:
Value r = (*reinterpret_cast<F *>(data))(args_view);
new (ret) Value(std::move(r));
};
return cbindgen_private::sixtyfps_interpreter_component_instance_set_global_callback(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
return cbindgen_private::slint_interpreter_component_instance_set_global_callback(
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -757,9 +754,9 @@ public:
reinterpret_cast<const ValueOpaque *>(args.data())),
args.size() };
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_invoke_global_callback(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(callback_name), args_view, &out)) {
if (slint_interpreter_component_instance_invoke_global_callback(
inner(), slint::private_api::string_to_slice(global),
slint::private_api::string_to_slice(callback_name), args_view, &out)) {
return Value(out);
} else {
return {};
@ -767,9 +764,9 @@ public:
}
};
/// ComponentDefinition is a representation of a compiled component from .60 markup.
/// ComponentDefinition is a representation of a compiled component from .slint markup.
///
/// It can be constructed from a .60 file using the ComponentCompiler::build_from_path() or
/// It can be constructed from a .slint file using the ComponentCompiler::build_from_path() or
/// ComponentCompiler::build_from_source() functions. And then it can be instantiated with the
/// create() function.
///
@ -779,7 +776,7 @@ class ComponentDefinition
{
friend class ComponentCompiler;
using ComponentDefinitionOpaque = sixtyfps::cbindgen_private::ComponentDefinitionOpaque;
using ComponentDefinitionOpaque = slint::cbindgen_private::ComponentDefinitionOpaque;
ComponentDefinitionOpaque inner;
ComponentDefinition() = delete;
@ -790,23 +787,23 @@ public:
/// Constructs a new ComponentDefinition as a copy of \a other.
ComponentDefinition(const ComponentDefinition &other)
{
sixtyfps_interpreter_component_definition_clone(&other.inner, &inner);
slint_interpreter_component_definition_clone(&other.inner, &inner);
}
/// Assigns \a other to this ComponentDefinition.
ComponentDefinition &operator=(const ComponentDefinition &other)
{
using namespace sixtyfps::cbindgen_private;
using namespace slint::cbindgen_private;
if (this == &other)
return *this;
sixtyfps_interpreter_component_definition_destructor(&inner);
sixtyfps_interpreter_component_definition_clone(&other.inner, &inner);
slint_interpreter_component_definition_destructor(&inner);
slint_interpreter_component_definition_clone(&other.inner, &inner);
return *this;
}
/// Destroys this ComponentDefinition.
~ComponentDefinition() { sixtyfps_interpreter_component_definition_destructor(&inner); }
~ComponentDefinition() { slint_interpreter_component_definition_destructor(&inner); }
/// Creates a new instance of the component and returns a shared handle to it.
ComponentHandle<ComponentInstance> create() const
{
@ -816,54 +813,54 @@ public:
~CI() { result.~ComponentHandle(); }
CI() { }
} u;
cbindgen_private::sixtyfps_interpreter_component_instance_create(&inner, &u.i);
cbindgen_private::slint_interpreter_component_instance_create(&inner, &u.i);
return u.result;
}
/// Returns a vector of that contains PropertyDescriptor instances that describe the list of
/// public properties that can be read and written using ComponentInstance::set_property and
/// ComponentInstance::get_property.
sixtyfps::SharedVector<PropertyDescriptor> properties() const
slint::SharedVector<PropertyDescriptor> properties() const
{
sixtyfps::SharedVector<PropertyDescriptor> props;
cbindgen_private::sixtyfps_interpreter_component_definition_properties(&inner, &props);
slint::SharedVector<PropertyDescriptor> props;
cbindgen_private::slint_interpreter_component_definition_properties(&inner, &props);
return props;
}
/// Returns a vector of strings that describe the list of public callbacks that can be invoked
/// using ComponentInstance::invoke_callback and set using ComponentInstance::set_callback.
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks() const
slint::SharedVector<slint::SharedString> callbacks() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks;
cbindgen_private::sixtyfps_interpreter_component_definition_callbacks(&inner, &callbacks);
slint::SharedVector<slint::SharedString> callbacks;
cbindgen_private::slint_interpreter_component_definition_callbacks(&inner, &callbacks);
return callbacks;
}
/// Returns the name of this Component as written in the .60 file
sixtyfps::SharedString name() const
/// Returns the name of this Component as written in the .slint file
slint::SharedString name() const
{
sixtyfps::SharedString name;
cbindgen_private::sixtyfps_interpreter_component_definition_name(&inner, &name);
slint::SharedString name;
cbindgen_private::slint_interpreter_component_definition_name(&inner, &name);
return name;
}
/// Returns a vector of strings with the names of all exported global singletons.
sixtyfps::SharedVector<sixtyfps::SharedString> globals() const
slint::SharedVector<slint::SharedString> globals() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
cbindgen_private::sixtyfps_interpreter_component_definition_globals(&inner, &names);
slint::SharedVector<slint::SharedString> names;
cbindgen_private::slint_interpreter_component_definition_globals(&inner, &names);
return names;
}
/// Returns a vector of the property descriptors of the properties of the specified
/// publicly exported global singleton. An empty optional is returned if there exists no
/// exported global singleton under the specified name.
std::optional<sixtyfps::SharedVector<PropertyDescriptor>>
std::optional<slint::SharedVector<PropertyDescriptor>>
global_properties(std::string_view global_name) const
{
sixtyfps::SharedVector<PropertyDescriptor> properties;
if (cbindgen_private::sixtyfps_interpreter_component_definition_global_properties(
&inner, sixtyfps::private_api::string_to_slice(global_name), &properties)) {
slint::SharedVector<PropertyDescriptor> properties;
if (cbindgen_private::slint_interpreter_component_definition_global_properties(
&inner, slint::private_api::string_to_slice(global_name), &properties)) {
return properties;
}
return {};
@ -872,20 +869,20 @@ public:
/// Returns a vector of the names of the callbacks of the specified publicly exported global
/// singleton. An empty optional is returned if there exists no exported global singleton
/// under the specified name.
std::optional<sixtyfps::SharedVector<sixtyfps::SharedString>>
std::optional<slint::SharedVector<slint::SharedString>>
global_callbacks(std::string_view global_name) const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
if (cbindgen_private::sixtyfps_interpreter_component_definition_global_callbacks(
&inner, sixtyfps::private_api::string_to_slice(global_name), &names)) {
slint::SharedVector<slint::SharedString> names;
if (cbindgen_private::slint_interpreter_component_definition_global_callbacks(
&inner, slint::private_api::string_to_slice(global_name), &names)) {
return names;
}
return {};
}
};
/// ComponentCompiler is the entry point to the SixtyFPS interpreter that can be used
/// to load .60 files or compile them on-the-fly from a string
/// ComponentCompiler is the entry point to the Slint interpreter that can be used
/// to load .slint files or compile them on-the-fly from a string
/// (using build_from_source()) or from a path (using build_from_source())
class ComponentCompiler
{
@ -896,53 +893,54 @@ class ComponentCompiler
public:
/// Constructs a new ComponentCompiler instance.
ComponentCompiler() { cbindgen_private::sixtyfps_interpreter_component_compiler_new(&inner); }
ComponentCompiler() { cbindgen_private::slint_interpreter_component_compiler_new(&inner); }
/// Destroys this ComponentCompiler.
~ComponentCompiler()
{
cbindgen_private::sixtyfps_interpreter_component_compiler_destructor(&inner);
cbindgen_private::slint_interpreter_component_compiler_destructor(&inner);
}
/// Sets the include paths used for looking up `.60` imports to the specified vector of paths.
void set_include_paths(const sixtyfps::SharedVector<sixtyfps::SharedString> &paths)
/// Sets the include paths used for looking up `.slint` imports to the specified vector of
/// paths.
void set_include_paths(const slint::SharedVector<slint::SharedString> &paths)
{
cbindgen_private::sixtyfps_interpreter_component_compiler_set_include_paths(&inner, &paths);
cbindgen_private::slint_interpreter_component_compiler_set_include_paths(&inner, &paths);
}
/// Sets the style to be used for widgets.
void set_style(std::string_view style)
{
cbindgen_private::sixtyfps_interpreter_component_compiler_set_style(
&inner, sixtyfps::private_api::string_to_slice(style));
cbindgen_private::slint_interpreter_component_compiler_set_style(
&inner, slint::private_api::string_to_slice(style));
}
/// Returns the widget style the compiler is currently using when compiling .60 files.
sixtyfps::SharedString style() const
/// Returns the widget style the compiler is currently using when compiling .slint files.
slint::SharedString style() const
{
sixtyfps::SharedString s;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_style(&inner, &s);
slint::SharedString s;
cbindgen_private::slint_interpreter_component_compiler_get_style(&inner, &s);
return s;
}
/// Returns the include paths the component compiler is currently configured with.
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
slint::SharedVector<slint::SharedString> include_paths() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_include_paths(&inner, &paths);
slint::SharedVector<slint::SharedString> paths;
cbindgen_private::slint_interpreter_component_compiler_get_include_paths(&inner, &paths);
return paths;
}
/// Returns the diagnostics that were produced in the last call to build_from_path() or
/// build_from_source().
sixtyfps::SharedVector<Diagnostic> diagnostics() const
slint::SharedVector<Diagnostic> diagnostics() const
{
sixtyfps::SharedVector<Diagnostic> result;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_diagnostics(&inner, &result);
slint::SharedVector<Diagnostic> result;
cbindgen_private::slint_interpreter_component_compiler_get_diagnostics(&inner, &result);
return result;
}
/// Compile a .60 file into a ComponentDefinition
/// Compile a .slint file into a ComponentDefinition
///
/// Returns the compiled `ComponentDefinition` if there were no errors.
///
@ -955,9 +953,9 @@ public:
std::string_view path)
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::sixtyfps_interpreter_component_compiler_build_from_source(
&inner, sixtyfps::private_api::string_to_slice(source_code),
sixtyfps::private_api::string_to_slice(path), &result)) {
if (cbindgen_private::slint_interpreter_component_compiler_build_from_source(
&inner, slint::private_api::string_to_slice(source_code),
slint::private_api::string_to_slice(path), &result)) {
return ComponentDefinition(result);
} else {
@ -965,7 +963,7 @@ public:
}
}
/// Compile some .60 code into a ComponentDefinition
/// Compile some .slint code into a ComponentDefinition
///
/// The `path` argument will be used for diagnostics and to compute relative
/// paths while importing.
@ -978,8 +976,8 @@ public:
std::optional<ComponentDefinition> build_from_path(std::string_view path)
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::sixtyfps_interpreter_component_compiler_build_from_path(
&inner, sixtyfps::private_api::string_to_slice(path), &result)) {
if (cbindgen_private::slint_interpreter_component_compiler_build_from_path(
&inner, slint::private_api::string_to_slice(path), &result)) {
return ComponentDefinition(result);
} else {
@ -990,17 +988,17 @@ public:
}
namespace sixtyfps::testing {
namespace slint::testing {
using cbindgen_private::KeyboardModifiers;
/// Send a key events to the given component instance
inline void send_keyboard_string_sequence(const sixtyfps::interpreter::ComponentInstance *component,
const sixtyfps::SharedString &str,
inline void send_keyboard_string_sequence(const slint::interpreter::ComponentInstance *component,
const slint::SharedString &str,
KeyboardModifiers modifiers = {})
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(
cbindgen_private::slint_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr));

View file

@ -4,13 +4,13 @@
#pragma once
#include <initializer_list>
#include <string_view>
#include "sixtyfps_pathdata_internal.h"
#include "slint_pathdata_internal.h"
// The C++ code generator assumes that enums are in the cbindgen_private namespace
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
using cbindgen_private::types::PathEvent;
}
namespace sixtyfps::private_api {
namespace slint::private_api {
using cbindgen_private::types::PathArcTo;
using cbindgen_private::types::PathCubicTo;
using cbindgen_private::types::PathElement;
@ -49,7 +49,7 @@ private:
size_t count)
{
SharedVector<PathElement> tmp;
sixtyfps_new_path_elements(&tmp, firstElement, count);
slint_new_path_elements(&tmp, firstElement, count);
return tmp;
}
@ -60,8 +60,8 @@ private:
{
SharedVector<PathEvent> events;
SharedVector<Point> coordinates;
sixtyfps_new_path_events(&events, &coordinates, firstEvent, event_count, firstCoordinate,
coordinate_count);
slint_new_path_events(&events, &coordinates, firstEvent, event_count, firstCoordinate,
coordinate_count);
return Data::Events(events, coordinates);
}

View file

@ -5,67 +5,67 @@
#include <string_view>
#include <memory>
namespace sixtyfps::cbindgen_private {
namespace slint::cbindgen_private {
struct PropertyAnimation;
}
#include "sixtyfps_properties_internal.h"
#include "slint_properties_internal.h"
namespace sixtyfps::private_api {
namespace slint::private_api {
using cbindgen_private::StateInfo;
inline void sixtyfps_property_set_animated_binding_helper(
inline void slint_property_set_animated_binding_helper(
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, int32_t *),
void *user_data, void (*drop_user_data)(void *),
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_int(
cbindgen_private::slint_property_set_animated_binding_int(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
inline void sixtyfps_property_set_animated_binding_helper(
inline void slint_property_set_animated_binding_helper(
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, float *),
void *user_data, void (*drop_user_data)(void *),
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_float(
cbindgen_private::slint_property_set_animated_binding_float(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
inline void sixtyfps_property_set_animated_binding_helper(
inline void slint_property_set_animated_binding_helper(
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, Color *),
void *user_data, void (*drop_user_data)(void *),
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_color(
cbindgen_private::slint_property_set_animated_binding_color(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
inline void sixtyfps_property_set_animated_binding_helper(
inline void slint_property_set_animated_binding_helper(
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, Brush *),
void *user_data, void (*drop_user_data)(void *),
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_brush(
cbindgen_private::slint_property_set_animated_binding_brush(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
template<typename T>
struct Property
{
Property() { cbindgen_private::sixtyfps_property_init(&inner); }
~Property() { cbindgen_private::sixtyfps_property_drop(&inner); }
Property() { cbindgen_private::slint_property_init(&inner); }
~Property() { cbindgen_private::slint_property_drop(&inner); }
Property(const Property &) = delete;
Property(Property &&) = delete;
Property &operator=(const Property &) = delete;
explicit Property(const T &value) : value(value)
{
cbindgen_private::sixtyfps_property_init(&inner);
cbindgen_private::slint_property_init(&inner);
}
/* Should it be implicit?
@ -77,20 +77,20 @@ struct Property
{
if (this->value != value) {
this->value = value;
cbindgen_private::sixtyfps_property_set_changed(&inner, &this->value);
cbindgen_private::slint_property_set_changed(&inner, &this->value);
}
}
const T &get() const
{
cbindgen_private::sixtyfps_property_update(&inner, &value);
cbindgen_private::slint_property_update(&inner, &value);
return value;
}
template<typename F>
void set_binding(F binding) const
{
cbindgen_private::sixtyfps_property_set_binding(
cbindgen_private::slint_property_set_binding(
&inner,
[](void *user_data, void *value) {
*reinterpret_cast<T *>(value) = (*reinterpret_cast<F *>(user_data))();
@ -105,7 +105,7 @@ struct Property
inline void
set_animated_binding(F binding, const cbindgen_private::PropertyAnimation &animation_data) const
{
private_api::sixtyfps_property_set_animated_binding_helper(
private_api::slint_property_set_animated_binding_helper(
&inner,
[](void *user_data, T *value) {
*reinterpret_cast<T *>(value) = (*reinterpret_cast<F *>(user_data))();
@ -122,7 +122,7 @@ struct Property
F binding;
Trans animation;
};
private_api::sixtyfps_property_set_animated_binding_helper(
private_api::slint_property_set_animated_binding_helper(
&inner,
[](void *user_data, T *value) {
*reinterpret_cast<T *>(value) =
@ -135,8 +135,8 @@ struct Property
});
}
bool is_dirty() const { return cbindgen_private::sixtyfps_property_is_dirty(&inner); }
void mark_dirty() const { cbindgen_private::sixtyfps_property_mark_dirty(&inner); }
bool is_dirty() const { return cbindgen_private::slint_property_is_dirty(&inner); }
void mark_dirty() const { cbindgen_private::slint_property_mark_dirty(&inner); }
static void link_two_way(const Property<T> *p1, const Property<T> *p2)
{
@ -161,16 +161,16 @@ struct Property
return true;
};
auto intercept_binding_fn = [](void *user_data, void *value) {
cbindgen_private::sixtyfps_property_set_binding_internal(
cbindgen_private::slint_property_set_binding_internal(
&reinterpret_cast<TwoWayBinding *>(user_data)->common_property->inner, value);
return true;
};
cbindgen_private::sixtyfps_property_set_binding(&p1->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
cbindgen_private::sixtyfps_property_set_binding(&p2->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
cbindgen_private::slint_property_set_binding(&p1->inner, call_fn,
new TwoWayBinding { common_property }, del_fn,
intercept_fn, intercept_binding_fn);
cbindgen_private::slint_property_set_binding(&p2->inner, call_fn,
new TwoWayBinding { common_property }, del_fn,
intercept_fn, intercept_binding_fn);
}
/// Internal (private) constructor used by link_two_way
@ -190,8 +190,8 @@ template<>
inline void Property<int32_t>::set_animated_value(
const int32_t &new_value, const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_int(&inner, value, new_value,
&animation_data);
cbindgen_private::slint_property_set_animated_value_int(&inner, value, new_value,
&animation_data);
}
template<>
@ -199,14 +199,14 @@ inline void
Property<float>::set_animated_value(const float &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_float(&inner, value, new_value,
&animation_data);
cbindgen_private::slint_property_set_animated_value_float(&inner, value, new_value,
&animation_data);
}
template<typename F>
void set_state_binding(const Property<StateInfo> &property, F binding)
{
cbindgen_private::sixtyfps_property_set_state_binding(
cbindgen_private::slint_property_set_state_binding(
&property.inner,
[](void *user_data) -> int32_t { return (*reinterpret_cast<F *>(user_data))(); },
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); });
@ -227,9 +227,9 @@ void set_state_binding(const Property<StateInfo> &property, F binding)
struct PropertyTracker
{
/// Constructs a new property tracker instance.
PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_init(&inner); }
PropertyTracker() { cbindgen_private::slint_property_tracker_init(&inner); }
/// Destroys the property tracker.
~PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_drop(&inner); }
~PropertyTracker() { cbindgen_private::slint_property_tracker_drop(&inner); }
/// The copy constructor is intentionally deleted, property trackers cannot be copied.
PropertyTracker(const PropertyTracker &) = delete;
/// The assignment operator is intentionally deleted, property trackers cannot be copied.
@ -237,14 +237,14 @@ struct PropertyTracker
/// Returns true if any properties accessed during the last evaluate() call have changed their
/// value since then.
bool is_dirty() const { return cbindgen_private::sixtyfps_property_tracker_is_dirty(&inner); }
bool is_dirty() const { return cbindgen_private::slint_property_tracker_is_dirty(&inner); }
/// Invokes the provided functor \a f and tracks accessed to any properties during that
/// invocation.
template<typename F>
auto evaluate(const F &f) const -> std::enable_if_t<std::is_same_v<decltype(f()), void>>
{
cbindgen_private::sixtyfps_property_tracker_evaluate(
cbindgen_private::slint_property_tracker_evaluate(
&inner, [](void *f) { (*reinterpret_cast<const F *>(f))(); }, const_cast<F *>(&f));
}
@ -269,7 +269,7 @@ struct PropertyTracker
auto evaluate_as_dependency_root(const F &f) const
-> std::enable_if_t<std::is_same_v<decltype(f()), void>>
{
cbindgen_private::sixtyfps_property_tracker_evaluate_as_dependency_root(
cbindgen_private::slint_property_tracker_evaluate_as_dependency_root(
&inner, [](void *f) { (*reinterpret_cast<const F *>(f))(); }, const_cast<F *>(&f));
}
@ -292,4 +292,4 @@ private:
cbindgen_private::PropertyTrackerOpaque inner;
};
} // namespace sixtyfps::private_api
} // namespace slint::private_api

View file

@ -2,15 +2,15 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
#pragma once
#include "sixtyfps_sharedvector_internal.h"
#include "slint_sharedvector_internal.h"
#include <atomic>
#include <algorithm>
#include <initializer_list>
namespace sixtyfps {
namespace slint {
/// SharedVector is a vector template class similar to std::vector that's primarily used for passing
/// data in and out of the SixtyFPS run-time library. It uses implicit-sharing to make creating
/// data in and out of the Slint run-time library. It uses implicit-sharing to make creating
/// copies cheap. Only when a function changes the vector's data, a copy is is made.
template<typename T>
struct SharedVector
@ -18,7 +18,7 @@ struct SharedVector
/// Creates a new, empty vector.
SharedVector()
: inner(const_cast<SharedVectorHeader *>(reinterpret_cast<const SharedVectorHeader *>(
cbindgen_private::sixtyfps_shared_vector_empty())))
cbindgen_private::slint_shared_vector_empty())))
{
}
/// Creates a new vector that holds all the elements of the given std::initializer_list \a args.
@ -173,16 +173,16 @@ private:
for (auto it = b; it < e; ++it) {
it->~T();
}
cbindgen_private::sixtyfps_shared_vector_free(reinterpret_cast<uint8_t *>(inner),
sizeof(SharedVectorHeader)
+ inner->capacity * sizeof(T),
alignof(SharedVectorHeader));
cbindgen_private::slint_shared_vector_free(reinterpret_cast<uint8_t *>(inner),
sizeof(SharedVectorHeader)
+ inner->capacity * sizeof(T),
alignof(SharedVectorHeader));
}
}
static SharedVector with_capacity(std::size_t capacity)
{
auto mem = cbindgen_private::sixtyfps_shared_vector_allocate(
auto mem = cbindgen_private::slint_shared_vector_allocate(
sizeof(SharedVectorHeader) + capacity * sizeof(T), alignof(SharedVectorHeader));
return SharedVector(new (mem) SharedVectorHeader { { 1 }, 0, capacity });
}

View file

@ -3,11 +3,11 @@
#pragma once
#include <string_view>
#include "sixtyfps_string_internal.h"
#include "slint_string_internal.h"
namespace sixtyfps {
namespace slint {
/// A string type used by the SixtyFPS run-time.
/// A string type used by the Slint run-time.
///
/// SharedString uses implicit data sharing to make it efficient to pass around copies. When
/// copying, a reference to the data is cloned, not the data itself.
@ -23,12 +23,12 @@ namespace sixtyfps {
struct SharedString
{
/// Creates an empty default constructed string.
SharedString() { cbindgen_private::sixtyfps_shared_string_from_bytes(this, "", 0); }
SharedString() { cbindgen_private::slint_shared_string_from_bytes(this, "", 0); }
/// Creates a new SharedString from the string view \a s. The underlying string data
/// is copied.
SharedString(std::string_view s)
{
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::slint_shared_string_from_bytes(this, s.data(), s.size());
}
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied. It is assumed that the string is UTF-8 encoded.
@ -36,37 +36,37 @@ struct SharedString
#if defined(__cpp_char8_t) || __cplusplus >= 202002L
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied.
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char*>(s)) { }
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char *>(s)) { }
#endif
#ifdef __cpp_lib_char8_t
/// Creates a new SharedString from the string view \a s. The underlying string data is copied.
SharedString(std::u8string_view s)
{
cbindgen_private::sixtyfps_shared_string_from_bytes(
this, reinterpret_cast<const char*>(s.data()), s.size());
cbindgen_private::slint_shared_string_from_bytes(
this, reinterpret_cast<const char *>(s.data()), s.size());
}
#endif
/// Creates a new SharedString from \a other.
SharedString(const SharedString &other)
{
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::slint_shared_string_clone(this, &other);
}
/// Destroys this SharedString and frees the memory if this is the last instance
/// referencing it.
~SharedString() { cbindgen_private::sixtyfps_shared_string_drop(this); }
~SharedString() { cbindgen_private::slint_shared_string_drop(this); }
/// Assigns \a other to this string and returns a reference to this string.
SharedString &operator=(const SharedString &other)
{
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::slint_shared_string_drop(this);
cbindgen_private::slint_shared_string_clone(this, &other);
return *this;
}
/// Assigns the string view \a s to this string and returns a reference to this string.
/// The underlying string data is copied. It is assumed that the string is UTF-8 encoded.
SharedString &operator=(std::string_view s)
{
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::slint_shared_string_drop(this);
cbindgen_private::slint_shared_string_from_bytes(this, s.data(), s.size());
return *this;
}
/// Assigns null-terminated string pointer \a s to this string and returns a reference
@ -83,16 +83,10 @@ struct SharedString
/// Provides a view to the string data. The returned view is only valid as long as at
/// least this SharedString exists.
operator std::string_view() const
{
return cbindgen_private::sixtyfps_shared_string_bytes(this);
}
operator std::string_view() const { return cbindgen_private::slint_shared_string_bytes(this); }
/// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
/// least this SharedString exists.
auto data() const -> const char *
{
return cbindgen_private::sixtyfps_shared_string_bytes(this);
}
auto data() const -> const char * { return cbindgen_private::slint_shared_string_bytes(this); }
/// Returns a pointer to the first character. It is only safe to dereference the pointer if the
/// string contains at least one character.
@ -126,8 +120,8 @@ struct SharedString
///
/// For example:
/// \code
/// auto str = sixtyfps::SharedString::from_number(42); // creates "42"
/// auto str2 = sixtyfps::SharedString::from_number(100.5) // creates "100.5"
/// auto str = slint::SharedString::from_number(42); // creates "42"
/// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5"
/// \endcode
static SharedString from_number(double n) { return SharedString(n); }
@ -185,16 +179,13 @@ struct SharedString
/// Appends \a other to this string and returns a reference to this.
SharedString &operator+=(std::string_view other)
{
cbindgen_private::sixtyfps_shared_string_append(this, other.data(), other.size());
cbindgen_private::slint_shared_string_append(this, other.data(), other.size());
return *this;
}
private:
/// Use SharedString::from_number
explicit SharedString(double n)
{
cbindgen_private::sixtyfps_shared_string_from_number(this, n);
}
explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
void *inner; // opaque
};

View file

@ -2,30 +2,30 @@
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
#pragma once
#include "sixtyfps.h"
#include "slint.h"
#include <iostream>
namespace sixtyfps::testing {
namespace slint::testing {
inline void init()
{
cbindgen_private::sixtyfps_testing_init_backend();
cbindgen_private::slint_testing_init_backend();
}
inline void mock_elapsed_time(int64_t time_in_ms)
{
cbindgen_private::sixtyfps_mock_elapsed_time(time_in_ms);
cbindgen_private::slint_mock_elapsed_time(time_in_ms);
}
template<typename Component>
inline void send_mouse_click(const Component *component, float x, float y)
{
auto crc = *component->self_weak.into_dyn().lock();
cbindgen_private::sixtyfps_send_mouse_click(&crc, x, y, &component->m_window.window_handle());
cbindgen_private::slint_send_mouse_click(&crc, x, y, &component->m_window.window_handle());
}
template<typename Component>
inline void send_keyboard_string_sequence(const Component *component,
const sixtyfps::SharedString &str,
const slint::SharedString &str,
cbindgen_private::KeyboardModifiers modifiers = {})
{
cbindgen_private::send_keyboard_string_sequence(&str, modifiers,
@ -33,7 +33,7 @@ inline void send_keyboard_string_sequence(const Component *component,
}
#define assert_eq(A, B) \
sixtyfps::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
slint::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
namespace private_api {
template<typename A, typename B>
@ -49,4 +49,4 @@ void assert_eq_impl(const A &a, const B &b, const char *a_str, const char *b_str
}
}
} // namespace sixtyfps
} // namespace slint

View file

@ -4,34 +4,34 @@
/*! This crate just expose the function used by the C++ integration */
use core::ffi::c_void;
use sixtyfps_corelib::window::ffi::WindowRcOpaque;
use sixtyfps_corelib::window::WindowRc;
use sixtyfps_rendering_backend_selector::backend;
use i_slint_backend_selector::backend;
use i_slint_core::window::ffi::WindowRcOpaque;
use i_slint_core::window::WindowRc;
#[doc(hidden)]
#[cold]
pub fn use_modules() -> usize {
#[cfg(feature = "sixtyfps-interpreter")]
sixtyfps_interpreter::use_modules();
sixtyfps_rendering_backend_selector::use_modules();
sixtyfps_corelib::use_modules()
#[cfg(feature = "slint-interpreter")]
slint_interpreter::use_modules();
i_slint_backend_selector::use_modules();
i_slint_core::use_modules()
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_windowrc_init(out: *mut WindowRcOpaque) {
pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowRcOpaque) {
assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::ptr::write(out as *mut WindowRc, crate::backend().create_window());
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_run_event_loop() {
pub unsafe extern "C" fn slint_run_event_loop() {
crate::backend()
.run_event_loop(sixtyfps_corelib::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
.run_event_loop(i_slint_core::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed);
}
/// Will execute the given functor in the main thread
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_post_event(
pub unsafe extern "C" fn slint_post_event(
event: extern "C" fn(user_data: *mut c_void),
user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>,
@ -57,14 +57,14 @@ pub unsafe extern "C" fn sixtyfps_post_event(
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_quit_event_loop() {
pub unsafe extern "C" fn slint_quit_event_loop() {
crate::backend().quit_event_loop();
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_register_font_from_path(
path: &sixtyfps_corelib::SharedString,
error_str: *mut sixtyfps_corelib::SharedString,
pub unsafe extern "C" fn slint_register_font_from_path(
path: &i_slint_core::SharedString,
error_str: *mut i_slint_core::SharedString,
) {
core::ptr::write(
error_str,
@ -76,9 +76,9 @@ pub unsafe extern "C" fn sixtyfps_register_font_from_path(
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_register_font_from_data(
data: sixtyfps_corelib::slice::Slice<'static, u8>,
error_str: *mut sixtyfps_corelib::SharedString,
pub unsafe extern "C" fn slint_register_font_from_data(
data: i_slint_core::slice::Slice<'static, u8>,
error_str: *mut i_slint_core::SharedString,
) {
core::ptr::write(
error_str,
@ -91,6 +91,6 @@ pub unsafe extern "C" fn sixtyfps_register_font_from_data(
#[cfg(feature = "testing")]
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_testing_init_backend() {
sixtyfps_rendering_backend_testing::init();
pub unsafe extern "C" fn slint_testing_init_backend() {
i_slint_backend_testing::init();
}

View file

@ -5,12 +5,12 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <sixtyfps.h>
#include <sixtyfps_image.h>
#include <slint.h>
#include <slint_image.h>
SCENARIO("SharedString API")
{
sixtyfps::SharedString str;
slint::SharedString str;
REQUIRE(str.empty());
REQUIRE(str == "");
@ -35,7 +35,7 @@ SCENARIO("SharedString API")
{
str = "Hello";
str += " ";
str += sixtyfps::SharedString("🦊") + sixtyfps::SharedString("!");
str += slint::SharedString("🦊") + slint::SharedString("!");
REQUIRE(str == "Hello 🦊!");
REQUIRE(std::string_view(str.data()) == "Hello 🦊!");
}
@ -43,12 +43,12 @@ SCENARIO("SharedString API")
TEST_CASE("Basic SharedVector API", "[vector]")
{
sixtyfps::SharedVector<int> vec;
slint::SharedVector<int> vec;
REQUIRE(vec.empty());
SECTION("Initializer list")
{
sixtyfps::SharedVector<int> vec({ 1, 4, 10 });
slint::SharedVector<int> vec({ 1, 4, 10 });
REQUIRE(vec.size() == 3);
REQUIRE(vec[0] == 1);
REQUIRE(vec[1] == 4);
@ -58,7 +58,7 @@ TEST_CASE("Basic SharedVector API", "[vector]")
TEST_CASE("Property Tracker")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
PropertyTracker tracker1;
PropertyTracker tracker2;
Property<int> prop(42);
@ -80,9 +80,9 @@ TEST_CASE("Property Tracker")
TEST_CASE("Model row changes")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
auto model = std::make_shared<sixtyfps::VectorModel<int>>();
auto model = std::make_shared<slint::VectorModel<int>>();
PropertyTracker tracker;
@ -109,9 +109,9 @@ TEST_CASE("Model row changes")
TEST_CASE("Track model row data changes")
{
using namespace sixtyfps::private_api;
using namespace slint::private_api;
auto model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
auto model = std::make_shared<slint::VectorModel<int>>(std::vector<int> { 0, 1, 2, 3, 4 });
PropertyTracker tracker;
@ -149,7 +149,7 @@ TEST_CASE("Track model row data changes")
TEST_CASE("Image")
{
using namespace sixtyfps;
using namespace slint;
// ensure a backend exists, using private api
private_api::WindowRc wnd;
@ -164,7 +164,7 @@ TEST_CASE("Image")
REQUIRE(!img.path().has_value());
}
img = Image::load_from_path(SOURCE_DIR "/../../vscode_extension/extension-logo.png");
img = Image::load_from_path(SOURCE_DIR "/../../logo/slint-logo-square-light-128x128.png");
{
auto size = img.size();
REQUIRE(size.width == 128.);
@ -173,13 +173,13 @@ TEST_CASE("Image")
{
auto actual_path = img.path();
REQUIRE(actual_path.has_value());
REQUIRE(*actual_path == SOURCE_DIR "/../../vscode_extension/extension-logo.png");
REQUIRE(*actual_path == SOURCE_DIR "/../../logo/slint-logo-square-light-128x128.png");
}
}
TEST_CASE("SharedVector")
{
using namespace sixtyfps;
using namespace slint;
SharedVector<SharedString> vec;
vec.clear();

View file

@ -4,40 +4,40 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <sixtyfps.h>
#include <slint.h>
#include <thread>
TEST_CASE("C++ Singleshot Timers")
{
using namespace sixtyfps;
using namespace slint;
int called = 0;
Timer testTimer(std::chrono::milliseconds(16), [&]() {
sixtyfps::quit_event_loop();
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
TEST_CASE("C++ Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -46,32 +46,32 @@ TEST_CASE("C++ Repeated Timer")
TEST_CASE("C++ Restart Singleshot Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::SingleShot, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::SingleShot, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
timer_triggered = 0;
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 1);
REQUIRE(timer_was_running);
@ -80,21 +80,21 @@ TEST_CASE("C++ Restart Singleshot Timer")
TEST_CASE("C++ Restart Repeated Timer")
{
int timer_triggered = 0;
sixtyfps::Timer timer;
slint::Timer timer;
timer.start(sixtyfps::TimerMode::Repeated, std::chrono::milliseconds(30),
timer.start(slint::TimerMode::Repeated, std::chrono::milliseconds(30),
[&]() { timer_triggered++; });
REQUIRE(timer_triggered == 0);
bool timer_was_running = false;
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -102,12 +102,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer_was_running = false;
timer_triggered = 0;
timer.stop();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered == 0);
REQUIRE(!timer_was_running);
@ -117,12 +117,12 @@ TEST_CASE("C++ Restart Repeated Timer")
timer.restart();
sixtyfps::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
slint::Timer::single_shot(std::chrono::milliseconds(500), [&]() {
timer_was_running = timer.running();
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(timer_triggered > 1);
REQUIRE(timer_was_running);
@ -131,12 +131,12 @@ TEST_CASE("C++ Restart Repeated Timer")
TEST_CASE("Quit from event")
{
int called = 0;
sixtyfps::invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::invoke_from_event_loop([&] {
slint::quit_event_loop();
called += 10;
});
REQUIRE(called == 0);
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 10);
}
@ -145,13 +145,13 @@ TEST_CASE("Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
called += 10;
sixtyfps::invoke_from_event_loop([&] {
slint::invoke_from_event_loop([&] {
called += 100;
sixtyfps::quit_event_loop();
slint::quit_event_loop();
});
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 110);
t.join();
}
@ -161,18 +161,18 @@ TEST_CASE("Blocking Event from thread")
std::atomic<int> called = 0;
auto t = std::thread([&] {
// test returning a, unique_ptr because it is movable-only
std::unique_ptr foo = sixtyfps::blocking_invoke_from_event_loop(
[&] { return std::make_unique<int>(42); });
std::unique_ptr foo =
slint::blocking_invoke_from_event_loop([&] { return std::make_unique<int>(42); });
called = *foo;
int xxx = 123;
sixtyfps::blocking_invoke_from_event_loop([&] {
sixtyfps::quit_event_loop();
slint::blocking_invoke_from_event_loop([&] {
slint::quit_event_loop();
xxx = 888999;
});
REQUIRE(xxx == 888999);
});
sixtyfps::run_event_loop();
slint::run_event_loop();
REQUIRE(called == 42);
t.join();
}

View file

@ -4,12 +4,12 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include <sixtyfps.h>
#include <sixtyfps_interpreter.h>
#include <slint.h>
#include <slint_interpreter.h>
SCENARIO("Value API")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Value value;
REQUIRE(value.type() == Value::Type::Void);
@ -17,7 +17,7 @@ SCENARIO("Value API")
SECTION("Construct a string")
{
REQUIRE(!value.to_string().has_value());
sixtyfps::SharedString cpp_str("Hello World");
slint::SharedString cpp_str("Hello World");
value = Value(cpp_str);
REQUIRE(value.type() == Value::Type::String);
@ -52,7 +52,7 @@ SCENARIO("Value API")
SECTION("Construct an array")
{
REQUIRE(!value.to_array().has_value());
sixtyfps::SharedVector<Value> array { Value(42.0), Value(true) };
slint::SharedVector<Value> array { Value(42.0), Value(true) };
value = Value(array);
REQUIRE(value.type() == Value::Type::Model);
@ -68,7 +68,7 @@ SCENARIO("Value API")
SECTION("Construct a brush")
{
REQUIRE(!value.to_brush().has_value());
sixtyfps::Brush brush(sixtyfps::Color::from_rgb_uint8(255, 0, 255));
slint::Brush brush(slint::Color::from_rgb_uint8(255, 0, 255));
value = Value(brush);
REQUIRE(value.type() == Value::Type::Brush);
@ -80,7 +80,7 @@ SCENARIO("Value API")
SECTION("Construct a struct")
{
REQUIRE(!value.to_struct().has_value());
sixtyfps::interpreter::Struct struc;
slint::interpreter::Struct struc;
value = Value(struc);
REQUIRE(value.type() == Value::Type::Struct);
@ -91,11 +91,11 @@ SCENARIO("Value API")
SECTION("Construct an image")
{
// ensure a backend exists, using private api
sixtyfps::private_api::WindowRc wnd;
slint::private_api::WindowRc wnd;
REQUIRE(!value.to_image().has_value());
sixtyfps::Image image = sixtyfps::Image::load_from_path(
SOURCE_DIR "/../../vscode_extension/extension-logo.png");
slint::Image image = slint::Image::load_from_path(
SOURCE_DIR "/../../logo/slint-logo-square-light-128x128.png");
REQUIRE(image.size().width == 128);
value = Value(image);
REQUIRE(value.type() == Value::Type::Image);
@ -109,7 +109,7 @@ SCENARIO("Value API")
SECTION("Construct a model")
{
// And test that it is properly destroyed when the value is destroyed
struct M : sixtyfps::VectorModel<Value>
struct M : slint::VectorModel<Value>
{
bool *destroyed;
explicit M(bool *destroyed) : destroyed(destroyed) { }
@ -139,8 +139,8 @@ SCENARIO("Value API")
SECTION("Compare Values")
{
Value str1 { sixtyfps::SharedString("Hello1") };
Value str2 { sixtyfps::SharedString("Hello2") };
Value str1 { slint::SharedString("Hello1") };
Value str2 { slint::SharedString("Hello2") };
Value fl1 { 10. };
Value fl2 { 12. };
@ -151,22 +151,22 @@ SCENARIO("Value API")
REQUIRE(fl1 != fl2);
REQUIRE(Value() == Value());
REQUIRE(Value() != str1);
REQUIRE(str1 == sixtyfps::SharedString("Hello1"));
REQUIRE(str1 != sixtyfps::SharedString("Hello2"));
REQUIRE(sixtyfps::SharedString("Hello2") == str2);
REQUIRE(fl1 != sixtyfps::SharedString("Hello2"));
REQUIRE(str1 == slint::SharedString("Hello1"));
REQUIRE(str1 != slint::SharedString("Hello2"));
REQUIRE(slint::SharedString("Hello2") == str2);
REQUIRE(fl1 != slint::SharedString("Hello2"));
REQUIRE(fl2 == 12.);
}
}
SCENARIO("Struct API")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc;
REQUIRE(!struc.get_field("not_there"));
struc.set_field("field_a", Value(sixtyfps::SharedString("Hallo")));
struc.set_field("field_a", Value(slint::SharedString("Hallo")));
auto value_opt = struc.get_field("field_a");
REQUIRE(value_opt.has_value());
@ -182,20 +182,20 @@ SCENARIO("Struct API")
REQUIRE(value.to_string().value() == "Hallo");
}
struc.set_field("field_b", Value(sixtyfps::SharedString("World")));
std::map<std::string, sixtyfps::SharedString> map;
struc.set_field("field_b", Value(slint::SharedString("World")));
std::map<std::string, slint::SharedString> map;
for (auto [k, value] : struc)
map[std::string(k)] = *value.to_string();
REQUIRE(map
== std::map<std::string, sixtyfps::SharedString> {
{ "field-a", sixtyfps::SharedString("Hallo") },
{ "field-b", sixtyfps::SharedString("World") } });
== std::map<std::string, slint::SharedString> {
{ "field-a", slint::SharedString("Hallo") },
{ "field-b", slint::SharedString("World") } });
}
SCENARIO("Struct Iterator Constructor")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
std::vector<std::pair<std::string_view, Value>> values = { { "field_a", Value(true) },
{ "field_b", Value(42.0) } };
@ -210,7 +210,7 @@ SCENARIO("Struct Iterator Constructor")
SCENARIO("Struct Initializer List Constructor")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
@ -222,14 +222,14 @@ SCENARIO("Struct Initializer List Constructor")
SCENARIO("Struct empty field iteration")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc;
REQUIRE(struc.begin() == struc.end());
}
SCENARIO("Struct field iteration")
{
using namespace sixtyfps::interpreter;
using namespace slint::interpreter;
Struct struc({ { "field_a", Value(true) }, { "field_b", Value(42.0) } });
@ -257,8 +257,8 @@ SCENARIO("Struct field iteration")
SCENARIO("Component Compiler")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -296,7 +296,7 @@ SCENARIO("Component Compiler")
SECTION("Compile failure from path")
{
auto result = compiler.build_from_path(SOURCE_DIR "/file-not-there.60");
auto result = compiler.build_from_path(SOURCE_DIR "/file-not-there.slint");
REQUIRE_FALSE(result.has_value());
auto diags = compiler.diagnostics();
@ -306,15 +306,15 @@ SCENARIO("Component Compiler")
SECTION("Compile from path")
{
auto result = compiler.build_from_path(SOURCE_DIR "/tests/test.60");
auto result = compiler.build_from_path(SOURCE_DIR "/tests/test.slint");
REQUIRE(result.has_value());
}
}
SCENARIO("Component Definition Properties")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
@ -331,8 +331,8 @@ SCENARIO("Component Definition Properties")
SCENARIO("Component Definition Properties / Two-way bindings")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
@ -348,8 +348,8 @@ SCENARIO("Component Definition Properties / Two-way bindings")
SCENARIO("Invoke callback")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -385,10 +385,10 @@ SCENARIO("Invoke callback")
}
}
SCENARIO("Array between .60 and C++")
SCENARIO("Array between .slint and C++")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -397,19 +397,19 @@ SCENARIO("Array between .60 and C++")
REQUIRE(result.has_value());
auto instance = result->create();
SECTION(".60 to C++")
SECTION(".slint to C++")
{
auto maybe_array = instance->get_property("array");
REQUIRE(maybe_array.has_value());
REQUIRE(maybe_array->type() == Value::Type::Model);
auto array = *maybe_array;
REQUIRE(array.to_array() == sixtyfps::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
REQUIRE(array.to_array() == slint::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
}
SECTION("C++ to .60")
SECTION("C++ to .slint")
{
sixtyfps::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
slint::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
instance->set_property("array", Value(cpp_array));
auto maybe_array = instance->get_property("array");
@ -421,10 +421,10 @@ SCENARIO("Array between .60 and C++")
}
}
SCENARIO("Angle between .60 and C++")
SCENARIO("Angle between .slint and C++")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
@ -456,8 +456,8 @@ SCENARIO("Angle between .60 and C++")
SCENARIO("Component Definition Name")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source("export IHaveAName := Rectangle { }", "");
@ -466,8 +466,8 @@ SCENARIO("Component Definition Name")
SCENARIO("Send key events")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;
auto comp_def = compiler.build_from_source(R"(
@ -485,14 +485,14 @@ SCENARIO("Send key events")
"");
REQUIRE(comp_def.has_value());
auto instance = comp_def->create();
sixtyfps::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
slint::testing::send_keyboard_string_sequence(&*instance, "Hello keys!", {});
REQUIRE(*instance->get_property("result")->to_string() == "Hello keys!");
}
SCENARIO("Global properties")
{
using namespace sixtyfps::interpreter;
using namespace sixtyfps;
using namespace slint::interpreter;
using namespace slint;
ComponentCompiler compiler;