Small consistency fixes and typos across quickstarts (#4813)

This commit is contained in:
Chris Chinchilla 2024-03-11 17:34:27 +01:00 committed by GitHub
parent 10afbbbfbb
commit 0095d65696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 71 additions and 66 deletions

View file

@ -7,8 +7,8 @@ game. There is much more to Slint, such as layouts, widgets, or styling.
We recommend the following links to continue:
- [Examples](https://github.com/slint-ui/slint/tree/master/examples): In the Slint repository we have collected several demos and examples. These are a great starting point to learn how to use many Slint features.
- [Examples](https://github.com/slint-ui/slint/tree/master/examples): The Slint repository has several demos and examples. These are a great starting point to learn how to use many Slint features.
- [Todo Example](https://github.com/slint-ui/slint/tree/master/examples/todo): This is one of the examples that implements a classic use-case.
- [Memory Puzzle](https://github.com/slint-ui/slint/tree/master/examples/memory): This is a slightly more polished version of the code in this example and you can <a href="https://slint.dev/demos/memory/" target="_blank">play the wasm version</a> in your browser.
- [Slint API Docs](https://slint.dev/docs/rust/slint/): The reference documentation for the main Rust crate.
- [Slint Interpreter API Docs](https://slint.dev/docs/rust/slint_interpreter/): The reference documentation for Rust crate that allows you to dynamically load Slint files.
- [Slint Interpreter API Docs](https://slint.dev/docs/rust/slint_interpreter/): The reference documentation for the Rust crate that allows you to dynamically load Slint files.

View file

@ -15,7 +15,7 @@ After modeling a single tile, this step creates a grid of them. For the grid to
With Slint you declare an array of structures based on a model using square brackets. Use a <span class="hljs-keyword">for</span> loop
to create multiple instances of the same element.
With Slint the <span class="hljs-keyword">for</span> loop is declarative and automatically updates when
The <span class="hljs-keyword">for</span> loop is declarative and automatically updates when
the model changes. The loop instantiates all the <span class="hljs-title">MemoryTile</span> elements and places them on a grid based on their
index with spacing between the tiles.

View file

@ -2,7 +2,7 @@
# Game Logic In C++
This step implements the rules of the game in C++ as well.
This step implements the rules of the game in C++.
Slint's general philosophy is that you implement the user interface in Slint and the business logic in your favorite programming
language.
@ -18,7 +18,7 @@ Add the following code inside the <span class="hljs-title">MainWindow</span> com
```
This change adds a way for the <span class="hljs-title">MainWindow</span> to call to the C++ code that it should
check if a player has solved a pair of tiles. The C++ code needs an additional property to toggle to disable further
check if a player has solved a pair of tiles. The Rust code needs an additional property to toggle to disable further
tile interaction, to prevent the player from opening more tiles than allowed. No cheating allowed!
The last change to the code is to act when the <span class="hljs-title">MemoryTile</span> signals that a player clicked it.

View file

@ -5,6 +5,8 @@
This tutorial uses C++ as the host programming language. Slint also supports other programming languages like
[Rust](https://slint.dev/docs/rust/slint/) or [JavaScript](https://slint.dev/docs/node/).
We recommend using [our editor integrations for Slint](https://github.com/slint-ui/slint/tree/master/editors) for following this tutorial.
Slint has an application template you can use to create a project with dependencies already set up that follows recommended best practices.
Before using the template, you need a C++ compiler that supports C++ 20 and to install [CMake](https://cmake.org/download/) 3.21 or newer.
@ -40,6 +42,10 @@ Configure with CMake:
cmake -B build
```
_Note_: When configuring with CMake, the FetchContent module fetches the source code of Slint via git.
This may take some time when building for the first time, as the process needs to build
the Slint runtime and compiler.
Build with CMake:
```sh
@ -67,7 +73,3 @@ my_application
```
![Screenshot of initial tutorial app showing Hello World](https://slint.dev/blog/memory-game-tutorial/getting-started.png "Hello World")
_Note_: When configuring with CMake, the FetchContent module fetches the source code of Slint via git.
This may take some time when building for the first time, as the process needs to build
the Slint runtime and compiler.

View file

@ -2,7 +2,7 @@
# Introduction
This tutorial introduces you to the Slint UI framework in a playful way by implementing a memory game. It combines the `.slint` language for the graphics with the game rules implemented in Rust.
This tutorial introduces you to the Slint UI framework in a playful way by implementing a memory game. It combines the Slint language for the graphics with the game rules implemented in C++.
The game consists of a grid of 16 rectangular tiles. Clicking on a tile uncovers an icon underneath.
There are 8 different icons in total, so each tile has a sibling somewhere in the grid with the

View file

@ -5,10 +5,10 @@
With the skeleton code in place, this step looks at the first element of the game, the memory tile. It's the
visual building block that consists of an underlying filled rectangle background, the icon image. Later steps add a covering rectangle that acts as a curtain.
Declare the background rectangle as 64 logical pixels wide and tall
You declare the background rectangle as 64 logical pixels wide and tall
filled with a soothing tone of blue.
Note how lengths in Slint have a unit, here, the `px` suffix.
Lengths in Slint have a unit, here, the `px` suffix.
This makes the code easier to read and the compiler can detect when you accidentally
mix values with different units attached to them.
@ -18,14 +18,15 @@ Copy the following code into `ui/appwindow.slint` file, replacing the current co
{{#include memory_tile.slint:main_window}}
```
The code exports the <span class="hljs-title">MainWindow</span> component. This is necessary so that the C++ code can access it later for business logic.
The code exports the <span class="hljs-title">MainWindow</span> component so that the C++ code can access it later.
Inside the <span class="hljs-built_in">Rectangle</span> place an <span class="hljs-built_in">Image</span> element that
loads an icon with the <span class="hljs-built_in">@image-url()</span> macro. The path is relative to the location of `ui/appwindow.slint`.
You need to install this icon and others you use later first. You can download a pre-prepared
[Zip archive](https://slint.dev/blog/memory-game-tutorial/icons.zip) to the `ui` folder and extract it with the
following commands:
[Zip archive](https://slint.dev/blog/memory-game-tutorial/icons.zip) to the `ui` folder,
If you are on Linux or macOS, download and extract it with the following commands:
```sh
cd ui
@ -37,13 +38,14 @@ cd ..
If you are on Windows, use the following commands:
```sh
cd ui
powershell curl -Uri https://slint.dev/blog/memory-game-tutorial/icons.zip -Outfile icons.zip
powershell Expand-Archive -Path icons.zip -DestinationPath .
cd ..
```
This unpacks an `icons` directory containing several icons.
Compile the program with `cmake --build build` and running with the `./build/my_application` gives us a
window on the screen that shows the icon of a bus on a blue background.
Compiling the program with `cmake --build build` and running with the `./build/my_application` opens a window that shows the icon of a bus on a blue background.
![Screenshot of the first tile](https://slint.dev/blog/memory-game-tutorial/memory-tile.png "Memory Tile Screenshot")