Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
Olivier found the following steps that reproduce the crash with Skia:
1. Open the gallery and select the "Text Edit" tab.
2. In the first text edit widget, select the first three letters.
3. Click into the second text edit (while the first one shows the selected text)
4. At the beginning of the text, insert the letter "ù" a few times.
This sequence would result in the cursor_position property get out of
sync. Since it represents a byte offset in the utf-8 text, it would
point straight into a utf-8 sequence, resulting in a panic when the
renderer would try to create a slice of the selected text.
As a remedy, this patch renames the cursor_position and anchor_position
properties and provides wrapper getter accessors for use within the
TextInput to safely bound the stored offset.
Eventually we need to intercept changes to the text property and adjust
the cursor and anchor position properties accordingly, so that they
remain valid. However this requires that the compiler is aware that a
property is not accessible directly but has a setter that needs to be
called instead.
This likely/hopefully also fixes#1707.
In the documentation and type register, `drop-shadow-blur` is of type `length`.
In `BoxShadow` it is also a `Property<Coord>` and treated as such: the value
is multiplied by the scale factor.
However in `builtins.slint` it was declared as a property of float, which
is incorrect.
This change should not have any visible impact, as the externally visible type
was always length.
Known caveats:
- winit doesn't forward mouse events to the IME, so clicking
with the mouse while composing results in funny effects such
as the pre-edit text following the cursor.
- With FemtoVG there's no text decoration support, thus no underlining
of the preedit area.
For example
Image {
x: 150px;
y: 50px;
rotation-angle: 45deg;
}
will end up rendering as if x and y are zero. This is because during
the injection we "move" x and y to the Rotate
element as bindings, but due to the lack of built-in
x/y properties, dummy properties are materialized
and they are not applied for the regular per-item translation.
Add x/y to the Rotate element and then it works.
The rotation-angle/rotation-origin-x/y properties are lowered to an
injected Rotate element, that we already had.
This needs further fixes for transforming input events and an
implementation of rotation in Skia.
Add flags that enable the Button to be used as a Toggle, e.g. for use in toolbars or similar places.
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
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
With the help of dark-light crate this is now exposed as dark-style
boolean property in NativeStyleMetrics.
Co-authored-by: Olivier Goffart <olivier@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>