Slintpad uses URLs to images. Do not fail when we "embed"
those so that we find the list of resources on the Documents
later.
This fixes image loading in slintpad again.
Do not extract the file loading into a fuinction: That keeps
`self` around which is part of a borrowed state. That is a
problem as during the load we end up in `ensure_document_loaded`
again, which will try to borrow_mut that same state.
This removes a lot of allocations and speeds up the compiler step
a bit. Sadly, this patch is very invasive as it touches a lot of
files. That said, each individual hunk is pretty trivial.
For a non-trivial real-world example, the impact is significant,
we get rid of ~29% of all allocations and improve the runtime by
about 4.8% (measured until the viewer loop would start).
Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
Time (mean ± σ): 664.2 ms ± 6.7 ms [User: 589.2 ms, System: 74.0 ms]
Range (min … max): 659.0 ms … 682.4 ms 10 runs
allocations: 4886888
temporary allocations: 857508
```
After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
Time (mean ± σ): 639.5 ms ± 17.8 ms [User: 556.9 ms, System: 76.2 ms]
Range (min … max): 621.4 ms … 666.5 ms 10 runs
allocations: 3544318
temporary allocations: 495685
```
Heaptrack showed a lot of memory allocations when the strings
in the NamedReference got copied around. Instead, we now use
SmolStr to benefit from SSO. This already removes ~320000
allocations for the benchmark app I am using here. Runtime
also improves by ca 1.8%.
Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
Time (mean ± σ): 676.6 ms ± 15.6 ms [User: 594.6 ms, System: 77.4 ms]
Range (min … max): 662.9 ms … 703.4 ms 10 runs
allocations: 5202354
temporary allocations: 857511
```
After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
Time (mean ± σ): 664.2 ms ± 6.7 ms [User: 589.2 ms, System: 74.0 ms]
Range (min … max): 659.0 ms … 682.4 ms 10 runs
allocations: 4886888
temporary allocations: 857508
```
Newer clang may produce warnings like this when using == with floating point numbers:
```
error: floating-point comparison is always false; constant cannot be represented exactly in type 'float' [-Werror,-Wliteral-range]
```
Use the C++ equivalent of approx_eq to avoid the warning and provide more reliable comparison.
... which will list all resources that are not going to get embedded
as `None` in the Document's `embedded_file_reosurces`.
The idea is to use that field to find all used resources in the
live preview so that we know what we can watch.
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.
ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.
Closes#6047
If the property was not used, it was optimized out and the compiler
would panic
Fixes#6331
ChangeLog: compiler: Fix changed callback of an unused property
The origin of this proposal is the name of the `swipe-left`, etc.
directional, boolean properties. They're missing another verb in their
name. In principle the right choice would be "recognize". That is what
the type name suggests, that's the term the documentation uses, so the
code should read `recognize-swipe-left: true;`. However that is a long
word. "Handle" is a verb that's simpler. It's also more generic (that's
a downside), but it's otherwise short enough to make things look
"right":
```
SwipeGestureHandler {
handle-swipe-left: true;
swiped => { something.naviate-left(); }
}
```
Therefore this patch proposes to rename the type to SwipeGestureHandler
and prefixes the boolean directional properties with "handle".
Don't return an Option, just return 0 when the timer is not started.
As discussed in the API review, the rational is that the interval is
just like a field in a struct and when the struct is default
constructed, it is initialized to 0
* Select text on SpinBox on double click
* Update CHANGELOG.md
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
* Code review feedback
---------
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
* Fixed button of cup. ComboBox not centered on bigger height
* Update CHANGELOG.md
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
---------
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
This is consistant so that `width: 100%` is the same as `width: parent.width`
This basically revert the previous commit that was just working around
the debug_assert to actually fix the behavior
ChangeLog: width and height expressed in `%` unit for an element in a
Flickable now refer to the size of the Flickable instead of that of
the viewport
The viewport of a flickable is of ElementType::Native, and `lookup_property`
don't query the builtin reserved properties in that case.
This commit fix the assert by allowing Type::Invalid as well.
Fixes#4163