Commit graph

205 commits

Author SHA1 Message Date
Olivier Goffart
c41749fc12 Rename PropertyChangeHandler to PropertyDirtyHandler
The handler is called whenever the properties it depends on becomes dirty,
not when it changes.

This has caused confusion before, so rename it
2022-07-21 13:16:40 +02:00
Olivier Goffart
7ccd36f7f2 Simplify PopupWindow handling
When the popup is implemented as an overlay on the window, no need
for the backend to do anything
2022-07-21 12:36:53 +02:00
Olivier Goffart
847a532732 Move the SVG rendering to a buffer in core 2022-07-20 12:57:37 +02:00
Simon Hausmann
67a2f0ce3f WIP: Make image decoding a feature of the core library
This includes the cache of decoded images, the HTMLImage element support
and the SVG rendering adapter.

The objective is that Image holds an ImageInner, which is not a path
anymore that the backend has to process, but instead always either
decoded image data, a pointer to a static texture or an SVG tree that
can be rendered to the desired size.
2022-07-20 12:57:37 +02:00
Simon Hausmann
9799571396 Make it possible to implement the ItemRenderer trait with a lifetime
The as_any() method returning a `&mut dyn Any` meant that the type has to be
'static. The class solution of returning &()
doesn't work because it has to be a mutable ref. Therefore just return an Option.
2022-07-12 20:37:14 +02:00
Simon Hausmann
94b4f81be6 Translate logical to physical coordinates for window position and size
Our API exposes physical coordinates, Qt operates on "logical" coordinates.
2022-07-08 18:37:01 +02:00
Simon Hausmann
937c37677e Add API for setting and getting the size of a Window in Rust and C++ 2022-07-08 18:37:01 +02:00
Simon Hausmann
3ce9977f0a Add slint::Window::(set_)position
Fixes #323
2022-07-08 18:37:01 +02:00
Tobias Hunger
82000405b3
qt_accessible: Fix warning suggesting to use std::move (#1400) 2022-07-08 17:04:53 +02:00
Tobias Hunger
20c1c45253
Button: Implement support to make the Button a toggle (#1384)
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>
2022-07-08 16:17:06 +02:00
ogoffart
6b15d2e479 Bump version number to 0.2.6 2022-07-06 09:58:14 +00:00
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