Commit graph

85 commits

Author SHA1 Message Date
Olivier Goffart
7b4d2fd3d3 Renames after the API review
CC #8631
2025-06-06 12:31:50 +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
Arnold Loubriat
5a9dc2152b Set size of set on AccessKit container nodes 2025-05-09 15:23:31 +02:00
Simon Hausmann
6aafdeefad Update to accesskit 0.18 and accesskit_winit 0.26
Fixes #8148
2025-05-09 13:07:50 +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
b098bccc32 Propagate default font properties into PopupWindow 2025-04-24 09:18: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
Arnold Loubriat
6aa7744868 Expose more kinds of text edit widgets to AccessKit 2025-03-17 14:27:08 +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
Arnold Loubriat
cc91de2d38 Add the accessible-read-only property 2025-02-19 09:16:41 +01:00
Arnold Loubriat
90c337f1d1
Add AccessibleRole::Image and use it in the AboutSlint widget (#7593)
* Add `AccessibleRole::Image`

* Improve accessibility of the `AboutSlint` widget

* Filter out some images from the accessibility tree
2025-02-18 09:43:53 +01:00
Simon Hausmann
8372cd6412
Convey clipping of children to accesskit (#7587)
and while at it, move is_clipping_item() that casts a function of the ItemVTable.

Fixes #2341
Fixes #7382
2025-02-10 13:42:10 +01:00
Arnold Loubriat
9375f9a08b Track the accessible-delegate-focus property of the focused item 2025-02-09 21:36:52 +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
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +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
Simon Hausmann
2a5e35a5e8
Fix typo 2025-01-31 21:59:05 +01:00
Simon Hausmann
5ff5c0464c Fix crash when AccessKit is active and combobox is opened
Opening a combobox with the winit backend implies creating a popup and a transfer of focus. The former will re-create the accessibility tree and cause pending_update to be set to true. The latter will send a notification to the accesskit adapter and unfortunately the (new) focus node will not be known to accesskit yet, causing it to panic.

Since we have a pending update and the new tree update will include the correct focus, we can just sking sending one in this moment.

Fixes #7403
2025-01-31 15:28:42 +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
Simon Hausmann
aa332202c5 Rename AccessibleRole.GroupBox to AccessibleRole.Groupbox
While unfortunate in casing, this is consistent with Checkbox, Combobox, and Spinbox.
2025-01-10 16:27:14 +01:00
Arnold Loubriat
49196728a7 Add AccessibleRole::GroupBox 2025-01-07 23:08:03 +01:00
Arnold Loubriat
e225ac15e0 Map the visible property to the AccessKit Node::hidden property 2025-01-06 09:30:11 +01:00
Arnold Loubriat
3304df0f82 Add AccessibleRole::TabPanel 2025-01-06 09:30:11 +01:00
Simon Hausmann
c31389dd14 AccessKit: expose popups in the accessibility tree
This is the plumbing, where a `PopupWindow` directly becomes a child of wherever it's declared in, when show() is called. Further changes may be necessary to make this really useful, such as new roles or improved dialog handling. (see ticket for comments)

Fixes #7209
2025-01-03 12:59:31 +01:00
Simon Hausmann
30ae161d51 AccessKit: Clean up internal helper function
accessible_parent_for_item_rc does not depend on NodeCollection.
2025-01-03 12:59:31 +01:00
Simon Hausmann
1320a839da AccessKit: simplify item to node id encoding API
Implicitly register the component if not found. This makes the API easier to use. In another patch I called encode_item_node_id() in some other place before the component happened to be registered, and then it would return
None and each call site would then register the same pre-registration as in build_node_for_item_recursively.
2025-01-03 12:59:31 +01:00
Olivier Goffart
a3dad45f0b Accessibility: rename a few properties after API review:
- Rename `accessible-selectable` and `accessible-selected` to `accessible-item-{selectable,selected}`.
   Because the property is for items in list rather than eg Text
 - Rename `accessible-position-in-set` to `accessible-item-index`.
 - Rename `accessible-size-of-set` to `accessible-item-count` and move
   the property to the container element rather than the item itself
2024-12-07 08:25:42 +01:00
Simon Hausmann
e074d05847
Fix panic in accesskit when focus change occurs before initial tree u… (#6952)
This is a prospective fix to avoid sending `tree: None` as the first tree update.

Fixes #6015
2024-12-06 10:53:28 +01:00
Simon Hausmann
0d7f4ecc1d Fix borrow_mut() panic in accesskit code when accesskit requests setting focus to an item
... which in turn requires a tree update with the new focus node, which requires &mut self.

Fixes #6922
2024-11-27 13:12:10 +01:00
Arnold Loubriat
12e7b8019d Update accesskit to 0.17 and accesskit_winit to 0.23 2024-11-24 13:36:06 +01:00
Simon Hausmann
ea6e5b2841 Fix accesskit adapter lifecycle
Let the adapter live as long as we have a winit window.
2024-11-21 13:27:30 +01:00
Arnold Loubriat
97219c21bf Add the accessible-size-of-set property 2024-10-30 15:54:01 +08:00
Arnold Loubriat
67166fcc2d Add the accessible-position-in-set property 2024-10-30 15:54:01 +08:00
DataTriny
2de3b9d455 Add the accessible-enabled property 2024-10-25 10:20:09 +02:00
DataTriny
28b5a67583 Implement accessible-delegate-focus for the AccessKit backend 2024-10-22 12:54:00 +02:00
DataTriny
be62567293 Tell AccessKit that ListItems can be focused 2024-10-21 07:13:07 +02:00
Arnold Loubriat
4621739cba Implement selectable and selected properties in the AccessKit accessibility backend 2024-10-16 15:38:46 +02:00
Arnold Loubriat
f01420258f Changelog: Introduce AccessibleRole::ListItem 2024-09-16 09:15:39 +02:00
Arnold Loubriat
54992477d8 Changelog: Fix AccessKit role mapping for AccessibleRole::List 2024-09-16 09:15:39 +02:00
Simon Hausmann
49df131625 Fix slint::Window::hide() on Wayland with winit
On Wayland hiding a window requires destroying the surface, which
means destroying the winit window as well as the underlying graphics
surface. The latter is tricky as we have to keep the renderer around,
as our WindowAdapter trait's `renderer()` function returns a `&dyn
Renderer` and that also has to work without a window (to obtain text
metrics).

Fixes #4225

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-07-03 14:22:30 +02:00
Olivier Goffart
1baf227e9e Update AccessKit 2024-07-02 11:45:46 +02:00
Arnold Loubriat
ce2db77e88
Add the accessible-placeholder-text property (#5464) 2024-06-26 12:59:22 +02:00
Olivier Goffart
dc9f1d5bf1 WIP: upgrade accesskit and accesskit_winit 2024-06-18 17:48:17 +02:00
Olivier Goffart
865e3e940d WIP: update winit, glutin, raw-window-handle 2024-06-18 17:48:17 +02:00
Simon Hausmann
97df6b1be1 Mark AccessibleRole as non-exhaustive
That way we can add new variants in the future, while still exporting this in our public API.
2024-06-11 08:02:10 -07:00
Arnold Loubriat
8ece16321b Add DefaultActionVerb to AccessKit nodes 2024-06-06 00:01:29 -07:00
Arnold Loubriat
2e5ebe2668 Address review comments 2024-06-03 01:38:06 -07:00
Arnold Loubriat
f97de46c6f Set accessible min/max values on progress indicator widgets 2024-06-03 01:38:06 -07:00