Commit graph

47 commits

Author SHA1 Message Date
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +02:00
Simon Hausmann
98e1befd0d Port the C++ generator and C++ API to the new window ownership model
One key difference to the Rust way is what `slint::Window` means. In
Rust that holds the `WindowInner` and `slint::Window` is only exposed as
`&slint::Window`. This is possible because the component owns the
`Rc<dyn PlatformWindow>`, which has a function to return the
`&slint::Window`.

In C++ `slint::Window` is also exposed as `slint::Window&` in the
`window()` getter, but there's no way to get a reference to a  C++
wrapper for the Rust `&slint::Window` that the `PlatformWindow` trait
returns. Therefore in C++ `slint::Window` wraps `Rc<dyn
PlatformWindow>`.
2022-08-19 15:07:27 +02:00
Olivier Goffart
8c70cd7f57
Move the fonts out of the Backend trait (#1438)
and remove the `'static`
2022-07-26 16:45:54 +02:00
Olivier Goffart
ac4f3e97ad Change slint enum values to be PascalCase in rust
... while still being kebab-case in .slint

Some enums might become public API and we want to have them as
PascalCase to respect the rust conventions
2022-07-22 12:23:52 +02:00
Olivier Goffart
65346c699c Attempt to get the "image-in-corelib" feature compile with C++ 2022-07-20 12:57:37 +02:00
Olivier Goffart
92b4f52556 Make mod() a macro that can take generic types instead of just integer 2022-07-11 17:49:28 +02:00
Olivier Goffart
d48c590346 Add animation-tick() builtin function
Low level primitive allowing to build always running animations
2022-07-11 17:49:28 +02:00
Olivier Goffart
1fac9b7ad0 Do the initialization in the same order in C++ and rust
First the parent component, then the properties.
2022-07-08 19:05:54 +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
Olivier Goffart
9111dbfbce Don't optimize const state property
state info properties are special and cannot simply be inlined or set
(because we need to record the time it was changed and stuff)
So disable the optimization for now.

In fact, what could be done is to remove the state entirely if the state property
is constant. But that change is a bit more involved

This patch does:
 - Don't inline const state property
 - Don't generate a call to .set in the generated code
 - Also allowed to debug the expression with a context from the generator
   (added T generic parameter to the pretty printer)

Fix panic reported in https://github.com/slint-ui/slint/issues/1327#issuecomment-1151244049
2022-06-27 16:25:57 +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
Tobias Hunger
9b535e8ee8 janitor: use matches! 2022-05-22 11:59:00 +02:00
Tobias Hunger
a71848fd2c janitor: Avoid some allocations warned about by clippy 2022-05-22 11:59:00 +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
c8e3a05116 Fix C++ compilation when writing to the model data from a sub component 2022-05-13 13:00:01 +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
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
f8f61dc2b7 Fix a bunch more issue with PopupWindow
* Make sure that the compiler don't panic if the parent of a PopupWindow
   is optimized (by not optiizing such element)

 * Ensure that we can call popup.show() from within a deeper repeater

 * Ensure that the parent element of the popup is the right one in case of
   repeater (and not the node in the parent component)

This partially revert ad5991f8fa and
6c7a7aed0e because we must do the lower_popup
adter the repeater pass, because otherwise the parent element of the
created component for the PopupWindow might be wrong and it is not easy to
adjust (we would have to make Component::parent_element a RefCell or duplicate
it again.

Fixes #1132
2022-04-01 14:06:38 +02:00
Tobias Hunger
072a6fd5e4 Update internal/compiler/generator/cpp.rs
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-03-31 17:43:57 +02:00
Tobias Hunger
e05d24b2cf c++: Implement subtree_index(...) 2022-03-31 17:43:57 +02:00
Tobias Hunger
1888ecfd65 c++: Generate better indices for the parent node of repeaters 2022-03-31 14:40:57 +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
Tobias Hunger
86a6add32c janitor: Fix typos and make cspell happy 2022-03-18 10:15:44 +01:00
Tobias Hunger
ea684fa4de Add item_tree function to Component VTable 2022-03-14 17:19:31 +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
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
Olivier Goffart
0dc188f328 Support for referring to other globals from globals
- We need to make sure that the initialization of global is in the right order.
 - In C++ and rust, we need to add accessor to the global component
 - There can be `PropertyReference::Global` in binding of globals
 - The interpreter globals need to hold references to the global they may depend on

Fixes #175
2022-02-28 10:14:34 +01:00
Olivier Goffart
a32eee64a7 Count the uses of property, and do not generate properties that are not used 2022-02-17 16:25:48 +01:00
Olivier Goffart
9f77e9a2e8 llr: note when a property binding is for a StateInfo 2022-02-16 18:46:37 +01:00
Olivier Goffart
9e938046ca llr: Add a helper function 2022-02-16 18:46:37 +01:00
Olivier Goffart
76a1bf8d7d LLR: Put the expression into a RefCell so they can be optimized 2022-02-16 18:46:37 +01:00
Simon Hausmann
304e06f758 Begin rasterizing glyphs for glyph embedding
Enable with `SLINT_EMBED_GLYPHS=1` and select sizes like
`SLINT_FONT_SIZES=12,16`

This change just puts the data structures in place, rasterizes a fixed
subset, embeds that into the rust generated code and calls a backend
function for registering the font that is unimplemented.
2022-02-15 15:52:24 +01:00
Simon Hausmann
29cbb9e181 Change names of identifiers used for accessing embedded resources in the compiler
Instead of using SFPS (Slint_Fast_Packing_System) use SLINT :-)
2022-02-14 16:17:55 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Simon Hausmann
fcf59f3793 Rename the C++ header files 2022-02-02 13:07:26 +01:00
Simon Hausmann
7d297da2fc Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
Simon Hausmann
5226feab01 Rename C++ pre-processor macros 2022-02-02 12:11:27 +01:00
Simon Hausmann
c846633708 Rename C ffi functions 2022-02-02 11:12:34 +01:00
Tobias Hunger
0d358251c9 Janitor: More clippy stuff 2022-01-31 20:59:45 +01:00
Tobias Hunger
cc568a63f5 Janitor: Fix stray @ in patterns 2022-01-31 20:59:45 +01:00
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
Renamed from sixtyfps_compiler/generator/cpp.rs (Browse further)