slint/examples
2022-02-02 12:11:27 +01:00
..
7gui Replace references to the .60 files that are now renamed with .slint 2022-02-02 10:12:31 +01:00
bash Rename all our .60 files to .slint 2022-02-02 10:05:45 +01:00
fancy_demo Rename all our .60 files to .slint 2022-02-02 10:05:45 +01:00
gallery Fix calls to slint_target_sources 2022-02-02 10:39:56 +01:00
imagefilter Rename sixtyfps_widgets.60 to std-widgets.slint 2022-02-01 18:58:54 +01:00
iot-dashboard Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
memory Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
plotter Replace references to the .60 files that are now renamed with .slint 2022-02-02 10:12:31 +01:00
printerdemo Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
printerdemo_old Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
qt_viewer Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
slide_puzzle Replace references to the .60 files that are now renamed with .slint 2022-02-02 10:12:31 +01:00
todo Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
CMakeLists.txt Rename the SixtyFPS CMake interface 2022-02-02 09:58:26 +01:00
README.md Replace more .60 by .slint 2022-02-02 10:12:31 +01:00

Examples

These examples demonstrate the main features of SixtyFPS and how to use them in different language environments.

printerdemo

A fictional user interface for the touch screen of a printer

.slint Design Rust Source C++ Source Node Source Online wasm Preview Open in code editor
ui.slint main.rs main.cpp main.js Online simulation Preview in Online Code Editor

Screenshot of the Printer Demo

A simple application showing the different widgets

.slint Design Rust Source C++ Source Online wasm Preview Open in code editor
gallery.slint main.rs main.cpp Online simulation Preview in Online Code Editor

Screenshot of the Gallery on Windows

todo

A simple todo mvc application

.slint Design Rust Source C++ Source NodeJS Online wasm Preview Open in code editor
todo.slint main.rs main.cpp main.js Online simulation Preview in Online Code Editor

Screenshot of the Todo Demo

slide_puzzle

Puzzle game based on a Flutter example. See Readme

.slint Design Rust Source Online wasm Preview Open in code editor
slide_puzzle.slint main.rs Online simulation Preview in Online Code Editor

Screenshot of the Slide Puzzle

memory

A basic memory game used as an example the tutorial:

.slint Design Rust Source C++ Source Online wasm Preview Open in code editor
memory.slint main.rs memory.cpp Online simulation Preview in Online Code Editor

iot-dashboard

A clone of one demo from the QSkinny framework.

Also show how a way to dynamically load widgets with the interpreter from C++.

.slint Design C++ Source Online wasm Preview Open in code editor
main.slint main.cpp Online preview Preview in Online Code Editor

Screenshot of the IOT Dashboard

imagefilter

A Rust-only example that shows how to use the Rust image crate to do image manipulations and feed the result into SixtyFPS.

Source Online wasm Preview
main.rs Online simulation

Screenshot of the imagefilter example

plotter

A Rust-only example that shows how to use the Rust plotters crate to do plot a graph and integrate the result into SixtyFPS.

.slint Design Rust Source Online wasm Preview
plotter.slint main.rs Online simulation

Screenshot of the plotter example

bash

Some examples of how to use the sixtyfps-viewer to add a GUI to shell scripts.

External examples

  • Cargo UI: A rust application that makes use of threads in the background.

Screenshot of Cargo UI

Loading the example with the viewer

Simply load the .slint file with the viewer application

cargo run --release --bin sixtyfps-viewer -- examples/printerdemo/ui/printerdemo.slint

Running the Rust Examples

You can run the examples either by going into the rust sub-folder and use cargo run, for example:

cd examples/printerdemo/rust
cargo run --release

or you can run them from anywhere in the Cargo workspace by name:

cargo run --release --bin printerdemo

Wasm builds

In order to make the wasm build of the example, you first need to edit the Cargo.toml files to uncomment the line starting with #wasm# (or use the sed line bellow) You can then use wasm-pack (which you may need to obtain with cargo install wasm-pack). This will generate the wasm in the ./pkg directory, which the index.html file will open. Since wasm files cannot be served from file:// URL, you need to open a wab server to serve the content

cd examples/printerdemo/rust
sed -i "s/^#wasm# //" Cargo.toml
wasm-pack build --release --target web
python3 -m http.server

Running the C++ Examples

  • When compiling SixtyFPS from sources: If you follow the C++ build instructions, this will build the C++ examples as well by default
  • From installed binary packages: Simply run cmake in one of the example directory containing a CMakeLists.txt
mkdir build && cd build
cmake -GNinja -DCMAKE_PREFIX_PATH="<path to installed>" ..
cmake --build .

Running the Node Examples

You can run the examples by going into the node sub-folder and use npm, for example:

cd examples/printerdemo/node
npm install
npm start