Commit graph

1614 commits

Author SHA1 Message Date
Olivier Goffart
617dc19f8e Interpreter: on wasm, check the user agent to resolve the native style
This impact everything that use the interpreter with wasm:
 - docs preview
 - slintpad
 - vscode wasm preview
2024-10-17 18:05:38 +02:00
Milian Wolff
0f6c3a4fd7 Use SmolStr in more places of the compiler infrastructure
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
```
2024-10-17 18:04:58 +02:00
Simon Hausmann
a7436f660f macOS: Add support for reloading the preview via cmd+r 2024-10-16 21:46:54 +02:00
Tobias Hunger
9449f23967 live-preview: Do not fail to render when top level sources are not loaded
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.
2024-10-16 10:59:01 +02:00
Tobias Hunger
041d2ae73e lsp: Remove some unnecessay lines 2024-10-15 16:55:30 +02:00
Tobias Hunger
5519efcd5a lsp: Use constant instead of repeating a slint/showPreview 2024-10-15 16:27:41 +02:00
Tobias Hunger
2008136316 lsp: Clean up language::test module use 2024-10-15 16:27:25 +02:00
Tobias Hunger
e726ee7df4 lsp: Consitently use the DocumentCache from common 2024-10-15 09:42:51 +02:00
Tobias Hunger
378682fd36 live-preview: Rename ContentCache member 2024-10-14 14:48:34 +02:00
Tobias Hunger
e6db88afbd live-preview: Reload when image resources change on disk
Reload the preview whenever the image resources change
on disk.
2024-10-14 13:41:01 +02:00
Tobias Hunger
e55f2ae04e compiler: Add a ListResources option for resource embedding
... 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.
2024-10-14 11:31:34 +02:00
Tobias Hunger
ea82c6285b live-preview: Delay updating the preview
Delay updating the live preview to prevent a
thundering herd effect when e.g. a git update changes
a lot of files at once.
2024-10-11 09:38:56 +02:00
Tobias Hunger
3d3bf9f01b lsp: Pass invalidation of files on to live-preview 2024-10-10 09:31:11 +02:00
Tobias Hunger
e62d9e0695 lsp: Remember which files are open in the editor
... 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.
2024-10-10 09:31:11 +02:00
Tobias Hunger
d87833a6bd lsp: Add a filesystem watch request to our LS
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.
2024-10-10 09:31:11 +02:00
Olivier Goffart
63df45d8c1
LSP: autocompletion: de-normalize the element id (#6491)
So that it preserves `-` vs. `_` in element id and global names

Fixes #6479

ChangeLog: LSP: preserve `_` when auto-completing element identifiers
2024-10-09 18:06:08 +02:00
Nigel Breslaw
6beb0c3f02
chore: Update npm dependencies
Update biome
Update typescript
Update esbuild
2024-10-08 13:13:49 +03:00
Tobias Hunger
40cd2cc8fe live-preview: Enforce minimum size consistently
Stop resizing to a size that is too small to interact with anymore.

This was enforced in most places, but I apparently missed one ;-)

Fixes: #6286
2024-10-07 19:38:07 +02:00
Tobias Hunger
d257bcdc9a lsp: Make live-preview preview on the type, not the base type
When writting

```slint
export component Foo inherits Bar { }
  
```

then highlight this element when the cursor is on Foo, not on Bar.

Fixes: #6409
2024-10-07 19:12:57 +02:00
Tobias Hunger
197ed638f6 live-preview: Reselect element after preview area changed size
This covers one case where the selection rectangles are wrong.

Fixes: #6438
2024-10-07 19:12:35 +02:00
Nigel Breslaw
e8c5e97c56
chore(deps): Update Vite to 5.4.8 2024-10-07 17:33:18 +03:00
Tobias Hunger
ae4ba159a5 live-preview: Always consider min/max size of the preview
Consider changes to min/max size of the preview whenever they change
and extract some common lines into a function.

Fixes: #6377
2024-10-07 15:21:43 +02:00
Nigel Breslaw
a97b7c7d92
Replace npm with pnpm
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.
2024-10-07 15:38:26 +03:00
Tobias Hunger
6ed506ab1f live-preview: Sort styles in style combobox
Fixes: #6251
2024-10-07 11:15:54 +02:00
Simon Hausmann
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
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
2024-10-05 17:00:46 +02:00
Tobias Hunger
0cd7b6196a lsp: Follow up cargo-machete
`cargo-machete` suggests unused dependencies, follow
up on its report.
2024-10-02 15:20:23 +02:00
Olivier Goffart
4abc35a5c4 LSP: Fix preview not showing at a decent size
ammend f772cb8e11
2024-10-02 10:50:46 +02:00
Olivier Goffart
d6706494a5
Binding between a read only property to input-output is deprecated (#6419)
ChangeLog: deprecated two way binding between `in` and `in-out` property

Fixes #6400
2024-10-01 16:00:06 +02:00
Tobias Hunger
57084a61ec live-preview: Do not consider negative numbers to be complex
... and add some tests ...
2024-09-30 14:54:03 +02:00
Tobias Hunger
d22f202012 live-preview: Filter out properties that make no sense
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.
2024-09-30 14:53:01 +02:00
Enyium
a2ded25914
SlintPad: Separate imports from rest with empty line. (#6364)
This is visually clearer, common, and relieves the user of doing it themselves.
2024-09-30 10:10:12 +02:00
Tobias Hunger
75bff689da slintpad: Move the copy URL button to the the back again
This backs out commit 10139a26ad

... and then changes the original code to wrap anywhere instead as
suggested in #6333.

Fixes: #6333
2024-09-27 15:48:43 +02:00
Tobias Hunger
2c9e79613e lsp: Ignore optimized out elements when looking for parent
Ignore elements that were optimized out when looking for a
`ElementRcNode`s parent.
2024-09-27 15:23:13 +02:00
Tobias Hunger
c75cf0c66b live-preview: Fix panic when dragging elements onto layouts
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.
2024-09-27 14:48:58 +02:00
Olivier Goffart
95a66d946e LSP preview: don't panic if run_event_loop returns an error
We already catch other sort of error, we should also catch
run_event_loop and report the error to the LSP
2024-09-27 10:19:17 +02:00
Olivier Goffart
cfa115affa LSP: changed callbacks auto-completion
ChangeLog: LSP: auto-completion of changed callbacks
2024-09-26 18:20:03 +02:00
Tobias Hunger
10139a26ad slintpad: Move the copy URL button to the front
.. and only print the URL after it: That way the button stays
visible at all times.

Closes: #6318
2024-09-26 17:52:51 +02:00
Tobias Hunger
3194d55ad1 slintpad: Include slint language configuration
... and add more key bindings.

This makes for a much better language integration, incl.
better word selection, auto-closing braces and commenting.

Closes: #6316
2024-09-26 12:54:57 +02:00
Simon Hausmann
746100b1d5 macOS: Rename "Quit" to "Close" in the system menu bar
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.
2024-09-26 10:39:26 +02:00
Tobias Hunger
ac7598f10a slintpad: Update monaco editor and other dependencies
... and modernize the code base. Trims about 200 lines
from the code and will hopefully simplify future updates.
2024-09-26 10:33:12 +02:00
ogoffart
eb273a63ee Bump version number to 1.9.0 2024-09-25 11:49:15 +00:00
Josh Wood
6a131e2648
Added PropertyAnimation.direction property for controlling animation direction (#6261)
Closes #6260

ChangeLog: Added property for controlling animation direction
2024-09-24 19:55:24 +02:00
Simon Hausmann
f772cb8e11
live-preview: Bring the window to the front and focus it when the use… (#6295)
Fixes #196


Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2024-09-24 17:05:03 +02:00
Tobias Hunger
a0c46d65bd live-preview: Use modern features in API now that 1.8 is out 2024-09-24 10:51:12 +02:00
Olivier Goffart
e753d21963 Preview: use a thread_local instead of an unsafe static mut
Fixes nightly build
CC #6102
2024-09-21 09:00:59 +02:00
Tobias Hunger
eb3e1dded1 live-preview: Re-ordering of properties in property editor
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.
2024-09-20 14:49:42 +02:00
Ian Hattendorf
adda07bd55
Support saving/loading images via their path (#6224)
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.
2024-09-20 08:56:16 +02:00
szecket
8f8eb0d120
made adjustments using the awesome new data in api (#6223) 2024-09-20 03:32:10 +12:00
Olivier Goffart
e842a25c81 live-preview: Allow resizing if only one of the dimention is contrained
If the height is contreained but not the width, we should still be able
to resize
2024-09-19 15:55:29 +02:00
Tobias Hunger
6b07d525ad live-preview: Add a Del key handler into the selection
Make sure the handler gets activated whenever the selection
gets clicked.
2024-09-19 15:51:56 +02:00