Commit graph

1368 commits

Author SHA1 Message Date
Olivier Goffart
54a6cb22ee Allow .darker and .brighter on Brush 2022-04-12 13:01:53 +02:00
Tobias Hunger
c825eee228 janitor: Update global cspell
Update global cspell words and remove some file-wide words.

Also remove a manual test that is now also run as a proper test case.
2022-04-12 12:03:45 +02:00
Tobias Hunger
73e178a840 Add enabled property to FocusScope 2022-04-12 10:48:09 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Simon Hausmann
afb59cba29 mcu: fix popups not visibly closing
When closing a popup, notify the platform window, so that the mcu
backend can remember that region and start the dirty region with it.

Also, free all the rendering cache items of deleted items, to avoid accidental re-use
when re-opening a popup.
2022-04-08 19:32:33 +02:00
Simon Hausmann
67af5a79f6 Revert "Avoid rendering if the clip is empty"
This reverts commit faf07ea237 as it
breaks dependency tracking with the partial renderer. The effect is that
the mcu printer demo (in release?) doesn't react to input events
anymore. They are delivered by the redraw tracker doesn't get notified.
2022-04-07 17:38:54 +02:00
Olivier Goffart
17fd446905 Get rid of a call to unsafe in the test 2022-04-07 16:59:38 +02:00
Olivier Goffart
0429e11cf7 Refactor: Move ItemRc and ItemWeak to item_tree.rs
Keep items.rs for the implementation of items, and move the logic
that helprs navigating the tree to the item_tree.rs module
2022-04-07 16:59:38 +02:00
Tobias Hunger
49dee3a7eb Match up doc strings and code 2022-04-07 16:50:07 +02:00
Olivier Goffart
d0501b4f3c Bump vtable version
Commit 99ac33c440 make use of the new Debug impl
in ctable from corelib, so we must update the minimum required version
from its Cargo.toml
2022-04-07 11:17:50 +02:00
Simon Hausmann
faf07ea237 Avoid rendering if the clip is empty
Take an early shortcut
2022-04-07 09:39:30 +02:00
Tobias Hunger
99ac33c440
Debug for ItemRc (#1151)
* vtable: Add Debug implementation to VRc

This will just print the pointer value to be able to destinguish between
different VRcs.

* Derive Debug implmentation for ItemRc

This needs vtable::VRc to have a Debug implementation!

* Update helper_crates/vtable/src/vrc.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-04-06 16:14:30 +02:00
Tobias Hunger
52c2fe585d
Fix forward tabbing through items (#1149)
* Fix forward tabbing through items

The implmentation never properly stepped out of repeaters, so it went
into a loop when a repeater was below a node without siblings. This in
turn led to the window aborting the focus item search. So the focus
never moved forward.

Add a test to make sure this stays fixed.

* Update internal/core/items.rs

Co-authored-by: Simon Hausmann <hausmann@gmail.com>

Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-04-06 13:11:36 +02:00
Tobias Hunger
18ea9d302b Add test for default focus chain implementation 2022-04-05 16:34:16 +02:00
Tobias Hunger
f85812135c Add some basic tests for ComponentItemTree walking 2022-04-05 16:34:16 +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
Lukas Jung
4a7a84f253
Text shortcuts (#1129)
* Add moving by word to TextInput

* moving cursor to end of line, paragraph and text

* fix shortcut in cursor move test
2022-04-04 15:25:50 +02:00
Tobias Hunger
0ca23948fb Do not overflow when walking the tree 2022-03-31 16:29:38 +02:00
Lukas Jung
98b084f80c Fix the redo shortcuts 2022-03-31 10:54:38 +02:00
Lukas Jung
54a2901777 Move TextShortcut to input.rs and rename Shortcut to StandardShortcut 2022-03-31 10:54:38 +02:00
Lukas Jung
068489d788 Use Shortcuts for Copy Paste in TextInput 2022-03-31 10:54:38 +02:00
Lukas Jung
1f5500ff7b Add Shortcuts to KeyEvent 2022-03-31 10:54:38 +02:00
Lukas Jung
7cffd928f2 add TextShortcut to text.rs and use it 2022-03-31 10:54:38 +02:00
Simon Hausmann
dbebdc190b Fix no_std build 2022-03-31 10:13:33 +02:00
Tobias Hunger
5a4226c03e Make tree-walking code DRY-er
Reuse step_into_node over redoing almost the same code again.
2022-03-31 10:09:34 +02:00
Tobias Hunger
3a9fe1d161 Use Vec from alloc crate 2022-03-28 14:13:36 +02:00
Tobias Hunger
03e6f104be Make ComponentItemTree::new take a ComponentRefPin 2022-03-28 14:13:36 +02:00
Tobias Hunger
f6d899b384 Window: Change signature of take_focus_item 2022-03-28 14:13:36 +02:00
Tobias Hunger
b9fddc4ae1 Wire up tab focus handling in Window
Tab/Back-Tab (when not handled by the currently focused window) trigger
a focus move.
2022-03-28 14:13:36 +02:00
Tobias Hunger
c443bb43cf Implement focus movement on ItemRc 2022-03-28 14:13:36 +02:00
Tobias Hunger
36421b193e Implement Component-wide default focus traversal helpers 2022-03-28 14:13:36 +02:00
Tobias Hunger
be43b648e1 Make visibility status of an item available on ItemRc 2022-03-28 14:13:36 +02:00
Tobias Hunger
d24906e2c2 Implement navigation of logical item tree on ItemRc 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
c1bb22bd00 Add helper struct to work with the ItemTree reported by the Component
Just a bit of convenience code to walk the ItemTree.
2022-03-28 14:13:36 +02:00
Lukas Jung
a3cb8c1200 remove redundant setting of preferred_x_pos in mouse events 2022-03-28 10:07:07 +02:00
Lukas Jung
3818b09626 reset the preferred_x_pos in set_cursor_position() 2022-03-28 10:07:07 +02:00
Lukas Jung
b6171530ab replace text_input_position_for_byte_offset with text_input_cursor_rect_for_byte_offset 2022-03-28 10:07:07 +02:00
Simon Hausmann
033cf3721e Improve performance of opacity rendering
Avoid an opacity layer also in the case where it is applied to an element with no children.
2022-03-25 10:50:02 +01:00
Simon Hausmann
d6a569b8f8 Make rendering_metrics_collector a public module
... instead of pulling it entirely into the graphics module.
2022-03-24 21:20:28 +01:00
Simon Hausmann
f3b1ba6717 Collect statistics about the number of layers created in the GL and Qt renderer 2022-03-24 21:20:28 +01:00
Simon Hausmann
7b194b3f8c Rename FPSCounter to RenderingMetricsCollector
In preparation for collecting additional data
2022-03-24 21:20:28 +01:00
Simon Hausmann
fee858271c Fix the frame per second counter when using refresh_full_speed
After commit 575665994a we need to explictly schedule a repaint,
so that we draw and call `measure_frame_rendered`.
2022-03-24 14:49:20 +01:00
Lukas Jung
8ca915d9bd add comment to TextInput's preferred_x_pos 2022-03-23 13:23:58 +01:00
Lukas Jung
8f3ab66de5 Add up and down cursor movement to TextInput 2022-03-23 13:23:58 +01:00
Olivier Goffart
e017d5118b Wasm GL backend: use a <input> element so it show the keyboard on mobile
cc #215

Handle Input event from the input directly instead of going through winit
for the TextInput.

Note that this doesn't handle the composition event well, so the text is
only considered written when it is accepted
2022-03-22 13:33:31 +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
Simon Hausmann
cd932d8cf9
MCU: fix text being cut in the printer demo sometimes being cut off (#1083)
* MCU: fix text being cut in the printer demo sometimes being cut off

When a text element is rendered at exactly the width it reports,
then last letter would be cut off.

* Adjust elision test
2022-03-21 18:47:35 +01:00
Simon Hausmann
d97710f3f9 Implement correct opacity for the GL backend
This also separates the blend-to-screen part of render_layer into a
helper function, as that will be useful in the future with public layer
elements.

Relates to #725
2022-03-18 16:35:26 +01:00