Commit graph

1488 commits

Author SHA1 Message Date
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
Simon Hausmann
0e404c835c Fix warnings about unused fields in glyph embedding
Make them always used by centralizing the design metrics reading code.
2024-10-23 09:12:30 +02:00
Simon Hausmann
241eb35a2d Fix compiler warning about unused function 2024-10-23 09:12:30 +02:00
Simon Hausmann
557729320f Blind attempt at fixing the sdf sizes
Scale the bounding box to the desired target pixel size and use the full range of the bitmap we have for the distances.
2024-10-23 09:12:30 +02:00
Simon Hausmann
a1231f1826 Fix panic when emojis appear in the font
For now, generate empyt bitmap glyphs instead of causing a panic.
2024-10-23 09:12:30 +02:00
Simon Hausmann
7b94b58a63 Don't generate glyph bitmaps for characters not present in any font 2024-10-23 09:12:30 +02:00
Simon Hausmann
18f645f814 WIP: Being adding support for generating SDF glyphs 2024-10-23 09:12:30 +02:00
DataTriny
28b5a67583 Implement accessible-delegate-focus for the AccessKit backend 2024-10-22 12:54:00 +02:00
Olivier Goffart
6717e627a1 Fix panic when a layout constraint has an Expression::Invalid as binding
We can detect this case earlier

Fix #6590
2024-10-22 09:35:57 +02:00
Olivier Goffart
6c81d5069e Fix parsing of unfinished import statement
Fix #6588

Note for the test: parse error at the end of the file are actually
reported at offset 0. Use a trick to add more `^` at the beginning to
mean that.
(Offset 0 is actually offset 1 as the column starts at 1)
2024-10-22 09:35:46 +02:00
Olivier Goffart
4e50fbdb15 Fix panic making an alias to a private property
Fixes #6587
2024-10-22 09:35:31 +02:00
Olivier Goffart
ff53791ce7 Support for changed callback in global
Fixes #6599

ChangeLog: Support property changed callbacks in globals
2024-10-22 09:26:48 +02:00
FloVanGH
25607a9706
fluent: fixed foreground of switch (#6613)
* fluent: formatting
* fluent: fixed foreground color of Switch
2024-10-22 07:24:18 +00:00
Tobias Hunger
7f8da7bf28 compiler: Do not fail the embed_images pass with URLs
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.
2024-10-21 15:00:55 +02:00
Tobias Hunger
30ef606d04 slintpad: Fix loading of additinal slint files
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.
2024-10-21 15:00:55 +02:00
DataTriny
9ff905f924 Fix ListItem accessible tree representation 2024-10-21 07:13:07 +02:00
Olivier Goffart
b0a1ae5b80 Emit a warning when the case of the import file differ from the case of the file that was imported
Fixes #4265

Not easy to test since this is platform dependent
2024-10-18 21:54:53 +02:00
Milian Wolff
d3905b4c41 Use to_smolstr in a few more places to reduce allocation pressure
Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     626.1 ms ±  16.0 ms    [User: 548.6 ms, System: 72.6 ms]
  Range (min … max):   610.9 ms … 653.0 ms    10 runs

        allocations:            3395727
        temporary allocations:  466634
```

After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     622.6 ms ±  13.9 ms    [User: 556.6 ms, System: 63.5 ms]
  Range (min … max):   609.7 ms … 645.4 ms    10 runs

        allocations:            3371931
        temporary allocations:  459315
```
2024-10-17 18:04:58 +02:00
Milian Wolff
fe2679e3ac Use SmolStr for parts of pathutils to remove temporary allocations
Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     632.4 ms ±  21.5 ms    [User: 555.1 ms, System: 76.2 ms]
  Range (min … max):   609.9 ms … 658.9 ms    10 runs

        allocations:            3455770
        temporary allocations:  495587
```

After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     626.1 ms ±  16.0 ms    [User: 548.6 ms, System: 72.6 ms]
  Range (min … max):   610.9 ms … 653.0 ms    10 runs

        allocations:            3395727
        temporary allocations:  466634
```
2024-10-17 18:04:58 +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
Milian Wolff
08a3a6cc4a Use SmolStr for NamedReferenceInner
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
```
2024-10-17 18:04:58 +02:00
Olivier Goffart
13d44130d9
Fix compiler panic binding to property with syntax error (#6572)
Fixes #6519
2024-10-16 21:35:35 +02:00
Arnold Loubriat
19f09950c2 Changelog: Add accessible-selectable and accessible-selected properties 2024-10-16 15:38:46 +02:00
Simon Hausmann
9eef4c9a96 Use approx_eq() also for comparing float point numbers in the Rust generated code
The parent commit does that for C++, and the interpreter's `PartialEq` impl for `Value` uses `approx_eq`, too.
2024-10-15 13:49:40 +02:00
Simon Hausmann
a4a5eb6f0f Simplify unit/float detection
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2024-10-15 13:49:40 +02:00
Simon Hausmann
bb4c77ce04 C++: Fix compilation of floating point equality comparison
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.
2024-10-15 13:49:40 +02:00
Olivier Goffart
f0e02a3aa3 Fix panic with invalid code
Fix #6518
2024-10-15 11:42:28 +02:00
Olivier Goffart
4718d5b050
Fix invalid node generated while parsing invalid @tr (#6560)
Fixes #6512

The TrPlural must always have an expression otherwise it panics later.
(Also adjust the panic message when nodes are missing)
2024-10-15 10:23:56 +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
FloVanGH
f8f1d468a0
widgets: fix tabs overflow behaviour (#6517) 2024-10-11 12:15:27 +00:00
Tobias Hunger
3d3bf9f01b lsp: Pass invalidation of files on to live-preview 2024-10-10 09:31:11 +02:00
FloVanGH
b3f19e446e
LineEdit: fixes cursor draws out of bounds (#6382) 2024-10-09 14:31:42 +00:00
Renato Araujo Oliveira Filho
1e4de3fe0c
Implement ScrollBarPolicy property for ScrollView (#6442)
ChangeLog: ScrollView: added  vertical-bar-policy and horizontal-bar-policy

Fixes: #3552
Fixes: #5578
2024-10-08 17:02:17 +02:00
Qubi0-0
f6184ef858
Fix Generated C++ code issue with keywords (#6441)
Fixes #5613

ChangeLog: C++: generated code adds `_` to the end of identifier that would otherwise be keywords
2024-10-08 15:03:03 +02:00
Olivier Goffart
0c36499936
Rename common.slint -> about-slint.slint
The file used to contain many things but now it only contains AboutSlint
widget, so we can as well rename it accordingly
2024-10-08 14:52:03 +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