Use two arrays, one for events and one for coordinates. That simplifies
the code generator and the generated code, and it also provides for
a more compact memory representation.
Using the commands property we can just paste SVG paths. This makes it
much easier to write examples/demos. A good online path designer is
for example https://codepen.io/anthonydugois/pen/mewdyZ
Require that the values to the path element properties are numerical literals.
The conversion happens in the path "compilation" pass, where we can do more
pre-calcuation in the future.
Making color a real property type broke the build of tests that compare
color properties. Fix this and the incorrect decoding of
strings in the cast to colors, by providing a proper public C++ color
wrapper type.
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
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.
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.
While properties declared in the root component are named as-is and
exposed as Property<T>, their get() function in particular is hard to
use because it requires an EvaluationContext as a parameter.
This patch adds get_foo() and set_foo() accessors for each public
property and hides the evaluation context business for the getter.
The added test uses this right away and adds missing test coverage for
the conditional expression.
The following scenario would fail compiling to C++ because we failed to
determine the return type of the conditional expression:
Test := Rectangle {
property<bool> condition;
property<color> extra_color;
color: condition ? root.extra_color : 4289374890;
}
The type of the true branch would be color and the false branch would be
a float. Since they "disagree", ty() on the expression would return
Type::Invalid. This was temporarily worked around in the C++ generator
by always returning the type of the true branch, but that's wrong.
Instead this patch changes maybe_convert_to to apply the Cast expression
to the individual branches, placing the cast only to the numberic
literal and correcting the return value of ty() on the conditional
expression.