Commit graph

544 commits

Author SHA1 Message Date
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
Olivier Goffart
ce93bf0856 Update some dependencies 2021-04-07 13:47:01 +02:00
Olivier Goffart
24cb910e83 GL: Don't set the windows size if it is empty.
The Qt backend already has a test for that
2021-04-07 13:05:35 +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
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
Simon Hausmann
b81803774b Start the LSP thread when the gui thread is ready
This way we can serve preview requests immediately.

This basically makes post_event safe to call before the event loop is entered.
The events will be queued up and sent when the event loop
is created and we have access
to the proxy, which will take over the queue.
2021-04-06 11:40:17 +02:00
Olivier Goffart
723b39c59a Wasm don't have threads anyway, so don't create a GLOBAL_PROXY that needs to be sync 2021-04-04 16:58:26 +02:00
Olivier Goffart
d76ee8371f Fix warning when Qt is not built 2021-04-03 10:23:41 +02:00
Olivier Goffart
309a9274e1 LSP: preview window
Currently not yet live preview from the open document content, but that should totaly be doable
2021-04-03 10:00:12 +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
Simon Hausmann
b654646722 Change the window property update event to use a window id
This will hopefully enable the custom event to be sendable across threads.
2021-04-02 12:00:32 +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
d829a18ddd Don't link the qt backend with winit
(this was also brigning in all the wayland dependency so it should save compile time)
2021-03-24 09:51:05 +01:00
Olivier Goffart
1dba04721a Add a qt_viewer example that uses QWidget 2021-03-23 17:13:41 +01:00
Olivier Goffart
41c6c79bc1 Better name for the femtovg feature
Just use the name of the crate, i believe this is the convension
2021-03-19 09:48:19 +01:00
Simon Hausmann
6de1c4e3b5 Use the new femtovg release instead of pinning to a sha1 2021-03-18 16:56:00 +01:00
Simon Hausmann
f5fb0bf297 Prospective Qt linkage fix for macOS
Try adding an LC_RPATH command to the cdylib that we're building (for example libsixtyfps_cpp.dylib),
to fix linkage against Qt, which uses `@rpath/QtCore.framework/XXX` for inter-library linkage dependencies.
2021-03-17 14:02:33 +01:00
Olivier Goffart
35cce45cbc Add a fii feature so that we don't compile in the ffi code if not required 2021-03-16 18:09:57 +01:00
Olivier Goffart
0e351de1a6 Create a new crate to expose the C++ 2021-03-16 16:34:02 +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
f4059ab3cf Fix wasm build 2021-03-02 13:55:34 +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
f087cc18bc Remove extern "C" functions from wasm module
We don't need these functions and their export. They account for ~20kb in
the optimized .wasm - plus JS glue code.
2021-02-26 17:04:49 +01:00
Simon Hausmann
1b870959e6 Use the Noto fonts from the C++ build of the printer demo
This adds API to register a font by path from C++
2021-02-22 11:17:39 +01:00
Simon Hausmann
d5d537b1ce Remove redundant to_string() call 2021-02-17 15:28:58 +01:00
Simon Hausmann
3ba92bdc6d Add API to the wasm interpreter to download and register fonts 2021-02-17 15:21:30 +01:00
Simon Hausmann
445ddd58d5 API cleanup
Remove the `application` infix from `register_application_font`, to
reduce the changes that it might be interpreted to be a function that
also changes the default font in all text elements.
2021-02-17 14:37:31 +01:00
Simon Hausmann
f7ab4625e4 Prospective build fix
Use the same to_string_lossy() code path on all platforms
2021-02-17 14:32:02 +01:00
Simon Hausmann
45fe6c3e8d Add the ability to load application fonts by path
The viewer command line tool also gains the ability to specify them via `--app-font=/path/to/font.ttf` , which can be specified multiple times.
2021-02-17 14:16:52 +01:00
Simon Hausmann
999145e7d3 Fix non-macOS build 2021-02-16 22:36:37 +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
05736c7803 GL: Fix rendering of scaled SVG for which height > width
We would not allocate a buffer big enough for it.
2021-02-16 10:42:13 +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
c4e7e38590 Workaround the fact that femtovg needs to explicitly set Hole or Solid
the actual wining is lost
2021-02-16 00:20:25 +01:00
Olivier Goffart
c7723a237b GL colorize
reset properly the canvas state (such as the clip and so on)
and rotate the image otherwise it is painted upside down
2021-02-15 21:00:39 +01:00
Olivier Goffart
1a9267aebe Some debugging aide 2021-02-15 20:15:35 +01:00
Simon Hausmann
a61bbb25b7 Fix colorizing images when transformations are in play
When painting intermittendly on the image for colorization, reset the
transformation on the canvas.

Amends commit fd5757bc44
2021-02-15 20:13:47 +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
799b3b16b1 GL backend: Fix clipping with transformations applied to the canvas
After commit fd5757bc44 we now need the
upstream fix to `intersect_scissor` for clipping to work
in flickable.

So patch upstream master in for now.
2021-02-15 11:17:14 +01:00
Olivier Goffart
a71edafa33 Refactor the way the mouse events are processed
Have a function first called before the children, and then the main function
called after the children if they did not accept the event.  This will allow
processing the Flickable gesture properly
2021-02-12 20:47:59 +01:00
Simon Hausmann
abe95688b9 Avoid re-parsing SVG images when scaling in the GL renderer
This isn't quite 100% clean but keeping a reference to the original svg tree
is maybe a reasonable compromise for now.
2021-02-12 18:59:02 +01:00