Commit graph

181 commits

Author SHA1 Message Date
Olivier Goffart
464ba195a8 Don't use deprecated API 2021-12-06 13:00:32 +01:00
Olivier Goffart
531dd96a9b Fix warning about not existing image when using the interpreter
Can be reproduced by running the todo example with the fluent style and the GL bakend

The default image should be None, not an empty path
2021-11-24 11:28:04 +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
Olivier Goffart
9c6bc6afc7 Do the property analysis accounting for several component 2021-10-28 15:52:29 +02:00
James Blacklock
1f0a5a6d7c fix formatting & cpp test case 2021-10-18 10:21:06 +02:00
James Blacklock
cc4105e274 no need for InferredGenericType! 2021-10-18 10:21:06 +02:00
James Blacklock
ab665ba7b6 enable scripts to access the length of arrays 2021-10-18 10:21:06 +02:00
Simon Hausmann
88ad176008 Improve diagnostics when images cannot be located for embedding
This is a two-stage change, that first centralizes the file I/O code
path for on-disk and builtin:/ files. Secondly the resource embedding
pass now produces diagnostics if a file cannot be located.
2021-10-05 23:16:46 +02:00
Olivier Goffart
b42c187ed1 Refactor the way the two-ways biding are represented internaly
Don't put them in a fake expression.
This simplifies a bit the expression handling, and will make
possible to fix analysis that needs a vew into the aliases
2021-08-20 18:26:36 +02:00
Simon Hausmann
2458ac5d02 Fix panic when calling focus() on a repeated element
When trying to reference an instance of a repeated item, for use with
ItemRc or VRef<Item>, the item_index (or id) of the ElementRc is not
directly what we want.

Adjust any element references to the repeater to to the inner instance
after creating them. Also make sure that the enclosing component is
respected in the C++ and Rust generators.

Fixes #422
2021-08-20 15:39:54 +02:00
Olivier Goffart
2c1e39f00e Fix priority when merging two_way_binding
We should not increase the priority when merging two way binding, only when
inlining.

This fixes the iot-dashboard's devices widget which were sometimes not
transparent as they should have been.
This was not deterministic because the order in which the two way binding are
merged is not deterministic because of hash table, and sometimes one binding
ended up having a higher priority as it should have had.
2021-08-17 11:57:35 +02:00
Tobias Hunger
c3ce321429 Janitor: Fix clippy::ptr_arg 2021-08-09 13:19:34 +02:00
Olivier Goffart
fa770ec262 Fix panic when one of the two branch of a condition is Type::Void
Throw a proper compilation error.
Note that there may be a bit too many error now when the two
branch of a condition are not the same, but it's better than a panic
2021-08-06 19:44:05 +02:00
Tobias Hunger
89a93db6c7 Janitor: Fix clippy::many_single_char_names 2021-08-04 22:50:35 +02:00
Olivier Goffart
1dab4c35d9 For embedded data, store the extension in the binary
This is usefull for the detection of SVG
2021-08-03 16:15:31 +02:00
Simon Hausmann
064c39d625 Fix disappearing elements with implicit width/height
When an element gets its width and height from the parent through an implicit 100% binding,
those bindings were missing when an animation was pre-defined.

The provided new-type wrapper offers a function to deal with replacing just
binding expression, instead of the
expression *and* the animation.

Fixes #376
2021-08-02 16:31:10 +02:00
Olivier Goffart
f544e67fa1 Fix panic or invalid code caused by invalid expression in the tree
When there is an animaiton but no expression, the binding is
left with an invalid expression.
State was keeping that invalid expression as part of sub expression
this is a regression since commit ba32777cab
2021-07-27 09:10:33 +02:00
Olivier Goffart
7f611d21e3 Fix Angles conversion 2021-07-26 17:36:02 +02:00
Olivier Goffart
01f11695a7 Properly merge the animation when inlining and removing aliases
Fix #193
Fix #345
2021-07-23 15:25:53 +02:00
Olivier Goffart
ba32777cab Refactoring: move the animation in the PropertyBinding struct
Since they always belong together.

This will help for issue #193
2021-07-23 15:25:53 +02:00
Olivier Goffart
f5de7e00a0 Make sure error messages don't end with '.'
As suggested in https://github.com/sixtyfpsui/sixtyfps/pull/275#issuecomment-881240725
2021-07-16 12:39:50 +02:00
Simon Hausmann
fcc71a3cce Fix image sizes not propagating into layouts when loading remotely
When images are loaded by the WASM-built interpreter, we do support
loading them asynchronously via the DOM. In that case we have a property
inside the HTMLImage in the GL backend that becomes dirty once loaded
and triggers re-evaluation of depending properties/layouts. However that
only works as long as uses of the image sizes are in property bindings.

BuiltinFunction::ImageSize however is marked as pure in the compiler, so
this may mean that something like this results in an initial assignment
instead of a binding:

    Image {
        source: ...
        height: source.height * 1px;
    }

For Rust, etc. that's fine, but when running in the WASM-built
interpreter the expression needs to remain in a binding. Therefore this
hack tries to narrow down this condition to wasm as target.
2021-07-09 14:56:02 +02:00
Tobias Hunger
35dd3ed282 Janitor: Remove redundant clone() calls 2021-07-08 20:43:38 +02:00
Tobias Hunger
e5bdeaa804 Janitor: Remove unnecessary & 2021-07-07 08:42:28 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Olivier Goffart
99c140ae08 Allow accessing the width and height of the image in .60
Closes #208
2021-06-21 11:22:50 +02:00
Olivier Goffart
a97bcd5ae1 Use BTreeMap unstead of HashMap to store the bindings
Because the order is important to keep deterministic error and output
2021-06-18 21:47:00 +02:00
Olivier Goffart
d758102f26 Make the orientation a static parameter to BuiltinFunction::ImplicitLayoutInfo 2021-06-16 15:14:07 +02:00
Olivier Goffart
deaa0fddb0 WIP layout: split vertical and horizontal cache
Split the vertical and horizontal pass into different property cache
This will allow to implement "height for with"

This patch does not port the Rust or C++ binding yet
2021-06-16 15:14:07 +02:00
Olivier Goffart
2483425d57 Add abs() 2021-06-11 14:17:47 +02:00
Olivier Goffart
3ddc3c6ce5 Don't re-use Type::Void for inferred type
Make it explicit that it is inferred, and differentiate callback and property
2021-06-07 20:40:36 +02:00
Olivier Goffart
0598b3f095 The debug() function can now take several args, and debug more types 2021-06-01 14:10:25 +02:00
Olivier Goffart
77b8bb615f Move some code in a new module 2021-06-01 12:50:29 +02:00
Olivier Goffart
a1880bd943 Report an error when trying to convert from logical to physical coordinate in a global 2021-05-20 18:11:58 +02:00
Olivier Goffart
a79a4351b5 Be smarter at detecting the constant property and at not generating bindings
this implies that we need to make sure the property are initialized in
order so that constant properties that depends on other constant properties
are correctly computed
2021-05-20 13:40:51 +02:00
Olivier Goffart
54be5f3a84 Some ground work to make more binding analysis
- Mark builtin properties that are modified by the native code as output
 - Record wether the property is set by code in the .60
 - Add a field that will tell us if a property binding is constant
2021-05-20 13:40:51 +02:00
Olivier Goffart
73c396ed7a Report binding loops for layouts 2021-05-18 12:25:19 +02:00
Olivier Goffart
3548c48bff Detect binding loop at compile-time
FIXME: i've currently disabled layout from the detection because it reports
error in our current examples
2021-05-15 15:49:27 +02:00
Olivier Goffart
c39cb48125 Move builtin types builtin function lookup in the lookup module
This way these function can also be auto-completed
2021-05-12 22:21:08 +02:00
Olivier Goffart
203c27c5e3 Properly visit the repeater_index expression in a Expression::LayoutCacheAccess 2021-05-11 14:59:57 +02:00
Olivier Goffart
81473c2541 Remove implicit_size from the Item vtable
Use the preferred size in the layouting_info instead.
2021-05-11 14:59:57 +02:00
Olivier Goffart
a43c2bb50a Component pretty print with indentation 2021-05-11 14:59:57 +02:00
Olivier Goffart
b463e3cca4 WIP refactor layout
This commit add support for the box layout
2021-05-11 14:59:57 +02:00
Olivier Goffart
21a80f4562 WIP: Layout refactoring
Instead of using a solve_layout function in the component, use property to hold
a layout cache.

This commit only implement the GridLayout and only the interpreter part
2021-05-11 14:59:57 +02:00
Olivier Goffart
1106f6f201 Fix conversion of some units 2021-05-07 17:13:38 +02:00
Olivier Goffart
f620351cbf Go to definition of structs
Also add the struct in the outline
2021-04-24 15:06:58 +02:00
Olivier Goffart
14772a9b58 Handle reduction of logical lenght when the units are more complex 2021-04-21 17:15:19 +02:00
Olivier Goffart
91ed04a72c Make length (still the default for all property) be the logical length
And a new `physical_length` is now the physical_length unit

Note: this does not change the runtime part yet
2021-04-21 17:15:19 +02:00