Commit graph

147 commits

Author SHA1 Message Date
Simon Hausmann
9ca87ab312 Simplify KeyEvent
Fold CharacterInput into KeyPressed/KeyReleased and store the "key" as a string.

Also, instead of exposing the KeyCode we're encoding special characters
into the string.
2021-01-22 10:15:05 +01:00
Olivier Goffart
db740831ee Fix warning about unused imports 2021-01-21 18:35:59 +01:00
Olivier Goffart
3340730ff7 Use lyon to convert to path to QPainterPath or femtovg::Path 2021-01-21 13:21:03 +01:00
Olivier Goffart
0fe5c535c1 Use text_size instead of text_width in FontMetrics
So that multi-line text can work
(At least it magically works with Qt)
2021-01-19 10:17:12 +01:00
Simon Hausmann
5f265ffc09 Split up ComponentWindow::run() into show(), hide() and sixtyfps::run_event_loop()
This allows creating multiple windows for example, and it will allow for
showing windows in those tests that require a mapped window.

As a bonus, the run() function on generated components is not consuming
anymore.
2021-01-19 09:50:22 +01:00
Simon Hausmann
003fdb2564 Fix property dependency chain for Image::implicit_size()
The GL backend uses the item graphics cache for the image size function,
which uses a PropertyTracker. That tracker must have the Image's source
included in its dependencies, to avoid that when loading a HTML image
for example, the cache isn't invalidated when the source is changed
before the HTML image was loaded async. That's why the get() call on the
source property must happen from within the PropertyTracker's callback.
2021-01-18 08:50:41 +01:00
Simon Hausmann
f5626eb163 Use QPixmap instead of QImage for image drawing
Compared to QImage::load(path), QPixmap::load(path) has the advantage
of using Qt's internal QPixmapCache, which will avoid repeated decoding of
images.
2021-01-17 11:42:45 +01:00
Olivier Goffart
2d7817e049 Rename GenericWindow -> PlatformWindow 2021-01-15 18:32:55 +01:00
Simon Hausmann
94c1d884ba Allow specifying 0/0 as width/height of an image
With the support for a default binding to width/height on the implicit
size, we can now revert commit 42a5a62fb5.
2021-01-15 17:58:32 +01:00
Simon Hausmann
77b5a86168 Add an implicit size to text and image items
For all other items the default is the empty size.

This also required three fixes for the HTML image loading:

  * The upload_pending property value was inverted, it needs to start
    out as true (pending yes) and be set to false when it finished
    loading (not pending anymore)
  * Mark the upload_pending property as dirty before scheduling the
    redraw, in case it's sync
  * Pass the item rendering cache to the image_size function to ensure
    that the Rc<CachedImage> is not only weak inside the image_cache
    of the GLRendererData but also strong on the item.
2021-01-15 17:56:49 +01:00
Olivier Goffart
43b04f438c Fix Qt backend accessing the component 2021-01-15 16:27:42 +01:00
Olivier Goffart
cb0a21115f Remove set_width/height from GenericWindow trait 2021-01-15 15:12:12 +01:00
Olivier Goffart
dcb347fb7b Move more functions from the GenericWindow to the Window 2021-01-15 15:02:55 +01:00
Olivier Goffart
0ab60dff81 continue Window refactoring. Remove a few function from GenericWindow 2021-01-15 15:02:55 +01:00
Olivier Goffart
f1ce103c7b WIP: start splitting Window and PLatformWindow 2021-01-15 15:02:55 +01:00
Olivier Goffart
9741b56e30 Start implementing path with the Qt backend
(WIP)
2021-01-14 13:22:53 +01:00
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
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
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
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
Olivier Goffart
10dffa7d79 Use the QPainter directly when using the Qt paint engine 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
Olivier Goffart
7d91651b48 Qt backend: input events 2021-01-14 08:53:13 +01:00
Olivier Goffart
4aa9faf532 Qt backend: border rectangle 2021-01-14 08:53:13 +01:00
Olivier Goffart
aeb67fa927 Qt backend: Resize event and layouting 2021-01-14 08:53:13 +01:00
Olivier Goffart
531ff42973 WIP: Qt backend using Qt 2021-01-14 08:53:13 +01:00