Commit graph

82 commits

Author SHA1 Message Date
Simon Hausmann
a881922dd2 Replace touch point workaround with winit patch
Commit c85e1b6d25 added a workaround for a
winit issue, which has been fixed upstream. Until a new release is
available, let's patch in winit from a branch that has the fix
cherry-picked.

This way we don't have to remember to remove the workaround with the
next update and this has been verified on the device.
2022-04-13 11:43:24 +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
c85e1b6d25 Fix touch position reported on touch release with wayland
Work around https://github.com/rust-windowing/winit/issues/1996 by tracking
touch positions ourselves
2022-04-11 15:56:34 +02:00
Olivier Goffart
14d251e63a winit backend: preserve the value of the scale_factor set programmatically 2022-04-11 14:23:28 +02:00
Simon Hausmann
56ead8689c Enable dark-light mode detection for WASM builds
The new dark-light release supports it
2022-04-10 10:45:58 +02:00
Simon Hausmann
335502be3f Upgrade to femtovg 0.3.4
The GL optimizations are in this release now and this also fixes #843
2022-04-07 13:56:23 +02:00
Simon Hausmann
063a292327 GL backend: add shortcut for zero opacity
If the global opacity is zero, we don't need to paint rectangles, etc.

This shortcut is a compromise between opting out much later on femtovg
level and too early before querying properties of the rectangle.  We
still want to do the latter as somebody might depend on that.
2022-04-07 11:37:51 +02:00
Simon Hausmann
206b765d5d Remove font-kit dependency on Windows
Use directwrite APIs directly to determine the font fallbacks for a given piece of text.
2022-04-06 17:30:30 +02:00
Simon Hausmann
d29f834e57 GL backend: minor optimization for image rendering
When colorizing or drawing images, it's not necessary to apply the extra edge anti-aliasing.
2022-04-06 11:33:18 +02:00
Simon Hausmann
6116bcb35d Minor memory usage optimization for clip layers in the GL backend
If a clipped rectangle transitions from having a border radius to none, then we can
delete the clip layer.
2022-04-06 11:32:57 +02:00
Simon Hausmann
f836322ca1 Speed up rendering of clip elements
When a clip element is enabled and it does not intersect with the current clip region,
then we don't even have to bother rendering any child elements.
2022-04-06 11:32:44 +02:00
Simon Hausmann
e06e99a4b9 GL backend: avoid triangle strip for stroke when filling plain rectangles
Similar to commit a329f052ea, we can apply the same
optimization to rectangles.
2022-04-06 11:32:23 +02:00
Simon Hausmann
a87f2abfd3 Fix font fallback determination on Windows with the GL backend
IDWriteFontFallback::MapCharacters only returns one single font that tries to cover
as much of the input string as possible. We need to continue processing the remaining parts of the text,
in order to get a complete list for all fonts we need.

Fixes #1139
2022-04-05 13:14:33 +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
Olivier Goffart
054144c236 text_input_byte_offset_for_position: clicking past the end should return the last position
Instead of 0.
(But passing a negative y coordinate should return 0)
2022-04-04 14:57:44 +02:00
Olivier Goffart
1891e4489a GL backend: update the resizable flag
I only tested on X11 plasma, and there this doesn't have any effect,
But this might be needed because i removed it a few commit ago in another
function.

I think the reason it is there is that it allow changing from a fixed size
to a custom size
2022-04-01 16:18:59 +02:00
Olivier Goffart
16a0f28449 Keep the existing size re-using a window
Eg, in the viewer or in the preview.

The preferred size is still set as the size when the window is first open
2022-04-01 16:18:59 +02:00
Simon Hausmann
a329f052ea GL backend: avoid stroke when blitting textures
When blitting a rectangular texture, we can disable the anti-aliasing on the edges
that femtovg applies by default. That avoids an extra triangle strip for
this stroke to apply anti-aliasing.
2022-04-01 13:32:25 +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
b4f7d135d6 Fix cargo fmt 2022-03-25 11:52:37 +01:00
Olivier Goffart
e6619438c6
Janitor: update a comment to match the implementation 2022-03-25 10:50:33 +01: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
Olivier Goffart
b4bbe0b6df
Wasm: Hack to get input working despite composition (#1101)
Since we don't have yet support for IME in Slint, simulate that by inserting
the text anyway, and rollback using backspaces.
2022-03-24 21:08:44 +01:00
Olivier Goffart
8984eadc05 Wasm: polish the mobile keyboard input
ensure that we don't add the text twice in firefox, and that not every
word is capitalized in chrome
2022-03-24 18:48:24 +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
Simon Hausmann
60bb30df8f Hide the cursor on mobile Safari 2022-03-24 11:55:56 +01:00
Simon Hausmann
e719357ffa janitor: Remove unnecessary clone 2022-03-24 09:10:29 +01:00
Olivier Goffart
575665994a GL backend: don't force every window to be redrawn in case of animation
When the animation tick occurs, the tracker will tell winit to repaint
the relevant window already.
2022-03-23 17:43:48 +01:00
Olivier Goffart
bd44afdbf4 Wasm: When getting native callback, make sure to call the winit event loop
Otherwise it won't be woken up if the window needs a redraw
2022-03-23 17:43:48 +01:00
Simon Hausmann
caca532ada Released unused opacity layers 2022-03-23 17:37:27 +01:00
Simon Hausmann
4799ac9ce8 Don't create layers for opacity if it's not needed
More could be done towards this, but after literally seeing `opacity: 1;` in
.slint files, this seems worth doing.
2022-03-23 17:37:27 +01:00
Olivier Goffart
b259656f4c Wasm: fix dead keys on firefox desktop
We don't want to intercept the press of the non dead key when it is composed
with a dead key. Let the input event handle it
2022-03-22 15:35:02 +01:00
Simon Hausmann
e9350403bc Fix animations not running in secondary windows with wasm
When a second canvas is visible, only animations in the first canvas
resulted in updates and visible animation.  An animation in the second
canvas wouldn't result in repaints.

When we start an animation, we request a redraw on all windows and
return with `ControlFlow::Poll` to winit.

Winit then schedules an animation frame request, and in the callback the
redraw request events are delivered. For the first window we call
`update_animations()`, a new tick is detected (different than the
previous one) and animated properties are dirty and yield new windows.

Then right away we get called again with a redraw request for the second
window. update_animations() determines that the instant::now() is the
same, and has_animations() returns false. So at the end of the event
handler we return fail to return `Poll` and therefore no animation frame
request is created, which means the animations just stop.

Fix this by calling update_animations() only once, when all input events
have been processed and the redraw events are up for delivery next.

This is visible in the preview canvases in the documentation, if a
canvas other than the first has animations.
2022-03-22 14:22:27 +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
849282a5a8 Don't render with layers if the layer property is false 2022-03-21 20:22:43 +01:00
Simon Hausmann
158cbfc68e Implement the layer hint for the GL backend 2022-03-21 20:22:43 +01:00
Simon Hausmann
fb20113f17 Fix manual application of the window constraints with the HTML canvas
The size returned by inner_size is a physical size, so we must convert it to
a logical one before comparing it with the logical constraint sizes.
2022-03-21 16:53:30 +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
Simon Hausmann
91b3765e97 Improve method naming in ItemRenderer
Use `visit_` for the pattern where the trait offers a default implementation that calls other
methods to do the actual work.
2022-03-18 15:42:49 +01:00
Simon Hausmann
f04f0a3e48 GL backend: use direct layers for non-rectangular clips
Delegate the decision how to implement the Clip element entirely into the backend,
where the GL backend can now explicitly render
children into a layer, instead of the hack with a layer in the renderer's
state and the extra save/restore pair.
2022-03-18 15:42:49 +01:00
Simon Hausmann
6a6a26569d Add support for rendering complex clip paths into cached layers
If the renderer supports it, clip elements with a complex clip render
the sub-tree into a cached layer.
2022-03-18 15:42:49 +01:00
Simon Hausmann
1a48cecf4f Clean path bounding box handling
Centralize the femtovg path bbox workaround in a helper function.
2022-03-18 15:42:49 +01:00
Lukas Jung
8617e92d65 add close request handling the gl backend 2022-03-17 08:51:00 +01:00
ogoffart
7b50791db4 Bump version number to 0.2.2 2022-03-10 08:48:33 +00:00
Simon Hausmann
59f06ed1b2 janitor: remove unused dependency 2022-03-04 11:33:39 +01:00
Olivier Goffart
a85482e5a4 Fix selection and clicking on password fields 2022-03-02 21:55:49 +01:00