Commit graph

53 commits

Author SHA1 Message Date
Olivier Goffart
bfa344415a LLR: Add back the index of first children in the runtime sub component
Using #component_id::item_tree for it does not work because the
public component id is not the right one, we need the one from
the current item tree which is not known at compile time
(could be several if the component is re-used accross item trees)

Also disable the code that sets the focus to the focued element for anything
but the window component: before, the setup code was only run for the
non-sub component, but now it is run for every sub component, and we
don't want to set the focus to anything that has a forward focus property
2022-01-12 16:22:35 +01:00
Olivier Goffart
d1298a9353 collect the globals once more at the end
Fix warning in the rust generated code about unused global.
After constant propagation, some uses of the global disapear, so we should
re-check which globals are really used
2022-01-12 16:22:35 +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
Olivier Goffart
0b5648c2f8 Fix default_geometry and visibility combination
Regression since 684a8c29a2

(This fixes the issue 107 on the cw. gitlab)
2021-12-28 18:05:02 +01:00
Olivier Goffart
ec26714cc0 Process the states before inlining
So that inlining don't merge the states

Since we need to apply default property before the states, we also needed
to move that.
But ensure_window can't be moved before the focus stuff that can't be move
before inlining, so set the default property of the Window in the ensure_window
pass

Fixes #752
2021-12-27 10:50:50 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Simon Hausmann
684a8c29a2 Fix opacity property not affecting the shadow color
The opacity on a rectangle should be applied before the shadow, so that it has
a visible effect.

This is a partial fix for #714 but needs also #725 to be entirely visually correct.
2021-12-14 14:32:46 +01:00
Olivier Goffart
b8cc59afca Fix panic when compiling a property that references itself
Fixes #737
2021-12-13 15:00:19 +01:00
Olivier Goffart
a3adfd94b1 Const propagation
Inline access to constant properties
2021-11-11 11:14:59 +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
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
a55718ae7a Fix error message about the inlining env variable 2021-11-03 09:37:08 +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
98f6cab553 Make it easier to distinguish between the component types in the generators
Besides `is_global()` add `is_root_component` to Rc<Component>, so that
we can distinguish between the main component (that should have the full
API, etc.) and supplementary components.

This also avoids the generation of unnecessary members when inlining is
disabled.
2021-10-28 15:52:29 +02:00
Olivier Goffart
bcc973bb63 Make sure the ids are unique globally
For the inner elements, they don't need to be unique, but that might
make debugging easier.
For the globals, their name need to be unique.
2021-10-28 15:52:29 +02:00
Olivier Goffart
9c6bc6afc7 Do the property analysis accounting for several component 2021-10-28 15:52:29 +02:00
Simon Hausmann
0238af1780 Minor cleanup in pass handling
Remove the roots vector again, with selective inlining it's better
to use the "live" data structures instead of a copy of the roots.

It would be nice to centralize that into a helper function that returns
say an `Ref<'_, impl Iterator<Item = &Rc<Component>>>>` but that's not
possible yet.

The same chained iterator pattern is also used in some passes already.
2021-10-28 15:52:29 +02:00
Simon Hausmann
bc81d80f4a Fix structure collection with non-inlined components
Make sure that doc.root_component.used_types.structs has all the
structs, instead of storing them in used_types for each sub-component.
That should also account for the same structures used by different
components.
2021-10-28 15:52:29 +02:00
Simon Hausmann
370e2ca14b Make the inlining pass remove inlined componts from used_types.sub_components
It seems cleaner to do this in the inlining pass, as we initially selectively inline.
2021-10-28 15:52:29 +02:00
Simon Hausmann
9028f69f27 C++ generator cleanup: Remove supplementary_components field again
This amends the parent commit, we don't need a separate vec, after
inlining the sub_components should simply be empty.
2021-10-28 15:52:29 +02:00
Simon Hausmann
b5f4a2c27c C++ generator: begin generating code for supplementary components
The generation is still incomplete, but this change passes them to the C++ generator
when not inlining.

Another option would've been a "inline: bool", but that won't suffice in
the future when we may want to use heuristics to selectively inline some
and others not. And always taking used_types.sub_components is wrong
when inlining as those are ... inlined.
2021-10-28 15:52:29 +02:00
Simon Hausmann
14eb078335 Fix tests
Don't disable inlining by default
2021-10-28 15:52:29 +02:00
Simon Hausmann
6c42998a57 Make it possible to disabling inlining by environment variable
`SIXTYFPS_DISABLE_INLINING=true` will do that and subsequently apply all the optimizations passes
on all components instead of just the root.

In the future we'll flip this around make make inlining opt-in, instead
of opt-out.
2021-10-28 15:52:29 +02:00
Olivier Goffart
25dfc218b0 Collect globals before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
f25a7cbc0a Do the apply_default_properties_from_style before inlining
Note: the extra parentheses allow to avoid rustfmt to split in many lines
2021-10-28 15:52:29 +02:00
Olivier Goffart
fd8b97b228 Do the materialize_fake_properties before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
2767ceb10b Make the visible pass work on the non-inlined tree 2021-10-28 15:52:29 +02:00
Olivier Goffart
8622dcb910 Do the default_geometry pass without inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
67dd409f87 Move a few more passes before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
5f07678478 Make the layout pass work on non-inlined tree 2021-10-28 15:52:29 +02:00
Olivier Goffart
7b41f8a4bc Do the popup window pass before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
6e5596cdfc Make the repeater pass work on the non-inlined object tree 2021-10-28 15:52:29 +02:00
Olivier Goffart
171a23d7d1 Do the flickable and states passes before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
fff6f04be0 Progressively work on pass so they work without inlining
Revert part of the previous commit that tries to do all the pass without inlining

Fixup the few first passes so they work without inlining, but still do a full
inlining for most passes

The goal is to make it work pass by pass until we can have everything without
requiring full inlining
2021-10-28 15:52:29 +02:00
Simon Hausmann
a318df522b Prepare for optional inlining
Even if we make inlining optional, there are *some* situations where we just
need to do the inlining anyway to avoid
needless complexity.
2021-10-28 15:52:29 +02:00
Simon Hausmann
bf6aaf4657 Rename the embed_resources pass to embed_images
... because that's what it does, it only looks at image references.
2021-10-06 21:28:35 +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
Simon Hausmann
4a26faef9a Add AboutSixtyFPS element 2021-10-05 23:16:46 +02:00
Olivier Goffart
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Simon Hausmann
fa89758dc5 Fix background color of window when viewing non-window elements
The synthetic window we "inject" in the ensure_window() pass did not
have the window-background from the style applied. This is visible
for example when viewing something like

    Rectangle { background: blue; border-radius: height / 2 }
2021-09-23 19:19:06 +02:00
Olivier Goffart
a883ca0569 Optimize away Rectangle that serve no purpose
Rectangles which do not draw anything and have no x or y don't need to be in
the item tree, we can just remove them.
2021-09-05 09:29:00 +02:00
Simon Hausmann
0d19e2d9b9 Add support for global aliases
When exporting an global multiple times under different names, make sure
that they alias in the generated code.

As a consequence, the compiler maintains the original unique name and in
Rust and C++ makes only the exported names public. In the interpreter
the internal name is theoretically still accessible from the outside.
2021-08-31 17:09:11 +02:00
Olivier Goffart
5f8cea5926 WIP interpreter API to access globals 2021-08-27 13:36:48 +02:00
Olivier Goffart
d41839abe3 Compiler pass for the TabWidget
it will lower the TabWidget into a TabWidgetImpl and the tabs into TabImpl
2021-08-06 15:58:13 +02:00
Olivier Goffart
f38ce3c090 Fix the tests 2021-07-29 18:25:23 +02:00
Olivier Goffart
6a32a8b37a Don't error on empty documents 2021-07-29 17:40:20 +02:00
Olivier Goffart
b0b3912c27 Add support for the visible property 2021-07-29 15:02:25 +02:00
Olivier Goffart
cc8249212d Fix name conflict when having two global with the same name in different files
Give globals an unique id so two global with the same name imported
from different file don't clash

Fixes #159
2021-07-13 14:36:38 +02:00
Olivier Goffart
4604b70463 We need to collect the ressources in the root component 2021-07-07 19:45:50 +02:00
Olivier Goffart
a987b225b5 Collect all used components before inlining
And do some passes before inlining

We will need the list of components before inlining in order to generate
them if we disable inlining

So we can do some passes on each component before they are inlining

I tried to put the flickable pass in that list, but it did not work
if the Flickable itself is the root of a component
2021-07-07 17:58:43 +02:00