Commit graph

936 commits

Author SHA1 Message Date
Simon Hausmann
ced05732a8 Improve robustness of unmapping windows with the GL backend
Make sure to make the GL context is current before destroying the femtovg canvas.

The drop implementation of the canvas will call functions to delete GL resources such as textures, FBOs, etc.
and for that to work reliably the context must be current.
2022-01-05 13:05:40 +01:00
Tobias Hunger
11d46892e4
janitor: Remove some unnecessary lazy evaluation 2022-01-04 18:22:49 +01:00
Tobias Hunger
3e448f75eb
janitor: Remove some unnecessary references
These are immediently dereferenced by the compiler according to clippy.

Remove some now unnecessary muts to make things build again.
2022-01-04 18:22:15 +01:00
Tobias Hunger
e99c1afa4b
janitor: Turn !x.is_ok() into x.is_err() 2022-01-04 18:21:36 +01:00
Tobias Hunger
06346ab2e6
janitor: Derive some Default traits 2022-01-04 18:21:25 +01:00
Tobias Hunger
c89fa46b2c
janitor: Remove some redundent clone() calls 2022-01-04 18:20:24 +01:00
Simon Hausmann
7a61d22c59 Make debug_log! work on the pico by using defmt::println!
This works like the other implementations, so it will allocate on the heap, format with core::fmt
, have no compile-time switch and not print the location.

It would be nicer to forward to defmt directly, but that means the regular
formatting wouldn't work and defmt needs to be a dependency at the call site.

For more fine-grained debugging it's easier to introduce local defmt usage.
2022-01-04 16:06:00 +01:00
Olivier Goffart
cc2a06dc07 Create an EmptyDisplay of a decent size
(The mock display is just 16x16 and nt representative of screen we want to draw on)
2022-01-04 16:06:00 +01:00
Olivier Goffart
d7911f1443 MCU: handle the scale factor 2022-01-04 16:06:00 +01:00
Simon Hausmann
93a0c5bc60 Make the mcu backend compile for the pico with the st7789 driven screen
This bundles all the board specific code in the mcu crate. There's much
to do though, so this is just a rough start and when it's all done we
should probably squash this.

Since the mcu crate dependencies require nightly and our CI builds with
stable, this removes the mcu backend from the default build and the ci.
2022-01-04 16:06:00 +01:00
Simon Hausmann
8858bf8794 Change the dummy backend in the mcu backend to render into a given DrawTarget
* This requires passing the target through a thread-local (hence the corelib export
* Also fetch the background color and resize the item to match the draw target size
* The draw target is a generic and it just needs to support convertion from rgb888
2022-01-04 16:06:00 +01:00
Olivier Goffart
0f2b9f7b78 Add a dummy "device" renderer for the MCU backend
This intends to render just one frame.
2022-01-04 16:06:00 +01:00
Simon Hausmann
dc90c5f35a Make it possible to depend on a no-std corelib
The default backend was the last crate that's in the MCU build that
would still depend default features, so remove that.
2022-01-04 16:06:00 +01:00
Olivier Goffart
f5cf60ea23 NativeComboBox: don't show the combobox as open
Because we currently don't have a way to detect when the popup is closed
we workaround the problem by never show the combo box as open.

Workaround #456
2022-01-03 12:52:20 +01:00
Tobias Hunger
597467fae9 Manually update license information in Cargo.toml files
... that are not published or private or not processed by xtask for
other reasons.
2021-12-22 10:06:12 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Simon Hausmann
215cf68152 Add a simple frames per second counter to the GL and Qt backend
It can be activated using the `SIXTYFPS_DEBUG_PERFORMANCE` environment
variable, which takes a comma separated list of options.

This could be extended in the future with different locations for the
overlay (corner_top_left, corner_top_right, etc.) - but this is a simple
start.

cc #728
2021-12-20 15:32:20 +01:00
Simon Hausmann
5b31fa97a1 Fix formatting 2021-12-13 15:51:28 +01:00
Jocelyn Turcotte
93c28d12db wasm32: Fix reentrancy issues with invoke_from_event_loop
If it's called on top of the an event processed on the event loop,
it might be that GLOBAL_PROXY is already borrowed further down
the stack.
2021-12-13 15:51:28 +01:00
Simon Hausmann
d8988cae6c Prospective fix for making invoke_from_event_loop work better in WASM
When called from inside some winit event handler, we'd go straight to
`with_window_target` to get hold of the event proxy and send it. However
when called through some external event handler (DOM), the scoped
CURRENT_WINDOW_TARGET would not be set and MAYBE_LOOP_INSTANCE would
also be empty because `run` takes it. So instead we'd end up creating an
new event loop instance and the event would sit in there forever.

Instead, this change brings WASM in line with the other platforms by
using the dedicated event loop proxy (global_proxy). Because of the lack
of threading the dance of storage for that is a little different though.
2021-12-13 15:51:28 +01:00
Simon Hausmann
e0a942dc1c Avoid the use of symlinks for source files
On Windows 10, the creation of symlinks by normal users requires
enabling the developer mode, which may or may not be acceptable in
corporate environments with restricted IT setups.

We introduced the symlinks for the shared special key codes mapping,
which instead this patch places into a shared sixtyfps-common crate.
2021-12-13 15:51:10 +01:00
Simon Hausmann
2a44afebb2 Minor cleanup in GL backend
Simplify TextureCacheKey::new
2021-12-11 13:22:27 +01:00
Simon Hausmann
d1ae109296 Fix SVGs not being re-rendered when the scale factor changes
This issue was caused by two bugs:

 * The scale factor was not a property dependency of the Image cache entry's property tracker
 * The texture cache key for SVGs should include the target size that's scaled to.

Fixes #734
2021-12-10 22:26:15 +01:00
Simon Hausmann
2dae2a01d2 Internal cleanup in the GL renderer
Separate the image cache from the texture cache.
The latter needs additional data in the key. The two have less in common that it seemed.

This also fixes a small issue with `CachedImage::upload_to_gpu` that for
SVGs would return a decoded (rendered) SVG image, instead of a texture.
That was harmless because we always call `ensure_uploaded_to_gpu`
later, but now we assert that the texture cache only holds textures,
because clear() (former remove_textures()) just clears everything.
2021-12-10 22:26:15 +01:00
Olivier Goffart
733d4ed365 Handle more non printable key
Share the code that defines the key with a macro over all the backends using
a symlink.

This is a symlink rather than exposing the macro directly since we add this
module in every backend, and each backend re-declares the macro to handle
the part that it needs. This needs to be a symlink because it will also be shared
with the compiler that does not depends on sixtyfps-corelib
2021-12-10 11:28:09 +01:00
Olivier Goffart
873ab9f2e0 GL backend: fix clipping when using scale factor
The initial clipping was set in physical size rather than in logical size.
When scaling up, this does not have visible effect, but when scaling down
it clips too much.
2021-12-08 17:28:23 +01:00
Olivier Goffart
181c8aced7 GL backend: allow to override scale factor with an env variable
SIXTYFPS_SCALE_FACTOR override the scale factor at runtime
2021-12-08 17:28:23 +01:00
Lukas Jung
25dc48ae27 remove move cursor from MouseCursor 2021-12-07 22:41:24 +01:00
Lukas Jung
939b280804 Add set_mouse_cursor dummy function to mcu SimulatorWindow 2021-12-07 22:41:24 +01:00
Lukas Jung
588a7b0c5c Format mouse-cursor changes with rustfmt 2021-12-07 22:41:24 +01:00
Lukas Jung
46c34a7a7e Add empty set_mouse_cursor function to TestingWindow 2021-12-07 22:41:24 +01:00
Lukas Jung
45942fbd82 Add mouse-cursor support to qt backend 2021-12-07 22:41:24 +01:00
Lukas Jung
d2abab5232 Add Qt::CursorShape to key_generated.rs 2021-12-07 22:41:24 +01:00
Lukas Jung
cea17c1958 Add mouse-cursor support to glwindow backend 2021-12-07 22:41:24 +01:00
Olivier Goffart
c964696e24 Bump winit version 2021-12-07 14:28:31 +01:00
Simon Hausmann
957186acb7 Fix drop shadow offset handling with the GL renderer
The cached shadow image should just be the cache of the shadow. This
removes a visible "edge" from the shadow sometimes and brings the
rendering in line with the Qt backend.
2021-12-07 13:06:31 +01:00
Olivier Goffart
9e1e7e3937 Qt backend: simplify the way we set the no-frame flag on the QWidget 2021-12-06 18:52:10 +01:00
Olivier Goffart
310bf897cd Native ComboBox: style the background of the popup
Fixes: #720
2021-12-06 18:52:10 +01:00
Olivier Goffart
2ffa83db0e Native Style: hover effect on NativeStandardListViewItem 2021-12-06 18:52:10 +01:00
Olivier Goffart
8b9be10ff8 Attempt to properly detect if the native style is available when cross compiling
... and using the sixtyfps! macro

The problem is that the OUT_DIR in the build script of the macro crate
is reporting a target directory for the host (since the macro itself is
built for the host), but we need to get the OUT_DIR of the crate, so query
it in the macro. Unfortunatelty, that env variable is only set when the
crate (using the macro) has a build script. So use a fallback to find the
target directory

Fixes #462
2021-12-06 12:59:48 +01:00
Olivier Goffart
691d43d416 MCU backend: build with no_std 2021-11-30 21:33:32 +01:00
Simon Hausmann
6ca63aac9c Make it possible to delegate the timer handling to the backend
When building with no_std, the backend can provide the global
instant.
2021-11-30 17:27:55 +01:00
Olivier Goffart
6004c4ee2f Make the std feature optional in sixtyfps-rs
And tweak the MCU backend dependencie
2021-11-30 15:48:05 +01:00
Simon Hausmann
8f4b256da0 Fix components being inadvertendly shown when using Qt
Remove a spurious show() call, only an explicit show() should bring up the widget on the screen.
2021-11-30 12:31:51 +01:00
Simon Hausmann
6233cc64f2 Fix build with Qt 5
The QPalette workaround is only needed for Qt 6.
2021-11-29 17:18:23 +01:00
Simon Hausmann
e512feb952 Fix reacting to palette changes when using Qt
Due to a bug in Qt's implicit sharing in QPalette, the resolve mask of
QGuiApplicationPrivate::app_pal would get changed with an unrelated setColor
call and thus break color resolution from a new base palette when the theme changes.
2021-11-29 17:18:23 +01:00
Olivier Goffart
e4bd6bbfb8 Native style: respond to the StyleChange event
So that color scheme is updated when switching to the dark style, for example

Fixes #687
2021-11-29 17:18:23 +01:00
Olivier Goffart
80c0602277 WIP: start making the corelib crate a no_std crate
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
ogoffart
3278b39549 Bump version number to 0.1.6 2021-11-24 14:19:09 +00:00
Olivier Goffart
3e3e98725f Fix build
apparently there was Some issue while rebasing
2021-11-22 17:57:08 +01:00