Commit graph

331 commits

Author SHA1 Message Date
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
Olivier Goffart
2edf247023 Rust: fix compilation when using bindings in global 2021-02-16 15:16:01 +01:00
Olivier Goffart
9eac131ae5 Add the logo in the docs 2021-02-12 08:24:42 +01:00
Olivier Goffart
c1b136b626 For the master documentation, use the master version of the interpreter 2021-02-03 15:50:34 +01:00
Simon Hausmann
7982325da4 Change Rectangle::background's type to be a brush
This also introduces the brush type in the compiler and generators. At the
moment only conversion from Color is implemented.
2021-02-03 12:49:44 +01:00
Olivier Goffart
c5ab214f55 Generate linear gradients in rust.rs 2021-02-03 09:52:38 +01:00
Olivier Goffart
09ce4142a5 Some reorganization of the testdriver 2021-02-01 18:13:19 +01:00
Olivier Goffart
60c80f4e9a Get ready to publish the docs with the preview. 2021-01-29 17:14:14 +01:00
Olivier Goffart
fea2478859 Update version number everywhere 2021-01-28 16:34:13 +01:00
Simon Hausmann
6a4f2aa572 Added the two missing path sub-elements for quadratic and cubic curves 2021-01-28 14:14:24 +01:00
Simon Hausmann
a6fbc4c05d Add missing MoveTo sub-element for Path 2021-01-28 13:16:25 +01:00
Olivier Goffart
5debc08f98 Parse @image-url 2021-01-28 11:49:24 +01:00
Olivier Goffart
1fda2e1c99 Remove unused item_parent_offset 2021-01-26 10:36:37 +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
Olivier Goffart
962a31d8f5 Layouting documentation 2021-01-23 10:25:43 +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
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
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
Olivier Goffart
dcb347fb7b Move more functions from the GenericWindow to the Window 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
46dbb1ee9e By default, enable the GL backend also on desktop
So it can be chosen with an env variable or if Qt is not available
2021-01-14 08:53:13 +01:00
Simon Hausmann
edb17f996f Move the entire custom application font handling into the backend
Some backends may not require a copy of the data, for example.
2021-01-14 08:53:13 +01:00
Simon Hausmann
727c9a19f7 Add basic text item support
This needs more work, but gets something onto the screen at least.
2021-01-14 08:53:13 +01:00
Olivier Goffart
9050c29305 Don't use the window through the eventloop module 2021-01-14 08:53:13 +01:00
Olivier Goffart
16f5a03c14 Run cargo fmt 2020-12-18 10:29:15 +01:00
Olivier Goffart
dfa25b96f7 Rename SharedArray to SharedVector 2020-12-18 10:26:07 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Olivier Goffart
63a0d9308b Bump version 2020-12-14 08:49:54 +01:00
Simon Hausmann
87e0cc7d85 Fix resource embedding doing a wasm build of a project using the sixtyfps! macro
We need to embed resources in wasm builds. Unfortunately we can't detect
that we're called by say wasm-pack and "TARGET"/"HOST" only works inside
build.rs. So instead, to keep things simple, this change always embeds
the image resources when targeting Rust.

The `SIXTYFPS_EMBED_RESOURCES` environment variable can be used to
override this anywhere for any language.

Fixes #130
2020-12-10 15:09:32 +01:00
Simon Hausmann
624113b0a2 Change the sixtyfps_build compiler configuration API
Don't expose the internal type but create a public wrapper with the
builder pattern. That makes it easier to change defaults and it hides
internals like the callback futures.
2020-12-10 14:22:14 +01:00
Simon Hausmann
c72c2a58ff Fix Rust docs about generated API 2020-12-09 16:48:02 +01:00
Olivier Goffart
77dc3a2ca9 Update the version in the README and doc as we prepare the release 2020-12-09 15:34:41 +01:00
Olivier Goffart
125ec13f24 Bump version numbers
Note: this does not update the documentation yet
2020-12-07 15:41:29 +01:00
Olivier Goffart
9d2d3e43eb Update rystc_version 2020-12-07 11:37:47 +01:00
Simon Hausmann
26cb05724e Implement Clone for sixtyfps::Weak 2020-12-03 14:41:25 +01:00
Simon Hausmann
23d54b1b89 Improve similarity of testing APIs between C++ and Rust
Let send_mouse_click also take a component reference, like in C++.
2020-12-03 13:35:10 +01:00
Simon Hausmann
4670854500 Remove as_ref from the public API of the generated Rust component
This was only needed in our tests.
2020-12-03 13:31:58 +01:00
Simon Hausmann
47152eee89 Remove the sixtyfps::Component trait
It is not needed anymore
2020-12-03 09:16:20 +01:00
Simon Hausmann
83191c82cc Remove ComponentHandle and ComponentWeakHandle 2020-12-03 08:13:40 +01:00
Simon Hausmann
4f412dcde4 Fix up the docs of the sample component for the new wrapping API 2020-12-03 08:13:40 +01:00
Simon Hausmann
7047856d4e Replace FooRc with Foo and without ComponentHandle in examples and tests 2020-12-03 08:13:24 +01:00
Simon Hausmann
dd64226dc1 Implement sixtyfps::Weak
This is the counter-part to the strongly referencing type the compiler
generates for components.
2020-12-03 08:13:15 +01:00
Simon Hausmann
ff1d752bc6 First step towards a wrapping public component API without ComponentHandle
For now the compiler also generates FooRc next to Foo, which wraps a
strong reference (VRc) to Foo.

This is an intermediate step and at the end of the series FooRc should
replace Foo and sixtyfps::ComponentHandle.
2020-12-03 08:13:15 +01:00
Olivier Goffart
8b10414451 Parse signal return type
(currently does nothing with it)
2020-12-01 18:47:49 +01:00
Olivier Goffart
2d016dffda Print the diagnostics in stderr for files which do not have span information 2020-12-01 12:10:43 +01:00
Olivier Goffart
19458eb2e6 sixtyfps-macro: recompile when the style changes 2020-12-01 12:10:43 +01:00
Simon Hausmann
2472eb51f0 Add the plaster font to plaster theme of the slide puzzle
For regular builds this is done by adding Rust API that allows
registering a font, and for the web the font is installed into the
browser using JavaScript API.

This is an initial approach to just add this ability. It might make
sense to introduce a syntax in the `.60` file to allow for the
registration of fonts and letting the compiler generate code that
performs this embedding and registration automatically.
2020-11-27 14:29:56 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Simon Hausmann
fa95064363 Fix resource embedding across component boundaries
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.

This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.

This patch addresses these two bugs by cleaning up the entire mechanism:

The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
2020-11-23 13:47:16 +01:00
Olivier Goffart
2e60afec39 Run cargo fmt 2020-11-23 12:08:23 +01:00