Commit graph

1507 commits

Author SHA1 Message Date
Simon Hausmann
644a57a29e Fix panic when starting the gallery
- When initializing the muda adapter, don't try to borrow from winit_window_or_none (how did this ever work?)
- When attempting to invoke the accesskit adapter, try to borrow winit_window_or_none. This may fail when updating the menu shadow tree (for which accessibility isn't handled by accesskit).

Amends 1c73144b09
2025-05-09 10:27:42 +02:00
Simon Hausmann
1c73144b09 Winit: Implement the "resume protocol"
In future versions of winit, it'll only be possible to create windows
when the active event loop signals availability. To upgrade to the latest
accesskit version as well as to run on iOS, we're going to implement support
for this earlier and stop using the deprecrated create_window() function
on the regular (not running) EventLoop.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-05-09 09:36:37 +02:00
Simon Hausmann
98a68b8a0c winit: Minor cleanup
Inline the code to create the event loop to the single call site.
2025-05-09 09:36:37 +02:00
Simon Hausmann
f4cab86d43 qt backend: Fix mouse up not being sent when pressing multiple buttons
Detect if a button is still pressed before deciding that no button is down.

Fixes #8335
2025-05-05 12:03:05 +02:00
wuwbobo2021
7cf5fc2bde
Android: use android-build dev dependency; small fixes (#8334) 2025-05-05 11:47:54 +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
4d41be428e CI: Fix build with unstable-wgpu-24 and renderer-skia feature flags 2025-05-01 21:11:19 +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
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
33581182ef backend-selector: Add the ability to configure WGPU
The `require_wgpu_24` function accepts either a fully setup WGPU, or one
can configure individual aspects such as features/limits.

The wgpu_texture example uses this to add push constants to the required
features and thus eliminates the need for uniform buffers.
2025-04-29 17:46:57 +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
8261e405d3 doc: Fix markdown syntax 2025-04-29 16:52:14 +02:00
npwoods
80cde76e2a
Qt backend: Created an accessor for the Qt backend to access a window's QWidget
This is a hook for the Qt backend that provides the ability to access the `QWidget` for a window, similar to how the `winit` back end supports accessing the `winit` `Window` object
2025-04-28 16:47:03 +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
Simon Hausmann
6595aee73c
Replace use of Rc<winit:🪟:Window> with Arc (#8257)
In preparation for wgpu usage, where the wgpu API requires the window
handle to be send, i.e. Arc<dyn HasWindowHandle>.
2025-04-24 13:28:51 +02:00
Simon Hausmann
b098bccc32 Propagate default font properties into PopupWindow 2025-04-24 09:18:45 +02:00
Simon Hausmann
b1f92f03d9 Add test case for font size propagation
...through a component factory, as we use that in the live-preview.
2025-04-24 09:18:45 +02:00
Simon Hausmann
eb825f2e95 Support default-font-* properties in Live-Preview
... by changing the resolution for the `WindowItem` to traverse the
item tree from the current item, instead of going to the window.

This doesn't quite fix #4298 because `rem` resolution is still missing.
That requires the built-in default font size function to be fixed as
well, which is non-trivial.

cc #4298
2025-04-24 09:18:45 +02:00
Simon Hausmann
8761eaadeb
Move Palette.style-name to internal protected StyleMetrics.style-name (#8200)
This is only exposed when internal types are exposed (such as in the lsp).

The plan is to make this public under a new name/global after the release.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-19 10:20:52 +02:00
Nigel Breslaw
62c5ff943e
Palette.style_name was missing from the Rust struct (#8157) 2025-04-15 16:41:10 +03:00
U-ALDEBERAN\Nate
a80e261d1d Resurrected create_winit_window
With a previous PR, I added a hook to enable the creation of a winit window, which necessitated accessing the winit event loop (https://github.com/slint-ui/slint/pull/7227).  This hook was removed in `cd29bdd367` because the Slint event loop was moved to `SharedBackendData`.

I'm very open to the possibility that this is not the correct change, perhaps due to one or more of the following
- Making `shared_backend_data` public
- The `unwrap()` calls
- The possibility that exposing `with_event_loop()` may be a better solution
2025-04-15 11:52:31 +02:00
Olivier Goffart
ce904dd518 muda: Implement the enabled flag
Follow-up of https://github.com/slint-ui/slint/pull/8145
2025-04-15 08:54:10 +02:00
Olivier Goffart
25a037437e janitor: Fix compilation warning about unused import
when compiling winit backend with software renderer only
2025-04-11 18:48:33 +02:00
Simon Hausmann
3116ccf6d5
winit: separate menubar vbox from muda adapter (#8109)
The latter's life time is tied to the winit window and should live in WinitWindowOrNone.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-11 13:02:34 +02:00
Olivier Goffart
409413b835 Qt: re-arm the timer after callback from invoke_from_event_loop
This fixes the preview window not showing with the Qt backend,
because the preview uses a timer to show the window, but we would not
start the Qt timer and so the window was never shown
2025-04-11 12:41:10 +02:00
Simon Hausmann
cd29bdd367 Winit: remove maybe_loop_instance thread local
In the future, the plain winit::event_loop::EventLoop won't be usable for window creation anymore. There are two places where we need it:

1. From places where we also have access to the shared backend data.
2. From the top-level create_winit_window() function.

The latter we have to eliminate in the future, so might as well do it now and clean up to have one thread local less.
2025-04-11 09:37:03 +02:00
Simon Hausmann
fe56fdd5e4 Minor cleanup
Reduce access to CURRENT_WINDOW_TARGET thread-local
(via renamed with_event_loop function) from the renderer adapters.
2025-04-11 09:37:03 +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
Simon Hausmann
390c56a30e Winit: Clean up EventLoopInterface
In preparation for removing it altogether, remove the call to winit::platform::wayland::EventLoopExtWayland::is_wayland() with a matches!(winit_window.window_handle(), WindowHandle::Wayland(...))
2025-04-09 08:53:07 +02:00
Olivier Goffart
d2fb69c182 winit backend: remove the GLOBAL_PROXY
We have a proxy in the backend, use it
2025-04-09 08:50:39 +02:00
Simon Hausmann
42e65da8e2 Minor cleanup in winit backend
Replace thread-local window registry with the pattern we recommend: reference counted data shared between the backend and the window adapters.
2025-04-09 08:50:39 +02:00
Simon Hausmann
ac256d61d8 winit: replace special private function to spawn event loop with public API in the winit backend builder
This means the event loop spawning goes through the backend, which will permit for state from the Backend struct to be available when spinning the event loop even when spawning it merely.
2025-04-09 08:50:39 +02:00
Simon Hausmann
6aa4c691f0 winit: Simplify default canvas element handling
The winit backend defaults to locating a canvas element with the id "canvas". After the parent commit, this id can't be overridden by the API, so we can remove the function parameters.

(The parent commit implements the override via an attribute hook)
2025-04-09 08:50:39 +02:00
Simon Hausmann
4e65998016 Clean up wasm-interpreter / winit interface
Use the window attributes hook instead of a private function in the winit backend.
2025-04-09 08:50:39 +02:00
Olivier Goffart
23aa4ed8c6 Fixup menu separator with muda 2025-04-03 15:49:35 +02:00
Olivier Goffart
e5289af154 Introduce MenuSeparator
Fixes #7790
2025-04-02 11:50:45 +02:00
Simon Hausmann
3797ed79bc Fix crash when opening ComboBox
Don't do partial tree rebuilds if we know that a full rebuild is pending and that the current focus node may thus not be node mapped yet.

Amends 5ff5c0464c

Fixes #7854
2025-04-02 11:49:54 +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
Simon Hausmann
072bff8c42
wasm: Fix some shortcuts on macOS (such as cmd+a) (#7908)
The core library expects command to be mapped to control, and control to meta, for the shortcut detection. This needs to be done separately for the wasm input handling.

This helps with #7477 by fixing cmd+a. Unfortunately, the "copy" and "paste" events, while intercepted by Safari, aren't somehow delivered to our canvas element.
2025-03-22 11:53:49 +01:00
szecket
ed47d1e70a
matching the math for skia and femtovg renders for radial gradient (#7899) 2025-03-21 10:53:04 -04:00
Arnold Loubriat
6aa7744868 Expose more kinds of text edit widgets to AccessKit 2025-03-17 14:27:08 +01:00
Simon Hausmann
d79689984e Upgrade muda 2025-02-25 16:08:48 +01:00
Olivier Goffart
7390df1b47
ContextMenuArea: Intercept long press on Android 2025-02-24 18:27:25 +01:00
Simon Hausmann
b4b1d329b6 Fix build on macOS
The tracker is optional for when there's no app supplied menu bar.
2025-02-24 14:12:51 +01:00
Olivier Goffart
f30c9ad2a0 Add a property tracker for the Muda Menu 2025-02-24 14:12:51 +01:00
Olivier Goffart
97fdda5c09 Qt: Fix processing of the mouse release event in popup menu
We really need to dispatch the release event otherwise the wrong
item keeps the drag and this breaks the behavior.

This is not perfect yet as if the release is done on the wrong popup,
then we'll still not get the release event.

We should probably remove the grab when a popup open. But that's
slightly more complicated
2025-02-24 12:02:38 +01:00
Simon Hausmann
164d5dfca7 Fix panic with accesskit when using nested context menus
Sub-menus will be declared as parents of the same item, so don't just match for the first but all popups.
2025-02-24 08:59:21 +00: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