Commit graph

1223 commits

Author SHA1 Message Date
FloVanGH
5ea05e18af
std-widgets: added horizontal-alignment to SpinBox (#6778) 2024-11-15 08:05:57 +00:00
Olivier Goffart
5b3ea5cdd5 LSP: record dependencies and invalid all dependents when a dependencies changes
Fixes #5797
2024-11-14 14:35:22 +01:00
Olivier Goffart
cde5133045 compiler: Remember all import in the document with their absolute path
That way we will be able to use that in the LSP to get the dependencies
2024-11-14 14:35:22 +01:00
Olivier Goffart
ed951202e4 compiler: process the import a bit differently
Don't filter type import with the extension. Instead if the import
statement is having braces, always consider it is a slint file, and if
not, consider it as a foreign import
2024-11-14 14:35:22 +01:00
Olivier Goffart
0533fa4acf compiler: don't call resolve_import_path twice
`resolved_import` is only used for non .slint file.
For slint file, `ensure_document_loaded` will call
`resolve_import_path` again.
2024-11-14 14:35:22 +01:00
FloVanGH
9cfe8862f9
embed glyphs: removed duplicated, added missing chars (#6782) 2024-11-14 07:36:25 +00:00
Olivier Goffart
ed372e91a1 Fix wrong optimization trying to merge common properties around assignments
the deduplicate_property_read was bailing out the replacement if one
part of the coinditional branch do assignment. But the other part might
already have partial assignment, so we must continue

Fixes #6616
2024-11-13 22:14:56 +01:00
Olivier Goffart
650fd0eef5 Fix panic when calling expression containing un-called macro
Fixes #6650
2024-11-11 16:08:22 +01:00
FloVanGH
2cb5fb1d99
std-widgets: fixed arrow size of scroll bar button (#6728) 2024-11-11 15:02:39 +00:00
Olivier Goffart
e854e11399 Error when making a for over an empty array
Instead of panicking.

Attempt to fix it in #6765 didn't work for C++.
Code generation might be hard for C++, so I thought it's better to error out.

Fix #6760
2024-11-11 13:23:56 +01:00
FloVanGH
c84af1a8d7
std-widgets: added LayoutSpec global (#6711) 2024-11-06 14:47:04 +00:00
Olivier Goffart
e3ea25f48c LSP: Signature Help 2024-11-06 13:27:29 +01:00
Olivier Goffart
3552e004e1 Fix wrong value or panic in the interpreter when converting struct of struct
The "tmpobj" variable was overwriten because the interpreter (contrary
to rust and C++) don't have scopes for the local variables, and local
variable of the same name would conflict.
(I think this could in theory be a problem in C++ and rust although i
haven't reproduced it)

Other uses of StoreLocalVariable also make the number unique with a
counter

Fixes #6721
2024-11-05 14:06:09 +01:00
Olivier Goffart
929e71e6b0 Widgets: add callback arg names to some callback
The ones that have a comment already.

Tests that the name is consistent accross the styles.
2024-11-04 17:09:57 +01:00
Olivier Goffart
51e4d4562a Do not print the internal struct name in LSP tooltip or error message
just strip the `slint::` or `slint::private_api::`
This is not a 100% match to the slint name (eg, LogicalPosition) but
it is better anyway
2024-11-04 17:09:57 +01:00
Olivier Goffart
b44172be4f Janitor: Remove BuiltinElement::reserved_properties
It was added when support for `font-metrics` was added, but there is no
reason why this can't simply be in the `properties` hash.
2024-11-04 17:09:57 +01:00
Brandon Fowler
6da0f55b05
Associate PopupWindows with an ID for their active popup (#6693)
Popups are stored in a HashMap and are assigned an ID so popup.close(); closes the correct popup and so a single PopupWindow cannot be opened multiple times
2024-11-04 09:17:55 +01:00
Ryan Naddy
908580b951
Added rejected to textedit (#6662) 2024-10-31 16:23:50 +01:00
Olivier Goffart
446bb4a6bf
swrenderer: signed distance field: properly round the x and y glyph coordinate (#6687) 2024-10-30 18:12:52 +01:00
Arnold Loubriat
17207b0508 Make accessible-position-in-set zero-based 2024-10-30 15:54:01 +08:00
Arnold Loubriat
97219c21bf Add the accessible-size-of-set property 2024-10-30 15:54:01 +08:00
Arnold Loubriat
67166fcc2d Add the accessible-position-in-set property 2024-10-30 15:54:01 +08:00
Olivier Goffart
95f5685789
Bundle translations (#6661)
This currently doesn't have public API to enable it yet.

TODO:
 - Error handling in the compiler
 - Public API in the compiler configuration
 - Documentation
2024-10-29 15:07:15 +01:00
Milian Wolff
2f62c60e3c
Optimize resolve_expression to operate on a single scope vector (#6664)
Instead of cloning the vector on every iteration level, pass the
scope in and out of the visitation function and push/pop the element
there as needed. This way we can operate on a single vector that
gets moved around, which removes a few thousand memory allocations.
The speed impact is not measurable, as the code also triggers rowan
API that is much more allocation happy.

Still, I believe this patch is still merge-worthy as it also reduces
the code duplication a bit and is subjectively better, esp. from a
performance pov.
2024-10-29 11:46:04 +01:00
Olivier Goffart
6bb0e6038f
Merge the Callback and Function type
There is no need for two of these
This simplify some code

Amend efdecf0a13
2024-10-28 14:36:30 +01:00
Olivier Goffart
dff19c52da Fix assertion failed: lhs_lookup.is_local_to_component
Fixes #6632
2024-10-28 11:44:25 +01:00
Milian Wolff
89bc023819 Optimize: Filter/map rowan nodes instead of doing multiple lookups
Instead of doing potentially multiple calls in the chained calls,
each of which would allocate in rowan, we now only call the iterator
function once and then leverage `find_map`. This is arguably even
more readable and it removes ~300k allocations and speeds up parsing.

Before:
```
  Time (mean ± σ):     930.7 ms ±  15.1 ms    [User: 678.7 ms, System: 165.5 ms]
  Range (min … max):   906.4 ms … 956.3 ms    10 runs

    allocations: 2339130

```

After:
```
  Time (mean ± σ):     914.6 ms ±  22.7 ms    [User: 649.6 ms, System: 174.5 ms]
  Range (min … max):   874.8 ms … 946.3 ms    10 runs

    allocations: 2017915

```
2024-10-28 09:40:58 +01:00
Milian Wolff
79e1592b9f Intern some more common types
This is just for completeness, we "only" save ~13k allocations
with no measurable speed impact:

Before:
```
  Time (mean ± σ):      1.019 s ±  0.033 s    [User: 0.716 s, System: 0.203 s]
  Range (min … max):    0.957 s …  1.061 s    10 runs

        allocations:            2679001

```

After:
```
  Time (mean ± σ):      1.015 s ±  0.015 s    [User: 0.715 s, System: 0.201 s]
  Range (min … max):    0.997 s …  1.038 s    10 runs

        allocations:            2666889
```
2024-10-28 09:39:54 +01:00
Milian Wolff
df1dd3b6cf Use one central thread_local for builtin function types
Instead of occupying multiple TLS slots, introduce a single type
that stores all the builtin function types in members. Use a macro
to define this struct then, which allows us to use a nice DSL to
define these function types, reducing the boiler plate significantly.

The downside is that we no longer have the ability to easily share
semantically equivalent function types (e.g. for `Round`, `Ceil`
and `Floor` etc.). Doing so would require us to introdue a separate
name for these types, and then use external matching to map the
BuiltinFunctions to the reduced list of types. The performance impact
is minimal though, so this is not done to KISS.
2024-10-28 09:39:54 +01:00
Milian Wolff
6ff8abfb1a Move thread local types from typeregister into BUILTIN
This way we don't need a separate TLS slot for these two types.
2024-10-28 09:39:54 +01:00
Milian Wolff
6e9e66ea7d Refactor typeregister's BUILTIN_ENUMS => BUILTIN.enums
This will allow us to add more buildin types to this thread local
in follow-up patches, to reduce the number of thread local slots.
2024-10-28 09:39:54 +01:00
Milian Wolff
00dec34d34 Cache the reserved properties in a hash map for reserved_property()
The latter accumulates ~2.6% of all CPU cycles, Now, it only takes
1.3% by using the hash map here.
2024-10-28 09:39:54 +01:00
Milian Wolff
0abfb056a1 Also use Rc for langtype::Type::Array
This is rarely used, but using Rc here like elsewhere allows us to
elide a few unneccessary memory allocations when copying such types.
The speed impact is not measurable though. With heaptrack I see that
we get rid of the last ~7600 allocations in my benchmark when cloning
Type.
2024-10-28 09:39:54 +01:00
Milian Wolff
fd0eb01c55 Share common definitions for builtin function types
This way we can reuse a single reference counted type where possible.
2024-10-28 09:39:54 +01:00
Milian Wolff
0fc9f3574a Only allocate the BuiltinFunction::ty() return types once
These are known statically, so let's store them once in thread local
statics and return them from there.

Before:
```
  Time (mean ± σ):      1.034 s ±  0.026 s    [User: 0.733 s, System: 0.201 s]
  Range (min … max):    1.000 s …  1.078 s    10 runs

        allocations:            2917476
```

After:
```
  Time (mean ± σ):     996.9 ms ±  17.7 ms    [User: 708.9 ms, System: 202.9 ms]
  Range (min … max):   977.8 ms … 1033.1 ms    10 runs

        allocations:            2686677
```
2024-10-28 09:39:54 +01:00
Milian Wolff
69c68b22b2 Also wrap langtype::Type::Struct in an Rc
This makes copying such types much cheaper and will allow us to
intern common struct types in the future too. This further
drops the sample cost for langtype.rs from ~6.6% down to 4.0%.

We are now also able to share/intern common struct types.

Before:
```
  Time (mean ± σ):      1.073 s ±  0.021 s    [User: 0.759 s, System: 0.215 s]
  Range (min … max):    1.034 s …  1.105 s    10 runs

        allocations:            3074261
```

After:
```
  Time (mean ± σ):      1.034 s ±  0.026 s    [User: 0.733 s, System: 0.201 s]
  Range (min … max):    1.000 s …  1.078 s    10 runs

        allocations:            2917476
```
2024-10-28 09:39:54 +01:00
Milian Wolff
efdecf0a13 Wrap langtype::Type::{Callback,Function} data in an Rc
This allows us to cheaply copy the langtype::Type values which
contain such a type. The runtime impact is small and barely noticable
but a sampling profiler shows a clear reduction in samples pointing
at langtype.rs, roughly reducing that from ~8.6% inclusive cost
down to 6.6% inclusive cost.

Furthermore, this allows us to share/intern common types.

Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):      1.089 s ±  0.026 s    [User: 0.771 s, System: 0.216 s]
  Range (min … max):    1.046 s …  1.130 s    10 runs

        allocations:            3152149
```

After:
```
  Time (mean ± σ):      1.073 s ±  0.021 s    [User: 0.759 s, System: 0.215 s]
  Range (min … max):    1.034 s …  1.105 s    10 runs

        allocations:            3074261
```
2024-10-28 09:39:54 +01:00
Ryan Naddy
58efd5312b
Added rejected to TextInput (#6649) 2024-10-25 17:24:47 +02:00
Simon Hausmann
58be568c0c Fix order of exports when adding implicit export
Fixes #6651
2024-10-25 12:10:40 +02:00
DataTriny
2de3b9d455 Add the accessible-enabled property 2024-10-25 10:20:09 +02:00
FloVanGH
de67a6d201
checkbox: fixed min-height on all styles (#6647) 2024-10-24 16:59:18 +00:00
FloVanGH
b874adbc1c
material: fixed button touch area (#6645) 2024-10-24 16:25:59 +00:00
FloVanGH
69bb6462c3
checkbox: remove margins for fluent and cupertino (#6639) 2024-10-24 11:17:37 +00:00
Olivier Goffart
716b31e6c8 Use PopupClosePolicy enum from the type register instead of re-creating it 2024-10-24 13:11:11 +02:00
FloVanGH
14c7910d49
PopupWindow: added close-policy property (#6614)
* Update api/cpp/include/slint_window.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update docs/reference/src/language/builtins/elements.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/core/window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/eval.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/backends/qt/qt_window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/dynamic_item_tree.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/compiler/passes/materialize_fake_properties.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-24 09:27:39 +00:00
Olivier Goffart
9e2576bc5c swrenderer: Small fixup in distance field
- include the ' ' char that doesn't have a bounding box but need to be
   included for the advance_x
 - Fix an off by one in rendering where the last pixel was missing
2024-10-24 08:12:13 +02:00
Simon Hausmann
094a8ea718 Add missing par_iter() call
Amends 08c3f7a79a
2024-10-23 19:42:35 +02:00
Simon Hausmann
08c3f7a79a Fix order of glyphs in BitmapFont's glyphs when using SDFs
Initially the character map is ordered by glyph index. Maintain that order for glyph embedding, so that we can safely collect() the bitmaps. Just before creating the final BitmapFont data structure, sort by code point for fast lookups at run-time.
2024-10-23 19:36:51 +02:00
Simon Hausmann
0ebcbbecbe Speed up SDF generation
Using Rayon shaves off ~10% off of gallery.slint on my M3.
2024-10-23 09:12:30 +02:00
Olivier Goffart
d8ab4e4600 Signed DistanceField font rendering in swrenderer
Note that this is still disabled in the compiler with no way to enable
it with public API
2024-10-23 09:12:30 +02:00