Commit graph

4925 commits

Author SHA1 Message Date
Olivier Goffart
f316c38d54 Do the apply_default_properties_from_style before the lower_states pass
because we don't want the lowered state property to look like we set a property on it.

Also do the ensure_window before because it need to be done before to be assigned
the default color
2021-11-04 10:08:30 +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
Simon Hausmann
4800217f2f Document the minimum supported Rust version
cc #622
2021-11-03 16:39:41 +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
Olivier Goffart
025b34e8e3 Fix wrong analysis leading to wrong optimization
We need to mark property as set externally before propagating
the is_set on aliases

Fixes test_cpp_bindings_two_way_model without inlining
2021-11-03 13:13:53 +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
Marat Nagayev
573588d634 Update cmake.md 2021-11-03 12:08:02 +01:00
Simon Hausmann
88293151b1 Remove unused variable in the Rust code generator 2021-11-03 11:49:18 +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
Olivier Goffart
19e9186a31 Add a way to run the C++ tests with valgrind 2021-11-03 10:35:12 +01:00
Simon Hausmann
7c8874e803 Fix nodejs test
There's in invoke_ prefix for callbacks :)
2021-11-03 10:23:00 +01:00
Olivier Goffart
6792b7ea23 Fix compilation error 2021-11-03 10:19:44 +01:00
Simon Hausmann
81a13219dc Fix C++ compilation when a component has a sub-component as a base type
Commit da169b0e3c surfaced the issue, which
existed earlier:

In such a scenarion the C++ struct has only one member (the sub-component) and it wasn't initialized,
because we never called visit_sub_component.
2021-11-03 10:15:10 +01:00
Olivier Goffart
114137ddfa Make sure to mark declared aliases as set
Fix the dialog test when not inlining, because it declared all these
xxx-clicked aliases and if we don't propagate their usage, they will be
optimized away
2021-11-03 09:55:04 +01:00
Simon Hausmann
da169b0e3c Fix calling focus() in sub-components when inlining is disabled
focus() is implemented by calling set_focus() on the window with the absolute item
index as a parameter. The
generate_item_indices pass generates local item indicies,
which need to made absolute.

Sadly there exists a gap in the item tree between the root element of a sub-component
and its children. Therefore each sub-component gets two members passed to the constructor,
the tree_index and tree_index_of_first_child.
The former is to be used when the local index is zero (indicates the root).
The latter is used as base for any children.
2021-11-03 09:45:35 +01:00
Simon Hausmann
a55718ae7a Fix error message about the inlining env variable 2021-11-03 09:37:08 +01:00
Simon Hausmann
bd971eda25 Fix local item indicies when using sub-components before other children
In a tree like this:

```
SubCompo := Rectangle { Image {} }
MainCompo := Window {
    TouchArea {}
    SubCompo {}
    Text {
        Path {}
    }
}
```

The path element would have a local item index of 4, which is wrong. Right before the path
there would be the child(ren) of the sub-component, which
were not accounted for.
2021-11-03 08:27:49 +01:00
Simon Hausmann
dd9f6787fd Silence clang warning about unused m_root variable
The variable in C++ sub-components is sometimes unused. We could try to lazily emit it, but
that requires more work and this is distracting :-). This silencing should hopefully also work for gcc.
2021-11-02 20:58:32 +01:00
Olivier Goffart
4390034d9e Interpreter: properly handle alias to global callback
Fixes test_nodejs_globals_global_callback

A recent change made the aliases to global be kept in the global
in case several components are using it.
2021-11-02 12:41:30 +01:00
Olivier Goffart
4b4870ceda CI: set the environment variable to get a backtrace when running the tests 2021-11-02 12:41:30 +01:00
Olivier Goffart
64499498b0 Fix the syntax_tests
We now get an error in recursive functions, but that's not the point of this test
2021-11-02 11:59:02 +01:00
Simon Hausmann
88d050d8ce Revert "Silence warning about unused m_root member in C++ sub-components"
This reverts commit fde3846392 because it
breaks the gcc build ("error: 'maybe_unused' attribute ignored
[-Werror=attributes]"). Will need a different solution that works for
clang (which warns about m_root_ being unused).
2021-11-02 11:56:08 +01:00
Olivier Goffart
4b73cce76e C++: make the member funciton layout_info and root_item const
It might be called with a const pointer
2021-11-02 11:49:30 +01:00
Simon Hausmann
fde3846392 Silence warning about unused m_root member in C++ sub-components
There are a few things we could probably do lazily in the code generator, but
for now this is distracting :-)
2021-11-02 11:29:07 +01:00
Olivier Goffart
3a27a18188 Fix detection of is_set_externally
Otherwise aliases can be optimized when they shouldn't
2021-11-02 11:14:20 +01:00
Olivier Goffart
e6d1f91948 The binding analysis also need to go in callback to detect usages 2021-11-02 10:35:42 +01:00
Olivier Goffart
e13263e760 Prefer keeping the global property when there is an alias to a global
That's because the global must stay in case it is used by more components

(That's a better fix than the one reverted in the previous commit)
2021-11-02 10:25:55 +01:00
Olivier Goffart
fa73833cc1 Revert "Aliases in global can no longer be optimized"
This reverts commit b4a2d0a902.

That was not the correct fix, because we need that for
aliases to global callbacks (these can't be actual two way binding
at runtime)
2021-11-02 10:08:21 +01:00
Olivier Goffart
e17e035251 Fix warning about unused variable in the C++ generated code 2021-11-02 09:58:26 +01:00
Olivier Goffart
08c1d875d3 C++: The property getter should be const
Because it is sompetimes used with const pointers
2021-11-02 09:51:38 +01:00
Olivier Goffart
b4a2d0a902 Aliases in global can no longer be optimized
Because they can be used by other components
2021-11-02 09:46:41 +01:00
Olivier Goffart
54f9ccfa8e Add all repeated components as friend of the root items
They need to be in order to access the globals

Now the test_cpp_models_for compiles, but it crashes at runtime
2021-11-02 09:20:48 +01:00
Simon Hausmann
167fa790fe Fix initialization of self_weak in sub-components in C++
Calling init on sub-components with self_weak as argument only works after self_weak is
initialized, which happens in create(). So a new init() function for root components is called afterwards.
2021-11-01 20:04:46 +01:00
Simon Hausmann
14cb0520a9 Fix drop implementation of Rust generated code
Call free_graphics_resources, not init_items %-)

Amends commit 67579ec560
2021-11-01 18:50:33 +01:00
Simon Hausmann
80f1a8ab11 Fix the parent index for sub-components
We never ended up passing the right index but always zero.

Fix by rewriting build_item_tree to be basically the same as build_array_helper,
with two differences:

(1) we maintain absolute and relative children offsets and parent indices
(2) When traversing over the children of an element there are two scenarios: either
  the element is a sub-component, in which case we iterate through the children of the root element,
  or we can use ElementRc's children directly
2021-11-01 17:57:39 +01:00
Olivier Goffart
efa1448565 C++: Pass the right root pointer 2021-11-01 17:04:31 +01:00
Olivier Goffart
789ac719eb Make the parent_item function work with repeater component 2021-11-01 16:11:38 +01:00
Simon Hausmann
7de0918f0d Fix the order of how sub-components are emitted into the sub-tree
We need to maintain the order of declaration and the sub-trees
of children need to be emitted before continuing with the parent.

This fixes the tab widget in the galler.y
2021-11-01 15:49:20 +01:00
Olivier Goffart
199fe1c676 C++: fix warning about unused variable and unordered initialization 2021-11-01 14:09:28 +01:00
Olivier Goffart
ab772828e9 Don't try to keep the used_component while doing the inline pass
Because some Component might be inlined, and some other not.
Instead, just call the collect_subcomponents pass.
2021-11-01 13:47:09 +01:00
Simon Hausmann
4316e1baac Fix asserts in item tree generator when using sub-components
There's a check that verifies that the relative item indices match, between what
the item tree building code in the generator sees and the generate_item_indices pass.

The counting of the relative indices was incorrect with regards to the sub-trees.
2021-11-01 13:40:08 +01:00
Olivier Goffart
a96ab1b8e5 CI: test the MSRV 2021-11-01 13:00:41 +01:00
Olivier Goffart
d26e95fb95 C++: Fixed sixtyfps::blocking_invoke_from_main_loop when the callable returns void
Fixes #623
2021-11-01 10:51:13 +01:00
Olivier Goffart
a102e9ed8d Fix fluent style's Slider changed callback not being called
Fixes #621
2021-11-01 10:29:51 +01:00
Simon Hausmann
096fbab93d Simplify the destructor of generated C++ components
Similar to the parent commit, avoid creating an array of item refs and pass the item tree instead
to a run-time helper function.
2021-11-01 10:19:17 +01:00
Simon Hausmann
67579ec560 Simplify drop implementation of generated components
Avoid creating an intermediate array of items to free the graphics resources.
Instead call run-time function with the item tree as a parameter, which is traversed.

It's practically the same data structure that was previously created, except
that it is shared/global and has little holes for the dynamic tree items, but those are easy to skip.
2021-11-01 08:58:53 +01:00