Commit graph

220 commits

Author SHA1 Message Date
Simon Hausmann
dc8bc5690b Fix C++ build with changed KeyEvent
cbindgen does not support Option.
2022-10-07 11:16:36 +02:00
Simon Hausmann
8cba0622f5 Initial input method support for the winit backend and the FemtoVG/Skia renderers
Known caveats:

- winit doesn't forward mouse events to the IME, so clicking
  with the mouse while composing results in funny effects such
  as the pre-edit text following the cursor.
- With FemtoVG there's no text decoration support, thus no underlining
  of the preedit area.
2022-10-07 11:16:36 +02:00
Simon Hausmann
c40b82c509 Add ItemRc to focus_event and key_event
This will be needed to compute the cursor rectangle in window coordinates, by
traversal of the parent chain.
2022-10-07 11:16:36 +02:00
Simon Hausmann
37a8c50c12 Simplify FontRequest
It doesn't have to be generic as mostly the frontend code creates it with logical lengths.
2022-09-30 23:31:32 +02:00
Simon Hausmann
8adc4404d7 Remove two uses untyped logical rect creation 2022-09-30 13:00:37 +02:00
Simon Hausmann
cc8ff56d98 Remove more uses of LogicalRect::from_untyped() 2022-09-30 13:00:37 +02:00
Simon Hausmann
57fe1b9c47 Replace manual calls to LogicalLength::new() for item fields with logical_XXX getters 2022-09-30 13:00:37 +02:00
Simon Hausmann
a52d633b59 Change FontRequest to be a generic over the length
The API uses a logical length for pixel sizes and letter spacing,
but the renderer will need the physical length eventually.
2022-09-30 13:00:37 +02:00
Simon Hausmann
1624a66ebc Change the Renderer trait's text related functions to explicitly operate on logical lengths 2022-09-30 13:00:37 +02:00
Simon Hausmann
59368363c9 Change the ItemRenderer trait to use logical lengths 2022-09-30 13:00:37 +02:00
Olivier Goffart
1afaab6cc1 TextInput: Change the mouse pointer to the Text cursor on hover 2022-09-16 19:14:49 +02:00
Olivier Goffart
f954cb4ced Add a 100ms delay before forwarding the event in a Flickable
It was reported an annoying visual bug when flicking over a listview
with item that has a special effect on pressed, that the items would
show "pressed" for a brief instant.  This patch add a small delay before
sending the press event to the children.

The FIXME in the test is not a regression. (This happens because we send
Exited event to the children when flicking, despite the mouse is still in
the area)

Added a update_timers_and_animations from slint_mock_elapsed_time so we
don't have to call update_timers_and_animations ourselves in the test
anymore to fire the timers (it was previously only touching the
animation property)
2022-09-16 19:14:15 +02:00
Simon Hausmann
7967bf1ab0 Replace the internal WindowHandleAccess trait with a helper function on WindowInner
The reversal of ownership removes the need for the glue trait in the
publicly visible API.
2022-09-06 16:17:06 +02:00
Simon Hausmann
7e5de3d5d3 Remove use of euclid types and tags for logical/physical position and size in the public API
Instead provide our own types.
2022-09-02 11:05:53 +02:00
Tobias Hunger
10c3c9d16d Api cleanup: Rename some remaining platform abstractions to platform 2022-08-29 16:53:47 +02:00
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +02:00
Tobias Hunger
259457eff8 API cleanup: Fix typo in variable name 2022-08-29 13:26:36 +02:00
Olivier Goffart
7417422e3c Make the PlatformAbstraction not Send using a EventLoopProxy trait
This changes the way the platform abstraction is initialized
2022-08-24 11:32:21 +02:00
Olivier Goffart
2e5ab86bea Rename backend module to platform
and the Backend trait into PlatfromAbstraction trait
2022-08-23 19:39:49 +02:00
Simon Hausmann
1d436778c1 Remove the use of the PlatformWindowRc alias again
and use Rc<dyn PlatformWindow> instead. The alias has to stay with the ffi
functions though and the item vtable definitions,
because we don't have an Rc<> template in C++.
2022-08-19 15:07:27 +02:00
Simon Hausmann
fd026a3991 Change itemtable to use &PlatformWindowRc instead of &WindowInner
The former is cbindgen friendly, the latter is entirely Rust internal.
2022-08-19 15:07:27 +02:00
Simon Hausmann
af86f36157 Invert slint:🪟:WindowInner and PlatformWindow ownership
Previously: Window is an Rc<WindowInner>, which has an Rc<dyn
PLatformWindow> - and weak references the other way around.

Now: Rc<dyn PlatformWindow> is the root of window ownership. The impl
PlatformWindow has a slint::api::Window, which just holds a WindowInner.

This change is incomplete on a few levels, mainly that neither of the
code generators nor the interpreter is ported.
2022-08-19 15:07:27 +02:00
Simon Hausmann
b0b8d8d899 Change the Item vtable to take a &WindowInner instead of &WindowRc
... in preparation for storing an Rc<dyn PlatformWindow> in the component.

This won't compile with C++ yet.
2022-08-19 15:07:27 +02:00
Simon Hausmann
262c96af8c Simplify receiver for WindowInner
Use &self consistently, instead of Rc<Self>, so that in the future we can
replace Window(Rc<WindowInner>) with Window(WindowInner).
2022-08-19 15:07:27 +02:00
Olivier Goffart
a62a5cbd19 Rename MouseEvent pos to position 2022-08-17 18:28:12 +02:00
Olivier Goffart
61739dcb81 Remove the Mouse prefix from enum value of the MouseEvent enum 2022-08-17 18:28:12 +02:00
Simon Hausmann
81ca8f54c2
Add missing shortcuts for delete word forward and backwards (#1483)
* Add missing shortcuts for delete word forward and backwards

Fixes #1467
2022-08-16 08:24:56 +02:00
Simon Hausmann
086880f605 Speed up rendering of clipped children
When the renderer does not re-implement visit_clip, we call combine_clip.
Then we're missing out on an optimization the GL renderer does: When the resulting clip region
is empty, we do not need to recurse into children for rendering.

That itself reduces the property dependency chain and avoids unnecessary
updates when invisible (clipped) children change properties.
2022-08-02 11:07:46 +02:00
Simon Hausmann
369f347b29 Move the clipboard back from the Window to the Backend trait
Found a way to connect the clipboard to the wayland display through the winit event loop target.
2022-07-25 15:41:51 +02:00
Olivier Goffart
74c041010e Move the text functions out of the Window, into the Renderer trait 2022-07-25 12:04:34 +02:00
Simon Hausmann
a5cd0a7173 Simplify window item interaction in the core library
Simlify the borrow_pin / downcast_pin dance a little by using VRcMapped.
2022-07-22 23:09:08 +02:00
Simon Hausmann
0ab71ec503 Perform resolution of font properties against the window defaults in the core library
This simplifies the renderer handling - the FontRequest arriving there
will always be resolved.

And this reduces the amount of property dependencies: If a Text elements
specifies a font-family, no dependency to the window's
default-font-family is created.
2022-07-22 23:09:08 +02:00
Olivier Goffart
dd081758b0 Upgrade to lyon 1.0 2022-07-22 19:27:49 +02:00
Simon Hausmann
f9791ea03a Simplify text selection extraction code 2022-07-22 15:21:21 +02:00
Simon Hausmann
465da27270 janitor: simplify string slice creation
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-07-22 15:21:21 +02:00
Simon Hausmann
c494861ddd Change set_clipboard_set to take a &str instead of a String
Every backend will do something different with the string that needs to go into the clipboard.

Qt will convert it to a QString, copypasta to a String, in theory it could be written
directly to a socket.

Given that we don't know what the perfect representation on the backend side is, passing
a string slice avoids any immediate conversions.
2022-07-22 15:21:21 +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
Simon Hausmann
8a3ff06eb5 Move the clipboard handling from the Backend trait into PlatformWindow
Access to the clipboard implies access to the windowing system.
2022-07-22 08:10:44 +02:00
Olivier Goffart
ced9504635 Fix warning in nightly rust
```
warning: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used
Warning:    --> internal/core/properties.rs:382:9
    |
382 |         Box::from_raw(_self as *mut BindingHolder<B>);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
```

Just do what the note says
2022-07-18 16:21:27 +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
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
Levin Rickert
e7aef68d1f accept wheel event from flickable 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
13b12fd0e0 Fix MCU build 2022-04-22 15:55:20 +02:00
Olivier Goffart
63b38d7f89 Move the Flickable item and implementation in the same module
The flickable module was created to hold the implementation for the Flickable
at a time were all the items lived in the items.rs module.
Now that some items moved into sub modules of items, we can also move the Flickable
in such module, alongside its implementation
2022-04-22 15:26:13 +02:00
Olivier Goffart
e85e69fda0
Declare .slint enum in one place in i-slint-common
This avoid repeating the enums both in the compiler and in
the runtime library, and register them in a bunch of other places.

So it should be easier to add enums and enum values

Since cbindgen doesn't see through the macro, generate the enum
manually
2022-04-14 19:17:48 +02:00