Commit graph

1597 commits

Author SHA1 Message Date
Lukas Jung
f0a47ff154 Add mouse-cursor property to TouchArea 2021-12-07 22:41:24 +01:00
Olivier Goffart
7ecbf4c81d Don't use deprecated itertools functions
A replacement is available in the std library
2021-12-07 12:10:38 +01:00
Olivier Goffart
310bf897cd Native ComboBox: style the background of the popup
Fixes: #720
2021-12-06 18:52:10 +01:00
Olivier Goffart
2ffa83db0e Native Style: hover effect on NativeStandardListViewItem 2021-12-06 18:52:10 +01:00
Olivier Goffart
53775465dc
C++: add version macro
Fixes #705
2021-12-06 15:36:16 +01:00
Olivier Goffart
f27a2b8c74 Fix issues related to alias to globals
two problems
 - For the interpreter, properly handle the case of an alias to a global
 - For the rust generator, we can't return a reference to a property held
   in a global, so we must 'inline' the get_xx funciton on sub-components
2021-12-06 14:30:47 +01:00
Olivier Goffart
464ba195a8 Don't use deprecated API 2021-12-06 13:00:32 +01:00
Olivier Goffart
cd47ef1100 Mark properties that we know are never modified as constant,
so that we don't need to register dependencies when accessing them
2021-12-04 22:00:12 +01:00
Olivier Goffart
524a9be377 Mark properies being set by the ListView and FLickable as set externally
As we will do more optimisation on constant properties, it is important
to detect the ones that aren't
2021-12-04 22:00:12 +01:00
Olivier Goffart
bc8d556799 Compiler: keep const-ness information of native property in the NativeClass 2021-12-04 22:00:12 +01:00
Olivier Goffart
a90013983b Add a way to debug the properties behind a configuration flag
I used a `#[cfg(..)]` instead of a feature flag because then it is enabled
for both the compiler and the lib at the same time, and since it is only a debug stuff
it does not need to be enabled within the project. So one must enable it with
`RUSTFLAGS='--cfg sixtyfps_debug_property'`
2021-12-04 22:00:12 +01:00
Olivier Goffart
0e174b6aba Start working on makeing the generated code no_std 2021-12-01 10:36:29 +01:00
Olivier Goffart
a201c31eaf Don't use Lazy to initialize the ITEM_TREE, use OnceBox instead
Lazy needs std
2021-12-01 10:36:29 +01:00
ogoffart
3278b39549 Bump version number to 0.1.6 2021-11-24 14:19:09 +00: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
06d1293afe Fix another regression in layout due to non inlining
override_from_parent.60 was panicking when compiling rust
because some expression had NamedReference that were relative to another
sub component.

Added a test as well for the case of multiple indirection (SubComp4)
that was also broken
2021-11-24 10:21:00 +01:00
Olivier Goffart
84e394a006 Fix regression when overriding the with of a Component that specifies limits
We were comparing the priorities of different component, which does
not make sense

This is a regression found with the crater run
2021-11-24 10:21:00 +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
Simon Hausmann
fa14a80ea8 Fix text rendered blurry when using Qt
After commit becb4574c1 we'll
make sure not to set the plugin application attribute when initializing
the Qt backend. Unfortunately in the generated struct the NativeStyleMetrics field
is placed and initialized before the m_window. The Default::default() impl
calls `ensure_initialized()` with `from_qt_backend = false` because we don't
know what backend is being used. Since due to the ordering this is the first
call to `ensure_initialized()`, we'll end up setting the plugin application
attribute.

This patch fixes that by ensuring that the m_window field always comes first,
which is initialized with a call into the run-time library, which in turn
delegates to the backend. That'll be the Qt backend and we'll initialize
the application object correctly.
2021-11-23 11:05:02 +01:00
Tobias Hunger
8b30849f7e compilerlib: Add tests for linear_gradient and image_url
Add two simple tests to make sure we do not exidentally break the
alternative spelling for linear-gradient and image-url.
2021-11-22 13:21:17 +01:00
Tobias Hunger
37a2ad5b0f compilerlib: Fix an assert triggered by linear_gradient
Allow both documented spellings of linear_gradient in the debug_assert.
2021-11-22 13:21:17 +01:00
Olivier Goffart
3534f3bd4c Disable texture embedding with wasm
We can't support it with the interpreter, and the compiler running on wasm
is only used for the interpreter.
And this cause compilation issue because some dependencies enable features
that breaks the build
2021-11-19 15:54:45 +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
Tobias Hunger
d3542c825f compilerlib: Report failure on unterminated escape sequence
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2021-11-19 13:03:40 +01:00
Tobias Hunger
a488a79d8e compilerlib: Report failure on unterminated escape sequence
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2021-11-19 13:03:40 +01:00
Tobias Hunger
46f291edff Update sixtyfps_compiler/lexer.rs
Be more clever about finding the next start of character.

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2021-11-19 13:03:40 +01:00
Tobias Hunger
bd1d820862 compilerlib: Fix panic when parsing "\ޱ 2021-11-19 13:03:40 +01:00
Tobias Hunger
5f2f82fd57 compilerlib: Fix panic when parsing "\ 2021-11-19 13:03:40 +01:00
Tobias Hunger
36c7aa85f8 compilerlib: Fix panic when parsing /** 2021-11-19 13:03:40 +01:00
Olivier Goffart
7a5fc72093 Fix black background with native style
If we don't tell the compiler that the properties are `native_output` then
it might const-propagate the default value which is transparent
2021-11-16 11:27:21 +01:00
Olivier Goffart
de43f0a783 Start doing some constant evaluation
There was a warning in the C++ generated code in the tests:  (in test_cpp_image_geometry)

```
/tmp/.tmpsAMWqZ.cpp:307:85: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
    this->image_in_layout_fit_ok.set((sixtyfps::cbindgen_private::ImageFit::contain == sixtyfps::cbindgen_private::ImageFit::contain));
                                                                                    ^
```

Deoing some simple evaluation prevent this warning at least
2021-11-11 11:14:59 +01:00
Olivier Goffart
4360dc2010 Fix const detection with declared aliases 2021-11-11 11:14:59 +01:00
Olivier Goffart
a3adfd94b1 Const propagation
Inline access to constant properties
2021-11-11 11:14:59 +01:00
Olivier Goffart
125ab12816 Don't take the binding when calling visit_element_expressions
So that we can visit the expression and the property reference
still have a meaning
2021-11-11 11:14:59 +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
0484c7ea4b Rename the env variable
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-11-09 15:32:33 +01:00
Olivier Goffart
61202c6cba Make the inlining decision part of the CompilerConfiguration
This also enable disable inlining by default
2021-11-09 15:32:33 +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
92998a76aa Rust: Don't mark the window as pub
No reason to have it public
2021-11-09 13:48:22 +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
f10f05c726 Fix set_focus_item and show_popup_window calls from within sub-components in Rust
Compute the absolute item index like in the C++ generator.
2021-11-09 11:50:36 +01:00
Simon Hausmann
270f8145ff Don't call set_focus_item in the init function of sub-components
We use the setup_code for that for now, so apply the same logic as in the C++ generator.

However there's more work to be done later to make forward-focus work corectly into sub-components.
2021-11-09 11:49:51 +01:00
Simon Hausmann
3e02c7090c Minor cleanup
Qualify the Default trait also for the root field
2021-11-09 11:09:56 +01:00
Simon Hausmann
b0d76d1bcc Fix dyn_index dispatch to sub-components in Rust
Correctly make the dyn_index a local index by subtracting the base
2021-11-09 10:46:48 +01:00
Simon Hausmann
f7415171d0 Fix generated Rust code when using sub-components in nested repeaters
The code to determine the root is a little more complex, as unlike in C++
we are not passing the root on in constructors.
2021-11-09 10:40:51 +01:00
Olivier Goffart
a5e1f35f7b Make sure that the BindingExpression with animation always has a binding
Consider this code:
```60
Foo := Rectangle {
   animate y { /*...*/ }
   x: some_binding;
}

Bar := Rectangle {
   foo_instance := Foo {
      y: some_binding;
      animate x { /*...*/ }
   }
}
```
We need to make sure that the binding are set with the right animation.

FIXME: the generator should actually handle this case without needing for inlining.
Also, this currently do not work if there is several level of "inheritence"
2021-11-09 10:22:11 +01:00
Olivier Goffart
f6cf8b6d47 Check the analysys of the base component
If there is a Expression::Invalid as a binding (because it has an animation,
for example) we must check that the binding expression in the base is not
constant.

This fixes the rust test `properties_animation_merging` without inlining
(The o4_val was considered constant despite it shouldn't be)
2021-11-08 20:03:26 +01:00
Simon Hausmann
1055b39c68 Fix calls to ItemRc that take a VRc, when called from sub-components
There are different ways to get the VRc.
2021-11-08 16:53:24 +01:00
Olivier Goffart
a3bafb59f0 Don't mark the internal components as pub 2021-11-08 16:46:13 +01:00
Olivier Goffart
a6a8f232db Fix error in generated code:
```
error[E0599]: no method named `unwrap` found for struct `sixtyfps::re_exports::OnceCell` in the current scope
   --> .../test-driver-rust-0868c471dd25beed/out/imports_external_type.rs:384:29
    |
384 |                 &_self.root.unwrap().upgrade(),
    |                             ^^^^^^ method not found in `sixtyfps::re_exports::OnceCell<VWeak<sixtyfps::re_exports::ComponentVTable, imports_external_type::sixtyfps_generated_TestCase::InnerTestCase>>`
```
2021-11-08 16:41:45 +01:00