Commit graph

1507 commits

Author SHA1 Message Date
Olivier Goffart
dd5ef9993f
Platform: Add a Resized event and use that to convey the changes in size (#2759) 2023-05-21 12:12:30 +02:00
Simon Hausmann
846c48b81d Add public API to allow platforms to report the window scale factor
Add WindowEvent::ScaleFactorChanged and made set_scale_factor on
WindowInner private.

This achieves what #2486 tried to do, but using the clean platform
window event interface.
2023-05-19 17:06:38 +02:00
Simon Hausmann
37a21ee13a Move the shared font database to core 2023-05-19 10:40:51 +02:00
Olivier Goffart
a68df6eb70
WindowAdaptor: change the 3 ime call into one single ime request enum (#2747) 2023-05-17 17:50:19 +02:00
Olivier Goffart
e3ecb5979c Simplify the way the window properties are applied 2023-05-17 10:22:54 +02:00
Simon Hausmann
20d206dc6b Mark the OpenGLContextWrapper trait as unsafe
There's on guarantee that the pointers returned by get_proc_address are
always valid. Our implementation might, but since the trait isn't
sealed, somebody else could implement it badly.
2023-05-17 09:01:02 +02:00
Simon Hausmann
8a2b40ca7d Simplify core Renderer trait for easier implementation
Make text_input_byte_offset_for_position and text_input_cursor_rect_for_byte_offset
low-level in the API, where the implementation becomes easier. Two
helper functions in TextInput in turn collect the necessary parameters
and thus also reduce the amount of duplicated code.

This also decouples the renderer further from the window.
2023-05-17 09:01:02 +02:00
Simon Hausmann
9c1e5efb43 Clean up FemtoVG renderer interface
Accept the OpenGL context as trait impl. This means we can also move the rendering notifier
into the femtovg renderer create and get rid of
the proxy Renderer trait impl.
2023-05-17 09:01:02 +02:00
Simon Hausmann
7f45d180a9 Clean up internal RenderingMetricsCollector API
Don't require passing a dyn WindowAdapter. This was only used for
calling request_redraw(), which a proper window adapter should do anyway
if has_active_animations() is true.
2023-05-17 09:01:02 +02:00
Olivier Goffart
6db08553a1 Wasm: Fixup Copy/paste
The PR #2703 wasn't complete and didn't work in practice because the
clipboard is always None.

Using the clipboard event data works
2023-05-16 22:41:38 +02:00
Olivier Goffart
fdfdd649f7 Winit: set the Windows scale factor once we got the winit::Window
Otherwise we have the bug that setting the maximum and minimum
constraint, that happens before show(), would use the wrong scale factor
2023-05-16 16:59:13 +02:00
Simon Hausmann
2c93ce73c0 janitor: bump winit version
This version still doesn't have the html canvas fix applied though.
2023-05-15 16:39:54 +02:00
Simon Hausmann
b1073b2ee3 Fix live-preview windows not closing when the user tries to close them
This is a regression from https://github.com/slint-ui/slint/pull/2708,
where previously we would have destroyed the winit window and that's how
it would have disappeared. Now we just need to call set_visible(false);
2023-05-12 16:12:58 +02:00
Simon Hausmann
7fe4cb39aa Cleanup: Remove unnecessary WinitWindow trait
WindowAdapter is not generic anymore, we can use it directly.
2023-05-11 10:42:09 +02:00
Simon Hausmann
1e90b1af80 Remove unused unmap() function 2023-05-11 10:42:09 +02:00
Simon Hausmann
7ab90857d5 Fix winit backend tests
Don't run them on macOS/wasm, but attempt to enable their use via the
winit threaded extension.
2023-05-11 10:42:09 +02:00
Simon Hausmann
12e6e322d9 Make the WinitWindowAdapter non-generic
This isn't necessary anymore
2023-05-11 10:42:09 +02:00
Simon Hausmann
e0bcfff0ab Fix doctests
Don't run them with the winit backend, and that'll try to create an
event loop in a thread.
2023-05-11 10:42:09 +02:00
Simon Hausmann
f10e3a35bc Disable winit accessor tests
Now that we always create a window, we end up also creating an event
loop, and that's inherently incompatible with the rust test harness that
creates threads.

We can try to re-enable this later on platforms where we can run an
event loop in a thread. I have a local WIP patch for that.
2023-05-11 10:42:09 +02:00
Simon Hausmann
c3cee1c3d9 winit: Simplify internal renderer trait
Don't require the creation of an Rc<winit window>, leave
that to the caller.
2023-05-11 10:42:09 +02:00
Simon Hausmann
0475b91daf skia: Simplify renderer API
Remove the generic window handle owner part of the API. Instead assume
that the caller provides safety for the given window handles, like we do
for FemtoVG and like softbuffer does it in its public API.
2023-05-11 10:42:09 +02:00
Simon Hausmann
a3a13c727a winit: Cleanup, move the winit window out of the individual renderers 2023-05-11 10:42:09 +02:00
Simon Hausmann
d0cdc462c7 Simplify Skia Renderer
Allocate the renderer's surface type in the constructor.

This also changes the C++ API to match this, which complicates some code
a little bit.
2023-05-11 10:42:09 +02:00
Simon Hausmann
7c0f9e3b15 Remove outdated doc comment 2023-05-11 10:42:09 +02:00
Simon Hausmann
0466ea139c Simplify state handling in the FemtoVG renderer
Create the OpenGL context and FemtoVG canvas in the renderer constructor. This allows
elimiating various levels of interior mutability.
2023-05-11 10:42:09 +02:00
Simon Hausmann
721e74238f winit: Simplify softbuffer handling
Allocate the softbuffer in the constructor
2023-05-11 10:42:09 +02:00
Simon Hausmann
7df902b53c winit: Create a winit window at renderer creation time
This simplifies the logic for how to apply window related requests as
they can be applied to the winit window immediately.

It also simplifies the state handling in the WinitWindowAdapter, as
there's no more distinction between mapped and unmapped. We always map
now (winit does).

One related change in core is that the window properties are now sent to
the backend before calling show(), instead of after.
2023-05-11 10:42:09 +02:00
Simon Hausmann
d18e5697de janitor: Prospective fix for docs.rs build for next release
Don't try to include the slint preview here, we don't need it.  An
alternative would be to also add a docs symlink here, but this seems
more pragmatic for the time being.
2023-05-10 19:34:17 +02:00
Olivier Goffart
eb0ba51252 Fixup copy/paste support
cc #2703
2023-05-09 20:59:37 +02:00
Amirhossein Akhlaghpour
2e8708be87
Feature: Add copy/paste listener on Wasm (#2703) 2023-05-09 15:55:35 +02:00
Simon Hausmann
481288d489 Initial support for rendering with Skia and Vulkan
Closes #1546
2023-05-09 08:58:35 +02:00
Simon Hausmann
ed4a0d65b9 janitor: Bump winit 2023-05-08 09:11:31 +02:00
Olivier Goffart
66342f67e3 qt: be consistant in rejecting items smaller than one pixel bix 2023-05-05 19:53:57 +02:00
Olivier Goffart
37e70c302e Refactoring: Pass the size to to the render function
So that we don't need to query the geometry multiple time, and this pave
the way to not have the geometry in the items

Part of #1932

As a drive by, fix the clipping of the Path element which incorrectly
offseted the clip by (x,y).
Similar fixes happen in the Clip element in some renderer, but that
didn't have effect because x and y are always 0 for the Clip element
2023-05-05 19:53:57 +02:00
Olivier Goffart
e4a8e4c8ab Upgrade copypasta
The old version depends on an old version of xcb that crashes.
Even if cargo update should fix the problem, it won't happen automatically with old Cargo.lock
Fixes #2682
2023-05-03 21:44:59 +02:00
Olivier Goffart
9e60eceb76 Qt: Fix translucent windows 2023-05-03 19:29:51 +02:00
Olivier Goffart
98747cd385 Winit software renderer: Fix transparent background
Despite the documentation of softbuffer claiming that the high bits
should be 0, it seems to be interpreted as an alpha value when the
window is actually transparent.
And the values are considered as premultiplied alpha

Also use a Premultiplied aplha for the buffer so we can even have
transparent window with the software renderer
2023-05-03 19:29:51 +02:00
Simon Hausmann
9c56bc2e66 winit: Fix rendering into a given canvas element
Make sure to pass the canvas_id along. Amends
2b45f9448e
2023-04-28 16:47:31 +02:00
Simon Hausmann
2b45f9448e Remove platform error from WinitWindowAdapter again
Instead leave it out and return Default::default() in Rc::new_cyclic().

The map state handling gets quite ugly, because it needs to go into a OnceCell. On the upside, if we succeed with creating the winit window
in new() in the future, then that entire cell goes away.
2023-04-27 17:37:36 +02:00
Simon Hausmann
098a078008 Make it possible for the window adapter creation to fail
The creation of the renderer might fail, for example if we tried to
create an OpenGL renderer on a display that doesn't support OpenGL. We
should catch that in the future and fall back to the software renderer.
2023-04-27 17:37:36 +02:00
Simon Hausmann
af8e71dacc Minor cleanup
Replace qualifier with use.
2023-04-27 17:37:36 +02:00
Simon Hausmann
7144b75adf Fix support for transparent windows on macOS when using OpenGL
CGL supports it as-is but with glutin this is only propagated onto the context
when it's set to true in the config template builder.
2023-04-27 17:11:41 +02:00
Simon Hausmann
16000577ce Fix support for transparent Windows on Wayland
We must tell winit that we want a transparent surface by default, to
avoid that winit sets an opaque region on the wayland surface.

In terms of the surface, we already prefer a GL config with a color
buffer that supports transparency.
2023-04-27 10:32:36 +02:00
Simon Hausmann
85da840603 Fold TextVisualRepresentation::apply_password_character_substitution into the TextInput's visual_representation() function
That way the call doesn't need to be duplicated on all call sites.
2023-04-26 17:48:46 +02:00
Simon Hausmann
baba08baeb Move the default password character into corelib
And only let Qt customize it
2023-04-26 17:48:46 +02:00
Simon Hausmann
d757456c5a Centralize all password character substitution in corelib
Use TextVisualRepresentation also in text_input_byte_offset_for_position
2023-04-26 17:48:46 +02:00
Simon Hausmann
fd9a2638b7 Use the common TextInputVisualization::apply_password_character_substitution also for the Qt renderer 2023-04-26 17:48:46 +02:00
ogoffart
dfd5fc38b3 Bump version number to 1.0.3 2023-04-26 14:04:08 +00:00
ogoffart
53cce5bf44 Bump version number to 1.0.2 2023-04-26 11:33:16 +02:00
Simon Hausmann
1abc599be5 Seal the WinitWindowAccessor trait
so that only we can implement it
2023-04-24 12:59:06 +02:00