Commit graph

830 commits

Author SHA1 Message Date
Simon Hausmann
05b7d3e2ee Avoid over-eager animation ticks
Only update animations on input events and when the windowing system requests a redraw.
2021-10-05 12:43:11 +02:00
Simon Hausmann
e987a4aba3 Fix granularity of run-time borrows in GL backend window handling
When processing window specific events, or generally when accessing
the ALL_WINDOWS refcell, keep the time for borrow to an absolute
miniumum. That way any subsequent method calls may further acquire the
refcell.

This patch re-organizes the entire deeply nested window event handling
in a function with slightly less indentation.

Fixes a panic when calling hide on a Window from within a callback
handler.

Fixes #539
2021-10-05 12:43:11 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00:00
Simon Hausmann
0e8efea2ff Further speed up font handling in the GL backend
Use the new fontdb API:

* When registering embedded fonts, we don't need to make a copy of the
  embedded font data anymore.
* We don't have to mmap the font files ourselves anymore, fontdb can
  do this now for us.
2021-10-04 15:11:55 +02:00
Olivier Goffart
2716e4b4dd TouchArea: add the pointer-event callback
... instead of `pressed-changed`

This allows to see what mouse button was pressed.

Closes #535
2021-10-04 14:39:49 +02:00
Simon Hausmann
137ad32886 Fix abrupt process abort when showing a window with constraints in Weston/Wayland
Don't apply constraints to the winit window if we're in fullscreen mode,
as that might result in us allocating a surface that's bigger than the
screen, which in turn may result in the process exiting right away.

Fixes #532
2021-10-02 09:07:57 +02:00
Olivier Goffart
dc10916129 Attempt to improve a bit the look of the native scrollbar
This tries to adjust the position of the scrollbar depending of the value of
SH_ScrollView_FrameOnlyAroundContents
2021-10-01 12:58:00 +02:00
Olivier Goffart
e858b3e8d5 Fix TabWidget drawing with the Qt Fusion style
- The Tab must be drawn before the contents, because the style draws something under the active tab,
   outside of its region
 - Also set the QStyleOptionTab::HasFrame flag since we are in the equivalent of a QTabWidget
2021-09-30 19:43:53 +02:00
Olivier Goffart
5935b99c73 Fix indentation 2021-09-30 19:11:40 +02:00
Olivier Goffart
c7227f35cc Native style: Fix size of button with icon
Some styles recompute the size based on the contents given in the QStyleOptionButton,
Some styles need to be given the icon in their content size. And this was not done properly
2021-09-30 19:10:00 +02:00
Simon Hausmann
f6f06a8ccb Fix compilation with Qt 6.2.0 and MSVC
Apply the same fix as woboq/qmetaobject-rs@fb6e8cda64
2021-09-30 15:45:14 +02:00
Simon Hausmann
4bda3c16db Bump GL backend dependencies
Various third-party bumps and femtovg bumped to include a fix for exact
GLES 2.0 detection. Glutin may give us a 3.x GLES context even if we ask
for 2.0 (https://github.com/rust-windowing/glutin/issues/1282) and I can
reproduce that for example on Raspbian with MESA. But femtovg should
work with both, hence the update.
2021-09-30 14:40:19 +02:00
Simon Hausmann
87dc98b5d9 GL backend: Fix rendering of SVGs with text inside
It works with the Qt backend, and it should work with the GL backend as
well. usvg supports it, uses the same underlying shaper and the API even
allows sharing the font database.
2021-09-30 14:32:46 +02:00
Olivier Goffart
33e0512448 Qt backend: Fix drawing of the TextInput with vertical alignement
This aligns the text properly in the LineEdit
2021-09-30 13:17:16 +02:00
Olivier Goffart
a72c442b58 Native style: use the QPalette for the placeholder color in a LineEdit 2021-09-30 12:50:30 +02:00
Olivier Goffart
465857c42e Handle the Keypad Enter as Return
Fixes #525 : LineEdit::accepted doesn't react on numpad Enter
2021-09-30 11:48:09 +02:00
Simon Hausmann
684fcc8dff Fix support for OpenGL ES 2.0
We default to querying GlLatest from glutin, which might run into a code
path in glutin's `bind_and_get_api` in `egl/mod.rs` that will return
None as version and pass that to `choose_fbconfig`. That function will
panic with unimplemented() if the bound API is GLES, because we need to
know which version of GLES. The bound API in turn might be GLES if
desktop GL is not supported.

To accomodate for this situation, this patch changes the GL context
creation logic to first try explicitly GLES 2.0 and then fall back to
the GlLatest variants.

In addition this pulls in a newer version of femtovg to fix FBO
rendering with stencil with GLES 2.0.
2021-09-30 11:10:42 +02:00
Simon Hausmann
001d8442a8 Remove unnecessary glow dependency
We depend on glow through femtovg, but we don't use any APIs of it anymore.
2021-09-30 10:58:48 +02:00
Simon Hausmann
dd92c84ea2 Apply suggestions from code review
* Remove stray debug statement
* Fix typo

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-09-29 17:03:46 +02:00
Simon Hausmann
91ffb4d41f Initial support for mmapping fonts directly into femtovg
This version doesn't require the change to fontdb yet, but uses the new
femtovg API to allow feeding in shared (mmapped) font data. On macOS
this saves 4-5 MB of ram just for the gallery, on my default Ubuntu it's
roughly ~40MB.
2021-09-29 17:03:46 +02:00
Olivier Goffart
671df0f24f New widget: StandardButton 2021-09-29 16:25:44 +02:00
Olivier Goffart
3f13c69ca8 Hide the cursor of the disabled TextEdit
Fixes #513
2021-09-23 12:39:57 +02:00
Simon Hausmann
7edf19d5b2 Fix GL backend build without x11
Copypasta's wayland clipboard requires a different API that we don't cater to yet, so
for now to fix the build, disable the clipboard (use in-app nop).
2021-09-22 11:52:42 +02:00
Simon Hausmann
043c1932ad Make it possible to disable x11 support
The GL backend defaults to enabling X11. The default crate depends on
the GL backend but it doesn't specify default-features = false,
therefore x11 is basically always enabled.

In line with commit 1fd8c7236a, this
change makes sure that the defaults are defined in the tree entry
points: The Rust API crate, the interpreter crate and the CMake project
define the defaults. The latter already enabled X11 by default, but the
first two did not.
2021-09-22 11:32:51 +02:00
Simon Hausmann
8fea1bf52e GL backend: Fix missing glyphs in the slide puzzle demo
The checkmark and reload have always been missing in some circumstances.
The recent fixes with glyph coverage check helped, but they do not account for the fact that
characters like the check mark map to the same script (Common). So for these scripts
we need to perform an exact glyph coverage check.
2021-09-21 14:12:44 +02:00
Simon Hausmann
1214e444f0 GL backend: minor speed up for font fallback handling
Avoid the dance of using font-kit to re-discover the same .ttf file and
read it all into memory every time we need to render text where the primary font
provides insufficient coverage.
2021-09-21 11:09:37 +02:00
Simon Hausmann
b5de610eb6 GL backend: minor speed up in text rendering
Only query fallback fonts from the system if we really need to.
2021-09-21 10:50:09 +02:00
Simon Hausmann
ac0cc85d33 Simplify font resolution in the GL backend
The font resolution function querying fontdb is fast now, so we can
always call it when rendering text. That way we don't need all the
indirection in the text_size(), etc. functions, we don't need an entry
in the item graphics cache for the font and we can avoid a lot of
property dependencies.
2021-09-21 10:10:45 +02:00
Simon Hausmann
2f1db396e8 GL backend: Speed up glyph coverage checking
Instead of always mapping the face (from disk), first fan out existing
cached coverage information. Any unchecked scripts are then checked
in the slow code path with `with_face_data` later.
2021-09-21 10:07:21 +02:00
Simon Hausmann
b021152fcc GL backend: Fix internal variable name
The available families is used on all platforms and doesn't need a _ prefix anymore.
2021-09-21 09:20:01 +02:00
Simon Hausmann
d2923d51f6 GL backend: add basic font fallback support for Linux
Use the static (but long) fallback list that we get from fontconfig in the beginning.

This works, but can be optimized to operate on a trimmed and shorter list,
which will speed up the fallback. But for now this makes it work.
2021-09-17 18:58:18 +02:00
Simon Hausmann
cc7ea5b92a GL renderer: fix rendering of Text/TextInput when the text property changes in a way that requires different fonts
Unfortunately the text property was not included in the property dependency chain
for the cached Font.
This is fixed by delaying that with a getter function, but in the mid term
we should be able to remove this again once
femtovg learns lazy font resolution.
2021-09-17 18:27:44 +02:00
Simon Hausmann
db842e1b6b Fix font fallback handling on macOS
Permit processing the entire font cascade list and load fonts from there
lazily by checking their glyph coverage and remembering it.
2021-09-17 18:27:40 +02:00
Simon Hausmann
6130e04e84 Rework the font loading in the GL backend
The basic idea is to use fontdb's load_system_fonts() mechanism, in
conjunction with its built-in mmap support, to get an overview over all
installed fonts on macOS, Windows and Linux.

This isn't quite perfect in terms of discovering systems defaults, but
it's much faster than font-kit's approach of querying the system (good)
but reading the matched files into memory (not using mmap). And we have
the option of perfecting it by using fontconfig directly on Linux (where
the backend is most important).

This also paves the way for better fallback handling, as now we have a
list of all available families and we can use system APIs to query for
fallbacks.
2021-09-17 14:41:14 +02:00
Simon Hausmann
c86f2617b3 Fix natively styled list view item active/inactive rendering
Amends commit ed3d848d02
2021-09-15 15:39:15 +02:00
Simon Hausmann
ed3d848d02 Fix native widget rendering when the window is inactive
Set QStyle::State_Active conditional to whether the window is active,
which maps to Qt's active window concept and winit's has-focus (until we
render popups differently).
2021-09-15 15:34:34 +02:00
Simon Hausmann
1b64db70bd Fix rendering of the current tab in the natively styled tab widget on macOS
It was impossible to see which tab was the current tab.
Ensure that we set State_Active, like we do for the other styled controls.

Later, the active state should be tied to whether the window is "active" or not.
2021-09-15 13:35:41 +02:00
Simon Hausmann
85a46c07b7 Fix panic when using height-for-width element in natively styled TabWidget
The metrics properties and the implementation of layout_info needs to
strictly reading cross-axis properties to avoid circular dependencies.

This patch applies a INT_MAX / 2 on the cross-axis to QStyle when
querying. Mostly the styles appear to just add/subtract margins, so this
value should not produce overflows while still providing an
approximation of "infinite" :)

Fixes #412
2021-09-14 10:05:15 +02:00
Simon Hausmann
37464a45c5 Fix rustdoc build in the CI
The nightly has become a bit more picky about seemingly unused variables
:-)
2021-09-13 14:19:17 +02:00
Simon Hausmann
011a9ffb83 GL backend: Prospective fix for panic when trying to create window with AMD GL driver
The srgb workaround from commit a0e827e200
appears to work with the AMD GL driver, without which the GL context
creation works (as tested by the reporter).

So instead of panicing, fall back to the glutin default with possibly an
srgb framebuffer, when trying to create a GL context. If that also
fails, provide a better error message than "called unwrap on an err".

cc #481
2021-09-09 11:53:19 +02:00
Simon Hausmann
1fd8c7236a Make it possible to disable the GL backend in the CMake build
Even if SIXTYFPS_BACKEND_GL is set to OFF, we would default to enabling
X11, which translates to enabling the x11 feature, which in turn
implicitly activates the GL backend. In addition, the interpreter Rust
API crate also enables the GL backend in its defeaults.

In order to make it possible to turn off the GL backend, three changes are necessary:

* The default backend no more selects a default :-). Instead the Rust
  API crate, Rust interpreter API crate and the CMake project define
  the same features and defaults.
* The C++ crate depends on the interpreter without its defaults (which enable GL)
* In CMake the X11 and Wayland features become dependent options, that
  are only show in the CMake configure UI if the GL backend is enabled.
  This way a GL-disabled build won't also pass --features x11.
2021-09-08 17:13:10 +02:00
Simon Hausmann
df4e06be98 GL backend: render the cursor also for an empty text input if requested 2021-09-07 11:33:28 +02:00
Simon Hausmann
c142cd61b3 Janitor: bump usvg and resvg once more :) 2021-09-07 08:38:40 +02:00
Simon Hausmann
9a947553b7 Janitor: Bump glow and femtovg versions
femtovg also brings in the same glow version, so no duplicates here
2021-09-07 08:33:37 +02:00
Olivier Goffart
cbf22d494e TextEdit 2021-09-06 21:52:12 +02:00
Simon Hausmann
8b5e29534f Upgrade fontdb
The new version splits the mmap feature out of the fs feature.
2021-09-06 15:41:52 +02:00
Olivier Goffart
56200fe296 Fixup previous commit 2021-09-06 14:59:19 +02:00
Olivier Goffart
b8c586e96e Qt backend Properly rebuild the c++ source code on changes 2021-09-06 14:58:27 +02:00
Simon Hausmann
dd043fc51b Fix texture caching for images with the same source but different image-rendering properties
As tests/cases/examples/image_rendering.60 itself demonstrates, the png file
should be loaded into the CPU side image cache once, but the two textures
should be cached independently.

cc #465
2021-09-06 13:47:41 +02:00
Simon Hausmann
71cd4bb3f0 GL backend: clean up of window map state handling
Use std::cell:Ref/RefMut to reduce the indentation and make it easier to
see where the borrow occurs.
2021-09-06 13:15:06 +02:00