Commit graph

1368 commits

Author SHA1 Message Date
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
372ad60a8f Add support for position() and set_position() to C++ slint::Window 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
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
Olivier Goffart
4ecc2cd1c0 swrenderer: add a renderer that operate dirrectly on the frame buffer 2022-07-06 17:06:40 +02:00
Olivier Goffart
1b551504a2 swrenderer: Refactor so that we can add a BufferRenderer 2022-07-06 17:06:40 +02:00
ogoffart
6b15d2e479 Bump version number to 0.2.6 2022-07-06 09:58:14 +00:00
Tobias Hunger
4da7588af4 Fix component_at in repeaters 2022-07-05 14:27:19 +02:00
Simon Hausmann
cdff68da17 Revert "Fixt listview jumping when scrolling and element have different size"
This reverts commit 1ae0e8f760.

Oops, this was not intended to be pushed to master.
2022-07-04 13:53:39 +02:00
Olivier Goffart
1ae0e8f760 Fixt listview jumping when scrolling and element have different size
The test test one particular case where we want to expand an item to
the size of the listview when clicking
2022-06-30 14:46:34 +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
Simon Hausmann
f5210b5586 Fix per-item pixmap/texture caching in the Qt and GL renderer
The borrow logic in ItemCache<T>::get_or_update_cache_entry requires us
to take the per-item cache dirty tracker out of the cache entry, so that
we can drop the ref and allow the update_fn to access the cache for
other items during evaluation.

However in order for the cache to work by not re-evaluating the
update_fn next time if nothing rendering related change, we must put the
tracker back after the check/evaluation, otherwise take() will always
return none.

This is a regression from commit
6cbf2c0609 that changed the call from
get_or_update() - which puts the tracker back - to
get_or_update_cache_entry(), which doesn't. Since the former is now
unused, this commit also removes it.
2022-06-29 21:00:41 +02:00
Olivier Goffart
dfc87e7c33 Janitor: cleanup a function
no need to have two separate function for clipping items
2022-06-18 22:31:38 +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
3a5c4981de Clarify comment about clipping in the sw renderer's text drawing 2022-06-17 12:59:48 +02:00
Simon Hausmann
27dc1ec1a6 Fix build with --cfg slint_int_coord 2022-06-17 12:59:48 +02:00
Simon Hausmann
2903b1814c swrenderer: clip glyphs to the text element's geometry
This ensures that the partial renderer updates correctly and this also
fixes a panic in the printer demo on the stm32h7 when opening the format
combobox in the scan page:

We would attempt to render the word "JPEG" with a font size of 12 pixels.
The letter J has a height of 12 pixels, like the font ascender reported, but it's
y coordinate is negative.
That would also result in a negative text item relative origin for the glyph (target
rect in physical pixels),
which fails to convert to an usize and panics.
2022-06-17 12:59:48 +02:00
Simon Hausmann
dcfb285aa8 Add test for whitespace between fragments that wasn't accounted for 2022-06-17 12:08:45 +02:00
Olivier Goffart
318bb5a56c MCU: Fix width of the text not including whitespaces
When concatenating two fragment, we should account for the trailing whitespace
in the previous fragment in the total width.

This fixes the "l" of "Ink level" not beoing drawn properly in the printer
demo with the partial renderer if the Text item (which is too small as a result
of this bug) does not overlap the dirty region, but part of the text still
need to be drawn outside before it overflows
2022-06-17 12:08:45 +02:00
Olivier Goffart
711fa66ca3 rp2040 backend: use DMA to send pixels to the screen via SPI 2022-06-17 09:30:09 +02:00
Lukas Jung
45406ddef0
Make the Pico use Interrupts and WFE (#1337) 2022-06-15 17:15:58 +02:00
Simon Hausmann
a5f29d401b Fix panic when clicking on an open printer queue in the printer demo with the partial renderer
When computing the dirty regions, the call to geometry() might end up
querying a value that's computed by the layout. For the layout
computation we might end up calling ensure_updated() on a repeater,
which then might destroy components. The destruction involves freeing
cached dirty rectangles (via free_graphics_resources), and that also
requires a write access to the cache. So after retrieving the property
tracker for the dirty geometry, drop access to the cache before calling
geometry().
2022-06-14 11:33:00 +02:00
Olivier Goffart
014c827194 swrenderer: Optimize image drawing by using premultiplied colors 2022-06-14 11:23:02 +02:00
Simon Hausmann
2d2eb70b51 Fix panic about multiple mutable borrows with the software renderer
When using repeaters - like in the slide puzzle - and during renderer a component
gets deleted, we call free_graphics_resources and try to free
the dirty rectangle list in the partial renderer cache. At that point the cache is
already mutably borrowed, which causes a panic.

As remedy, apply the mutable borrow more fine grained and not right when calling
render().
2022-06-10 08:38:34 +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
dc7117eeb1 swrenderer: move some computation outside of loop 2022-06-08 16:36:46 +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
Simon Hausmann
16dd2e6597
Decrease stickyness of Flickable slightly
Increase the duration for the decelerating animation slightly in order to make
it more obvious that the surface is flickable.
2022-06-07 13:53:50 +02:00
Olivier Goffart
dc5d1e87cd Compile fix for the MCU simulator
The mcu simulator builds i-slint-core with the std feature, but debug_log maybe
used in #[no_std] contexts, so we need to use a re-export rather than rely on std
being present
2022-06-07 00:05:01 +02:00
Olivier Goffart
a72115518d Move the software renderer to core 2022-06-04 13:40:50 +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
Olivier Goffart
3a6f6d25e6 Fix wasm compilation
For some reason when compiling slint-lsp for wasm, rustc cannot infer this type
2022-05-30 11:07:29 +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
7bf5c7e28e janitor: Use is_empty over comparison with len 2022-05-22 11:59:00 +02:00
Olivier Goffart
6ba76d1708 Fix interpolation between gradiants of different size
The loop was skipping one of the stop to interpolate
because when one iterator was returning None, the other
one had also advenced and its result discared.
We can just unwrap the value instead from the longer chain.

For the radial gradiant, we need to interpolate the last
colors to avoid a flash at the beginning for all the area
"outside" the circle.
2022-05-20 09:06:55 +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
Levin Rickert
e7aef68d1f accept wheel event from flickable 2022-05-19 16:45:29 +02:00
Levin Rickert
8a3b24868b add docs comment 2022-05-19 16:45:29 +02:00
Levin Rickert
5094a59f82 convert scroll to move event for flickable children 2022-05-19 16:45:29 +02:00
Levin Rickert
cdc9ea0e94 WIP 2022-05-19 16:45:29 +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
Simon Hausmann
77445e9dc5 text handling: simplify text_size signature
We can calculate the line height in the common code, that doesn't need to be done in the backends.
2022-05-16 08:21:14 +02:00
Simon Hausmann
0f06d7ea93 text handling: minor cleanup
Use a usize for the line count, not the font length.
2022-05-16 08:21:14 +02:00