mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
SixtyFPS -> Slint in the C++ documentation
This commit is contained in:
parent
ad4eea9e96
commit
f48d7d9f9e
13 changed files with 44 additions and 44 deletions
|
@ -78,7 +78,7 @@ Set up the environment and build:
|
|||
cd sixtyfps
|
||||
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 .
|
||||
```
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Installing or Building with CMake
|
||||
|
||||
SixtyFPS comes with a CMake integration that automates the compilation step of the `.slint` 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 `.slint` dependency tracking.
|
||||
|
@ -8,7 +8,7 @@ You can select the CMake Ninja backend by passing `-GNinja` or setting the `CMAK
|
|||
|
||||
## 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:
|
||||
|
||||
|
@ -25,7 +25,7 @@ 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,26 +35,26 @@ 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
|
||||
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.
|
||||
|
||||
|
@ -67,17 +67,17 @@ different ways of toggling CMake options. For example on the command line using
|
|||
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 SixtyFPS 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
|
||||
|
@ -106,7 +106,7 @@ Set up the environment and build:
|
|||
cd sixtyfps
|
||||
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 .
|
||||
```
|
||||
|
|
|
@ -21,7 +21,7 @@ import textwrap
|
|||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = "SixtyFPS C++"
|
||||
project = "Slint C++"
|
||||
copyright = "2021, info@sixtyfps.io"
|
||||
author = "info@sixtyfps.io"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ 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
|
||||
|
||||
|
@ -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 `.60` 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,7 +55,7 @@ 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);
|
||||
```
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Generated code
|
||||
|
||||
The SixtyFPS compiler called by the build system will generate a header file for the root `.slint`
|
||||
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:
|
||||
|
|
|
@ -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 `.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 SixtyFPS run-time library. This dependency is satisfied by linking `Slint::Slint`
|
||||
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:
|
||||
|
@ -18,12 +18,12 @@ project(my_application LANGUAGES CXX)
|
|||
# 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)
|
||||
slint_target_sources(my_application my_application_ui.slint)
|
||||
|
@ -65,17 +65,17 @@ int main(int argc, char **argv)
|
|||
}
|
||||
```
|
||||
|
||||
This works because the SixtyFPS compiler translated `my_application_ui.slint` 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>.
|
||||
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.
|
||||
|
|
|
@ -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::
|
||||
|
@ -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://sixtyfps.io/>`_ 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 .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;
|
||||
|
@ -87,10 +87,10 @@ is compiled to native code.
|
|||
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 `.60` files using our `Slint Visual Studio Code Extension <https://marketplace.visualstudio.com/items?itemName=SixtyFPS.sixtyfps-vscode>`_,
|
||||
which features syntax highlighting and live design preview.
|
||||
|
||||
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=SixtyFPS.sixtyfps-vscode>`_ 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.
|
||||
|
|
|
@ -19,7 +19,7 @@ and lowest memory consumption.
|
|||
|
||||
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>`
|
||||
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 `.slint` designs
|
||||
|
|
|
@ -29,7 +29,7 @@ struct ItemVTable;
|
|||
#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
|
||||
|
@ -845,7 +845,7 @@ cbindgen_private::NativeStyleMetrics::~NativeStyleMetrics()
|
|||
#endif // !defined(DOXYGEN)
|
||||
|
||||
namespace private_api {
|
||||
// Code generated by SixtyFPS <= 0.1.5 uses this enum with VersionCheckHelper
|
||||
// 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>
|
||||
|
@ -878,7 +878,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
|
||||
|
@ -920,7 +920,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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ struct ErasedComponentBox : vtable::Dyn
|
|||
/// 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 .slint code, which is
|
||||
/// the normal way to use SixtyFPS.
|
||||
/// 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
|
||||
|
@ -227,7 +227,7 @@ private:
|
|||
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.
|
||||
|
@ -881,7 +881,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// ComponentCompiler is the entry point to the SixtyFPS interpreter that can be used
|
||||
/// 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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue