Commit graph

38 commits

Author SHA1 Message Date
Oleh Kulish
58447c99e7
Add error handling for the slide puzzle example (#7917)
* Add impl From<PlatformError> for JsValue
2025-03-25 10:07:16 +01:00
Olivier Goffart
0359071b1e
Winit initial size adjustments and wasm size fixes
Following the winit 0.29 merge, a few adjustments are in order:

 - Make slint::Window.set_size() before show keep the size
 - on wasm, attempt to keep the size of the canvas from CSS
 - on wasm, one must set the width and height explicitly on the canvas
   otherwise there is wierd scaling
 - on wasm, we can't set None as maximum or minimum size otherwise winit
   panics
 - It seems that the hack we had to keep the size in range is no longer
   necessary
 - The hack in the slide puzzle can be removed. (but unfortunately it
   doesn't follow resizes

Unfortunatelly we always call set_inner_size to avoid infinite loop when
the css properties are not specificed, so this will override layouts

Also we don't default anymore to the preferred size

* Update internal/backends/winit/winitwindowadapter.rs
2023-10-24 15:28:18 +02:00
Tobias Hunger
8345c6cd79 Do automatic clippy fixes 2023-06-28 14:22:30 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
e4338300de
Change license for examples to MIT (#2887) 2023-06-15 11:23:17 +02:00
Olivier Goffart
e8f21035ff Fix the slide_puzzle canvas size on wasm
Since winit can't handle resize from the CSS or JS, work it around in
the demo by calling set_size on the slint window.

Also fix slint_size panicking not working on wasm as the map_state was
mutably borrowed by the set_size, and this may recurse into other
functions (eg, draw) causing a panic. So don't keep the state borrowed
when calling winit.

Another fix is fixing the initialization size of the window item when
the initial size is set with set_size

Fixes #547
2023-03-29 15:41:07 +02:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Tobias Hunger
2ebe788afe
Update some broken URLs 2022-02-08 12:14:01 +01:00
Tobias Hunger
cc3994b58d
Rename rust API 2022-02-02 13:26:35 +01:00
Olivier Goffart
929166f06c Change what is accepted by ModelRc::new and ModelRc::from
- ModelRc::new constructs a ModelRc from a impl Model
 - ModelRc::form constructs a ModelRc from a `Rc<dyn Model>` or `Rc<impl Model>`
2022-01-31 14:44:35 +01:00
Tobias Hunger
018c1a6666 Rename ModelHandle to SharedModel
This patch is mostly a rename now, but also contains a few small
cleanups.

SharedModel implements the Model trait itself and gracefully falls back
to an empty model is no Model was provided. This allows for some small
simplifications.

Also make sure to use the same comparision for SharedModels everywhere.
This fixes the last remaining clippy errors we had.
2022-01-30 01:26:35 +01:00
Tobias Hunger
e3c4209b1f
Change Model::row_data to return an Option<T> (#873)
Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++)

Co-authored-by: Olivier Goffart <olivier@woboq.com>
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-01-26 13:55:38 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Tobias Hunger
9539a53480 Janitor: Fix clippy::redundant_clone 2021-07-23 13:48:52 +02:00
Tobias Hunger
aeebbb1d96 Janitor: Fix remaining clippy::option_map_unit_fn 2021-07-21 19:44:57 +02:00
Tobias Hunger
b402faff13 Janitor: Deduplicate if blocks 2021-07-12 15:01:19 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Simon Hausmann
cb70f58990 Port the slide puzzle over to specifying the custom font in .60 2021-04-14 09:49:51 +02:00
Simon Hausmann
445ddd58d5 API cleanup
Remove the `application` infix from `register_application_font`, to
reduce the changes that it might be interpreted to be a function that
also changes the default font in all text elements.
2021-02-17 14:37:31 +01:00
Olivier Goffart
17eaffb6e1 Update rand dependency in the examples 2021-01-28 15:43:38 +01:00
Simon Hausmann
727c9a19f7 Add basic text item support
This needs more work, but gets something onto the screen at least.
2021-01-14 08:53:13 +01:00
Simon Hausmann
1e683de64d Simplify Rust Timer API
Don't require the caller to Box the closure. With the assumption that
the majority of callers *want* the closure to be boxed (i.e. it's not
already boxed), the API becomes easier to use.
2020-12-04 10:57:19 +01:00
Simon Hausmann
7047856d4e Replace FooRc with Foo and without ComponentHandle in examples and tests 2020-12-03 08:13:24 +01:00
Simon Hausmann
08b8a8cb83 Port the examples away from the ComponentHandle based API 2020-12-03 08:13:15 +01:00
Simon Hausmann
4c5e43c919 Move the plaster font into a sub-directory on its own
Otherwise it might look like the example is under the OFL license :)
2020-11-27 15:44:53 +01:00
Simon Hausmann
2472eb51f0 Add the plaster font to plaster theme of the slide puzzle
For regular builds this is done by adding Rust API that allows
registering a font, and for the web the font is installed into the
browser using JavaScript API.

This is an initial approach to just add this ability. It might make
sense to introduce a syntax in the `.60` file to allow for the
registration of fonts and letting the compiler generate code that
performs this embedding and registration automatically.
2020-11-27 14:29:56 +01:00
Olivier Goffart
2d6751a87a Puzzle: stop the auto-play when resetting 2020-11-23 13:41:48 +01:00
Olivier Goffart
807dbb3c00 Puzzle: Kick animation
Also support timer that can be cancelled from the timer event
2020-11-23 13:38:44 +01:00
Simon Hausmann
9283a43d3e Small typo fixes 2020-11-20 16:19:00 +01:00
Olivier Goffart
280414b556 slide_puzzle: Thumb up icon when winning 2020-11-16 13:30:48 +01:00
Olivier Goffart
0672f4b3cd Expose Timer API to rust API
And use it in the puzzle demo to implement the auto play mode
2020-11-16 12:17:02 +01:00
Olivier Goffart
69aa4cb03b Make the puzzle solvable 2020-11-13 16:52:40 +01:00
Olivier Goffart
01356bde33 Some more logic got the sliding puzzle 2020-11-12 12:59:18 +01:00
Olivier Goffart
8f362ead43 Missing license header 2020-11-10 15:12:25 +01:00
Olivier Goffart
270e1b3e5b Start experimenting with the sliding puzzle example 2020-11-10 14:30:36 +01:00