Commit graph

169 commits

Author SHA1 Message Date
Simon Hausmann
628e6fdb38 Add a BoxShadow element
This intends to provide a configurable rectangular "drop shadow". The
API is modeled after CSS/HTML5 Canvas where the element can be "bound"
to an existing rectangular shape (geometry and radius), the offset can
be used to place the shadow and color and blur configure the shadow.

The shadow's color fades into transparent.

TODO (in subsequent changes):
 * Documentation
 * Qt implementation
2021-01-26 13:56:12 +01:00
Simon Hausmann
918aab667c Fix path rendering
Don't emit move() to for every relative event, as that starts a new subpath
2021-01-25 22:04:27 +01:00
Simon Hausmann
e2abdff83c
Fix path move to with Qt
Call the correct function :)
2021-01-25 21:37:26 +01:00
Olivier Goffart
5a21f1bd81 Rename emit_ to call_ for callback
Signal was renamed to Callback, but one does not emit a callback, one calls it
2021-01-25 15:59:10 +01:00
Simon Hausmann
a69ce3a397 Remove the 'align-' prefix from TextHorizontal/TextVerticalAlignment 2021-01-25 10:59:18 +01:00
Olivier Goffart
e37ac6e45f Add a documentaion on how to install Qt
And link from it from the warning
2021-01-24 14:06:14 +01:00
Olivier Goffart
86d40ad5e0 Some warning fix in the CI
- re-enable Qt for the C++ part now that the download server is back up
 - Use the proper way to set env variable on Windows
 - Silent deprecated warning for alloc::LayoutError
 - Silent warning in qt/lib.rs when Qt is not there
 - remove LD_LIBRARY_PATH workaround as the install-qt-action is fixed
2021-01-22 17:58:53 +01:00
Olivier Goffart
9eedb730d2 Fix build when Qt is not available 2021-01-22 17:11:21 +01:00
Simon Hausmann
2d5f5fb821 Fix copy & paste shortcuts with Qt
* Rename logo to the more generic meta as keyboard modifier.
* Use control as the real modifier and map command key to it with
  winit and keep Qt semantics as-is.
2021-01-22 17:06:35 +01:00
Simon Hausmann
1fcfc6cea8 Fix key event text with Qt with modifiers
With modifiers, QKeyEvent::text() might be an empty string. In that case
we have to fall back.
2021-01-22 17:04:50 +01:00
Simon Hausmann
9e0927f324 Move the clipboard access from corelib to the backend
This way the backend doesn't need to depend on copypasta.
2021-01-22 15:25:06 +01:00
Simon Hausmann
8dee095480 Minor cleanup
Clarify precedence
2021-01-22 15:21:35 +01:00
Simon Hausmann
d022dc1293 Make KeyEvent a struct
This way it's easier to expose to .60
2021-01-22 13:47:52 +01:00
Simon Hausmann
ae1178dd55 Make the modifiers simple booleans in the key event
This will give a nicer API to expose to .60. If the struct weren't
repr(C) then the booleans would be nicely packed, but alas that's not
happening. On the other hand we're not keeping many instances of them
around.
2021-01-22 13:47:52 +01:00
Simon Hausmann
886dd425fc Rename KeyEvent::KeyPress::string to text
It's the textual representation of the key
2021-01-22 13:47:52 +01:00
Olivier Goffart
916ad96ea5 Allow to disable Qt build with an env variable 2021-01-22 13:28:08 +01:00
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
4af4924567 C++: Fix cbindgen so it can process callback with arguments 2021-01-20 10:25:15 +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
d65a655333 Fix Wasm build error and warnings 2021-01-15 15:23:17 +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
547b2a7f6e Introduce Backend trait
Such that the font are properly registered when the GL backend is chosen at runtime
2021-01-15 12:20:32 +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
a069ceae7f Fix warning with wasm 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