Commit graph

148 commits

Author SHA1 Message Date
Simon Hausmann
d650cadc02 Release graphics resources of items when deleting components in C++ 2020-08-13 13:31:52 +02:00
Olivier Goffart
2ddfe76840 Fix bug with mouse input and dynamic models 2020-08-13 10:59:45 +02:00
Olivier Goffart
7e1af72a2e Implement minimum/maximum width/height properties 2020-08-12 14:00:51 +02:00
Olivier Goffart
092411ccef Attempt to merge the layout code between rust and C++
This does not actually merge so much but it is better than nothing.

I was not able to merge the code from the interpreter because of the life time issues
2020-08-12 11:53:39 +02:00
Simon Hausmann
b21aa4f9e7 Rename PropertyListenerScope to PropertyTracker 2020-08-12 11:31:33 +02:00
Simon Hausmann
aafb96cb93 Get rid of abi::datastructures::WindowProperties
Instead, pass a reference to the root item when mapping the window,
at which point we can downcast to the new Window item. If we have one,
then we'll read its width/height (for initial values) and install
bindings to keep them up-to-date.
2020-08-12 09:44:42 +02:00
Simon Hausmann
c1f91e38ca Move the window scale factor into GraphicsWindow 2020-08-11 13:42:51 +02:00
Simon Hausmann
f2eec61968 Add a window to the top-level component
This means that we always have a window and for the C++
API we don't require this ComponentWindow use anymore.
2020-08-11 13:38:38 +02:00
Simon Hausmann
0fb6eef939 Fix build with Apple clang
The compiler complains that intptr_t is not the same type as "long long".
The "long long" originates from "pub struct VisitChildrenResult(i64);"
and I suppose the compiler is right for potential 32-bit architectures. So
let's use int64_t as counter-part to i64.
2020-08-11 10:16:37 +02:00
Olivier Goffart
f4cce26d51 Test the mouse click 2020-08-10 12:54:29 +02:00
Olivier Goffart
36243ccdf7 Traverse item front to back for input events 2020-08-10 10:45:02 +02:00
Olivier Goffart
cc5d5cc92b C++: Fix input event within repeater 2020-08-10 08:55:42 +02:00
Olivier Goffart
5de801d023 C++: grabbed mouse input 2020-08-07 16:06:49 +02:00
Olivier Goffart
b4684cc1f5 C++: put thre item_tree in a separate function.
We'll need that for the input event
2020-08-07 16:06:49 +02:00
Olivier Goffart
1ee313c643 C++: separate the declaration and the definition of functions
We already did it manually for some functions. But more functions are
about to require the full definition of the other classes
2020-08-07 16:06:49 +02:00
Olivier Goffart
5aa7ee86fe Use a newtype for VisitChildrenResult instead of just isize
Makes the code easier to unserstand
2020-08-07 16:06:49 +02:00
Olivier Goffart
55ec533c40 WIP input events
Compile and passes tests. But the mouse event are currently not working
2020-08-07 16:06:49 +02:00
Simon Hausmann
fcc819e395 Add support for enums to the compiler
This replaces the duplicated text alignment enums
2020-08-07 13:15:43 +02:00
Simon Hausmann
aecf6a8878 Center text in buttons in the demo and gallery
This adds horizontal_alignment/vertical_alignment properties, along with
width/height to Text.

This still uses a hard-coded enumeration in the compiler, which is meant
to go away in favor of general enum support.
2020-08-07 10:02:52 +02:00
Olivier Goffart
479173c22f Implement spacing in GridLayout 2020-08-05 15:42:38 +02:00
Olivier Goffart
2518af41b1 Fix for in a declared component 2020-08-04 18:51:39 +02:00
Olivier Goffart
0199b70cea if statements 2020-08-04 17:36:20 +02:00
Simon Hausmann
254df328d0 Add support for images (resources) in models
This also allows replacing the emojis (not working due to lack of fallback) with images
2020-08-04 16:09:33 +02:00
Simon Hausmann
7277d15394 Provide a better error message when failing to convert a type to C++ 2020-08-04 15:04:18 +02:00
Simon Hausmann
41671e3efb Represent the window scale factor conversions in the IR
That means less code in the generators and easier to extend in the
future with more built-in functions.
2020-08-04 12:49:37 +02:00
Olivier Goffart
2b9e529af7 Fix unicode in strings in C++ 2020-08-04 11:52:47 +02:00
Simon Hausmann
4f0bf0b982 Rename dpi to (window) scale_factor 2020-08-04 09:01:30 +02:00
Olivier Goffart
d7bb993d7b Fix clang warnings 2020-08-03 18:46:11 +02:00
Olivier Goffart
da11b33e9b Version check
Compilation error when the compiler and the runtime are not on the same version
2020-08-03 18:44:36 +02:00
Olivier Goffart
b2a1a72450 C++: add on_* funciton to connect to signals 2020-08-03 15:01:10 +02:00
Olivier Goffart
a4efac920a C++: make all properties and sub elements private 2020-08-03 15:01:10 +02:00
Simon Hausmann
480a8470f5 Remove dead code 2020-07-30 19:51:33 +02:00
Simon Hausmann
cb7aca54d4 Implement support for nested layouts in the C++ generator 2020-07-30 19:41:38 +02:00
Olivier Goffart
9760cf4969 Begin to implement a Flickable
The implementation is still very rough and will need to be improved
2020-07-30 14:36:21 +02:00
Simon Hausmann
e881d89bf9 Get rid of visible x/y properties in GridLayout
It doesn't really make sense to have them in the API, the grid layout is
supposed to "own" the surrounding space. That can be an element and then
it should be a (0, 0) and distribute the element's width/height, or in
the future it can be a cell of a grid layout. Then there's an (x/y), but
that's implicit / hidden.
2020-07-29 18:52:22 +02:00
Simon Hausmann
4fccbba29d Prepare for "virtualizing" the grid layout's width/height
Instead of storing the "within" element that we unconditionally take the
"width" and "height" properties from, let's pass through a property
reference expression to the width/height to use. For now that's still
the layout parent's width/height, but with this it can be replaced in
the future to refer to a "virtual" property that belongs to parent cell.
2020-07-29 18:52:22 +02:00
Simon Hausmann
00271a3746 Extend the layout data structure in the compiler to allow nesting 2020-07-29 18:52:22 +02:00
Simon Hausmann
f853843bc4 Store layouts in a common enum and vector
That'll make it easier later to allow for nesting them.
2020-07-29 18:52:02 +02:00
Olivier Goffart
edd9575b53 Add easing curve in the C++ backend 2020-07-29 15:29:55 +02:00
Olivier Goffart
feec73674f Start implementing easing curve 2020-07-29 15:19:41 +02:00
Olivier Goffart
f02512f467 Allow to get the span of a binding 2020-07-28 18:02:23 +02:00
Olivier Goffart
b57f3775c9 Refactor GridLayout 2020-07-28 10:31:05 +02:00
Simon Hausmann
88fb491837 Add support for mapping elements to different native classes
The Rectangle element has properties for a border outline. If those are
used, then the generated code should use BorderRectangle. But if they are
not used, then we can fall back to just generating a Rectangle.
2020-07-24 17:48:19 +02:00
Simon Hausmann
6c27451761 Begin separating builtin elements from the underlying types
This uses a NativeClass type in the registry to represent the underlying
Rust/C++ types.
2020-07-24 16:11:46 +02:00
Olivier Goffart
f87a3e2c13 Assignment operator 2020-07-24 11:43:23 +02:00
Olivier Goffart
05c5f7c53d Test and fix animations on properties
The animation should not start when the property is initialized, only when the
property is set by the setter
2020-07-23 11:45:34 +02:00
Olivier Goffart
1a1d3dbec0 Store two consecutive read of the same variable in a temporary variable
Avoid to create too many dependencies when not required.
Especially the state transformation can create a lots of read to the same property
2020-07-22 17:24:26 +02:00
Simon Hausmann
f8c0eb0bd6 Prepare for passing passing more information from syntax node to diagnostics
Let the bulk of the push_error() calls take a Spanned trait impl, so
that we can pass node on the call sites. Then when later change the
underyling trait to pass something that can also provide the source file
and we don't have to change all call sites again.
2020-07-20 16:01:15 +02:00
Simon Hausmann
0cb59381e4 Fix type of PropertyDeclaration::type_location
In preparation for passing through the source file, avoid storing the Span
in the object tree and instead store the syntax node.
2020-07-20 15:36:17 +02:00
Olivier Goffart
6c54dfb67d Layout the item in a PathLayout if they are part of a repeater 2020-07-17 15:00:12 +02:00