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
```
Ths can open one file in VSCode and show the preview. Then you click
on another file in the file tree, which will replace the current file.
This replacement invalidates the data stored in the live-previews caches, so
it used to render an empty file. Read the data from disc instead -- if
that is an option.
... 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.
... and ignore them on file change notifications: The
Editor manages the file content, so we do not need to
care for the on-disk content for these files.
Get a notification of any file change/deleteion. This feels like
overdoing it a bit, but we need to reload when resources change
and those can be anything.
Replaces the use of NPM with PNPM. This should make it quick and easy to update any of the dependencies as dependabot will now see everything in one go.
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
Filter out properties related to layouts that make no sense
for the current element. These are x/y coordinates and the
grid layout related properties.
It's tricky to do: The properties are looked up in the
context of the unoptimized DocumentCache, so that
(most) properties are visible. The layout information is
not available there though as base types are not resolved yet.
So the layout information is taken from the preview data.
Fix panic when dragging objects onto layouts that have an x/y
coordinate set. The hit rect was miscalculated, taking the
origin of the layout into account when calculating its size.
... and add more key bindings.
This makes for a much better language integration, incl.
better word selection, auto-closing braces and commenting.
Closes: #6316
This makes it a little clearer that this hides.
You can still quit the process via cmd+q when cmd+tab is shown, as well as via the context menu in the dock.
All other tools have custom widgets for x/y, width/height, etc.,
let's try to come close by at least presenting the properties in
in a logical order that lends itself to data input.
This reorders geometry to show `x`, `y`, `width` and `height` followed by `z`.
It also orders layout as `min-width`, `min-height`, `preferred-width/-height',
and `max-width/height` followed by horizontal and vertical stretch.
This assumes any string value for an image property is a path. This
could be expanded in the future to support loading raw pixel values by
e.g. parsing a data URI.
ChangeLog: viewer: `--save-data`/`--load-data`: support for images with paths (#6169)
Closes#6169.