Commit graph

89 commits

Author SHA1 Message Date
Olivier Goffart
18ba3c2ae2 Slint enums in Rust and C++ 2023-06-12 13:02:14 +02:00
Simon Hausmann
1bf05eae7c
Add support for absolute-x and absolute-y properties on any element (#2823)
Fixes #1691
2023-06-06 14:37:53 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
41157b9984 Fix visible property on the root of a component
Just like opacity and other properties, it needs to prevent inlining.

And also add the same warning as for opacity if it is used on the root
(the Window)
2023-02-14 13:28:54 +01:00
Olivier Goffart
a0d6199391 Updater: annotate pure to all function and callback that returns something 2022-12-22 00:26:27 -08:00
Olivier Goffart
1cbd61145e WIP: pure qualifier for callback and functions 2022-12-22 00:26:27 -08:00
Olivier Goffart
151df7167d Fix visibility on drop shadow
`visible:false` would't hide the drop shadow

Fixes: #1460
2022-11-29 17:00:52 +01:00
Olivier Goffart
eee2a3d012 Fix two ways binding between globals
The previous code did not remove two ways binding that were between two
globals. Now we do the remove_aliases pass over the whole document at
once which allos to simplify aliases between globals.
2022-11-28 14:39:47 +01:00
Simon Hausmann
f2c5184bf2 Fix embedding of images referenced in globals
When doing builds that require image embedding (such as for WASM), it's crucial
to also visit the globals (after they've been collected) to catch all image references.
2022-11-24 15:04:25 +01:00
Tobias Hunger
a4e070bdfd compiler: Add support for handling binding expressions for the LSP 2022-11-21 15:01:09 +01:00
Olivier Goffart
1884750960 WIP: LSP: highlight selected element in the preview 2022-11-17 12:23:23 +01:00
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +01:00
Olivier Goffart
4556291e1a Compiler: move the image and font embedding behind a software-renderer flag
Limit the dependency tree of things like the interpreter or the C++ compiler that
doesn't support it anyway.
It is still enabled inconditionally in slint-build though
2022-11-09 12:56:44 +01:00
Olivier Goffart
f4bd77461d Remove the check_aliases pass
The behavior has now changed, so no need for the warning

cc #1394
2022-11-04 15:32:20 +01:00
Olivier Goffart
28ae8f7bc4 Refactoring: split ElementType away from the types used as property type
These are two different concept, and it is confusing to keep them in the
same enum

We want to support component without any base element, and Void is
already used for global component, so do this refactoring before
2022-10-26 14:50:44 +02:00
Olivier Goffart
6d12b276a9
Polish of the rotation feature
- Add a check that this only Applies to Image element without children
 - Default the origin to the center of the Image
 - Add docs and test

cc: #1481
2022-08-30 12:10:42 +02:00
Simon Hausmann
e5d8b0e9d9 Remove unnecessary collect in lower_property_to_element
We can pass an iterator instead
2022-08-17 08:39:10 +02:00
Simon Hausmann
56cbb0e642 Adjust lower_property_to_element signature to visibily separate between main property and extra properties 2022-08-17 08:39:10 +02:00
Simon Hausmann
ef318c4f69 Make the property to element lowering a little less magic
Instead of automatically mapping property bindings if the initial property has a `-` infix,
supply the list of all properties as a parameter.
2022-08-17 08:39:10 +02:00
Simon Hausmann
686df50e9f Revive support for rotation of elements
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.
2022-08-11 10:34:41 +02:00
Olivier Goffart
9eb8518278 Add a warning when setting a two way binding for which the rhs does not declare a default value
Because of issue #1394 and because the semantic are not properly defined
currently, we decided that future version of slint should always and only
take the binding from the right hand side, even if it has no bindings.

Since we can't change the behavior in 0.2, just add a warning instead for now.
The warning can be silenced by setting a default binding for the property on the rhs.

Ignoring the warning can still lead to panic (the one in #1394)
2022-07-08 19:05:54 +02:00
Simon Hausmann
7c37a3b14e mcu: Fix missing glyphs in the slide puzzle
Scan for string literals to make sure to include the special characters used in the demo.
2022-06-16 15:21:01 +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
31502d5918 VSCode web extension: load files from the vscode API
We can't use file system call to load files with wasm, we need to go through the vscode API

Note that this is all async, so i had to prevent re-entry within the compiler using a rentry trick.

I removed the lifetime in the TypeLoader because I thought this was going to be necessary
to get 'static futures. But it turned out not to be necessary. Anyway, I kept it htis way because
it is actually nicer IMHO, even if the CompilationConfiguration is now copied
2022-06-02 16:21:07 +02:00
Simon Hausmann
07d0c6e578 mcu: provide a default font size
We default to 12 pixels in the MCU renderer if no size is specified
2022-04-08 15:11:26 +02:00
Simon Hausmann
70f3f50359 mcu: Add support for automatic font size detection
Continue to support specififying logical font sizes in the compile step
via SLINT_FONT_SIZES, but additionally look for Text/TextInput/Window elements
and extract any constant font sizes
found.

This makes it work out of the box with the printer demo.
2022-04-08 15:11:26 +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
Olivier Goffart
cf49568373 Compiler: make the image processing an enum in the config 2022-03-24 13:16:21 +01:00
Simon Hausmann
bef31d3169 Rename the layer boolean property to cache-rendering-hit 2022-03-21 20:22:43 +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
Olivier Goffart
6c7a7aed0e Error out when a PopupWindow is in a if or for
instead of panicking

We need to mve stuff in the parent element and that doesn't work if
it is a repeated element. Also there would not be ways to call show
on it anyway.

Fixes #1079
2022-03-21 12:50:49 +01:00
Simon Hausmann
738ac0dc01 mcu: scale images at compile time (#966)
Apply a scale factor to reduce the size of embedded images at compile
time.
2022-03-03 13:28:47 +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
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
Olivier Goffart
91e107150e Merge remote-tracking branch 'origin/wip/rename'
Conflicts:
	examples/opengl_underlay/index.html
	examples/opengl_underlay/main.cpp
2022-02-08 07:29:41 +01:00
Olivier Goffart
c5a2e96755 Fix opacity on Image in for in layout
Do the default_geometry pass before injecting elements:
The reason is that the defaut_geometry pass must know if an element is in
a layout and what kind of default geometry needs to be applied depending
on its actual structure, not whatever results after we injected elements

We were relying on the default_geometry pass to set the size of elements,
but that doesn't work for elements that are not covering 100% of their
parents by default. So to that manually instead.

Fixes #915
2022-02-07 18:07:09 +01:00
Olivier Goffart
2816a09911 Fix a panic occuring when some layout may still contains reference to optimized item
We need to simplify all the optimized items before the move_declaration pass
This include innter item of repeater that might be used by layouts

But that also means we can now uptimize children of layouts
2022-02-07 18:07:09 +01:00
Olivier Goffart
0308f86cd4 Rename sixtyfps_widgets.60 to std-widgets.slint 2022-02-01 18:58:54 +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/passes.rs (Browse further)