Commit graph

1368 commits

Author SHA1 Message Date
Tobias Hunger
9737720cf2 touch-area: Trigger pointer-evnet on mouse move
Trigger the `pointer-event` callback on mouse move. This is of "kind"
Move and the mouse button will always be `Other`, but at least the mappings
will be correct:-)

Closes: #2770
2023-12-11 09:07:44 +01:00
Tobias Hunger
2bdcbc8e9f
core: Add a double-click callback to the TouchArea (#4060)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-12-08 12:12:41 +01:00
Olivier Goffart
f25a419009 swrenderer: More fix to the screen rotation for line by line 2023-12-08 10:36:04 +01:00
Tobias Hunger
3b7e79958a cpp: Make Timer available to other FFI-exported types
We have a nice FFI-compatible wrapper areound rust timers in C++, so
allow to use that in other types exported to C++.

This also makes sure the rust and C++ side agree on the size of the
type, with the nice side effect that the rust Timer now uses half as
much space now as it did before.
2023-12-01 18:47:00 +01:00
Tobias Hunger
3a87342073 testing: Add a method to the testing interface to query the mocked time
I find this helpful when debugging tests using mocked time.
2023-12-01 17:36:18 +01:00
Tobias Hunger
471bef422d core: Do not report singleshot timers set up via start() as running
... after firing once. `running()` will now return `true` for such timers
till just before the callback is run and `false` after that point.

Add test a new test and update existing C++ tests to make them comply
with the changed behavior.
2023-11-30 20:14:45 +01:00
Olivier Goffart
e9079e6db5 Fix position of grabbed event on popups
Fixes #4033  (combobox don't select entries)
Fixes #4036
2023-11-30 10:18:30 +01:00
今何求
607bdbfcf8
Upgrade to fontdue 0.8
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-29 10:52:27 +01:00
Jocelyn Turcotte
678c7678e9 C++ API for KeyEvent.repeat
Add a new dispatch_key_press_repeat_event function to dispatch auto-repeated
key events.
2023-11-29 09:31:31 +01:00
Jocelyn Turcotte
82916bc2ec Implement KeyEvent.repeat
Now that winit was upgraded do 0.29 we can use its KeyEvent::repeat field.
Also feed Qt's QKeyEvent::isAutoRepeat() in the Qt backend.
2023-11-29 09:31:31 +01:00
xgroleau🐢
9bc8d203fe doc: matched the comments with the changes 2023-11-28 16:54:00 +01:00
xgroleau🐢
a6feda5233 fix: return transformed on render() 2023-11-28 16:54:00 +01:00
xgroleau🐢
15770ef7e6 fix: compare current line with dirty region 2023-11-28 16:54:00 +01:00
Tobias Hunger
2ad9e07225 component_container: Add has-component property
... that returns a bool when a component is set up in the
ComponentContainer.
2023-11-28 10:38:46 +01:00
Olivier Goffart
7008b11e3e Properly send exit events when mouse is outside of a PopupWindow
... for non-native PopupWindow.

We first need to handle the grabbed event regardless of popup window.

Then, if we are outside of the popup window, we should send exit events
so that, for example, the has-hover and mouse cursor get properly
updated.

Fixes #3934
2023-11-23 07:25:46 +01:00
Olivier Goffart
84202f6af3 Fix ComponentContainer causing panic when using forward-focus
The ComponentContainer is usually instentiated when trying to evaluate a
property such as the geometry or moving the focus. But the init code of
the ComponentContainer would then tries to change the focus which will
indirectly re-visit items and recurse into some property which are being
evaluated.

We do not need to set the focus on instentiation of the
ComponentContainer anyway, intentiating it shouldn't change the current
focus.

This fixes the LSP preview crashing when trying to preview a component
that has forward-focus

Fixes: #3950
2023-11-22 14:13:27 +01:00
George Hopkins
0a56f43ae4 Implement std::error::Error for LoadImageError 2023-11-20 11:43:13 +01:00
Olivier Goffart
277dce6345 swrenderer: Optimize image rendering
Do the match on the format before the loop
2023-11-18 13:21:11 +01:00
Olivier Goffart
1a0e065a54 Speedup SharedPixelBuffer::clone_from_slice in debug mode
Discussed in https://github.com/slint-ui/slint/discussions/3912
2023-11-17 12:06:44 +01:00
Simon Hausmann
e054684bb2 Bump femtovg and associated ttf-parser, glow, and rustybuzz dependencies
cc #3922
2023-11-14 19:40:40 +08:00
Simon Hausmann
ba28846dc3 Bump fontdb and resvg version
The memmap and fontconfig features of fontdb are enabled by default.
2023-11-14 19:40:40 +08:00
Olivier Goffart
0b70cbc9a9 Don't use workspace deps for dev-dependencies
They can't have version otherwise we can't upload to crates.io
2023-11-10 11:03:10 +01:00
Olivier Goffart
b27264934a Fix BorrowMut error showing the preview with the software renderer
We used to called borrow_mut twice in a row, that can never work.
I suspect we never reached this code path before, but the preview does
because the ComponentContainer probably instentiate its contents in
places that can cause the geometry cache to be empty while doing the
rendering (while it is most likely being filled when computing the dirty
regions
2023-11-09 16:58:19 +01:00
Olivier Goffart
2f6410515c Assign value to ImageInnner enum
To make sure there are no binary incompatibilities when features are missing
2023-11-07 12:01:38 +01:00
Simon Hausmann
7b61e455eb Initial implementation of a Slint event loop sitting on top of Node.js
At the moment this is implemented using polling.

cc #2477
2023-11-06 11:37:45 +01:00
Tobias Hunger
5e257e2654 LSP: Fix highlighting of top-level item 2023-11-03 22:14:20 +01:00
Tobias Hunger
87c65ec536 core: Add some small helpers to ItemRc
So that it becomes a bit easier to work on with things that should not
cross certain component boundaries (like `ComponentContainer`)
2023-11-03 22:14:20 +01:00
Ken Carpenter
b20536131f
Add more easing formulas (#3812)
Closes #2655
2023-11-03 09:20:44 +01:00
Olivier Goffart
5f36eaca9a Android: handle InputEvent::TextEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
243b44d424 Fix C++ after refactoring of the KeyEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
f24014a2dd Refactor the internal IME event
Base the info on what's discussed in #3811
but this is just the internal event and not the public API
2023-11-02 12:16:40 +01:00
Olivier Goffart
1efd83621d Refactor: Merge KeyInputEvent and KeyEvent
Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
2023-11-02 12:16:40 +01:00
Olivier Goffart
bebec49398 Refactor input_method_request
Part of #3811

But this is still on the internal trait for now
2023-11-02 12:16:40 +01:00
Olivier Goffart
1864257f29 Silence error when rendering SVG in an 0x0 size
Make the size argument to svg::render optional to mean that it is the
default size of the image.
Otherwise, passing None as the size to ImageInner::render_to_buffer
would not render the image which is possible in some backend (eg: the
button image icon with the qt backend)

And if the image is really rendered on an empty because of layouting or
so, we don't need to show a warning anyway.

Fix #3790
2023-11-02 11:09:20 +01:00
Tobias Hunger
83e37f7c51 component_container: Do not auto-match the parent's size
This fixes the widget having the right size and sifes some strange
issues I had been wondering about for a while now!

Pass own size to children instead, so that they will always have
matching sizes.
2023-11-01 17:25:42 +01:00
Olivier Goffart
d55803d290 Models: fix writing data doesn't update ListView model data property
This fixes a couple of bug:
 - Bug #3740 happens because `Repeater::model_set_row_data` did not use
   the inner.offset to get the instance (So that's the `val == 106` part
   of the test)
 - But I went ahead and also tested what happenned if you changed the
   model from the "outside" using the `model[i] = `, and that was not
   implemented, hence the move of the code from
   `Repeater::model_set_row_data` to `RepeaterTracker::row_changed`,
   That does need Pin though, so Pin was added everywhere
 - C++ is not affected by bug #3740, because because the C++ listview
   don't do the "allocate only visible" optimization. But the
   "val == 1106" part of the test would fail so this patch also moces
   the update from  `model_set_row_data` to `row_changed`.
   But following that we don't set the state as Dirty in `row_changed`,
   the write_to_model test started filling  because the `row_added`
   function was missing an update of the index on every further items

The change in the interpreter prevent a borrow_mut from causing trouble.
The Value really don't need to be in a RefCell anyway

Fix #3740
2023-10-31 13:41:31 +01:00
Tobias Hunger
23f3e61227
core: Make debug print of PropertyHandle more useful (#3780)
core: Make debug print of `PropertyHandle` more useful

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-10-30 09:18:45 +01:00
Olivier Goffart
aeb76593ee C++: fix string conversion from float not being round
Converting 12.3 to a string would be "12.30000001907" which is not what
one would want
2023-10-27 13:20:24 +02:00
Simon Hausmann
fff15b9018 Don't close embedded popups when clicking outside and click-on-close: false is set
cc #3712
2023-10-27 11:49:09 +02:00
Olivier Goffart
43caf257f6 janitor: feature cleanup (std is mandatory for the interpreter)
also no need to add default for our internal features, that's counter
productive
2023-10-27 10:08:42 +02:00
Olivier Goffart
0359071b1e
Winit initial size adjustments and wasm size fixes
Following the winit 0.29 merge, a few adjustments are in order:

 - Make slint::Window.set_size() before show keep the size
 - on wasm, attempt to keep the size of the canvas from CSS
 - on wasm, one must set the width and height explicitly on the canvas
   otherwise there is wierd scaling
 - on wasm, we can't set None as maximum or minimum size otherwise winit
   panics
 - It seems that the hack we had to keep the size in range is no longer
   necessary
 - The hack in the slide puzzle can be removed. (but unfortunately it
   doesn't follow resizes

Unfortunatelly we always call set_inner_size to avoid infinite loop when
the css properties are not specificed, so this will override layouts

Also we don't default anymore to the preferred size

* Update internal/backends/winit/winitwindowadapter.rs
2023-10-24 15:28:18 +02:00
Tobias Hunger
b6b3337430 component_container: Fix background being rendered too big
... and simplify the code, getting rid of the width/height/x/y properties.
2023-10-24 14:12:35 +02:00
Olivier Goffart
78d273e599 Revert "Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)"
This reverts commit 1162ebbb79.

Because otherwise if we keep the elements, their internal state is kept
and this causes bug #2598

Fixes #2598
2023-10-23 16:52:03 +02:00
Olivier Goffart
58e5d62a02 Winit port: Fix wasm build
Port everything from instant to web-time
2023-10-23 14:22:48 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Simon Hausmann
e0cc2e30a3 skia: Avoid unsafe in favor of bytemuck::cast_slice_mut 2023-10-23 13:55:23 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
Tobias Hunger
d6ec7f23a1 Change component factory API
... to avoid winit panicing on us when embedding some item tree.
2023-10-20 15:34:49 +02:00
Guilhem Vallat
75b3a3e07b Implement Model:as_any() for all adapter models 2023-10-19 17:19:40 +02:00
Guilhem Vallat
dc43c6f620 Add source_model() to FilterModel, SortModel, ReverseModel and MapModel
As a mean of getting the inner model, useful to be able to push into the
underlying model.
2023-10-19 17:19:40 +02:00