Olivier Goffart
fff024731b
Don't pass Pin by reference
...
(consistant with other method in that trait)
2021-01-14 11:54:17 +01:00
Simon Hausmann
42a5a62fb5
Fix rendering of image elements without specified width/height
...
Fall back to the source image dimensions like the old renderer
2021-01-14 08:53:14 +01:00
Olivier Goffart
a069ceae7f
Fix warning with wasm
2021-01-14 08:53:14 +01:00
Simon Hausmann
de67b865dc
Implement basic font fallbacks for WASM and macOS
...
Our demos use some symbols such as the back arrow and the ugly style
uses a down arrow for the combo box. These symbols are not in Roboto and
also not in the default font font_kit gives us on macOS.
Therefore for WASM we switch over to DejaVu, which is bigger than
Roboto.
For macOS this patch implements rudimentary fallback list generation
using CTFontCopyDefaultCascadeListForLanguages. This needs further work
to respect the locale and correctly translate styles - eventually this
should go into font-kit.
A general aspect with the font fallback handling is that femtovg doesn't
support on-demand loading yet. Instead it uses owned_ttf_parser, so
every font will be read entirely off disk. That's why for macOS we trim
the list. We could perhaps do the analysis ourselves.
Linux and Windows are to follow.
2021-01-14 08:53:14 +01:00
Simon Hausmann
cd1ef1c80e
Simplify fontdb handling
...
`with_face_source` falls back to memmap and provides a nicer interface
2021-01-14 08:53:14 +01:00
Simon Hausmann
f4d3395f61
Prepare for font fallback lists
...
Separate GLFont from GLFontMetrics, the latter being as light as keeping
primarily the request around (and canvas), the former holding the list
of font resolution.
2021-01-14 08:53:14 +01:00
Olivier Goffart
fa3d26fea8
Make the fallback to GL when Qt is not available work
2021-01-14 08:53:14 +01:00
Olivier Goffart
44e279382f
Qt backend: fix tests
2021-01-14 08:53:14 +01:00
Olivier Goffart
21c2100f8d
Fix warnings
2021-01-14 08:53:14 +01:00
Olivier Goffart
2231711cf9
Qt text backend: draw the TextInput
2021-01-14 08:53:14 +01:00
Simon Hausmann
653fa491d9
Fix sub-image rendering
...
* Fix passing the correct source clip rect (width and height were missing)
* Adjust to nanovg's image rendering model where the image is basically
a patter underneath the path rendered. So for a sub-image
we need to offset the image pattern and scale the pattern and the path.
2021-01-14 08:53:14 +01:00
Simon Hausmann
1c8ab9829c
Minor cleanup in GLFont's paint creation
2021-01-14 08:53:14 +01:00
Simon Hausmann
b79e4180c8
Rename trait Font
to trait FontMetrics
...
This name more closely resembles the functionality it provides.
2021-01-14 08:53:14 +01:00
Olivier Goffart
62150cba1a
Basic text input
2021-01-14 08:53:13 +01:00
Olivier Goffart
f396c1749f
Qt backend: Don't cache the font
...
Not necessary after all
2021-01-14 08:53:13 +01:00
Olivier Goffart
61e6e9cf74
Qt backend: Actually fix border drawing
2021-01-14 08:53:13 +01:00
Olivier Goffart
55da32c343
Qt backend: fix border rectangle of the checkbox in the slide puzzle
2021-01-14 08:53:13 +01:00
Olivier Goffart
705c3f6ec0
Qt Backend: enable anti-aliasing
2021-01-14 08:53:13 +01:00
Olivier Goffart
b0d89d5fd7
Qt backend: font cache
2021-01-14 08:53:13 +01:00
Olivier Goffart
12e954ad03
Qt backend: properly clear the cache
2021-01-14 08:53:13 +01:00
Olivier Goffart
00f165f6ed
Qt backend: cache images
2021-01-14 08:53:13 +01:00
Olivier Goffart
84c7b28256
Decouple the ItemRenderer from QPainter so it can hold a cache
2021-01-14 08:53:13 +01:00
Simon Hausmann
21bd79c1b7
Prospective C++ build fix
...
Include <memory> for std::unique_ptr
2021-01-14 08:53:13 +01:00
Simon Hausmann
e74159f993
Fix license header check
2021-01-14 08:53:13 +01:00
Simon Hausmann
6b300ab194
Use the latest release of femtovg
2021-01-14 08:53:13 +01:00
Simon Hausmann
98162e6325
Implement image fitting
...
Based on the old renderer code
2021-01-14 08:53:13 +01:00
Simon Hausmann
6c24a98036
Unify image drawing functions
2021-01-14 08:53:13 +01:00
Simon Hausmann
30bc16db73
Avoid possible leaks when loading html images and then destroying the window
...
Keep weak references to the canvas, etc. for the DOM closure
2021-01-14 08:53:13 +01:00
Olivier Goffart
0b20d13401
Qt backend: Implement register_application_font_from_memory
2021-01-14 08:53:13 +01:00
Simon Hausmann
54ae1310af
Add support for loading remote images for wasm builds
2021-01-14 08:53:13 +01:00
Olivier Goffart
e77872c775
Let Qt handle all the highdpi thing, and don't borther within SixtyFPS
...
This is less than ideal, because the phx unit has no meening anymore.
Eventually we will want to do that right
2021-01-14 08:53:13 +01:00
Olivier Goffart
754020d999
Qt backend: Popup menu
2021-01-14 08:53:13 +01:00
Simon Hausmann
3dba030243
Fix wasm build
...
This re-enables the wasm port through femtovg's wasm support. The Roboto
is included as a generic fallback font.
2021-01-14 08:53:13 +01:00
Olivier Goffart
10dffa7d79
Use the QPainter directly when using the Qt paint engine
2021-01-14 08:53:13 +01:00
Olivier Goffart
46dbb1ee9e
By default, enable the GL backend also on desktop
...
So it can be chosen with an env variable or if Qt is not available
2021-01-14 08:53:13 +01:00
Olivier Goffart
58904f1858
Revert "Switch to a released version of femtovg"
...
This reverts commit cce8fb8c3863eb9b734e0a6755ebec9fd72dc895.
The version 0.1.0 of femtovg brings an old version of harfbuzz_rs
which brings a conflicting version of freetype with font-kit
2021-01-14 08:53:13 +01:00
Simon Hausmann
930ef429ef
Removed unused crate dependencies
2021-01-14 08:53:13 +01:00
Simon Hausmann
66a34cede9
Switch to a released version of femtovg
...
Only the wasm build will require a git version for now, which we'll patch.
2021-01-14 08:53:13 +01:00
Simon Hausmann
8c23155cae
Implement text selection drawing
2021-01-14 08:53:13 +01:00
Simon Hausmann
cdfc36e881
Fix clicking into text input to place the cursor
...
Implement text_offset_for_x_position
2021-01-14 08:53:13 +01:00
Simon Hausmann
743bcc77f6
Render text inputs and cursors
...
The selection is still missing
2021-01-14 08:53:13 +01:00
Simon Hausmann
cb972402e7
Fix rendering of rectangles with large borders
...
Constrain the border width by the rectangle to avoid that the border
would cancel itself out when too big.
This fixes most of the checkbox rendering in the slide puzzle.
2021-01-14 08:53:13 +01:00
Olivier Goffart
7bd1fb9ec8
Silence warning
2021-01-14 08:53:13 +01:00
Olivier Goffart
1ea522a7d0
Qt backend: Make the animation not take 100% CPU
2021-01-14 08:53:13 +01:00
Olivier Goffart
7dfc43977f
Qt backend: animations
2021-01-14 08:53:13 +01:00
Olivier Goffart
118d40d9e9
QtBackend: Timer
2021-01-14 08:53:13 +01:00
Olivier Goffart
7b4c600a4f
Fix compilation after rebase
2021-01-14 08:53:13 +01:00
Olivier Goffart
d4c357195d
Qt backend: make clicking on a TextInput not panic
2021-01-14 08:53:13 +01:00
Olivier Goffart
1eac260d99
Qt Backend: font size fixes
2021-01-14 08:53:13 +01:00
Olivier Goffart
d71bb9ab84
Qt backend: Image rendering
2021-01-14 08:53:13 +01:00