Commit graph

495 commits

Author SHA1 Message Date
Simon Hausmann
76b6e75543 cpp llr: Fix image/resource embedding
Re-enable the old code :-)
2022-01-19 10:02:23 +01:00
Simon Hausmann
abe69aa4a3 c++ llr: implement property assignment and callback calls 2022-01-19 10:02:23 +01:00
Simon Hausmann
fd4ea37ff7 c++ llr: fix support for callback initialization and declaration in the public API 2022-01-19 10:02:23 +01:00
Simon Hausmann
440c15d1b2 cpp llr: Re-add generation of structs (not llr bound) and implement Expression::Array for models 2022-01-19 10:02:23 +01:00
Simon Hausmann
cc580e4476 llr cpp: implement mod
Co-authored-by: Tobias Hunger <hunger@users.noreply.github.com>
2022-01-19 10:02:23 +01:00
Simon Hausmann
52a21ebf2d llr c++: fix generated property getters/setters
Use the new access_member function
2022-01-19 10:02:23 +01:00
Simon Hausmann
da3d97b4bf c++ llr: remove llr_ prefix from ported functions and comment/remove out old ones 2022-01-19 10:02:23 +01:00
Simon Hausmann
9b570c7365 llr cpp: Remove some commented out code that exists also in the origin non-llr method 2022-01-19 10:02:23 +01:00
Simon Hausmann
79ea070bdc cpp llr: Fix -Werror build 2022-01-19 10:02:23 +01:00
Simon Hausmann
010d374c05 Fill out more component vtable stubs to fix linking 2022-01-19 10:02:23 +01:00
Simon Hausmann
f96df74a6f llr cpp: compile the most basic export App := Window {} test case
Linking still fails though
2022-01-19 10:02:23 +01:00
Simon Hausmann
0b7eae426d llr cpp: add rudimentary support for declaring properties/callbacks 2022-01-19 10:02:23 +01:00
Simon Hausmann
eddf176d49 llr cpp: Implement more of llr_compile_expression 2022-01-19 10:02:23 +01:00
Simon Hausmann
90e9829233 cpp llr: implement PropertyReference::Local 2022-01-19 10:02:23 +01:00
Simon Hausmann
62486ed41f Implement more of llr_compile_expression
* PropertyReference
 * BinaryExpression
 * Cast
2022-01-19 10:02:23 +01:00
Simon Hausmann
51d3376731 Begin generating basic property init expressions with the llr in C++ 2022-01-19 10:02:23 +01:00
Tobias Hunger
8150e5271d WIP: Make cpp.rs use LLR 2022-01-19 10:02:23 +01:00
Simon Hausmann
360a3c3b30 Re-evaluate bindings when data in models accessed via index expressions change
Call the new track_row_data_changes function in the model before
retrieving the data.
2022-01-14 13:38:25 +01:00
Olivier Goffart
d3a9437309 Support for writing in the model with the [] syntax 2022-01-14 13:38:25 +01:00
James Blacklock
7ad1ba209d Add support for array index expressions
This is a squash of the changes in
https://github.com/sixtyfpsui/sixtyfps/pull/605
2022-01-14 13:38:25 +01:00
Simon Hausmann
6e2f55e1b8 Fix calls to solve_path_layout
The function takes a reference to the `PathLayoutData` struct, which in
turn had a reference to the path data. The old rust generator had
special knowledge of calling solve_path_layout, so it knew to take a
reference of the path data.

In the llr there's no expression to take a reference. However since
PathData is cheap to move/copy (just holds SharedVector), we can pass it
by value (move) in the PathLayoutData.

This also means a copy in C++, which I *think* is safe, because the
constructor and destructor will be called on the C++ side, and the Rust
side still just operates on references or would try to move out a field
from the struct.
2022-01-12 16:22:35 +01:00
Simon Hausmann
44297bad24 Fix build of generated Rust code for path elements with the llr
* Move the C++ elements back into private_api (despite being generated), so that struct_name_to_tokens can generate the right name in re_exports
* When generating the llr_Expression::Struct for the path elements, make sure
  that all fields are filled out, to avoid an empty value expression in Expression::Struct
  in the Rust generator. Since we don't generate tuples but a named struct, we must provide all fields.
2022-01-12 16:22:35 +01:00
Simon Hausmann
31471fcf89 Complete path support in the llr / rust generator
This patch takes care of the lowering of events/coordinates arrays as
path data, which originates from a `commands: ...` string of SVG path
commands.

In order to minimize the path specific code in the generator, the
compile_paths now generates a Vec<Expression> for the events and
coordinates.
2022-01-12 16:22:35 +01:00
Simon Hausmann
9e61d4168b Fix build of Paths with path elements with rust/llr
A `Path` with `MoveTo`/`LineTo`/etc. sub-elements now maps to an Expression::PathData of type
Type::PathData.

The llr lowering creates an Array of Type::PathElement, which is casted to PathData.

This only covers the element case. The compiled path events are still todo.
2022-01-12 16:22:35 +01:00
Tobias Hunger
79e2456ead Allow for bigger indices in VisitChildrenResult
The indexes stored in `VisitChildrenResult` are unsigned. We have 64
bits to store two values and we need to have one special value as a flag.

So accept any index `< u32::MAX` instead of `< i32::MAX`, which should
allow for more data to be visited;-)
2022-01-08 20:55:22 +01:00
Jared Moulton
c5c139fbc9
Feat: Add math funcs Log10, Log2, Log and Exp (#813)
Implement Math.log and Math.pow
2022-01-07 12:07:58 +01:00
Tobias Hunger
3e448f75eb
janitor: Remove some unnecessary references
These are immediently dereferenced by the compiler according to clippy.

Remove some now unnecessary muts to make things build again.
2022-01-04 18:22:15 +01:00
Tobias Hunger
767704a88b
janitor: Remove some redundant closures 2022-01-04 18:21:07 +01:00
Tobias Hunger
d54e2a642a
Janitor: Change push_str of a one-char str to push 2022-01-04 09:39:41 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Olivier Goffart
53775465dc
C++: add version macro
Fixes #705
2021-12-06 15:36:16 +01:00
Olivier Goffart
47a4463abc Rename the sub component id to avoid error in the generated code with duplicated names 2021-11-23 12:03:03 +01:00
Olivier Goffart
d1cae710df preprocess the images at compile time
For the MCU port, we need to proccess the image to save them in the binary
in a convenient format.
This patch start this work by trying to anaylyze what format should an image
be using, and saving it as a texture in the binary.

The current graphical backend and the C++ frontend are not yet supported
2021-11-19 15:54:45 +01:00
Olivier Goffart
dd3fa1c221 Make the BindingMap hold RefCell of the BindingExpression
This will allow later to be able to operate on the binding despite the
element is borrowed.

Since the Binding itself is in a RefCell, the analysis don't need to
be anymore.
To do this change, a small change in the binding_analysis logic was required
which means that we will now detect binding loop if a binding was causing
two binding loop. (before, only one binding loop was detected)
2021-11-11 11:14:59 +01:00
Simon Hausmann
8ff27671ef Fix absolute item index computation for children of nested sub-components
Somehow the focus_change_subcompo test missed this case and the visible
issue of this off-by-one was that
the combo boxes in the printer demo's settings page opened at the wrong location (wrong parent).
2021-11-09 14:52:47 +01:00
Olivier Goffart
aea68b9ad8 C++: Fix subcomponents/nested_repeater.60 when not inlining
More or less the same fix as what was done in rust when the test was added
2021-11-09 12:40:04 +01:00
Simon Hausmann
13de800ba3 Internal cleanup: Rename layouting_info to layout_info
That's making the call on the Component VTable consistent(ish) with the Item VTable.
2021-11-08 10:24:30 +01:00
Simon Hausmann
7354b17a6a Minor cleanup in ItemTreeBuilder trait
Pass the sub-component as a parameter in enter_component(), as it's needed in the C++
implementation, it's readily available (no need to unwrap again) and Rust will need it, too.
2021-11-04 17:55:39 +01:00
Simon Hausmann
ac945a8f37 Minor cleanup in C++ code generator
In the tree builder's enter_component we registered the sub-component as a member
and also registered the member initializer
in the constructor.

However the call to `init()` to initialize the bindings was registered in `enter_component_children` for no good reason.

It's cleaner to do that all in one place.
2021-11-04 16:27:35 +01:00
Simon Hausmann
2b98e503f1 Fix build by adding missing Write trait use 2021-11-04 11:03:44 +01:00
Simon Hausmann
6528963bd2 Simplify and speed up string concatenation by using write!()
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-11-04 11:03:44 +01:00
Simon Hausmann
e0f3e6b782 Fix the C++ printer demo with disabled inline
For the following reduced test-case the order in how the dynamic nodes
in the item tree were generated (and dyn indices assigned) differed from
the way the visit_dynamic_children slots were generated:

```
Blah := Rectangle {
    for x in 1: Text {
        text: "Should be on the right";
    }
}

MainWindow := Window {
    width: 772px;
    height: 504px;
    Text {
        if (false): TouchArea {
        }
    }
    Blah {
        x: 200px;
    }
}
```

The item tree node was constructed using build_item_tree, which
basically assigned dyn index 0 to the "repater" for the touch area
and "1" to the one for the repeater inside the sub-component.

Afterwards we traversed the element tree - without descending into the
sub-components - to generate the fields and the dispatch in in the
dynamic visitor. Here a subtle order would result in a mismatch of
indices:

recurse_elem_level_order would end up visiting Text, Blah and then
Text's children, assigning the first dynamic index to Blah.

This is now fixed by merging the two iterations into one.
2021-11-04 11:03:44 +01:00
Simon Hausmann
90a97cd737 Remove unused variable 2021-11-03 18:37:40 +01:00
Olivier Goffart
d438374792 Refactor the build_item_tree
Use a trait instead of two functions
2021-11-03 17:46:48 +01:00
Olivier Goffart
ab88e3553e Fix the item tree building for components whose base is a component
We should only visit element that are native item with the visit_item function
2021-11-03 14:59:27 +01:00
Simon Hausmann
2a8c004a7e Fix repeated elements in C++ sub-components
Delegate the visitation of dynamic children. Fixes test_cpp_models_for.
2021-11-03 12:35:32 +01:00
Olivier Goffart
db52f8e726 Fix the C++ compilation of the gallery without inlining
Some code like this was generated:
`if (*self->checkbox_31.get_checked()).get()`
the remove_parentheses function removed a parentheses that it shouldn't have removed
2021-11-03 11:48:05 +01:00
Simon Hausmann
8ddd01ad9a Remove unused variable in the C++ code generator 2021-11-03 11:40:24 +01:00
Simon Hausmann
76b4d7ec75 Remove trailing whitespace 2021-11-03 10:53:40 +01:00
Simon Hausmann
a0c644ab25 Fix compilation of root_item() implementation for the ComponentVTable in C++
... when the root item is a sub-component.
2021-11-03 10:47:11 +01:00