Commit graph

61 commits

Author SHA1 Message Date
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
Olivier Goffart
70bc75c267 Use a better character for the password replacement char
Also don't use the byte len, but the char length.
It's not entierly correct, but it's good enough
2022-03-02 21:55:49 +01:00
Jared Moulton
b884a4ca19 Fix CI issues, remove references to replace-char, add a test, fix creation of string 2022-03-02 15:47:32 +01:00
Jared Moulton
fdbc8056b3 Add an option to draw *'s instead of characters for password fields 2022-03-02 15:47:32 +01:00
Simon Hausmann
39a2290221
Build the backends without rtti unless needed (#1001)
* Build the backends without rtti unless needed

Only the interpreter needs the rtti generated code.

 * Since `SlintElement` emits `#[cfg(feature = "rtti")]` tokens, each
 crate using `SlintElement` needs to have an `rtti` feature.
 * The selector gets backend specific rtti selection features, in order
   for the interpreter to enable them.
* Enable rtti when building the C++ project with the interpreter enabled
2022-03-01 18:37:07 +01:00
n-raine
beda5aca07 Add dark style detection support for GL backend
With the help of dark-light crate this is now exposed as dark-style
boolean property in NativeStyleMetrics.

Co-authored-by: Olivier Goffart <olivier@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-03-01 16:41:20 +01:00
Olivier Goffart
f7a0fda86c
Send a MouseExit event when the mouse leaves the window
Fixes #989
2022-03-01 11:23:39 +01:00
Simon Hausmann
668e02aa83 Fix glyph embedding on Linux
Copy the fontconfig code from the GL backend to find out what the font for "sans-serif" is, in case we need a fallback.
2022-02-23 12:13:10 +01:00
Tobias Hunger
f3feab1267
Implement ptr_eq for VWeak and PartialEq for Items (#976)
* Implement ptr_eq for VWeaks

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-02-21 17:45:18 +01:00
Simon Hausmann
b482105402 Bump femtovg, fontdb, usvg and resvg dependencies
This re-aligns the ttf-parser and rustybuzz dependencies in the GL
backend. There's still one other version of ttf-parser pulled into the
compiler due to fontdue, but that's minor.
2022-02-21 09:10:11 +01:00
Simon Hausmann
e30e18a450 janitor: Bump RazrFalcon's dependencies 2022-02-18 10:46:21 +01:00
Tobias Hunger
a8756119eb Update internal/backends/gl/event_loop.rs
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-02-16 12:09:03 +01:00
Tobias Hunger
d443481dee Send less key events from the GL backend
When "combining" information from winit's ReceiveCharacter and
KeyboardInput events, then do not create a second KeyPress event
when the KeyboardInput contained a control character.

This makes us not send duplicate events for `Tab`, but leaves the
handling for e.g. `Ctrl-C` unchanged.
2022-02-16 12:09:03 +01:00
ogoffart
ecd0fb7ecd Bump version number to 0.2.1 2022-02-10 16:25:28 +01:00
Tobias Hunger
58e7caafb0
Fix LICENSES symlinks 2022-02-09 17:05:47 +01:00
Simon Hausmann
260c09199a Fix rendering of png images with alpha in the online editor
It appears that HTMLImageElement is not guaranteed to provide a texture with pre-multiplied alpha. Let's limit this assumption to
SVGs.
2022-02-09 12:41:20 +01:00
Simon Hausmann
c51cc35544 janitor: silence compiler warning
If `fill_text` fails we have different problems :-)
2022-02-09 11:01:18 +01:00
Simon Hausmann
75bb4ac3df Improve error handling when we fail to create a WebGL context in the browser
Bump the femtovg dependency to ensure we get the fix for error detection on the renderer side
and handle it in the GL backend side by rendering text to the 2D canvas, followed by a panic.

This was moved up to before the resize handler can be installed, as that would end up
clearing the canvas when resizing.

A message on the 2D canvas was chose over an alert message box, as the latter
is rather intrusive and would be a nightmare if many of them popped up
when viewing our docs with a browser
configured that way.
2022-02-09 10:53:52 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Simon Hausmann
05b16bed89 Prospective fix for rendering of Slint logo as SVG in the wasm demos and online editor
resvg produces an image with pre-multipled alpha and anecdotal evidence suggests that HTMLImageElement on an SVG does, too.

This might need further restriction for the HTMLImageElement case just to svg, but
let's try this.
2022-02-08 17:39:10 +01:00
Olivier Goffart
1425ef63de Change the Url from sixtyfps.io to slint-ui.com
Also, change the URL of the logo in the docs
2022-02-08 08:52:46 +01:00
Olivier Goffart
00ff5e21a7 Update git repository URL 2022-02-08 08:26:21 +01:00