Commit graph

436 commits

Author SHA1 Message Date
Olivier Goffart
73d6095535 winit: Rename some function and add docs cross reference
CC https://github.com/slint-ui/slint/issues/8631#issuecomment-2957986384
2025-06-10 16:21:58 +02:00
Olivier Goffart
c0cac46009 Add --generate-link-to-definition in the docs of all our published crate
This is a nice nightly rustdoc feature and we should make use of it
2025-06-06 21:47:36 +02:00
Olivier Goffart
55eaa3c1e2 docs: document relative path in the translation bundle dir 2025-06-06 12:30:45 +02:00
Avery Townsend
8c4ccabf7d
Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close #8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.

In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.

Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.

close #8387

ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope.  Pass an `FocusReason` enum to the FocusScope callbacks
2025-06-04 09:51:26 +02:00
Avery Townsend
c41d4a4df3
Add FocusEventReason to FocusEvent and add a select all on keyboard focus for TextInput (#8523)
Closes #5992

Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.

Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close #5992.

ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
2025-05-27 07:56:13 +02:00
MusicalNinjaDad
7afd5dfc4a
Make CompilerConfiguration Clone (#8492)
Some checks are pending
CI / mcu-embassy (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
2025-05-21 18:05:29 +02:00
MusicalNinjaDad
2a81357c03
slint-build: Add option to create CompilerConfiguration with_debug_info (#8489)
Some checks are pending
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
2025-05-21 08:17:09 +02:00
Olivier Goffart
6d8ea50f40 Janitor: fix missing period in docs
As reported in #8448
2025-05-19 15:53:53 +02:00
Giona Imperatori
14483a6e32
feat: raise compiler error if musl is used (#8450) 2025-05-19 13:10:34 +02:00
Simon Hausmann
f983cf0b19 Add Platform.os as well as a rudimentary test 2025-05-06 13:06:27 +02:00
Olivier Goffart
6e316a9929 docs: Fix missing paragraphs in the slint crate docs
Regression in e1a6cbf8b4
2025-05-05 12:56:32 +02:00
Simon Hausmann
0002df2520
slint crate: Expose parts of the winit backend's previously private API (#8315)
Similar to the wgpu access, the `unstable-winit-030` feature exposes a
`slint::winit_030` module, which in turn re-exports `winit` but also
provides access to the `WinitWindowAccessor` trait. The
`BackendSelector` is extended to provide a way to hook into window
attribute creation as well as providing a custom event loop builder,
similar to what `i_slint_backend_winit::BackendBuilder` provides.
2025-05-02 09:21:13 +02:00
Simon Hausmann
0151ac4902 slint crate: Replace early return with no_run tag on code fence 2025-04-30 18:20:16 +02:00
Simon Hausmann
2f2478d1ea WGPU: Clean up public API
- Create a `slint::wgpu_24` module
- Re-export `wgpu` in it
- Place the WGPU config types used by the `BackendSelector::require_wgpu_24` function in it, and remove the 24 infix.

As an upside, this also adds the feature guard to the docs at least for the `wgpu_24` module.
2025-04-30 15:54:06 +02:00
ogoffart
e0099ea500 Bump version number to 1.12.0 2025-04-30 13:27:50 +00:00
Simon Hausmann
302926edfa
Skia: Improve multi-window rendering resource consumption (#8304)
Share Vulkan instance as well as Metal device and command queue across windows.
2025-04-29 18:58:09 +02:00
Simon Hausmann
da5e7d5b22 WGPU: Add support for using WGPU textures in Slint
This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.

The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-29 17:46:57 +02:00
Simon Hausmann
a50b8f8793
FemtoVG: Add support for WGPU based rendering (#8268)
Enable via the `renderer-femtovg-wgpu` feature flag.

cc #171
2025-04-25 14:37:32 +02:00
Simon Hausmann
98dc4a8657 FemtoVG: Abstract the rest of the FemtoVGRenderer type to be independent from OpenGL
The main visible external change is that FemtoVGRenderer is now a generic type, but in the public Slint API the type alias that uses the OpenGL backend is re-exported under the old name. This looks a little different in rustdoc
but appears to be source compatible.
2025-04-25 10:08:38 +02:00
Olivier Goffart
78a3757b7f
Remormat all the toml file again to fix npm upload
Commit cd6f2e2 reformated the .toml, but the 80 char width column is
judged too small to be practical

Add a .taplo.toml file

Also do not split feature array
2025-04-09 15:06:00 +02:00
Tobias Hunger
cd6f2e2cf2 ci: Format toml files
... using taplo with default settings

I tried this with 4 spaces indentation, but the patch is almost as
big as this one, so I went with default settings instead as that
is just easier:-)
2025-04-02 11:03:41 +02:00
Olivier Goffart
6f4f5aeefa Replace no_mangle with unsafe(no_mangle) in example and docs
We can't just do `s/#\[no_mangle]/#[unsafe(no_mangle)]/g`
because the version of cbingen we use doesn't understand the unsafe
attribute yet.

Part of #7998
2025-03-31 17:35:22 +02:00
crai0
4bb7412460 ChangeLog: Add float.to-fixed and float.to-precision
Add two new float to string conversion methods that mimic
JavaScript's Number.toFixed() and Number.toPrecision().

They are implemented as no_mangle functions similar to the already
existing float to shared string conversion.

Closes #5822
2025-03-18 11:44:28 +01:00
ogoffart
178cf21c2e Bump version number to 1.11.0 2025-03-18 09:48:22 +00:00
Olivier Goffart
c8780ef875 Update version in docs 2025-02-28 08:19:35 +01:00
Simon Hausmann
e1a6cbf8b4 Add links to the slint-build crate 2025-02-26 16:46:36 +01:00
Olivier Goffart
c3e32c1665
Don't enable image-default-formats by default, remove compat-1-10 feature
We decided that the compatibility with people having enabled the extra
format in image 0.24 [1] is not worth it compared to the extra compilation
time most people gets by default when they don't need this feature.
(Which is less than 10% slower when the feature is enabled)

Since then there is no need for compat-1-10, remove it

[1] by depending directly on image 0.24 in their Cargo.toml and enabling
the features, which will not work with Slint 1.10 that now use image 0.25
2025-02-22 11:15:18 +01:00
Olivier Goffart
1e814c9bdc
Stabilize the sdf-fonts feature
Enable the SDF feature by default in our compiler binaries

(Still disabled by default for other users because it takes up compile
time for something they probably don't need)
2025-02-19 21:24:53 +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
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
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
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
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
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
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
ogoffart
c83af3ca5c Bump version number to 1.10.0 2025-01-13 13:38:41 +00: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
Jocelyn Turcotte
8ea5662242 Fix the hello world slint macro example
The slint VS Code plugin is otherwise reporting the warning:
Exported component 'HelloWorld' doesn't inherit Window. This is deprecated
2025-01-09 11:09:53 +01:00