Commit graph

742 commits

Author SHA1 Message Date
ogoffart
e7f48512ee Bump version number to 1.0.0 2023-02-03 11:07:15 +01:00
Olivier Goffart
f34b1bda2e Add primary keyboard support on unix (selection copy, middle click paste)
Closes #2146
2023-01-31 16:39:22 +01:00
Simon Hausmann
32d2ba70ca
Change WindowEvent::KeyPressed/Released to use a SharedString instead of a char (#2148)
Also, `WindowEvent` is not `Copy` anymore.

Closes #1749
2023-01-31 15:44:54 +01:00
Florian Blasius
d84de623b4
TextEdit select text with double and dribble click (#2088)
* Select word in `TextEdit` by double click
* Select paragraph in `TextEdit` by dribble click
2023-01-31 15:04:19 +01:00
Simon Hausmann
04ceb63433 Update to FemtoVG 4.0
Not big changes, just API and Cargo feature cleanups
2023-01-27 12:03:33 +01:00
Olivier Goffart
ae20ec59c8 Rename PointerEventButton::None to PointerEventButton::Other
And mark the enum non_exhaustive

closes #1903
2023-01-26 13:36:54 +01:00
Simon Hausmann
52fb1ab9fe Fix signature of get_proc_address in Rust GraphicsAPI
Use a CStr instead of str, to avoid an extra CString allocation. The underlying operating system API for
this expects a zero terminated C String.

Fixes #1943
2023-01-26 11:55:10 +01:00
Olivier Goffart
f4fca41173 Compile the winit backend's with RUSTFLAGS='--cfg slint_int_coord'
(at least the swrenderer part)
2023-01-24 15:52:49 +01:00
Simon Hausmann
5ff0278185 Simplify path event extraction
Return the path events for rendering as an Option, so that if the path is empty,
we simply return.

This avoids a double property dependency in the (likely) event the path is not empty.
2023-01-21 13:10:19 +01:00
Olivier Goffart
d6b66a0690 Skia/femtfovg rectangle with transluscent border: set minimum radius
Set the minimum radius of the background to limit the artifact when
drawing the border
2023-01-20 14:12:43 +01:00
Simon Hausmann
911d0e42a9 Fix FemtoVG's drawing of the border rectangle with non-opaque borders (#2079)
Also fix the border radius to be the outer radius of the rectangle

FemtoVG renderer part of #1988 (minus clipping)
2023-01-19 12:13:11 +01:00
Olivier Goffart
00de1867ae Janitor: deps upgrade 2023-01-16 10:47:55 +01:00
Florian Blasius
ed67f3aabb
bump soft-buffer to 0.2 (#2038) 2023-01-09 09:08:59 +01:00
Simon Hausmann
9b2726f0eb Further cleanups in Femtovg renderer's GL context handling
Make with_graphics_api robus by ensuring that the context is always current (similar to commit a124f4b8fe)
and remove the with_current_context boilerplate.
2022-12-22 09:15:47 +01:00
Simon Hausmann
1505826e7d Simplify glutin context handling in the femtovg renderer
Similar to commit a124f4b8fe,
always use a PossiblyCurrentContext
and use glutin's interior mutability to ensure that the context is current.
2022-12-22 09:15:47 +01:00
Simon Hausmann
4c1eff5812 Move the glutin context wrapper into the femtovg renderer
It's only needed there.
2022-12-22 09:15:47 +01:00
Olivier Goffart
5cd38adb14 Move the colorize property to the Image item
Instead of the ClippedImage. Because we use the colorize property more
often than the source property, and these are soon going to be even more
expensive
2022-12-20 08:42:47 -08:00
Simon Hausmann
dee1b11a83 Initial support for truetype fonts in the software renderer
This works, but it's super slow as for every glyph the font is loaded
again and the glyphs are rasterized every time they're drawn.
2022-12-16 18:20:12 +01:00
ogoffart
ce07d078ce Bump version number to 0.3.4 2022-12-16 09:36:15 +00:00
Olivier Goffart
80a834f489 Janitor: fix warning about unusd function
Move the function in the module that uses it (which can be disabled with
features)
2022-12-15 15:15:04 +01:00
Simon Hausmann
aea216fb49 Fix rendering of border widths with FemtoVG and Skia
Commit f66a2a5775 and dc048a11db introduced
the regression of issue #1985 where in adjust_rect_and_border_for_inner_drawing
instead of subtracting the entire border width from the size,
only half of it was subtracted,
leaving an inner area of the rectangle visible.

Fixes #1985
2022-12-14 15:32:53 +01:00
Olivier Goffart
11022b01f3 Fix winit not taking the original size of the canvas into account
We need to check the original size of the canvas before winit override it

The previous code didn't work for two reason
 - It was done after winit had reset the size of the canvas to the
   default size
 - It just calls set_inner_size on the winit Window, which is not what we want,
   we want to call the api::Window::set_size funciton so it can keep all
   different sizes in sync
2022-12-14 14:03:26 +01:00
Simon Hausmann
14350a970b Cleanup: consume the original pixel buffer in the conversion for softbuffer 2022-12-13 16:51:26 +01:00
Simon Hausmann
64a42ca97d Remove unnecessary import of the old raw-window-handle trait 2022-12-13 16:51:26 +01:00
Simon Hausmann
5820db6088 Remove the OpenGL dependency for renderer-winit-software
Use softbuffer to bring pixels produced by the software renderer to the screen.
2022-12-13 16:51:26 +01:00
Simon Hausmann
4883786546 Try to clean up the workaround for the window resizing bug on Windows
Use a dedicated cell and clean up the comments.
2022-12-13 16:50:35 +01:00
Simon Hausmann
f45ab26efe Fix endless window resize on Windows with winit
Restore the resize_event recursion guard accidentally removed in commit 06f7f76b69
2022-12-13 13:31:35 +01:00
Simon Hausmann
8e3df98ffe Minor cleanup
Replace indirect access to the window field with direct access.
2022-12-12 14:24:55 +01:00
Simon Hausmann
a4e4863669 Fix SkiaRenderer::new to take the window adapter weak by value
... for consistency with the software renderer API.
2022-12-12 12:01:12 +01:00
Simon Hausmann
7b4a3cd29a Improve the safety of the skia renderer API
Claim a strong reference (ownership or RC) on the value that provides the raw window handle.
2022-12-12 11:59:50 +01:00
Simon Hausmann
01d2efce4e Move the Skia renderer into a separate crate
The crate is an internal crate until the API has been polished and
documented, after which we can call slint-renderer-skia for example.

This also duplicates a little bit of the glutin setup code, because
that would otherwise have to go into another shared crate.
2022-12-09 17:04:54 +01:00
Simon Hausmann
b2ebac63c2 Remove component_destroyed from winit's internal renderer interface
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.

Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
2022-12-09 09:03:27 +01:00
Simon Hausmann
f5bbca9fce Remove default_font_size() from internal winit renderer interface
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.

This is overall simpler and allows removing the doc-hidden getter in the software renderer.
2022-12-09 09:03:27 +01:00
Simon Hausmann
06f7f76b69 Reduce the renderer interface further in the winit backend
Move the canvas into the renderer entirely as interior state.

This complicates the implementation but paves the way for an easy-to-use API.
2022-12-09 09:03:27 +01:00
Simon Hausmann
6c22af4247 Wrap the software renderer into a struct
This is in preparation for internalizing the canvas state.
2022-12-09 09:03:27 +01:00
Simon Hausmann
ff119eab4f Minimize the WinitCompatibleRenderer trait a little
Replace the raw-window-handle traits with a winit window. It's okay to
use winit one level into the renderer (the part that lives in this
crate).
2022-12-09 09:03:27 +01:00
Simon Hausmann
2fd8bf426a Move the box shadow cache helpers to core::graphics::boxshadowcache
This way the box shadow cache can also be used from the Skia renderer,
which is to be moved into a different crate.
2022-12-09 09:03:27 +01:00
Simon Hausmann
7fb7804d52 Rename window member in MappedWindow struct to winit_window 2022-12-08 12:12:11 +01:00
Simon Hausmann
6a9ff686fc Simplify size conversions between winit and Slint
Encapsulate the direct conversion between physical sizes in functions,
so that the conversion remains type safe and the code remains easy to read.
2022-12-08 12:12:11 +01:00
Simon Hausmann
307636d652 Remove winit dependency from the renderers
GLWindow (yes, misnomed) is now responsible to creating and owing the
winit:🪟:Window.
2022-12-08 12:12:11 +01:00
Simon Hausmann
d9185053eb Implement windowing system name helper function by means of raw_window_handle 2022-12-08 12:12:11 +01:00
Simon Hausmann
ea16113aad Remove glutin-winit dependency 2022-12-08 12:12:11 +01:00
Simon Hausmann
26ff1f6a79 Cleanup: simplify internal render() signature by removing adapter argument
We can unwrap internally.
2022-12-08 12:12:11 +01:00
Simon Hausmann
e573f5b9e0 Speed up window resizing with GL on Linux
When selecting the egl/glx config, select a configuration that has multisampling disabled,
as opposed to one that maximizes the number of samples per pixel.

This also fixes XIO errors causing the process to abort, when resizing very quickly.
2022-12-07 16:49:57 +01:00
Simon Hausmann
958cafc357 Fix build of skia-opengl on macOS and Windows
Since commit ea4ad7297b, the metal and d3d
surfaces are built unconditionally when Skia is enabled, which means we
also need to have their dependencies enabled in the "other" skia
feature.
2022-12-06 16:52:45 +01:00
Simon Hausmann
18bf24e7bf cleanup: simplify access to the winit window
We can now return a reference.
2022-12-06 14:15:56 +01:00
Simon Hausmann
8dd28d232e Port to new major glutin version 2022-12-06 14:15:56 +01:00
Simon Hausmann
755cd66398 Revert "Prospective build fix for arm cross build" and "With Rust 1.64 we can use core:ffi types instead of depending on libc"
This reverts commit 000d95670b and commit
d764796e0c to fix arm cross build and
x86-64 linux.

Let's use the core::ffi types when fontconfig-sys switches to it.
2022-12-06 09:16:03 +01:00
Simon Hausmann
000d95670b Prospective build fix for arm cross build
Use the `c_char` type that adapts to the signedness
2022-12-06 09:07:48 +01:00
Simon Hausmann
11f46906a2 Centralize rust-version in Cargo.toml
Require 1.64 in the workspace and inherit the setting in package
Cargo.toml files.
2022-12-05 12:39:14 +01:00