Commit graph

871 commits

Author SHA1 Message Date
Olivier Goffart
deba176c72 Janitor: bump dependencies versions 2022-06-29 09:02:43 +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
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
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
48f818df62 C++ VBox: make the destructor delete the content in C++ 2022-05-30 13:54:35 +02:00
Olivier Goffart
66c443c90c Add the rust-version field to make the MRSV explicit
We changed the MSRV in the last release because some dependency depended on
Rust 1.59. But that did not concern the C++ build, for example.
Now that we rely on rust 1.59 in our own code, we should make it explicit
so that the compilation error show the proper error
2022-05-20 08:18:11 +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
Olivier Goffart
9fa59d38cd Generate the enum documentation based of the common/enums.rs
So that makes it harder to forget to update the docs

Note that the new builtin_enums.md does not contain a `### Values`
section header anymore. Also some enum where documented with the full
enum value (such as `TextHorizontalAlignment.left`) while now this
is omitted

The CI should fail if one forget to run `cargo xtask enumdocs` after
adding an enum or changing the docs
2022-05-13 13:15:51 +02:00
ogoffart
3709ded44d Bump version number to 0.2.5 2022-05-09 16:16:00 +00:00
ogoffart
c160ec2aef Bump version number to 0.2.4 2022-05-09 13:49:25 +00:00
Olivier Goffart
2aaefa8e0d C++: Setting a value to a property having a binding should always clear the binding
... even if the old value holds the same value as the new value

This fixes test_cpp_bindings_two_way_priority_default

Also add a C++ unit test that tests the Property type specificaly
2022-05-09 09:30:01 +02:00
Olivier Goffart
51146eccd1 Update corrosion 2022-05-09 09:23:23 +02:00
Olivier Goffart
bc0f878799 Update corrosion 2022-05-05 08:54:32 +02:00
ogoffart
6395cdfc09 Bump version number to 0.2.3 2022-05-04 12:32:58 +00:00
Olivier Goffart
59cc65c774 Janitor: upgrade cbindgen 2022-04-26 11:55:34 +02:00
Tobias Hunger
416aa42d90 Component: Replace parent_item to parent_node
Remove the `parent_item` function. After the recent changes that did not
return an item anymore and since the item tree is exposed, this function
was only used to find the repeater a component was created by.

So replace the old function with a new one that only returns the parent
node in the parent component.

This saves a few lines of generated code that is not used anymore.

Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-04-20 14:29:18 +02:00
Olivier Goffart
af3db79472 Janitor: Update cbindgen 2022-04-19 15:32:42 +02:00
Olivier Goffart
8117e7f03d C++: make Model::track_row_data_changes const 2022-04-19 15:12:15 +02:00
Olivier Goffart
2f67564ea9 C++: add a Model::row_data_tracked function 2022-04-19 15:12:15 +02:00
Olivier Goffart
452bc2a696 Update MSRV to rust 1.59 in the CI and documentation
This is only required for dependencies of slint-build and xtask.
So this is not enforced yet and will still work with 1.56 with
for C++ or when not using slint-build.
2022-04-14 19:18:05 +02:00
Olivier Goffart
e85e69fda0
Declare .slint enum in one place in i-slint-common
This avoid repeating the enums both in the compiler and in
the runtime library, and register them in a bunch of other places.

So it should be easier to add enums and enum values

Since cbindgen doesn't see through the macro, generate the enum
manually
2022-04-14 19:17:48 +02:00
Olivier Goffart
f5030cff06
Add a reset function to the model notifier 2022-04-14 14:06:34 +02:00
Simon Hausmann
9a8c5fed9f Remove the ugly style
It's ugly ;-)

The combo box for the style is commented out for now, so that we can
easily re-add it in the future once we add a new style.
2022-04-13 10:35:42 +02:00
Olivier Goffart
54a6cb22ee Allow .darker and .brighter on Brush 2022-04-12 13:01:53 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +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
d940a0b35d Fix NativeSlider::changed in C++
FloatArgs is not properly exposed to C++
2022-04-04 17:33:54 +02:00
Simon Hausmann
4c88b2b19b Start a page with examples and recipes
This is the beginning of a page to collect common things users need to
do, in a format that they can copy & paste into their application code.

There's a lot more that could be done though.
2022-04-04 10:01:26 +02:00
Simon Hausmann
ed5b76e7fc Improve syntax highlighting in the language reference
Highlight all Slint code and don't do the preview on snippets where it
doesn't make sense.

Some snippets, such as the bare statement or expression snippets, are
now highlighted, but they are continued to be excluded from the doctest.
2022-04-04 09:58:09 +02:00
Simon Hausmann
9582168d94 Fix broken links to C++ types in C++ Type mapping documentation
The links to slint::Color (and other types) was coded to their direct
.html file name, so for example classslint_1_1_color.html.
Unfortunately in the CI the class name became classslint_1_1color.html
and therefore the links on our website were broken.

Now my-st parser has a way of resolving links in markdown to references,
basically {cpp:class}`slint::Color`. Unfortunately that link resolution
is not working when used inside markdown tables.

Therefore this patch converts the entire table to restructured text,
where we can use native references to hopefully always generate the
correct links, regardless of the doxygen/breathe/exhale version.
2022-03-31 21:48:27 +02:00
Tobias Hunger
e5aadd7c26 C++: Make component_at() return a ComponentWeak 2022-03-28 14:13:36 +02:00
Tobias Hunger
ee68716d07 Component: Add information to stich together ItemTrees
Add accessors to the information necessary to stitch together the
Component-wide ItemTrees (which include DynamicNodes) into one logical
tree of Items.
2022-03-28 14:13:36 +02:00
Simon Hausmann
df2d6442d4 Make it possible to disable the slint compiler from the CMake build
This isn't always needed, for example when using only the interpreter API,
and its dependency to native libraries on Linux (namely fontconfig) makes it difficult to cross-compile with
CMake.

While cargo is invoked correctly for the native binary build, the library search paths
coming from CMake will be target specific, not host specific.

So for now this provides a way of disabling the compiler.
2022-03-22 12:59:52 +01:00
Simon Hausmann
535e134223 Add a Layer element that's created when using a layer boolean property
For now no backend implements this optimization hint.
2022-03-21 20:22:43 +01:00
Simon Hausmann
9b62b08ed6 Fix CMake setting DT_NEEDED to the absolute soname of libslint_cpp in apps
As per rust-lang/cargo#5045, cargo does not set soname on created
cdylibs. We use corrosion to import our .so into CMake, which ends up
passing the absolute path to the .so to the link line of the
application. Due to the lack of DT_SONAME, this means that DT_NEEDED of
the application contains the full path to libslint_cpp.so. This is
sub-optimal for example for building Yocto SDKs, the build paths should
not end up in the created binaries.

The library should be located using the linker's search paths and the
.so name. For convenience, the application can use rpath to extend those
search paths (and usually CMake already does that), but there is no need
to code the absolute path to the library.

Set the IMPORTED_NO_SONAME CMake variable to work around this.

This can be verified with the steps as in #1066.

Fixes #1066
2022-03-18 16:58:53 +01:00
Tobias Hunger
86a6add32c janitor: Fix typos and make cspell happy 2022-03-18 10:15:44 +01:00
Tobias Hunger
526166090e cmake: Do not break when slint is build with empty CMAKE_BUILD_TYPE
Do not break building against slint using CMake from C++ when no
CMAKE_BUILD_TYPE was set when building Slint.

This just makes sure the build type is properly quoted, which makes sure
we keep a (empty) string token where CMake expects one.

Fixes: #1065
2022-03-17 18:18:20 +01:00
Olivier Goffart
ca5151de11 C++: implement Window::on_close_requested 2022-03-17 14:49:12 +01:00
Tobias Hunger
bdc3778cec Rename init/free item functions back 2022-03-14 09:43:50 +01:00
Tobias Hunger
095537e3fd Remove item from ItemTreeNode
... and make ItemTreeNode non-generic this way.

The Item is now only in the extra ItemArray struct and we are free to
expose the ItemTree further.
2022-03-14 09:43:50 +01:00
Tobias Hunger
5d3f296af9 API: Change WindowRc::free_graphics_resources and init_items on C++
Use the ItemArray in both cases.
2022-03-14 09:43:50 +01:00
Tobias Hunger
1fd14272cf Use item_array in C++ 2022-03-14 09:43:50 +01:00
Simon Hausmann
b34f733716 Point C++ users to the new release/0.2 branch
That way version upgrades to new patch release become easier.
2022-03-10 11:08:58 +01:00
ogoffart
7b50791db4 Bump version number to 0.2.2 2022-03-10 08:48:33 +00:00
Olivier Goffart
3b2b1c92a4 Update version number in docs and readmes
```
sed --follow-symlinks -i 's/^\(slint.*\) = ".*"/\1 = "0.2.1"/' **/*.rs **/*.md
sed --follow-symlinks -i 's/GIT_TAG v.*$/GIT_TAG v0.2.1/' **/*.md
```
2022-03-10 08:46:16 +01:00
Tobias Hunger
ebe3a3c37c cpp: Fix cmake property mapping
Fix the mapping between a projects CMAKE_BUILD_TYPE and the build type
of the imported Slint library.

Fixes #1027
2022-03-09 19:53:06 +01:00
Olivier Goffart
15781411de C++ interpreter: Cast the pointer, not the reference
May result in warnings otherwise

```
slint_interpreter.h:426:79: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  426 |                 &inner, &reinterpret_cast<slint::SharedVector<ValueOpaque> &>(array))) {
      |                                                                               ^~~~~
```
2022-03-09 13:11:05 +01:00
Simon Hausmann
583c7a1b80 Fix C++ build
With ImageInner::StaticTextures (the variant) and StaticTextures (the
struct), we need to disambiguate for the generated enum contructor
functions. This is done by prefixing the enum variant with their name.
2022-03-03 14:39:11 +01:00
Jared Moulton
fdbc8056b3 Add an option to draw *'s instead of characters for password fields 2022-03-02 15:47:32 +01:00