Commit graph

250 commits

Author SHA1 Message Date
Olivier Goffart
7bfa998f00 Popup positioning 2020-11-30 18:39:41 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Olivier Goffart
0c97b4f296 More use of the ItemRc 2020-11-24 13:42:34 +01:00
Simon Hausmann
3d85e45ec3 Add support for source clipping to the Image element
This allows rendering only a sub-rectangle of the original image, which
we can use right away in the sliding puzzle demo.
2020-11-23 15:46:59 +01:00
Olivier Goffart
08fe5f6c72 Add a Clip 2020-11-20 15:45:45 +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
3cd84473e2 Transitions in the interpreter 2020-11-20 12:32:43 +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
Olivier Goffart
cfa9413861 More work on the state binding for transition:
When there is a transition, turn the state property into a property of StateInfo

Not yet implemented for C++
2020-11-19 12:43:28 +01:00
Simon Hausmann
ba96e8570f Interpreter: Fix self_weak location
It needs to be in the instance (the extra data), in order for us to be able to access it conveniently.
2020-11-18 10:50:56 +01:00
Simon Hausmann
b4ad5786d5 Simplify VRc handling in the interpreter
All call sites of dynamic_component::instantiate move the result into a VRc<ErasedComponentBox>,
so might as well do this in that function.

Also added a self_weak for future use.
2020-11-18 09:59:05 +01:00
Simon Hausmann
7a5113ece1 Free graphics resources without item tree traversal 2020-11-18 08:49:57 +01:00
Simon Hausmann
04e1774b7e Interpreter: Make the window a permanent field of each instance
Avoid the parent dance in the interpreter as well to get the window reference.
2020-11-17 11:43:08 +01:00
Simon Hausmann
c258a907f0 Simplify event loop start-up
Move the layout constraint tracker into the window where we can apply
the constraints right before drawing, instead of doing that from within
the event loop. This allows to remove the component parameter from the
run function.
2020-11-12 15:04:48 +01:00
Simon Hausmann
79bfa080c6 Fix crash of the online editor
Component's get_item_ref has a life time attached to it, and in the
interpreter we're having two vtable implementations, one for
ErasedComponentBox and another generated one. The approach with
as_pin_ref to transfer the lifetime to a reference to the trait object
for the other vtable isn't working because as_pin_ref consumes the VRef
and then takes the address of a temporary on the stack.

Short of a cleaner solution, this patch circumvents the second vtable
indirection and calls our extern "C" function directly.
2020-11-12 14:35:01 +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
Simon Hausmann
a9791c390d Wrap the main component in a VRc 2020-11-11 18:14:15 +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
a1f1fcb3a6 Use VRc<ComponentVTable> in the rust generated code 2020-11-09 14:58:37 +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
4a182ef4d0 Layout alignment 2020-11-03 12:22:34 +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
2ece3817cc Make ModelHandle a struct
Last commit broke for structures containing models, because models are not PartialEq.
So we need to implement PartialEq for ModelHandle. Which means a struct needs to
be created
2020-10-31 13:32:19 +01:00
Olivier Goffart
d2255327fe Properties: make sure that the falue is different before marking all dependencies dirty
Fix the animation of the gauge in the printer demo
2020-10-31 12:58:11 +01:00
Olivier Goffart
e4e7ae46f4 Support for for in box layout in the interpreter 2020-10-31 11:24:31 +01:00
Olivier Goffart
359f42c5f7 Prepare the compiler to be async
This will allow the online editor to load imports from URL asynchroniously later

Since currently the compiler is only working on a single thread, and that we
never await on a future that could block, it is allowed to use the spin_on executor
2020-10-30 15:00:04 +01:00
Olivier Goffart
f855b18fb0 Implement min/max size restriction on the window
(Implemented in the interpreter only for now)
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
9dc0d69cbb Intepreter: refactor the eval function: put the component in the context 2020-10-29 11:01:04 +01:00
Olivier Goffart
64afcdb813 rename a variable so it has the same name as in the other frontend 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
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
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
c659c4369a Refactor the Layout generation code 2020-10-26 10:07:31 +01:00
Olivier Goffart
ed01d8369a Start working on VerticalLayout/HorizontalLayout 2020-10-23 14:08:58 +02:00
Olivier Goffart
27a6ff1227 Move Type and related concepts in a different module
Leaving only the TypeRegister in the typeregister module
2020-10-23 11:17:14 +02:00
Olivier Goffart
4fb87f401e Some fixes for the initializations of two way bindings within sub components
There are still more issues
2020-10-20 14:33:06 +02:00
Simon Hausmann
13f845ee4f Add support for property<percent> 2020-10-16 18:56:54 +02:00
Olivier Goffart
58193ff1c3 Fix resizing of listview should recompute the layout 2020-10-16 11:09:12 +02:00
Olivier Goffart
d57ad389e0 Default to the native style in the viewer if it is available 2020-10-14 14:51:47 +02:00
Simon Hausmann
d8459ef00e GridLayout cleanup
Separate out the padding and spacing parameter handling. A separate data
holds these and the code generation is also split out into
helper functions in the C++ and Rust generator. This will allow re-use in the future.
2020-10-13 22:52:04 +02:00
Simon Hausmann
e5b8e5d64d Prepare for more code sharing in layout handling
Move layout constraints for layout items into a separate
helper struct.
2020-10-13 18:17:47 +02:00
Simon Hausmann
1b4317a93a Minor cleanup in the layout code in the compiler
Free the term "Layout Constraints" for use later for the actual constraints
of layouts.
2020-10-13 18:00:54 +02:00