Commit graph

122 commits

Author SHA1 Message Date
Olivier Goffart
3983e47720 Fix initial window size 2021-05-18 16:55:07 +02:00
Olivier Goffart
fbdbe69fe7 Window: make hight and width fixed size, preferred-* property set the initial size
Issue #227
2021-05-18 10:23:06 +02:00
Olivier Goffart
987f4666b8 Fix Qt6 build 2021-05-14 14:02:43 +02:00
Simon Hausmann
5b9d64b26e Fix failing assert in QFont with the printer demo
We use a weight of 900 in the demo, which results in a QFont::Weight of 100.
Unfortunately QFont::setWeight() doesn't cap itself, but brutally asserts
if the value is > 99. So let's cap ourselves.
2021-05-14 09:25:47 +02:00
Simon Hausmann
290759cf16 Fix Qt build
Amends ea358d9b2c
2021-05-12 22:06:39 +02:00
Olivier Goffart
7b2653db23 MouseWheel support for the Flickable
cc #222
2021-05-12 13:28:39 +02:00
Olivier Goffart
5f74475224 Refactor the MouseEvent 2021-05-12 12:03:03 +02:00
Olivier Goffart
720001a223 Remove the solve_layout from the component vtable
no longer required
2021-05-11 14:59:57 +02:00
Olivier Goffart
a4b31fbe2e CI: -W was not enough to override the -D, use -A instead
Also fix a warning about the usage of std::any::Any without dyn
2021-05-06 19:03:52 +02:00
Olivier Goffart
0bb61cc1b3 Fix popup placmement and size with the qt backend 2021-04-26 17:29:06 +02:00
Olivier Goffart
6fe2c1fa56 Prevent the maximum size to be set to 0,0
Otherwise the window will disapear and will never be seen again

This is a mitigation for #194
2021-04-23 13:10:53 +02:00
Olivier Goffart
2e09a58fd7 Use the qttypes crate 2021-04-20 12:41:44 +02:00
Simon Hausmann
6d7f8b6bab Fix handling of border width for clip in the GL backend
Similar to commit 48e6d2f48b, share the rect adjustment
code between the rectangle drawing code and the clipping.
2021-04-15 15:43:49 +02:00
Olivier Goffart
3bf3761450 Implement the Opacity filter.
Notice that the GL implementation currently don't combine the opacity
2021-04-15 10:17:52 +02:00
Simon Hausmann
48e6d2f48b Fix handling of non-zero border width in clip-enabled Rectangles
The border should be visible (as in the included test case), which this
patch fixes for Qt by subtracting the border width just like when drawing.
2021-04-14 13:34:51 +02:00
Simon Hausmann
47a255eea5 Further preparation for more aggressive font caching
Pass everything needed for delayed evaluation for
`PlatformWindow::font_metrics()` to permit caching the font matching
result in the Text/TextInput's rendering cache.
2021-04-13 15:30:33 +02:00
Simon Hausmann
a48b81022b Prepare for font caching in text items in the GL renderer
We query text metrics frequently for text items, for example when in
layouts. This requires font resolution, which is about to become more
much more expensive due to analysis of the underlying text. To speed
this up, the objective is to use the item rendering cache. Making that
work in turn requires querying all related properties inside a property
tracker. That means we need to delay querying anything related to that,
including the font request needed for the `font_metrics()` function on
the PlatformWindow trait.
2021-04-13 15:02:57 +02:00
Simon Hausmann
f42d759131 Remove dead code
The height method on FontMetrics is not needed anymore. We call `text_size` nowadays.
2021-04-13 11:26:26 +02:00
Simon Hausmann
a792b52515 Load custom fonts from disk only once with Qt
Amends commit 4cf3fa5179
2021-04-13 10:53:21 +02:00
Olivier Goffart
1773f9143b Add a border-radius property to the Clip
So that `clip: true` used on a Rectangle with border radius can be clipped
with that radius

Only the Qt backend is implemented for now
2021-04-12 19:47:18 +02:00
Olivier Goffart
cdcf0faa5f Set the size to the Window element when it is shown, when the size would otherwise be empty 2021-04-08 08:46:08 +02:00
Simon Hausmann
418bc2f62c Fix printer demo showing garbage after live preview update
The component layout needs to be re-calculated. For some reason it is with
the Qt backend but not with GL.
Either way we can force it to re-calculate when the component changes.
It possibly doesn't get dirty when the dependencies are deleted.
2021-04-06 23:03:56 +02:00
Simon Hausmann
e7cde00113 Partial window properties update for the winit window
Remove the intermediate properties for width and height and - just like
qt backend - apply the width and height in apply_window_properties
and when receiving a window resize event.

This also elimiates the get_geometry() getter as that would otherwise just
have been a FIXME'ed default().
2021-04-06 22:47:30 +02:00
Simon Hausmann
4cbcf2611f Fix recurring C++ timers
* sixtyfps_timer_start needs to *take* the timer id out of the Rust
  timer to avoid that the subsequent drop stops the timer again
* For the Qt event loop, call `timer_event()` once before entering
  QCoreApplication::exec(), to schedule any timers that were started
  beforehand.
* Added a way to quit the event loop gently, in order to use that
  from the C++ unit test.
2021-03-25 20:07:12 +01:00
Simon Hausmann
b875a19310 Implement redraw handling lazily
Similar to the window properties, use a property tracker with a change
handler in window to issue redraw requests. This allows eliminating the
forced repaints in the event loop after event processing and ensures
that the UI is repainted when programmatically setting a property, for
example.
2021-03-25 16:33:54 +01:00
Simon Hausmann
c9f4c17665 Implement window property synchronization lazily
Synchronize title/background/etc. once when the window is mapped and
afterwards lazily when the corresponding property tracker notifies us.

Since that callback can happen at any point in time and to also capture
potentially multiple changes, this first triggers a wakeup of the event
loop, when the actual application of properties happens.
2021-03-25 16:33:54 +01:00
Simon Hausmann
3bd5b0eadf Add support for recursive dependency tracking across PropertyTracker instances
By default PropertyTracker::evaluate() registers the currently
evaluating binding/tracker as a dependency. This should help with
repeaters and other scenarios where in the run-time we use property
trackers but want to track the overall "dirtyness" in the window with
regards to whether a redraw is needed or not.

The new evaluate_as_dependency_root() function allows skipping this
mechanism and is used for the two trackers in the window.
2021-03-25 12:29:19 +01:00
Simon Hausmann
e63baa5766 Re-organize Window and PlatformWindow construction and referencing
Initialize the self_weak in the PlatformWindow impl using the
Rc::new_cyclic pattern with a construction parameter.
2021-03-25 09:43:59 +01:00
Olivier Goffart
4ee0a02366 Tell Qt that the widget can get the focus
Usefull when the widget is embedded in a Qt application
2021-03-24 12:16:51 +01:00
Olivier Goffart
1dba04721a Add a qt_viewer example that uses QWidget 2021-03-23 17:13:41 +01:00
Olivier Goffart
6f88d78303 Rename Resource to ImageReference in the runtime 2021-03-11 10:06:23 +01:00
Olivier Goffart
89bbdce88e Polish a bit the Brush API 2021-03-10 16:54:33 +01:00
Olivier Goffart
6f715c5612 Don't call render for items outside of the clip rects 2021-03-05 13:05:02 +01:00
Simon Hausmann
27bdb4d481 Added Window.default-font-family
One step towards getting rid of `DemoText` in the printer demo
2021-03-02 13:25:21 +01:00
Simon Hausmann
7cea088a2c Add support for letter-spacing in text
This is conveniently supported by femtovg and Qt
2021-02-16 22:14:50 +01:00
Olivier Goffart
15e0112d2d Qt: Fix image-fit of colorized image
Since colorize property force the native item to be a ClippedImage, it had
a source rectangle, despite with and height defaulting to 0 and therefore
having an empty source rect would cause the scaling to not be right
2021-02-16 10:10:30 +01:00
Olivier Goffart
ed1fc31b84 Put the window background color in the StyleMetrics
And make use of Window::background in Qt
2021-02-15 15:57:58 +01:00
Olivier Goffart
deea260eac Fix image-fit in the Qt backend
Only scale the loaded image for image format that make sense (ie: svg)
and when doing that, keep the aspect ratio
2021-02-15 12:10:43 +01:00
Simon Hausmann
fd5757bc44 Simplify coordinate handling for item rendering
Remove the pos parameter to the render functions and instead let
the item renderer apply the transformation on the rendere (femtovg
canvas or QPainter).

So `draw_*` functions in the backend now always operate in item local
coordinates.
2021-02-12 17:12:58 +01:00
Simon Hausmann
b5095e9729 Fix source scaling detection for the Qt backend
ClippedImage without a source rect or one that's identical to the target should also allow for source scaling
2021-02-10 21:33:04 +01:00
Simon Hausmann
f704e4c823 Implement rendering SVG with specified size
Relates to #129
2021-02-10 21:08:58 +01:00
Simon Hausmann
8a66af0746 Clean up image size determination in the rendering backend
Don't use the item's rendering cache to determine the image size, as
that's soley for rendering. The Qt backend doesn't use the item cache
and the GL backend neither after this change. Instead both backends have
a cache for decoded images.
2021-02-10 17:34:29 +01:00
Simon Hausmann
2dd5ea61bb Add support for Path.fill-rule
For some reason it's not working with the Qt renderer though
2021-02-10 14:08:32 +01:00
Olivier Goffart
9db575952d Fix bold font with Qt
Qt expect a font between 0 and 99.
This is the mapping somehow used for QFont::Weight enum
2021-02-09 10:59:11 +01:00
Olivier Goffart
f7a76dc352 Add ImageFit::cover, and fix ImageFit::contain 2021-02-09 10:52:04 +01:00
Olivier Goffart
743d729ecb Silent warning 2021-02-04 18:15:06 +01:00
Olivier Goffart
0e2471f76b Image::colorize support
(Qt only)
2021-02-04 17:44:01 +01:00
Simon Hausmann
3f541972ef Change Rectangle::border-color to be a brush
This allows things like filling a thick border with a gradient.
2021-02-04 17:05:00 +01:00
Simon Hausmann
1a9419638d Change the type of the color property for Text and TextInput to be a brush
This allows filling glyphs with gradients. However femtovg
appears to apply the start/end position per-glyph
instead of globally - resulting in a different result than Qt.
2021-02-04 11:54:57 +01:00
Simon Hausmann
d92c8cab23 Fix path fitting
Include the stroke width in the boundaries when fitting a path into the
size of a `Path` element.
2021-02-04 09:09:23 +01:00