Fix some links in Rust tutorial

This commit is contained in:
runiq 2023-06-23 10:23:15 +02:00 committed by Olivier Goffart
parent 1b9e245b4e
commit 65712e89ae
3 changed files with 4 additions and 4 deletions

View file

@ -10,9 +10,9 @@ cargo add rand@0.8
What we'll do is take the list of tiles declared in the .slint language, duplicate it, and shuffle it.
We'll do so by accessing the `memory_tiles` property through the Rust code. For each top-level property,
a getter and a setter function is generated - in our case `get_memory_tiles` and `set_memory_tiles`.
Since `memory_tiles` is an array in the `.slint` language, it's represented as a [`Rc<dyn slint::Model>`](https://slint.dev/docs/rust/slint/trait.model).
Since `memory_tiles` is an array in the `.slint` language, it's represented as a [`Rc<dyn slint::Model>`](https://slint.dev/docs/rust/slint/trait.Model).
We can't modify the model generated by the .slint, but we can extract the tiles from it, and put it
in a [`VecModel`](https://slint.dev/docs/rust/slint/struct.vecmodel) which implements the `Model` trait.
in a [`VecModel`](https://slint.dev/docs/rust/slint/struct.VecModel) which implements the `Model` trait.
`VecModel` allows us to make modifications and we can use it to replace the static generated model.
We modify the main function like so:

View file

@ -34,7 +34,7 @@ Insert this code before the `main_window.run()` call:
{{#include main_game_logic_in_rust.rs:game_logic}}
```
Notice that we take a [Weak](https://slint.dev/docs/rust/slint/struct.weak) pointer of our `main_window`. This is very
Notice that we take a [Weak](https://slint.dev/docs/rust/slint/struct.Weak) pointer of our `main_window`. This is very
important because capturing a copy of the `main_window` itself within the callback handler would result in a circular ownership.
The `MainWindow` owns the callback handler, which itself owns a reference to the `MainWindow`, which must be weak
instead of strong to avoid a memory leak.

View file

@ -3,7 +3,7 @@
The game is visually a little bare. Here are some ideas how you could make further changes to enhance it:
- The tiles could have rounded corners, to look a little less sharp. The [border-radius](https://slint.dev/docs/slint/src/builtins/elements.html#rectangle)
property of _Rectangle_ can be used to achieve that.
property of _[Rectangle](https://slint.dev/docs/slint/src/builtins/elements#rectangle)_ can be used to achieve that.
- In real world memory games, the back of the tiles often have some common graphic. You could add an image with
the help of another _[Image](https://slint.dev/docs/slint/src/builtins/elements.html#image)_