Commit graph

2336 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
Simon Hausmann
a98d4709be Move printer demo and energy-monitor into new top-level demos/ folder
These are showing off use-cases for Slint, but they're not examples showing individual Slint features.

Also removed the old printerdemo while at it.
2024-10-25 12:09:32 +02:00
DataTriny
2de3b9d455 Add the accessible-enabled property 2024-10-25 10:20:09 +02:00
FloVanGH
181739d624
node: add tests for color set (#6646) 2024-10-24 17:45:27 +00: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
Ian Hattendorf
ac9b85049a Add PlatformBuilder API to allow selecting OpenGL API
Right now this just allows selecting between OpenGL and OpenGL ES.
2024-10-23 11:13:49 +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
40faf0e1c4 Fix CMake package version compatibility checking
We're compatible across minor versions, only the major version change
would mean incompatibility. This way for example find_package(Slint 1.6.0)
will work with newer versions and makes it a minimum version specifier.
2024-10-16 16:02:43 +02:00
Arnold Loubriat
19f09950c2 Changelog: Add accessible-selectable and accessible-selected properties 2024-10-16 15:38:46 +02:00
Tobias Hunger
df4f9b38ee femtovg: Fix warning about deprecated web_sys::set_fill_style
Use set_fill_style_str insterad, it avoids constructing a JSValue
from a str.
2024-10-16 13:25:00 +02:00
Simon Hausmann
11128809fb Fix compilation on ARM host systems
The file was renamed before the release. However the install is useless, since the api_headers global covers it already.
2024-10-15 20:08:53 +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
feee9aa056 Clean up file loader callback
This will have to be async in the future in its entirety, not just smaller parts.
2024-10-14 14:31:52 +02:00
FloVanGH
fe596179da
node: added fileloader to LoadData. (#6530) 2024-10-14 07:33:42 +02:00
FloVanGH
300c66fef3
node: added getting started (bun) to cover.md (#6516)
* Update api/node/cover.md

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

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-11 06:12:50 +00:00
FloVanGH
ccf5f04087
node: added initTranslations function (#6504) 2024-10-10 16:37:33 +02:00
FloVanGH
f01ac8fc39
node: added url support to loadFile (#6507) 2024-10-10 11:43:32 +00:00
Florian Blasius
610a23b487 removed slint tags from cover.md 2024-10-10 07:32:24 +02:00
Florian Blasius
99702779a6 node: added structs and enums doc to cover.md 2024-10-10 07:13:42 +02:00
FloVanGH
499a522f99
node: better ergonomics for structs and enums (#6500) 2024-10-10 04:12:32 +00:00
Nigel Breslaw
6beb0c3f02
chore: Update npm dependencies
Update biome
Update typescript
Update esbuild
2024-10-08 13:13:49 +03: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
Enyium
b3c9dfc6dc
Docs: Clarify that components' invoke_...() calls through synchronously. 2024-10-07 10:11:57 +02:00
Olivier Goffart
df88ac422d Update documentation of slint_buid::compile_with_output
CC: #6340
2024-10-04 15:26:20 +02:00
Willem Vanhulle
595221f928
Remove dependency on Cargo variables in a helper function for the Slint to Rust compiler (#6430)
Co-authored-by: Willem Vanhulle <willemvanhulle@gmail.com>
2024-10-04 15:18:37 +02:00
Olivier Goffart
1c3eb46752 Fixup dead links to the old tutorial 2024-10-03 10:15:52 +02:00
ArcticLampyrid
132e09130e feat(cpp): evaluate generator expression in the context of target
Link: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:TARGET_GENEX_EVAL
2024-10-02 11:41:09 +02:00
ArcticLampyrid
c145345827 feat(cpp): support generator expression for SLINT_EMBED_RESOURCES & SLINT_SCALE_FACTOR 2024-10-02 11:41:09 +02:00
FloVanGH
9d3a8c9dd2
node: added support for enums (#6421) 2024-10-01 16:49:39 +02:00
U. Bruhin
40811193aa
C++: Add size() method to SharedString (#6417)
The length is an important property of a string and should be available
as a getter. The new size() method is consistent with std::string.

ChangeLog: [C++] Added `SharedString::size()`
2024-10-01 14:51:56 +02:00
Simon Hausmann
51a241edd6
Node.js: If a JS callback throws an exception, report the exception t… (#6416)
As a drive-by, this introduces a macro that allows for explicit logging to console.error (which goes to stderr). This is something we should gradually start using, as it allows for capturing on the Node.js side (by the user or our tests).
2024-10-01 13:57:50 +02:00
Simon Hausmann
fdec55cd47 Node.js: Fix tense in error messages produced when exceptions are throw
At this point the exception _was_ thrown.
2024-10-01 13:28:48 +02:00
Simon Hausmann
5c612cda61 Fix biome invocations after re-organizing the files
After commit 25ae55b5dd, ignore dist/ as
well as the .cjs file that `npm run format` would complain about.
2024-10-01 13:27:00 +02:00
Simon Hausmann
7db5024c52
Generate bindings of Image::to_rgb8/to_rgba8/to_rgba8_premultiplied f… (#6405)
ChangeLog: [C++] Add `Image::to_rgb8/to_rgba8/to_rgba8_premultiplied` pixel buffer accessors.

Fixes #6399
2024-10-01 10:55:11 +02:00
FloVanGH
4b880a7b49
node: less unwraps (#6388)
* Update api/node/rust/interpreter/value.rs

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

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-01 08:47:53 +00:00
FloVanGH
25ae55b5dd
Improve source structure in the node api (#6164)
* Update api/node/typescript/models.ts

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

* Code review feedback
---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-09-30 08:49:35 +00:00
Olivier Goffart
ad1614bb10 Rust: attempt to gracefully handle situation where the property depends on a binding from a destroyed component
Prospective fix for #6262
2024-09-27 16:08:01 +02:00
Simon Hausmann
43d3cdb6c4 Fix esp-idf nightly builds
After commit 3139171d77, the way of using the nightly is to omit the version.
We just need to add it again for the release.
2024-09-26 10:12:10 +02:00
Olivier Goffart
fc324a4db2 Update MSRV to 1.77 2024-09-26 09:14:58 +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
bb28018c50 doc: fix esp-idf hello world list numbering 2024-09-23 18:10:05 +02:00
Simon Hausmann
fb7472fff8 doc: Remove rust toolchain from esp-idf steps
This is slightly confusing as it's not needed anymore.
2024-09-23 18:08:08 +02:00
Simon Hausmann
b0db6d78fd Prospective fix for downloadling slint-compiler for Slint releases
The GitHub release name has the git tag name, so a v prefix.
2024-09-23 17:23:02 +02:00
Simon Hausmann
3139171d77 Sync FindSlint.cmake
This pulls in
7e6a6a3e2d
to fix build against the release.
2024-09-23 17:23:02 +02:00
Olivier Goffart
ea9f5d58a5 Update version number in docs and readme 2024-09-23 11:14:22 +02:00
Simon Hausmann
0dcbaff886 Generic stm32 docs: Merge the app-window.slint addition to CMakeLists into the common CMakeLists.txt edit
... and introduce the .slint file first then, so that its existence is known when reading the CMakeLists.txt snippet.
2024-09-20 10:30:25 +02:00
Simon Hausmann
bb7355878f Improve comment about SLINT_EMBED_RESOURCES target property use 2024-09-20 10:30:25 +02:00
Simon Hausmann
9534aaa155 stm32 docs: Set SLINT_EMBED_RESOURCES target property instead of DEFAULT_SLINT_EMBED_RESOURCES as global variable 2024-09-20 10:30:25 +02:00