Commit graph

100 commits

Author SHA1 Message Date
Simon Hausmann
3e90a3c827 Improve relative image path resolution
Don't just try to resolve relative paths against the current path,
resolve them against all directories in the include search path.

Together with the include search path directive for tests in tests/cases
this will allow working around the fact that the base directory for the
rust tests is different than for the C++/NodeJS tests.
2021-01-15 16:28:17 +01:00
Olivier Goffart
9aca0b0a7e LSP: Allow to access to the type loader documents
So that we can go to the definition of un-open documents
2020-12-28 12:48:32 +01:00
Olivier Goffart
8267590282 Refactor: move a bunch of code in TypeLoader::new
So it will be shared
2020-12-28 12:48:32 +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
Olivier Goffart
7f78bea8b5 Fix a bunch of cargo clippy warnings in the compiler 2020-12-07 12:54:38 +01:00
Olivier Goffart
f3f18259ae Some items default size is the parent size
Fixes #122
2020-12-02 18:36:23 +01:00
Olivier Goffart
852eeb1c11 WIP popup 2020-11-30 15:20:51 +01:00
Olivier Goffart
5654ecccb4 Style: only have one level of braces in imports 2020-11-26 17:15:45 +01:00
Olivier Goffart
c37f0ce4c4 Load the cursor width property from the style
Ideally we would put the bindings dirrectly in the builtins.60
But this is unfortunately not possible because the "StyleMetrics" is not
yet available there and that would be a circular dependencies.
2020-11-25 09:58:54 +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
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
cfa9413861 More work on the state binding for transition:
When there is a transition, turn the state property into a property of StateInfo

Not yet implemented for C++
2020-11-19 12:43:28 +01:00
Olivier Goffart
7967a074fb Fix accessing struct declared in a different file 2020-11-17 12:02:21 +01:00
Olivier Goffart
d499e86640 Implement cubic-bezier 2020-11-13 13:36:32 +01:00
Olivier Goffart
281a744e86 Load the builtin from a fake .60 file 2020-11-04 16:56:35 +01:00
Simon Hausmann
9df18a3747 Apply default layout spacing and padding from the style
Extract the StyleMetrics from the style and pass it to the layout
lowering pass for application.

The tests were adjusted to explicitly specify the padding/spacing to
override the ugly style default.
2020-11-04 15:20:43 +01:00
Simon Hausmann
01be063299 Typeloader cleanup
The all_documents member does not have to be externally provided, as
long as we keep the typeloader in scope instead. Since we'll later pass
it down to the layout lowering pass, that's fine.
2020-11-04 14:16:34 +01:00
Simon Hausmann
43052dec42 Another typeloader cleanup
Use the same future interface with an std::io::Result in the
CompilerConfiguration for the fallback loading.
2020-11-03 13:54:09 +01:00
Simon Hausmann
94265cb9e6 Clean up typeloader a bit
Move the many duplicated parameters into a shared TypeLoader structure
2020-11-02 15:58:53 +01:00
Simon Hausmann
d435a7c8b8 Fix loading of images from imported files in the online editor
We need to separate the url resolution step from the document fetching,
as we need to keep the loaded url in Rust for further
resolution.
2020-11-02 14:57:49 +01:00
Olivier Goffart
ea5e140d00 Add a callback to load the import files if they are not on the file system 2020-10-30 15:09:24 +01:00
Olivier Goffart
359f42c5f7 Prepare the compiler to be async
This will allow the online editor to load imports from URL asynchroniously later

Since currently the compiler is only working on a single thread, and that we
never await on a future that could block, it is allowed to use the spin_on executor
2020-10-30 15:00:04 +01:00
Olivier Goffart
2d55b2a51a Don't load document twice if they are imported twice
Also protect against cyclic imports
2020-10-30 10:14:27 +01:00
Simon Hausmann
ed714bd332 Fix type leak across imports
Given the test case

    import { SomeType } from "somewhere.60";
    import { Blah } from "foo.60";

and foo.60 trying to use "SomeType":

    export Blah := SomeType {}

then the lookup for "SomeType" in foo.60 should fail. Instead it leaked
through the populated type registry when processing the dependencies for
the outer file.

This is fixed by ensuring that the type registry for a file only has the
global type registry as parent. To ensure that the test reliably covers
this, the import dependencies are now processed in declaration order
(hence the switch to IndexMap that preserves insertion order).
2020-10-29 12:55:00 +01:00
Olivier Goffart
6d440eb7e3 Fix using global in imported files
This required doing the type resolving for the export with all
component in the export
2020-10-29 11:01:04 +01:00
Olivier Goffart
5f5e5b7420 Access global properties from rust
C++ and interpreter implementation is still missing so the new stest is failling
2020-10-29 11:01:04 +01:00
Olivier Goffart
c659c4369a Refactor the Layout generation code 2020-10-26 10:07:31 +01:00
Olivier Goffart
27a6ff1227 Move Type and related concepts in a different module
Leaving only the TypeRegister in the typeregister module
2020-10-23 11:17:14 +02:00
Olivier Goffart
dbdc8483e2 Disable the check for the SIXTYFPS_STYLE env variable on wasm 2020-10-13 09:30:18 +02:00
Simon Hausmann
b9dee9fcce Fix issue link 2020-10-12 21:30:59 +02:00
Olivier Goffart
84f0fb7b07 Display a warning when no style is selected 2020-10-12 11:50:39 +02:00
Simon Hausmann
9ad8968529 Add support for the initial_focus synthetic property
Setting it will translate to a set_focus_item call in the constructor.

This implements parts of #55
2020-09-30 15:11:01 +02:00
Olivier Goffart
8361ef4019 Start code egeneration for the two ways binding
This is only meant to include the cases in which the property are optimized.
Does not work yet for the dynamic component
2020-09-24 14:37:16 +02:00
Olivier Goffart
8134fe5088 Support for named type as property 2020-09-17 13:14:01 +02:00
Olivier Goffart
d924ec6bd9 Fix a bug when using layout within a for loop 2020-09-07 14:03:46 +02:00
Simon Hausmann
2a9c962b8d Exclude exposure of easing and duration typed properties
We decided that their type mapping is not ready for public API yet. For
example for duration we'd like to replace the opaque i64 with another
opaque type that however has convenient conversions to
std::time::Duration or std::chrono::milliseconds. We can't use either
directly because we need ffi compatibility, in order to create an
instance in C++ and pass it to the Rust run-time.

So this hides such properties and instead produces a warning.
2020-09-04 21:25:11 +02:00
Olivier Goffart
59dbb610be Materialize fake properties such as layout width/height 2020-09-01 18:49:49 +02:00
Olivier Goffart
f1ad78bc25 Qt style support for the rust backend
Need to set the SIXTYFPS_STYLE=native env variable while compiling
2020-09-01 12:25:11 +02:00
Olivier Goffart
10e8d7ffb9 Replace the regexp-based lexer with a custom lexer
The regexp crate is huge and takes more than a third of the size of the
wasm-interpreter.
2020-08-28 13:34:43 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
5b9c41b76b Add referenced image resources to the dependencies for the rust build 2020-08-07 13:35:44 +02:00
Olivier Goffart
38cd9158ac Report the error while building the Document node
Instead of panicking in later phase.

Use the same function in the syntax_tests that the one we use in the different
compiler frontend so that the problems would also be shown in the tests
2020-08-05 10:54:59 +02:00
Olivier Goffart
52cf481dc4 Fix states in repeated elements
This create reference to new property that needs to be adjusted
2020-08-04 14:02:18 +02:00
Simon Hausmann
30acb11362 Fix handling of properties of nested optimized layout elements
We need to traverse also into the expressions of nested layouts to ensure
any references inside are updated as the
"virtual" properties are moved.
2020-07-29 18:52:22 +02:00
Olivier Goffart
b57f3775c9 Refactor GridLayout 2020-07-28 10:31:05 +02:00
Simon Hausmann
09cae799d3 Fix return type of compile_syntax_node
All call sites are only interested in the root component, so might
as well return that.
2020-07-28 09:21:32 +02:00
Olivier Goffart
def42ba3df Add reserved properties that every item has
These properties are materialized if used
2020-07-27 12:18:55 +02:00
Simon Hausmann
88fb491837 Add support for mapping elements to different native classes
The Rectangle element has properties for a border outline. If those are
used, then the generated code should use BorderRectangle. But if they are
not used, then we can fall back to just generating a Rectangle.
2020-07-24 17:48:19 +02:00
Simon Hausmann
c1c2f63f29 Fix error propagation from imported files
Don't forget to collect the build diagnostics.
2020-07-23 15:32:08 +02:00