Commit graph

1368 commits

Author SHA1 Message Date
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
8287ed4b9e Some more simplifications of the PlatformWindow and Backend trait 2022-07-25 14:51:03 +02:00
Olivier Goffart
f7637b521f More PlatformWindow trait simplification: Component registation optional
Forward the free graphics resource to the renderer by default
2022-07-25 12:04:34 +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
f0faa8aaca Simplify code reading properties from the Window item
Use the new getter in WindowInner.
2022-07-23 13:25:44 +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
5f4923a6f0 Fix build with slint_int_coord 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
Olivier Goffart
9794a4dfad Simplification of the PlatformWindow trait 2022-07-22 18:12:00 +02:00
Olivier Goffart
6de5a42ab2 Use the public Window as a result of the create_popup function 2022-07-22 18:12:00 +02:00
Olivier Goffart
c2fe06d82d Use the public api::Window for the interface of the software renderer 2022-07-22 18:12:00 +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
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
Simon Hausmann
e5e7c61414 Simplify the rendering metrics collector API
Instead of a new() function and a start() and no stop() function, create the collector
when we want to measure and drop it when we're done.

This will also make it possible to move the collector into the renderer
in the future.
2022-07-22 15:18:13 +02:00
Simon Hausmann
26b3505542 Fix memory leak in rendering metrics collector
Avoid a cycling reference
2022-07-22 15:18:13 +02:00
Olivier Goffart
3639ba2644 Don't expose the KeyEventType to .slint
This enum is not used in any builtin things anyway, so it shouldn't be
used at all in .slint code.
2022-07-22 12:23:52 +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
Simon Hausmann
8056836b1f Fix failing i-slint-core tests
Fix the path to the test font.
2022-07-21 14:48:49 +02:00
Olivier Goffart
c28c527e0e Split the properties.rs files in modules 2022-07-21 14:07:15 +02:00
Olivier Goffart
c41749fc12 Rename PropertyChangeHandler to PropertyDirtyHandler
The handler is called whenever the properties it depends on becomes dirty,
not when it changes.

This has caused confusion before, so rename it
2022-07-21 13:16:40 +02:00
Olivier Goffart
7ccd36f7f2 Simplify PopupWindow handling
When the popup is implemented as an overlay on the window, no need
for the backend to do anything
2022-07-21 12:36:53 +02:00
Simon Hausmann
650fd2c6ba Simplify internal svg rendering API a little bit
Since there is only one call site now, we can also return the correct
type without inconveniencing any other code.
2022-07-20 12:57:37 +02:00
Olivier Goffart
847a532732 Move the SVG rendering to a buffer in core 2022-07-20 12:57:37 +02:00
Simon Hausmann
b4b7b27db8 Add bounds to the decoded image cache
This defaults to 5 MB right now and SVGs aren't counted properly.
2022-07-20 12:57:37 +02:00
Simon Hausmann
4b8432c5f5 Remove unused by_address dependency 2022-07-20 12:57:37 +02:00
Simon Hausmann
5619abb878 Move ImageCacheKey into the image module
That way it'll be eaiser to deal with the code with image-decoders disabled
2022-07-20 12:57:37 +02:00
Simon Hausmann
34dc0a80e7 Fix duplicated images when building with embedded images
For embedded images the path is empty but we unconditionally used it to create a TextureCacheKey,
which clashes.

Instead, preserve and store the ImageCacheKey in the ImageInner variants.
2022-07-20 12:57:37 +02:00
Simon Hausmann
71d6717b68 Simplify image cache API
Make the image cache return Image, instead of ImageInner
2022-07-20 12:57:37 +02:00
Olivier Goffart
b8e3d2af89 HTML image in core 2022-07-20 12:57:37 +02:00
Olivier Goffart
c404194a8d Cleanup an unwanted impl From on Image 2022-07-20 12:57:37 +02:00
Simon Hausmann
b56a5581ed Fix build of generated MCU code 2022-07-20 12:57:37 +02:00
Simon Hausmann
4bb3fee04e Fix doc warnings 2022-07-20 12:57:37 +02:00
Simon Hausmann
3ef35c5ef9 WIP: compile the GL backend without image cache and its own image decoding 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
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
9799571396 Make it possible to implement the ItemRenderer trait with a lifetime
The as_any() method returning a `&mut dyn Any` meant that the type has to be
'static. The class solution of returning &()
doesn't work because it has to be a mutable ref. Therefore just return an Option.
2022-07-12 20:37:14 +02:00
Olivier Goffart
30f95e3aca Fix animation-tick() to register that there are running animation 2022-07-12 17:36:04 +02:00
Simon Hausmann
211aaf1dd8 Simplify with_entry
Use `.and_then()` instead of `.map().flatten()`

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-07-11 23:19:05 +02:00
Simon Hausmann
0b20f58ada GL backend: speed up updates to layer content
Now that we store the layer textures as Rc<Texture>, before rendering a
layer we can take a clone of a possibly existing layer texture and if if
the layer's tracker is dirty, we can re-use the existing layer texture
if it's the same size.

This avoids unnecessary texture allocations.
2022-07-11 23:19:05 +02:00
Olivier Goffart
4d05688730 ListView: try the best to keep the listview elements consistant when scrolling
Even when the average height changes
2022-07-11 19:33:05 +02:00
Olivier Goffart
55155915d2 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-07-11 19:33:05 +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
Olivier Goffart
d89d62b6de Properties: Try to re-use the shared property if more than two property are linked
... via two ways bindings

Otherwise we could be in a case where we have an unbounded number of "shared" property
which might not be shared anymore if the original property goes out of scope
2022-07-08 19:05:54 +02:00
Simon Hausmann
8d3bb877b7 Use euclid::Point2D also for the getter, but with out parameter instead of return value 2022-07-08 18:37:01 +02:00
Simon Hausmann
d6f8048232 Use Point2D in the C++ ffi when setting the window position 2022-07-08 18:37:01 +02:00