Commit graph

255 commits

Author SHA1 Message Date
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Simon Hausmann
fa95064363 Fix resource embedding across component boundaries
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.

This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.

This patch addresses these two bugs by cleaning up the entire mechanism:

The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
2020-11-23 13:47:16 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
551c50560f Fix warning with clang 2020-11-20 12:47:32 +01:00
Olivier Goffart
d5c4885955 Transitions in C++ 2020-11-20 11:38:03 +01:00
Olivier Goffart
4d4c73925c Some refactoring to prepare for transitions on properties 2020-11-20 09:39:06 +01:00
Simon Hausmann
78fae068dd Use ComponentRc during item tree traversal
This is in preparation for allowing the run-time / items to clone VRc's
of the component.

ComponentVTable functions like visit_children_item contine to take a
ComponentRefPin as "self" parameter type, as a VRc would not be
supported by rust right now. That means the implementation then uses
self_weak to obtain a strong self-reference.
2020-11-19 17:04:01 +01:00
Simon Hausmann
54cc66c400 Fix timing/placement of extra setup code
The setup code is used to place an initial set_focus_item call, for
example. In preparation for future changes, this needs to happen *after*
self_weak has been set up. For C++ this means placing the code into the
create() function, where there's no (implicit) this pointer, so we need
to use self in some places.
2020-11-19 17:00:56 +01:00
Simon Hausmann
9c9e6c7563 Clean up C++ repeated component creation
Centralize the self_weak setup to be emitted only once, in the create()
function. create() is now always emitted and equipped with a parent
parameter, for non-root components. This allows slightly simplifying the
generic repeater code.
2020-11-19 16:41:26 +01:00
Simon Hausmann
7d7903d1ae Fix warning about extra parentheses for conditionals 2020-11-19 15:50:26 +01:00
Simon Hausmann
ce8c728c57 Fix clang warning about implicitly truncating double to int
Well, let's do that explicitly then. The test case mod.60 uses

    mod(8.3, 10)
2020-11-19 15:46:07 +01:00
Olivier Goffart
15fd1c45a3 More warning fixes with clang 2020-11-19 15:04:39 +01:00
Olivier Goffart
6b3dd802a3 Another attempt to fix clang warning about unused captures 2020-11-19 14:42:29 +01:00
Olivier Goffart
88d559eb09 Revert "Attempt to fix clang warning about unused capture"
This reverts commit 3b26dc215e.

This did not work
2020-11-19 14:39:46 +01:00
Olivier Goffart
3b26dc215e Attempt to fix clang warning about unused capture 2020-11-19 14:28:06 +01:00
Olivier Goffart
3fce3e6f1b Get rid of the component in the C++ ComponentWindow::run 2020-11-19 13:42:52 +01:00
Olivier Goffart
c50fc6f51c More work on state properties with transitions
C++ set the proper binding for StateInfo state binding
2020-11-19 13:31:18 +01:00
Simon Hausmann
a2839e03c2 Cpp: Add a self_weak to repeated components
The main struct has it, and sub-components should have it, too.
2020-11-18 12:00:30 +01:00
Simon Hausmann
7a5113ece1 Free graphics resources without item tree traversal 2020-11-18 08:49:57 +01:00
Olivier Goffart
7967a074fb Fix accessing struct declared in a different file 2020-11-17 12:02:21 +01:00
Simon Hausmann
54ee7b3556 Cpp: Give each generated component a ComponentWindow
That's a counted reference to the window in the run-time and avoids the need to do the parent->parent->window dance.
2020-11-16 16:59:57 +01:00
Olivier Goffart
dd4435fe5d Add round/ceil/floor 2020-11-16 12:52:01 +01:00
Olivier Goffart
b45a14bd7a modulo 2020-11-13 16:07:18 +01:00
Olivier Goffart
d499e86640 Implement cubic-bezier 2020-11-13 13:36:32 +01:00
Simon Hausmann
64b92df87e Initialize the component in the Window at component creation time
This will allow getting rid of the component as parameter to run()
2020-11-11 19:03:04 +01:00
Simon Hausmann
5d744c86c2 Begin passing the VRC<ComponentVTable, Dyn> into the run-time library
First by changing the signature of run() and by adding a self_weak
to the C++ struct.
2020-11-11 18:31:51 +01:00
Olivier Goffart
7f66ca9584 Add a function in the ComponentVTable to get an ItemRef from an index
Needed to adjust vtable so it can work if the return type has a reference
2020-11-11 14:29:44 +01:00
Olivier Goffart
d6a440aa4a Change C++ API to use the ComponentHandle 2020-11-10 19:28:34 +01:00
Olivier Goffart
95c4bac794 Add a dealloc and drop_in_place function to the ComponentVTable 2020-11-06 17:13:01 +01:00
Olivier Goffart
11e55dd8d2 String -> Float conversions 2020-11-03 15:19:58 +01:00
Olivier Goffart
4a182ef4d0 Layout alignment 2020-11-03 12:22:34 +01:00
Olivier Goffart
661982e747 Fix bindings on animation duration 2020-11-02 21:15:22 +01:00
Olivier Goffart
a82c23fc41 Add ability for the native style to export native Globals 2020-11-02 16:13:04 +01:00
Olivier Goffart
232d59bf24 Ensure that the repeater are updated when layouting box layout 2020-11-02 11:37:04 +01:00
Olivier Goffart
1eb7203ec8 Also do the comperty comparison in C++ 2020-10-31 14:36:38 +01:00
Olivier Goffart
ab14978fa8 Support for in box layout in the C++ backtend 2020-10-31 09:10:16 +01:00
Olivier Goffart
a4b476bdf3 implement Component::layout_info in C++ 2020-10-29 19:08:52 +01:00
Olivier Goffart
5face45c51 Rename Component::compute_layout to apply_layout
And pass the expected rectangle.
This is currently not used yet but will be needed when we can have
repeated elements within a box layout
2020-10-29 19:08:52 +01:00
Olivier Goffart
1479bc956e Support for global in the interpreter 2020-10-29 11:01:04 +01:00
Olivier Goffart
7f7bf6acb4 Access of global items from C++ 2020-10-29 11:01:04 +01:00
Olivier Goffart
70d6648880 Remove some remains of code that allowed to use Component as Object 2020-10-27 16:25:21 +01:00
Olivier Goffart
d3801e26d3 Change the syntax of structures to require the struct keyword 2020-10-27 16:09:05 +01:00
Olivier Goffart
333c96fd79 Change Type::Object to be able to hold a name
Internally, structure will be represented with a Type::Object with a name
instead of a Component with a void base type
2020-10-27 16:09:05 +01:00
Olivier Goffart
4a702243d1 Fix C++ layouts 2020-10-27 08:16:02 +01:00
Olivier Goffart
9ec2013a3a Layout refactor: move the constraints dirrectly into the layout item 2020-10-26 17:17:29 +01:00
Olivier Goffart
47be71e16d Introduce layout stretching 2020-10-26 16:40:35 +01:00
Olivier Goffart
7ff0b4b73f Vertical layout 2020-10-26 14:19:12 +01:00
Olivier Goffart
aeade826fe New runtime implementation for the box layout
Currently only horizontal layout is supported
2020-10-26 14:19:12 +01:00
Olivier Goffart
537051a1e4 Refactor get_layout_info_ref to contains the constraints 2020-10-26 14:19:12 +01:00
Olivier Goffart
c659c4369a Refactor the Layout generation code 2020-10-26 10:07:31 +01:00