Commit graph

280 commits

Author SHA1 Message Date
Simon Hausmann
fe3d4b7177 Bump MSRV to 1.60 2022-07-26 09:20:52 +02:00
Olivier Goffart
dd081758b0 Upgrade to lyon 1.0 2022-07-22 19:27:49 +02:00
Olivier Goffart
29404e3f2c Rename i_slint_core:🪟:Window into WindowInner
We already have `api::Window` and also the Window element (`WindowItem`),
So rename the inner part to avoid confusion
2022-07-22 18:12:00 +02:00
Olivier Goffart
57d61475b3 Detect loop on the property itself
This is the most basic loop and we wouldn't show a signal.

Turn out the comment was wrong and we do not seem to emit the error
twice for two ways binding to itself

Fixes #1407
2022-07-22 13:29:18 +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
f6a3e741cf Fix the AboutSlint in fluent style with dark style desktop
The widget should not reach into the NativeStyleMetrics directly,
it should get the information from the StyleMetrics which return
the right value (which is not dark style, for the fluent style)
2022-07-22 12:23:36 +02:00
Olivier Goffart
c404194a8d Cleanup an unwanted impl From on Image 2022-07-20 12:57:37 +02:00
Olivier Goffart
65346c699c Attempt to get the "image-in-corelib" feature compile with C++ 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
Olivier Goffart
30f95e3aca Fix animation-tick() to register that there are running animation 2022-07-12 17:36:04 +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
Simon Hausmann
a23a941cf5 Fix slint compiler warning about two-way bindings and missing default 2022-07-08 19:07:20 +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
Olivier Goffart
2c64cfcc82 Keep the same priority for property changed by states with or without default value 2022-07-08 19:05:54 +02:00
Olivier Goffart
d7dc9821a7 Take the priority into account when emitting the compat alias warning 2022-07-08 19:05:54 +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
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
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
Olivier Goffart
a2484cfc64 fluent TabWidget: ensure the minimum width is the one of the tabbar
This is what the native style does

Fixes #1363
2022-06-27 10:07:54 +02:00
Olivier Goffart
00583ade05 Add env variable to put data into a different section
This also makes sixtyfps::Slice Send and Sync
2022-06-18 20:00:21 +02:00
Simon Hausmann
8428a1dad1 Fix wasm build 2022-06-16 15:21:01 +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
Simon Hausmann
9f957e7db5 Fix some missing glyphs in the slide puzzle on stm32h7
Implement some very rudimentary font fallback handling and add some the
glyphs the puzzle needs.

The font fallback handling deserves to go into a module shared between
GL backend and the compiler.

For the character selection we should scan the text elements for
literals just like we do for the font size.
2022-06-16 15:21:01 +02:00
Simon Hausmann
3bc43cdcfa mcu: embed default font and imported fonts
Make sure to embed whatever we pick as default font, but also register
any custom imported fonts.

This fixes the plaster font not showing up in the slide puzzle on the
stm32.
2022-06-16 15:21:01 +02:00
Olivier Goffart
014c827194 swrenderer: Optimize image drawing by using premultiplied colors 2022-06-14 11:23:02 +02:00
Simon Hausmann
65419240b4 Bump resvg/usvg versions 2022-06-12 10:58:42 +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
f0c14bea54 Fix memory leak with repeated elements in generated Rust code
The generated code provides a PinnedDrop implementation that calls
free_component_item_graphics_resources. We must annotate the components
correctly to make sure to the drop implementation is called and graphics
resources are released.

Thanks to Jocelyn!

Fixes #1261
2022-06-08 15:56:47 +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
8e0c88a991 Fix compiler warning about usage of deprecated method 2022-06-04 10:23:32 +02:00
Olivier Goffart
81b53e2ae0 LSP: fetch the file content from cache instead of from disk to compute the line number
Otherwise it doesn't work with the web extension. And the file must anyway be in the cache
2022-06-02 21:45:50 +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
Olivier Goffart
42c7b8819d LSP: Auto-complete types that are not yet imported, and add the import 2022-06-01 14:55:38 +02:00
Olivier Goffart
a20d08b45f deduplicate_property_read: bail out if there is a write
Fixes #1271
2022-05-31 14:55:09 +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
Lukas Jung
2c416670e5
Add support for the log crate (#1283) 2022-05-27 13:30:11 +02:00
Tobias Hunger
96b6ca8830 janitor: Remove unnecessary references 2022-05-22 11:59:00 +02:00
Tobias Hunger
55249c90de janitor: fix redundant clones 2022-05-22 11:59:00 +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
9fc838206a Fix gradient interpolation
When the percentage is missing, we should interpolate between the
last valid entry to the first valid entry after that, not always the
last valid entry in the whole gradient
2022-05-21 12:00:20 +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
f611651bb7 LSP: Fix auto-completion of @-macros 2022-05-19 19:22:56 +02:00
Simon Hausmann
fd195904a1 Allow for the use of cache-rendering-hint in separate components
The `lower_property_to_element` pass usually disallows that because it
injects the Layer element and we can't do that for components. But we
can handle this like with opacity and inline.
2022-05-19 18:50:45 +02:00