Commit graph

1092 commits

Author SHA1 Message Date
Olivier Goffart
720001a223 Remove the solve_layout from the component vtable
no longer required
2021-05-11 14:59:57 +02:00
Olivier Goffart
8da6c8cdb3 Lower PathLayout
As part of the layout refactoring, most of the path layout lowering
was gone. Add it back
2021-05-11 14:59:57 +02:00
Olivier Goffart
11158fa922 Remove implicit_size from the Item vtable
Use the preferred size in the layouting_info instead.
2021-05-11 14:59:57 +02:00
Olivier Goffart
81473c2541 Remove implicit_size from the Item vtable
Use the preferred size in the layouting_info instead.
2021-05-11 14:59:57 +02:00
Olivier Goffart
f06bf8d5a7 Fix repeater in box layout 2021-05-11 14:59:57 +02:00
Olivier Goffart
b463e3cca4 WIP refactor layout
This commit add support for the box layout
2021-05-11 14:59:57 +02:00
Olivier Goffart
21a80f4562 WIP: Layout refactoring
Instead of using a solve_layout function in the component, use property to hold
a layout cache.

This commit only implement the GridLayout and only the interpreter part
2021-05-11 14:59:57 +02:00
Simon Hausmann
9ff3b01b54 Remove doc comment that failed to contain the type name
Can't use concat! yet in doc attributes, so it looks strange with $ty.
2021-05-11 09:43:14 +02:00
Simon Hausmann
5d6c8e7ee1 Make the export of the vtable getter functions conditional
We only need the create these getter functions and export them on Windows
for ffi enabled builds.
2021-05-11 08:03:50 +02:00
Simon Hausmann
c84e6d2945 Export getter functions for all item vtable implementations 2021-05-10 22:54:06 +02:00
Olivier Goffart
9e6970abfe ListView: Fix panic when removing item that are not visible 2021-04-27 16:37:17 +02:00
Olivier Goffart
576eb116e8 Make the is_dirty flag a property so that changing it will force a repaint 2021-04-27 11:05:35 +02:00
Simon Hausmann
30ffe731b2 Bump femtovg and remove the patch 2021-04-27 11:01:47 +02:00
Olivier Goffart
76befb63a3 Fix the dependency tracker not registering a dependency if it was not dirty
Also fix opening/closing the popup should refresh the window
2021-04-26 15:24:48 +02:00
Olivier Goffart
c9c0f8d638 Fix useless dependency on the animation tick
This was causing the Qt backend to redraw parmanently
2021-04-26 15:24:48 +02:00
Olivier Goffart
3380383787 Bump version number
(Does not include docs and README yet)
2021-04-26 13:16:48 +02:00
Olivier Goffart
37f5cf5ce7 Fix the text being cut of in some cases 2021-04-26 11:28:37 +02:00
Olivier Goffart
1f64f7ab27 Also set the preferred size for the GridLayout
Issue #182
2021-04-21 18:56:28 +02:00
Olivier Goffart
74e0a98105 Adapt the GL backend to the logical/physical pixel changes 2021-04-21 17:44:53 +02:00
Olivier Goffart
302867d865 Attemt to speed up compilation times
According to llvm-lines, MaybeAnimatedPropertyInfoWrapper::set_binding was
in the top 5 of functions with 15971 lines over 46 copies.
Split the code that does not depend on the Item parameter in a different function
2021-04-18 12:21:09 +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
Olivier Goffart
ba2f2d5719 Add an Opacity element that does nothing 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
6a1191c5a5 Add Window.default-font-weight
This completes the font properties that can be set as default.
2021-04-14 11:16:22 +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
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
f3da9532d7 Remove left over debug output 2021-04-12 13:05:00 +02:00
Olivier Goffart
af8be46019 Interpolation between gradients for the animations 2021-04-12 12:33:15 +02:00
Olivier Goffart
d7ae574d9a Fix clipping of Clip of empty size 2021-04-09 20:43:14 +02:00
Olivier Goffart
7589a301f2 The stretch factor for the Flickable should be 1 2021-04-09 19:14:48 +02:00
Simon Hausmann
7c1738eeea Fix height of image in horizontal layout
Commit 843f52b3c5 erroneously applied the cross-axis
preferred size, which breaks the
images in buttons in the printer demo.

Also use the same value for shrink as for flex-grow, as advised by Olivier :-)
2021-04-08 15:09:35 +02:00
Simon Hausmann
843f52b3c5 Implement preferred size for images in box layouts
This partially implements #168 as well as #182
2021-04-08 12:06:42 +02:00
Olivier Goffart
fb4f955302 Fix angle within gradients
line_for_angle takes a value in degrees, but the sin and cos are expected to be in radians
2021-04-07 18:31:13 +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
d05894abde Minor cleanup in Window::set_component
Setting the redraw and window_properties tracker dirty won't have an
effect by itself, as nobody is tracking them in turn nor is any code
checking is_dirty(). Instead both trackers use callbacks to send events
(redraw or prop update), and so we can do these by hand with the already
existing request_redraw() call and the additional
request_window_properties_update() one.
2021-04-06 22:43:03 +02:00
Simon Hausmann
ac0d15da6a Fix PropertyTracker::set_dirty() when nesting 2021-04-06 19:14:30 +02:00
Simon Hausmann
b818fd6761 Fix crash with nested property trackers
After commit 3bd5b0eadf the trackers register themselves,
so on Drop they also need to unregister.
2021-04-06 19:07:54 +02:00
Olivier Goffart
de6d35bfbe Request a redraw when the component change 2021-04-06 14:15:11 +02:00
Simon Hausmann
1e4921de13 Fix LSP server staying alive when closing preview window
* Provide an internal behavior parameter to run_event_loop() that we can use
from the preview to not quit when the last window was closed.
* Fix Drop for the winit event loop GraphicsWindow to drop the backend window correctly
  when unmapping, not when the graphics window dies. Otherwise QuitOnLastWindowClosed doesn't work.
2021-04-06 12:11:55 +02:00
Olivier Goffart
c3046f5a55 Add a way to send an event to the GUI thread from any thread
The idea is that the callback is meant to be run in the gui thread

(untested)
2021-04-03 10:00:12 +02:00
Olivier Goffart
162944b8c9 Add ability in the interpreter to re-use an existing window 2021-04-03 10:00:12 +02:00
Simon Hausmann
477729da52 Improve brush property test coverage
Test that assigning colors works:

* Test the implicit `Brush(const Color &)` C++ constructor
* Add derive_more::From to allow convenient conversion in Rust
* When assigning to brush properties in JavaScript, try at least to see if it's a color string (could be extended in the future)
2021-04-01 08:27:10 +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
a05bcc206a Add support for property change handlers in PropertyTracker
A Property tracker can now be constructed with a callback that's invoked
when a property accessed during evaluate is changed.

The callback is guarded to be called only once until the tracker has
been evaluated. This is implemented by passing the information about
whether the property/tracker was already dirty before through the
mark_dirty() vtable call.
2021-03-25 12:29:19 +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