Commit graph

444 commits

Author SHA1 Message Date
Tobias Hunger
a30533a053 Do not needlessly create the tree of accessible items
... only do that when the OS accessibility layer requests this
data.
2022-07-05 16:53:29 +02:00
Olivier Goffart
9ee13035de Qt backend: rerun the build script when qt_accessible.rs changes as it contains C++ 2022-07-05 10:10:09 +02:00
Tobias Hunger
29248f0c6f Qt: Update the accessibility tree when the component tree changes
This makes the Qt accessibility story actually useful: It will now
update as the models in the UI update:-)
2022-06-30 11:51:49 +02:00
Tobias Hunger
dd59d41ee6 Rename init_*_items to register_component
I want to track component structure changes in the window without
generating more code. So use a more generic name for the init_*_items
functions, so that I can add the functionality I need in there.

Also add a register_component to PlatformWindow and call that.
2022-06-30 11:51:49 +02:00
Tobias Hunger
581533f302 Rename free_*_graphics_resources to unregister_component
I want a more generic name as I want to do to track component structure
changes in addition to resource freeing and I do not want to add another
call into the generated code.
2022-06-30 11:51:49 +02:00
Tobias Hunger
539dec2962 a11y: Allow to update the accessibility tree
Qt sends the necessary crate/delete events automatically as the
placeholder QObjects are created/deleted.
2022-06-30 11:51:49 +02:00
Tobias Hunger
821b5fc141
qt_accessible: Fix another warning about an unused constant (#1352) 2022-06-16 15:14:04 +02:00
Tobias Hunger
fcf8528bf3
qt_accessible: Fix some warnings (#1351) 2022-06-16 13:48:22 +02:00
Tobias Hunger
07ad20a09c
Basic Slint accessibility support (#1294)
Implement basic accessibility (a11y) support, using the Qt backend.

_This should get us started, but accessibility support is an additional way to interact with UIs that is very different from the "graphical way" most users will interact with the UI. No single PR will "make a toolkit accessibility", this needs to be an ongoing effort!_

Parts of this PR:

* Add functions to access a11y-related properties to Component
* Add helper functions to Item struct 
* Handle accessible- properties in the compiler
* Add documentation, add description, enforce some basic rules
* Make the Text element accessible by default
* Don't optimize away accessibility property in the LLR
* Ensure that accessibility property are marked as used
* Add some accessibility properties to the native style widgets
* Support for bool and integer `accessible` properties
* Implement basic support for accessibility
* Make basic widgets accessible by default
* Make slider focus-able and interactable with keyboard
* Tell a11y layer about value changes
* Generate QAccessible constants using bindgen
* Don't expose the `accessible` properties when using the MCU backend: There is no backend to make use of them
* Handle focus change based on keyboard focus of the window
* Report accessible widgets at correct positions
* Allow for (virtual) focus delegation at the a11y level
* Calculate value step size dynamically
* Make sure to not send notifications to a11y backend about dead objects
2022-06-08 20:42:10 +02:00
Simon Hausmann
565262f5c1 Fix formatting
Re-ran `cargo fmt`
2022-06-08 09:23:31 +02:00
pubg-hacks
aed71311ca Add a read-only propery to TextInput, LineEdit and TextEdit 2022-06-08 09:23:01 +02:00
Olivier Goffart
fa6be65a04 Revert "Rename the free_graphics_resources to component_destroyed"
This reverts commit 1b9fee96c16f7a660ed2c14bb3287fceedc72ba7.

The MCU backend still need the array of item, so it's too realy for this change
2022-05-31 10:48:24 +02:00
Olivier Goffart
ad2d19165a Rename the free_graphics_resources to component_destroyed
And do not iterate over the items anymore
2022-05-31 10:48:24 +02:00
Olivier Goffart
6cbf2c0609 Put the new cache in corelib and use it in the GL backend 2022-05-31 10:48:24 +02:00
Olivier Goffart
615c7635ee Qt: use a HashMap for the cache
And not the cache dirrectly within the item, because it is already in use
for the partial rendering
2022-05-31 10:48:24 +02:00
Olivier Goffart
d2186593c0 Pass the ItemRc to each draw_function
So that it can be used as a key to the cache
2022-05-31 10:48:24 +02:00
Tobias Hunger
18cbda0269 janitor: Run cargo clippy --fix 2022-05-22 11:59:00 +02:00
Olivier Goffart
9ae6d71619 Qt: fix gradient that have stop at the same position
Qt implementation only keep one stop if two are at the same location.
So mangle the stop position to be sure they are all at sligntly different position
2022-05-21 11:43:53 +02:00
Olivier Goffart
b4ebd88d35 Implements @radial-gradient(circle, ...)
Only the circle is implemented so far.

Part of #263
2022-05-19 14:07:20 +02:00
ogoffart
3709ded44d Bump version number to 0.2.5 2022-05-09 16:16:00 +00:00
Olivier Goffart
226ceca58d Native style: Fix crash when opening a combobox
Bug introduced by https://github.com/slint-ui/slint/pull/1231
2022-05-09 17:27:32 +02:00
ogoffart
c160ec2aef Bump version number to 0.2.4 2022-05-09 13:49:25 +00:00
Olivier Goffart
0c19751a1e Qt: do not wrap QPainter directly, but use a unique_ptr instead
Because QPainter can't be relocated.

Fixes #1230
2022-05-05 13:50:26 +02:00
ogoffart
6395cdfc09 Bump version number to 0.2.3 2022-05-04 12:32:58 +00:00
Tobias Hunger
11f23cbbdb
Hack to make Qt not close newly opened popups when running on Windows (#1227)
* Hack to make Qt not close newly opened popups when running on Windows

Windows sends a mouse release event after the close event when running
on windows. This confuses our hack to close popups!

So hack around the problem by ignoring any mouse button release event
that does not follow a mouse button press event. I hope this will
not couse too many side effects.

Fixes: #1211

* Update internal/backends/qt/qt_window.rs

Co-authored-by: Olivier Goffart <olivier@woboq.com>

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-05-03 18:46:53 +02:00
Olivier Goffart
931838e2ce Qt: quit the application when calling hide() on the last window
Fixes the todo example not exiting when clicking on "yes" in
the close popup

cc #1212
2022-05-03 17:20:41 +02:00
Olivier Goffart
1b9917db37 Fix PopupMenu showing in a wrong place from qt_viewer
qt_viewer reparent the window so we need to use mapToGlobal to compute
the popup position

Fixes #1219
2022-05-03 11:54:53 +02:00
Tobias Hunger
9ef1f08163 Take alignment from QStyle infos into account when rendering the TabBar 2022-04-20 15:19:16 +02:00
Tobias Hunger
6c10edc957 Draw focus rect on focused tabs 2022-04-20 15:19:16 +02:00
Olivier Goffart
f117cb77cc NativeSpinBox: Handle the key press in native code 2022-04-19 11:27:19 +02:00
Tobias Hunger
df9f86ba4a janitor: cspell fixes 2022-04-13 14:42:32 +02:00
Tobias Hunger
2c82fd7618 Tab: Make tab accept keyboard 2022-04-13 14:42:32 +02:00
Tobias Hunger
57e120509d qt: Handle focus in checkbox 2022-04-08 08:32:05 +02:00
Tobias Hunger
70cfc33659 qt: Handle focus in native button 2022-04-08 08:32:05 +02:00
Olivier Goffart
40c98d6d05 Update cbindgen and enable MouseCursor::move
cbindgen 0.21 was released which contains https://github.com/eqrion/cbindgen/pull/724
which allow to use raw identifier in enums shared with C++.
So now we can have `MouseCursor.move` in slint  despite it being a rust keyword

Note that the strum macro also have trouble with the raw identifier, so we
take that in account in the conversion functions in the interpreter
2022-04-05 06:39:50 +02:00
Olivier Goffart
8eddeb6a80 Qt: Fix text_input_byte_offset_for_position when at the end of the last line 2022-04-04 15:36:43 +02:00
Olivier Goffart
d7616ae03b Qt backend: fix text_input_byte_offset_for_position at end of lines
We must include the trailing spaces in the lines, and if we are past that
we must always go back to the last character of the line
2022-04-04 14:57:44 +02:00
Olivier Goffart
054144c236 text_input_byte_offset_for_position: clicking past the end should return the last position
Instead of 0.
(But passing a negative y coordinate should return 0)
2022-04-04 14:57:44 +02:00
Olivier Goffart
16a0f28449 Keep the existing size re-using a window
Eg, in the viewer or in the preview.

The preferred size is still set as the size when the window is first open
2022-04-01 16:18:59 +02:00
Lukas Jung
b6171530ab replace text_input_position_for_byte_offset with text_input_cursor_rect_for_byte_offset 2022-03-28 10:07:07 +02:00
Simon Hausmann
033cf3721e Improve performance of opacity rendering
Avoid an opacity layer also in the case where it is applied to an element with no children.
2022-03-25 10:50:02 +01:00
Simon Hausmann
d6a569b8f8 Make rendering_metrics_collector a public module
... instead of pulling it entirely into the graphics module.
2022-03-24 21:20:28 +01:00
Simon Hausmann
f3b1ba6717 Collect statistics about the number of layers created in the GL and Qt renderer 2022-03-24 21:20:28 +01:00
Simon Hausmann
7b194b3f8c Rename FPSCounter to RenderingMetricsCollector
In preparation for collecting additional data
2022-03-24 21:20:28 +01:00
Simon Hausmann
fee858271c Fix the frame per second counter when using refresh_full_speed
After commit 575665994a we need to explictly schedule a repaint,
so that we draw and call `measure_frame_rendered`.
2022-03-24 14:49:20 +01:00
Simon Hausmann
caca532ada Released unused opacity layers 2022-03-23 17:37:27 +01:00
Simon Hausmann
4799ac9ce8 Don't create layers for opacity if it's not needed
More could be done towards this, but after literally seeing `opacity: 1;` in
.slint files, this seems worth doing.
2022-03-23 17:37:27 +01:00
Simon Hausmann
bef31d3169 Rename the layer boolean property to cache-rendering-hit 2022-03-21 20:22:43 +01:00
Simon Hausmann
849282a5a8 Don't render with layers if the layer property is false 2022-03-21 20:22:43 +01:00
Simon Hausmann
3a5181d31f Implement the Layer element for the Qt renderer 2022-03-21 20:22:43 +01:00