Commit graph

2651 commits

Author SHA1 Message Date
Olivier Goffart
7104c6e88e
Rudimentary key navigation of the popup menu (#7556)
Closing the menus is still not implemented
2025-02-07 10:01:40 +01:00
Yuri Astrakhan
05f4fc0cde Auto-fixed clippy::needless_return
`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.

See https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::needless_return

cargo fmt --all
```
2025-02-07 09:46:49 +01:00
Yuri Astrakhan
9621cae218 Auto-fixed clippy::needless_lifetimes
`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.

See https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::needless_lifetimes

cargo fmt --all
```
2025-02-07 09:20:49 +01:00
Yuri Astrakhan
6324b35e94 Auto-fixed clippy::needless_borrow
`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.

See https://rust-lang.github.io/rust-clippy/master/index.html#/needless_borrow

```
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::needless_borrow

cargo fmt --all
```
2025-02-07 09:02:45 +01:00
Yuri Astrakhan
bcb2953f00 Auto-fixed clippy::unnecessary_map_or
This is a hacky approach, but does help a lot with the tedious fixes.

See https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_map_or

```
__CARGO_FIX_YOLO=1 cargo clippy --fix  --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::unnecessary_map_or

cargo fmt --all
```
2025-02-07 09:02:31 +01:00
Yuri Astrakhan
4ae2627ade A few more format arg inlining
Used these commands and some manual searching

```
cargo clippy --fix  --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::uninlined_format_args
cargo clippy --all-targets -- -A clippy::all -W clippy::uninlined_format_args
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2025-02-07 06:43:19 +01:00
Bedis Nbiba
417eaeb38a
fix(node): prevent 100% CPU usage on Wayland by enforcing minimum event timeout (#7550) 2025-02-06 17:00:50 +01:00
Yuri Astrakhan
61de4d56b0 Fix all format arg inlining
Ran this command:

```shell
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2025-02-06 10:16:20 +01:00
Tobias Hunger
b5520ef370 interpreter: Expose visibility of exported components 2025-02-05 12:56:32 +01:00
Arnold Loubriat
358e42a8d5 Add the accessible-action-expand action 2025-02-03 20:32:45 +01:00
Arnold Loubriat
f30f953ffd Add the accessible-expanded property 2025-02-03 20:32:45 +01:00
Arnold Loubriat
53fd7b12e4 Add the accessible-expandable property 2025-02-03 20:32:45 +01:00
Simon Hausmann
ac7c2dd791 Enable partial rendering with Skia's software renderer by default 2025-01-30 22:44:57 +01:00
Simon Hausmann
a4ff057ad4 Fix incorrect bounding text for Text(Input) when element is bigger than intrinsic text size
The Text element may be given a size that exceeds its intrinsic size, however we returned the intrinsic size. The broke partial rendering when for example text was aligned within the bigger geometry:

    Text {
        text: "Ok";
        horizontal-alignment: right;
        x: 0px;
        y: 0px;
        width: 100px;
        height: 50px;
    }

This would return a bounding rect with an origin of (0, 0) and a width of maybe 20px, while the text is being rendered centered in the 100px wide geometry. That in turn meant that if that area with the text was marked as dirty, due to some overlap or for example linuxkms mouse cursor, then the Text element wasn't re-rendered because the bounding rect doesn't intersect with the clip.

One option would be to teach the renderers text_size() about alignment, but it turns out that this is the only place where this is needed. So instead, fix this by using bounding_rect() to cover only the case it was originally introduced for - text exceeding the geometry - and otherwise return the geometry.
2025-01-30 21:44:38 +01:00
Olivier Goffart
094ff8f56b Refrersh the menubar when one of the property get changed
Install a PropertyTracker to update the shadow tree if something changes
2025-01-30 17:43:33 +01:00
Simon Hausmann
58a14fe28d Add a test that the box shadow's bounding rect is property tracked by the partial renderer 2025-01-30 10:55:28 +01:00
Simon Hausmann
a51369465c Add a test that verifies that moving a touch area doesn't cause the touch area's area to be redrawn 2025-01-30 10:55:28 +01:00
Olivier Goffart
010126992e MenuItem with for and if 2025-01-30 10:08:22 +01:00
Olivier Goffart
e75415554a Create a menus module in i-slint-corelib 2025-01-30 10:08:22 +01:00
Simon Hausmann
05e70e8c8b Fix support for Window.background tracking with the partial renderer
Fixes #5219
2025-01-29 16:32:42 +01:00
Simon Hausmann
67940f8ff9 Fix cross-compilation of slint-compiler in Yocto environments (or when CC, etc. are set)
Don't enable jemalloc when cross-compiling.

Fixes #7463
2025-01-29 09:05:56 +01:00
Olivier Goffart
62e9111842 Fix C++ slint_register_font_from_* functions regarding to the error string
The C++ code already instentiate a `SharedString` on the stack, we are
not supposed to ptr::write into it.
Lickyly this didn't have any effect because the default constructed
string can be leaked without problem, but better be correct.

Also aboud temporary String allocation
2025-01-27 19:22:00 +01:00
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Simon Hausmann
3cb4bd174d Add support for triple buffered partial rendering with Skia 2025-01-23 18:27:01 +01:00
Simon Hausmann
3d90434067 Add support for rotation to the partial renderer
The use of the rotation-* properties creates a hidden Rotate item,
which applyes a rotation to the renderer. This rotation (and translation
by rotation origin) is now also applied when the partial renderer
computes the dirty regions.
2025-01-23 09:17:54 +01:00
Olivier Goffart
3d664578dd Fix ListView implementation in C++
Regressed in commit 4da79ac69a
2025-01-22 19:52:02 +01:00
Olivier Goffart
7e37f19e2c ListView: fix continuous redraw with fluent style
Because we set the viewport-width several time to different value during
the layouting of the ListView, it will cause this property to always be
dirty. In particular, this causes permanent restart of the fluent's
scrollbar animation on the size of the handle, causing continous
repaints.
2025-01-21 14:31:55 +01:00
Olivier Goffart
4da79ac69a Fix layouting of huge ListView with millions of items
The problem is that the precision of f32 for coordinate wouldn't be
accurate enough with such big viewport to put the elements so that they
are next to eachother.
So put the elements relative to the Flickable instead of relative to the
created moving viewport Rectangle.

Fixes #3700

Note that the ListView still use f32 for the scrollbar value, meaning
that at some point, the wheel stops working as the wheel increment is
smaller than the f32 increment, and scrolling becomes somehow fuzzy.
But this only happens after one more billions pixels now, so one can
have more than 50 millions of elements without much problems
2025-01-20 17:41:38 +01:00
Olivier Goffart
90f5621985 Fix string formatting of big integer
Don't lower the precision to f32 for big enough numbers
2025-01-20 15:55:44 +01:00
Simon Hausmann
62d9f8b13f Minor dependency cleanup
- static_assertions is only needed with ffi.
- i-slint-core-macro is not needed in the build crate.
2025-01-16 14:45:05 +01:00
Nigel Breslaw
741627f1b0
Fix dependabot unable to update Typedoc (#7376) 2025-01-15 16:24:28 +02:00
Simon Hausmann
8e6d2c80e5 Use unicode-segmentation from the Cargo workspace 2025-01-14 19:31:34 +01:00
Tasuku Suzuki
68b9dfc247 String: Add .is-empty and .character-count properties
Introduce two new properties for string in .slint:
- .is-empty: Checks if a string is empty.
- .character-count: Retrieves the number of grapheme clusters
  https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries

These additions enhance functionality and improve convenience when working with string properties.
2025-01-14 19:29:05 +01:00
Olivier Goffart
8a5df27469
Update to Image 0.25 (#7365)
Added image-default-formats with all the format supported by image by
default, and enable that feature by default.
Also put that feature in compat-1-2 for compatibility with user that
have used image 0.24 with enabled features.
Make a new compat-1-10 feature that does not enable default format by
default

ChangeLog: upgraded image crate to 0.25, added a new cargo feature
to enable all image formats. (that feature is enabled by default with
compat-1-2, added compat-1-10 to disable it

Fixes https://github.com/slint-ui/slint/issues/7251
2025-01-14 16:31:05 +01:00
Simon Hausmann
dacfea7466 Include rust-module.d.cts in the biome linter output
Some of this is also part of our public API, so let's also check it
(and avoid API clashes like `arguments`).
2025-01-14 14:49:02 +01:00
Simon Hausmann
87b893add7 Node.js: Upgrade TypeScript
Sadly, ts-node doesn't work with the newer typescript anymore. As per https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md , this patch changes
from the second to the first method: build the tests first, then run them with ava.

This requires a few small changes in the tests, as import.meta.url now returns the transpiled .mjs file in the build dir, instead of the source dir, as expected by the test.
2025-01-14 14:49:02 +01:00
Simon Hausmann
22e7c4d4a6 Fix Node.js docs missing Diagnostic, DiagnosticLevel, RgbaColor, and Brush
typedoc uses typescript under the hood. An import from "rust-module.cjs" won't look for .d.ts but .d.cts as per https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution .

This way the existing warning from the TS compiler that rust-module.cjs was imported as any goes away and actual type checking is being done. The rest of this commit fixes those type errors, including missing type casts to make ts-node's transpiler not thrown an exception.
2025-01-14 14:49:02 +01:00
Olivier Goffart
5c6ddfdda9 C++ tests: disable false positive warning on more recent version of GCC
CC #7358

(Test for version 14 because that is what i have installed and haven't
tested any other versions)
2025-01-14 09:54:51 +01:00
Simon Hausmann
43db58aaf5 Bump MSRV to 1.82
Fixes #7254
2025-01-14 08:33:21 +01:00
ogoffart
c83af3ca5c Bump version number to 1.10.0 2025-01-13 13:38:41 +00:00
Simon Hausmann
6e81f90d33 esp-idf: Remove unecessary template parameter from EspWindowAdapter 2025-01-13 14:27:37 +01:00
Simon Hausmann
f5909807ea esp-idf: Rename SlintPlatformConfiguration's color_swap to byte_swap and deprecate color_swap_16 2025-01-13 14:27:37 +01:00
Simon Hausmann
287bd922a4 Apply Olivier's suggestion for the byte_swap field's behaviour for RGB8 displays. 2025-01-13 14:27:37 +01:00
Simon Hausmann
1f205dffe7 esp-idf: Document SlintPlatformConfiguration's PixelType parameter 2025-01-13 14:27:37 +01:00
Simon Hausmann
5ef3fb8b26 esp-idf: Implement color_swap for RGB8 pixels
Use Olivier's great trick to rename color_swap_16 to color_swap via
union.
2025-01-13 14:27:37 +01:00
Simon Hausmann
8903124239 esp-idf: Add support for RGB8 rendering
... by making SlintPlatformConfiguration a template and using a deduction guide to make it source compatible (Olivier's magic :)
2025-01-13 14:27:37 +01:00
Olivier Goffart
87d86ae7d2 Only re-create elements if the model actually changed
Being dirty is not enough

Fixes #7245

ChangeLog: Elements of a `for` now only get re-created if the model is
changed, not if it is only dirty
2025-01-13 12:11:21 +01:00
Tasuku Suzuki
346d1c2df3 Fix typos
Ran `typos .` and fixed all typos that do make sense.
https://crates.io/crates/typos
2025-01-13 08:35:20 +01:00
Olivier Goffart
3e94bd2167 Janitor: Remove trailing whitespaces from all files
`git grep -I -l -O'sed -i "s/[[:space:]]*$//"' -e ''`
2025-01-10 13:23:22 +01:00
Olivier Goffart
cfbcf0b1d7
Introduce Window::try_dispatch_event (#7313)
That is the same as Window::dispatch_event, but it reports an error
instead of panicking
2025-01-09 19:39:38 +01:00