Commit graph

175 commits

Author SHA1 Message Date
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
Olivier Goffart
46a011683f Implement easing curve in the runtime 2020-07-29 15:20:28 +02:00
Olivier Goffart
b57f3775c9 Refactor GridLayout 2020-07-28 10:31:05 +02:00
Simon Hausmann
389c2ab3cd Fix build of C++ tests 2020-07-24 11:08:40 +02:00
Olivier Goffart
1d7effd030 Add missing files 2020-07-23 11:56:43 +02:00
Olivier Goffart
1dec276002 Continue adapting the window size
Implement the Rust and C++ part
2020-07-15 17:52:14 +02:00
Simon Hausmann
ddc4fb6e1f WIP: window size
Just playing around with propagating the width/height of the window.
2020-07-15 17:52:14 +02:00
Olivier Goffart
96e5738785 Add a DPI variable in the interpreter and in the C++ backend 2020-07-15 17:13:23 +02:00
Olivier Goffart
e00491811b Get rid of the context in properties/signal 2020-07-13 18:49:06 +02:00
Simon Hausmann
535da41ae0 More naming cleanups
PathData::PathElements has one redundant "Path" in the name, so eliminate
for Events and Elements.
2020-07-10 13:06:28 +02:00
Simon Hausmann
1f7ae1b318 Rename PathElements to PathData
as it can now consists of elements or events.
2020-07-10 13:01:05 +02:00
Simon Hausmann
4b6e549b96 Simplify compiled path data structure
Use two arrays, one for events and one for coordinates. That simplifies
the code generator and the generated code, and it also provides for
a more compact memory representation.
2020-07-10 10:20:59 +02:00
Simon Hausmann
4b75ec0ee8 Lay out items on a path
This works, but it's still missing support for positioning of the layout
itself.
2020-07-09 15:32:47 +02:00
Simon Hausmann
251ef7fc97 Add support for SVG commands in Path elements
Using the commands property we can just paste SVG paths. This makes it
much easier to write examples/demos. A good online path designer is
for example https://codepen.io/anthonydugois/pen/mewdyZ
2020-07-09 13:41:57 +02:00
Simon Hausmann
f646809ff4 Added ArcTo element for paths 2020-07-07 16:02:46 +02:00
Simon Hausmann
1ab71b8ca3 Prepare the path element setup in the run-time for extensibility
Make the anonymous struct for the LineTo variant in the PathElement enum
as separate structure, which can be introspected using rtto::FieldInfo.
2020-07-07 14:14:17 +02:00
Olivier Goffart
90532e80d2 C++: Support of dynamic model and if expression 2020-07-03 17:37:07 +02:00
Olivier Goffart
769474a478 Introduce a property listener 2020-07-03 13:02:50 +02:00
Olivier Goffart
9d852f802e Property refactoring
The tests are working and everything seems to be back normal.
But there is still some cleanup required
2020-07-02 14:14:49 +02:00
Simon Hausmann
4e22c2839e Add the rendering primitives for rendering a path
Right now the path is limited to polygons (only LineTo elements) and only the fill color can be specified.
2020-07-01 14:58:09 +02:00
Simon Hausmann
e4ab64f858 Add a SharedArray type
This is based on the SharedString code and will allow sharing ownership
of arrays between Rust and C++.
2020-07-01 14:58:09 +02:00
Olivier Goffart
967a2b94eb C++: put a pointer to the parent in the component 2020-06-29 10:35:18 +02:00
Simon Hausmann
b8ca0fe3c9 Add support for animating color properties 2020-06-27 16:51:48 +02:00
Simon Hausmann
be75cb2b21 Fix failing C++ build tests
Making color a real property type broke the build of tests that compare
color properties. Fix this and the incorrect decoding of
strings in the cast to colors, by providing a proper public C++ color
wrapper type.
2020-06-27 16:09:59 +02:00
Simon Hausmann
e6b386ab53 Implement property animations for C++ 2020-06-25 13:38:51 +02:00
Olivier Goffart
f50a705e00 Add the #[pin] attribute to be able to project to the pinned item 2020-06-25 12:18:09 +02:00
Olivier Goffart
caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00
Olivier Goffart
f8b7989c0b Access the properties in the parent component of a repeated element
This required some refactoring of the EvaluationContext structure to include the parent context
2020-06-22 14:38:38 +02:00
Olivier Goffart
4e3473d40c clang_format 2020-06-19 14:30:50 +02:00
Olivier Goffart
022cd64625 Support for array model in C++ 2020-06-19 14:29:54 +02:00
Olivier Goffart
6238d0d14f Prepare for the ability to access the model
Add an expression type for the access of the model variable from a repeater
2020-06-19 13:46:55 +02:00
Olivier Goffart
864e74601d Add a Model type for
I guess in the future we want to make model a type that knows its inside
2020-06-19 13:13:19 +02:00
Simon Hausmann
8f613685ba Expose a ComponentWindow in C++
This paves a way for a more modular API.
2020-06-17 19:15:18 +02:00
Olivier Goffart
096fd7bbb4 Repeater in C++ 2020-06-17 14:39:33 +02:00
Olivier Goffart
e8c825b434 Add a test for embedded conditionals
Also fix the initialization of properties in C++, make them zero-initialized like in rust
2020-06-16 17:47:10 +02:00
Olivier Goffart
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +02:00
Olivier Goffart
e7644eba94 Fix C++ compilation with the new item visitor 2020-06-12 17:09:51 +02:00
Olivier Goffart
ef9d3963e4 Fix casting of conditional operator 2020-06-12 10:32:56 +02:00
Olivier Goffart
9c23326c60 Layout for the C++ as well 2020-06-10 19:41:24 +02:00
Olivier Goffart
bd4bcdfeb3 Even better way to use enums from C++ 2020-06-10 10:18:27 +02:00
Olivier Goffart
4c6205d09b Use the generated internal::types::Resource from the C++ resource header 2020-06-10 10:06:41 +02:00
Simon Hausmann
1404cb73ae Add support for embedding resources in the rust generator
This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
2020-06-09 22:54:29 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Simon Hausmann
547a732e33 Fix rebuild issues, part 10523
By setting RUSTFLAGS in the Cargo config we run into the situation that
when doing a host build, all rust files are compiled with the flags,
including build.rs. When cross-compiling, build.rs is not build with the
RUSTFLAGS specified. That makes kind of sense, but it also means that
all the build scripts are always recompiled when switching between a
target and a host build - and that applies to *all* packages, including
dependencies.

So short of a better solution, this patch removes the need to set
RUSTFLAGS. It was used to extract the system library dependencies for
the static library we'd create. Instead we're now building two shared
libraries and are linking against them. They contain the rust library
twice, so that's not really a desirable final state either, but
productivity wins right now :-)

It might make sense to go back to creating *one* shared library through
a dedicated crate and -- since 'pub extern "C"' functions are not
transitively exported, it may require re-exporting them by hand or using
some clever build trick perhaps.
2020-06-09 13:08:59 +02:00
Simon Hausmann
2e0a5ddb25 Create & install a cmake package file (part 3)
The cargo target directory tree is now populated with a cmake package
file and that's also installed into the prefix specified with the cargo
cmake xtask.

As a consequence, the cpptest example can be built by first building the
cmake package:

    cargo xtask cmake

    or

    cargo xtask cmake --release --target some-triplet)

    or

    cargo xtask cmake --release --prefix /somewhere --install

and then run cmake in the cpptest example with a prefix path:

    -DCMAKE_PREFIX_PATH=/where/you/installed/it or simply
    -DCMAKE_PREFIX_PATH=../../target/debug for example.

Pending still is the sixtyfps compiler tool installation and discovery.
2020-06-04 15:33:18 +02:00
Simon Hausmann
c5001703d4 Build the cmake module for our runtime as xtask, part 2
This is done by calling cargo with json output to build the libraries,
collect the .a files, extract the native libraries needed for final
linkage and pass all that to a CMake project that cobbles together the
.a files into a propery cmake target with include paths, etc.
2020-06-04 15:29:19 +02:00
Olivier Goffart
ec8baa81f2 formating 2020-06-04 14:05:17 +02:00
Simon Hausmann
12457ed7f3 Fix crash when using optimized gcc builds
Don't return void in non-void functions.
2020-06-04 08:44:24 +02:00
Olivier Goffart
63430c2acb Add a readme for the cpp api 2020-05-31 15:34:04 +02:00