Commit graph

1092 commits

Author SHA1 Message Date
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
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
Olivier Goffart
e20dd384f5 Expose an iterator to interpreter::Struct 2021-03-17 15:29:03 +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
455693dbc0 Documentation for the interpreter crate 2021-03-16 11:24: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
16426c91b0 There is no x11 feature for corelib anymore since that is moved to the backend 2021-03-09 19:52:18 +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
b591f7de2c Add Window.default-font-size
This allows getting rid of the `DemoText` element in the printer demo
2021-03-02 13:33:43 +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
391d0152f0 Add Color::brighter/darker functions
These are exposed in .60 as well as in Rust and C++ and implemented by
converting to HSV color space and adjusting the brightness (value).
2021-02-24 10:49:27 +01:00
Simon Hausmann
b174d5aa7c Fix the minimum size of Text elements that permit elision
Fixes #179
2021-02-18 12:24:19 +01:00
Olivier Goffart
90fd7b1403 Manual implementation of Debug for Property
Helps with debugging. It is too verbose with useless info otherwise
2021-02-18 10:30:59 +01:00
Olivier Goffart
13a2138022 GridLayout: Don't divide the max cell size by the colspan or rowspan
Otherwise we end up contraining the layout too much.
The result is still wrong, but probably better. (see #42)
2021-02-17 18:59:49 +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
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
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
18cbd4427f Flickable: also have a duration threshold 2021-02-13 17:10:22 +01:00
Olivier Goffart
1f318f2d10 Use the new mouse event API for the flickable
Issue #166
2021-02-13 16:58:04 +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
500919745e Add an internal Rotate element
This is just a starting point, to be turned into a real Transform
element later, along with syntactic sugar to turn rotation, etc.  into a
transform matrix in the generated output.
2021-02-12 17:31:06 +01:00
Simon Hausmann
cb25dce6c9 Fix the build
Forgot to remove the unused reprc structure.

Amends fd5757bc44
2021-02-12 17:24: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
Olivier Goffart
81b63c3b3f Small reformating fix 2021-02-12 09:56:37 +01:00
Olivier Goffart
9eac131ae5 Add the logo in the docs 2021-02-12 08:24:42 +01:00
Olivier Goffart
096f55e365 Change behavior of percent sice within the layout
So that size with percentages don't affect the maximum/minimum size

Fixes #117
2021-02-11 20:32:26 +01:00
Simon Hausmann
92218a8b6e Add a debug log helper macro
I'm getting tired of copy & pasting temporarily the same wasm bindgen
snippet and then deleting it again,
or loosing time by accidentally using eprintln! when debugging a wasm
issue.
2021-02-11 08:50:49 +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
Simon Hausmann
57d3a34996 Prospective fix for doc errors
In the nightly it appears that `no_mangle` is now considered "unsafe",
so we need to allow that in the ffi modules. For the layout code this
patch also creates that ffi module with prefixed function names, like in
the other modules and only allows unsafe in there.
2021-02-10 11:26:28 +01:00
Simon Hausmann
0a2385ad58 Fix colorization of images loaded via HTTP
There are two problems that this patch fixes:

  * It may happen that the image is not loaded yet, which means
    we need to wait with the colorization effect instead of colorizing
    the dummy (1x1) texture.

  * It may happen that we transition from a regular image to one
    that has a valid colorization brush, in which case we need to
    invalidate the graphics item cache.
2021-02-10 09:06:09 +01:00
Simon Hausmann
2ce672bd68 Reduce dependencies
Use only specific lyon packages instead of pulling all of them in.
This slightly speeds up compilation as well as for example lyon_tesselation
doesn't need to be compiled anymore.
2021-02-09 17:22:01 +01:00
Olivier Goffart
f7a76dc352 Add ImageFit::cover, and fix ImageFit::contain 2021-02-09 10:52:04 +01:00
Olivier Goffart
2c322de46b Flickable: keep mouse grabbed while flicking 2021-02-08 17:20:48 +01:00
Olivier Goffart
7e17806aa4 Flickable: don't grab the event on mouse move 2021-02-08 17:13:51 +01:00
Olivier Goffart
f1300a7f2d Fix propagation of mouse event.
Process the event in the post visit if the children did not intercept the event
2021-02-08 14:08:14 +01:00
Olivier Goffart
8b535991ec Handle Esc in the GL backend
Issue #165
2021-02-08 09:00:09 +01:00
Olivier Goffart
d30f5138b8 Box layout: ensure max size is >= min
Fixes #160
2021-02-05 19:18:09 +01:00
Olivier Goffart
afbb537bc1 Add TouchArea::enabled
and use it in the ugly style
2021-02-05 14:21:20 +01:00
Olivier Goffart
9bdb793ec1 Rename Window::color to background 2021-02-05 09:38:40 +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
50d9211e0a Fix failing default_color.60 test
Allow converting a brush to a color. In the case of a gradient, the color of the first stop is returned.

For the C++ generator this requires adding the extra case of explicitly
calling the `Brush(const Color &)` constructor, despite it being implicit,
in order to generate the correct code when we have IR that casts twice:

```
   Expression::Cast {
       from: Expression::Cast {
           from: Expression::Cast {
               from: Expression::NumberLiteral(...),
               to: Type::Color,
           }
           to: Type::Brush,
       },
       to: Type::Color,
   }
```
2021-02-04 13:44:10 +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