Commit graph

281 commits

Author SHA1 Message Date
Simon Hausmann
3d85cb7f23 Add basic support for property animations to the rust generator
Setting values on animated properties now results in set_animated_value
being called on the property instead of set, and the animation data is
passed on the spot.
2020-06-24 17:54:25 +02:00
Simon Hausmann
ab697ab71d Parse animation declarations into the object tree
So

    animate x { ... }

is basically a short-hand for

    PropertyAnimation {
        ...
    }

    <magically associated that animation with x whenever x is changed>

We could also support a shared animation syntax in the future:

    blah := PropertyAnimation { ... }

    animate x with blah;
    animate y with blah;

This patch also adds a primitive PropertyAnimation struct, which will be
used by the generated code to collect the values specified in the .60
markup.
2020-06-24 17:43:48 +02:00
Simon Hausmann
388c98bba5 Parse animate someProperty { ... } declarations 2020-06-24 17:43:48 +02:00
Olivier Goffart
caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00
Simon Hausmann
de74ae4534 Fix warrning warnings in C++ code when using array models with integer literals
For the generated

   std::make_shared<sixtyfps::ArrayModel<3,float>>(1, 3, 2);

gcc would complain

    non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list [-Wc++11-narrowing]

So this patch casts the individual elements to the target (float) type.
2020-06-24 10:47:00 +02:00
Olivier Goffart
c682d14e0b C++: Object literal and ObjectAccess 2020-06-22 18:30:40 +02:00
Olivier Goffart
6133e35df8 Rust: Object literal and ObjectAccess 2020-06-22 18:10:32 +02:00
Olivier Goffart
f744fcccab Lookup within objects properties
Generated code not yet implemented
2020-06-22 17:35:01 +02:00
Olivier Goffart
f8b7989c0b Access the properties in the parent component of a repeated element
This required some refactoring of the EvaluationContext structure to include the parent context
2020-06-22 14:38:38 +02:00
Olivier Goffart
53e61629ca Fix access to property declared within the repeater.
The move_declaration pass should recurse into sub-components for repeater elements
2020-06-22 10:26:22 +02:00
Olivier Goffart
1bb8d94ab8 Support array for model in rust and in the interpreter 2020-06-19 19:46:59 +02:00
Olivier Goffart
022cd64625 Support for array model in C++ 2020-06-19 14:29:54 +02:00
Olivier Goffart
6238d0d14f Prepare for the ability to access the model
Add an expression type for the access of the model variable from a repeater
2020-06-19 13:46:55 +02:00
Olivier Goffart
864e74601d Add a Model type for
I guess in the future we want to make model a type that knows its inside
2020-06-19 13:13:19 +02:00
Olivier Goffart
911d34e777 Use BTreeMap for the object type so that type order is deterministic 2020-06-18 17:48:08 +02:00
Olivier Goffart
be8f127317 Object and array parsing 2020-06-18 15:22:30 +02:00
Olivier Goffart
897edb8ac1 Parse object literal 2020-06-18 12:35:37 +02:00
Olivier Goffart
93dbc3b02d Parse array 2020-06-18 12:20:04 +02:00
Simon Hausmann
9df888578f Expose a ComponentWindow type in Rust
This comes with a factory function that re-directs to the backend and a
run member function to replace
sixtyfps_runtime_run_component_with_gl_renderer. For now it's all still
hidden in the generated run() method.
2020-06-17 19:15:18 +02:00
Olivier Goffart
096fd7bbb4 Repeater in C++ 2020-06-17 14:39:33 +02:00
Olivier Goffart
8651acbef4 Small renaming in the cpp generator
Take the component by Rc as this will be usefull when generating repeated expression
2020-06-17 10:50:20 +02:00
Olivier Goffart
7bd186a159 Small fixups 2020-06-17 10:35:30 +02:00
Olivier Goffart
f74c801b59 Fix a bunch of warning in the generated rust 2020-06-17 10:26:20 +02:00
Olivier Goffart
5cd4ed7347 Arithmetic operations 2020-06-16 19:04:03 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +02:00
Olivier Goffart
56aad7f474 Fix looking up of 'id' so that we can't access inaccessible id 2020-06-16 16:04:38 +02:00
Olivier Goffart
c940e8d734 Add missing files 2020-06-16 14:11:26 +02:00
Olivier Goffart
a4423374d8 Fix warnings 2020-06-16 13:59:10 +02:00
Olivier Goffart
6122f91fba Begin with the generation of rhe repeater (rust only for now) 2020-06-16 13:47:02 +02:00
Olivier Goffart
064db5aa5b const-field-offset: Add a way to specify the crate name 2020-06-16 13:47:02 +02:00
Simon Hausmann
2f7b46fb90 Improve Rust API
run() on the component can now take a reference instead of consuming the
component.
2020-06-15 18:02:23 +02:00
Olivier Goffart
81ce11ee8b Add a reference to the enclosing component in the element itself 2020-06-15 16:40:55 +02:00
Olivier Goffart
58ac9e964c Visit the model expression in the passes that visit the expressions 2020-06-15 14:00:39 +02:00
Olivier Goffart
9adc55cd70 Partially revert the refactoring that changed the Element::children list
Put the information about RepeatedElement in an Option within the normlal Element
2020-06-15 13:42:11 +02:00
Olivier Goffart
c956fb94f0 Put the RepeatedElement in the object_tree 2020-06-15 10:09:32 +02:00
Olivier Goffart
195a5d0e84 Syntax tests: do not try to generate a document tree if the parser did not succeed 2020-06-15 09:37:56 +02:00
Olivier Goffart
f71b778e76 Syntax tests: Log which file is causing a panic 2020-06-15 09:34:41 +02:00
Olivier Goffart
136a90907b Refactor the element children to account for RepeatedElements 2020-06-12 22:24:50 +02:00
Olivier Goffart
e9b75d30b7 Add a bunch of deny(unsafe_code) 2020-06-12 21:04:27 +02:00
Olivier Goffart
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +02:00
Olivier Goffart
e7644eba94 Fix C++ compilation with the new item visitor 2020-06-12 17:09:51 +02:00
Olivier Goffart
66dc643bf9 WIP: refactor the item visitor
The C++ part hasn't been ported yet and some things still need polish

Introduce a visitor to not rely on the unsafe ItemTreeNode array.
2020-06-12 13:32:40 +02:00
Olivier Goffart
ef9d3963e4 Fix casting of conditional operator 2020-06-12 10:32:56 +02:00
Simon Hausmann
9a935bdd0f Provide convenience accessors for public signals in C++ and Rust
Typically their emission requires an evaluation context parameter.
Similar to properties, provide a public emitter function that takes care
of the context.

This also required two fixes in the compiler, in order to make the
following (as part of the test case) work:

    signal foo;
    foo => { ... }

    (1) Register declared signals before attempting to implement the
    connection handlers.
    (2) When looking up the signal property, not only look in the base
    type but also in the current type.
2020-06-11 21:05:52 +02:00
Olivier Goffart
8713c10d48 Color literals 2020-06-11 19:26:41 +02:00
Olivier Goffart
e95d7da888 Parser: typed syntax node accessor 2020-06-11 17:50:28 +02:00
Olivier Goffart
d4594cff97 Introduce a new DeclaredIdentifier syntax kind to disambiguiate identifiers when there are several 2020-06-11 16:55:38 +02:00
Olivier Goffart
788137e3d5 Parser: allow to specify an index token in bracket in the for loop 2020-06-11 16:55:22 +02:00
Simon Hausmann
d0b1f83297 Fix warning in Rust generated code
Allow the property accessors to be unused code
2020-06-11 16:23:53 +02:00
Simon Hausmann
0cf86dced2 Provide convenience accessors for public properties in C++
See parent commit for the rationale :-)
2020-06-11 15:45:16 +02:00