Commit graph

179 commits

Author SHA1 Message Date
Olivier Goffart
2ee861365c Flickable: expose the viewport property as viewport_*
The code generator forward that the the viewport
2020-09-22 13:52:27 +02:00
Simon Hausmann
7053aee0c8 Pass the ComponentWindow to ItemVTable::input_event 2020-09-18 16:18:48 +02:00
Simon Hausmann
72ee03a1a5 Fix build with clang
Similar to the issue fixed in commit
de74ae4534, clang appears to assume that
the float literal is a double our object literals and aggregate
initialization to float members (like the level of InkLevel) requires an
explicit cast.

I don't know of a way to determine the type of a struct field by index easily,
so this build fix instead uses C++17 destructuring to initialize the fields by index.

So

    InkLevel{ std::get<0>(o), std::get<1>(0) }
                              (^^ fails when get returns double and
                              field is float)

becomes

    InkLevel s; auto& [f1, f2] = s; f1 = std::get<0>(o); f2 = std:get<1>(o); return s;
2020-09-17 16:40:05 +02:00
Olivier Goffart
bfe2bf2478 Ability to read properties of a struct 2020-09-17 13:53:00 +02:00
Olivier Goffart
8134fe5088 Support for named type as property 2020-09-17 13:14:01 +02:00
Simon Hausmann
79ba5d9de8 Provide a window reference in various ItemVTable functions
Access to the window, in particular the scale factor, will be needed in a few places.
2020-09-15 15:55:47 +02:00
Olivier Goffart
4a0a65f113 C++ model that can be changed 2020-09-15 12:18:36 +02:00
Simon Hausmann
09142beac4 Make C++'s Color consistent with Rust's Color
sixtyfps::Color shall have the same minimal API by providing from_argb_encoded and as_argb_encoded.
2020-09-08 22:19:58 +02:00
Olivier Goffart
6065127581 Some progress towards signal with arguments
Generated code compile, but i haven't tested if it works yet
2020-09-08 17:41:20 +02:00
Olivier Goffart
a6504ee61b Start implementing some code that passes argument to functions and signals 2020-09-08 14:37:44 +02:00
Olivier Goffart
a192ffe283 Make the C++ Signal class templated on the arguments 2020-09-08 13:11:32 +02:00
Olivier Goffart
e10ed650ee Lookup of signal argument within a signal handler 2020-09-08 12:12:01 +02:00
Olivier Goffart
9f026c820d Parse declaration of signal with arguments 2020-09-07 17:41:24 +02:00
Olivier Goffart
16f5cf42e3 Actually compute the layout of elements within a for loop 2020-09-07 14:04:14 +02:00
Simon Hausmann
ec36a50a25 Add support for warning diagnostics
They're emitted via codemap_diagnostics. For the Rust proc-macro we
generate a funny warning symbol until the proper APIs are stable.
2020-09-04 20:28:43 +02:00
Olivier Goffart
f6c8ea0f20 Make the Model/Repeater type safe in C++ 2020-09-04 19:02:56 +02:00
Olivier Goffart
f5aeb9ba60 Only the computation of the model needs to be done in the evaluation scope for it
Otherwise any change in any of the properties of the delegate will cause
the model to be reset.
2020-09-04 15:37:38 +02:00
Olivier Goffart
9fbb40d91b Start working on a debug statement 2020-09-03 19:10:07 +02:00
Simon Hausmann
fab3d9355d Remove ItemVisitorRefMut and ComponentRef from the public C++ API
It's only for internal use and just typedefs to private types anyway.
2020-09-03 15:44:36 +02:00
Olivier Goffart
a36cb2d9b4 Layout: add a padding shorthand property
Also fix a bug in the C++ code generator where two layout have padding
in the same component
2020-09-01 13:29:13 +02:00
Simon Hausmann
5dbd0b213c Add support for grid layout padding 2020-08-28 15:06:14 +02:00
Simon Hausmann
7976a4057f Improve handling of nested layouts
We support directly nested layouts, but we did not support indirect
nesting:

    GridLayout {
        Rectangle {
            l2 := GridLayout { ... }
        }
    }

This patch fixes that by detecting this scenario and merging the layout
info of the element (Rectangle) and the layout inside (l2). This makes
it much easier to create re-usable components that use layouts
themselves and allows placing them in layouts.
2020-08-28 15:06:14 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
7fb4c544f9 Fix C++ build 2020-08-25 23:01:20 +02:00
Simon Hausmann
9785919f6e Hide a few APIs from the C++ documentation
Since Doxygen can't seem to just exclude them via command, they are moved
into a private_api namespace and then excluded via Doxygen config:

    * *VTable
    * make_dyn_node, ItemTreeNode, etc.
    * VersionCheck
2020-08-25 17:45:12 +02:00
Simon Hausmann
9dd6101494 Avoid using cbindgen_private in generated C++ code
Instead, pull in the types manually.
2020-08-25 15:36:29 +02:00
Simon Hausmann
14fe897086 Move all cbindgen generated code into
sixtyfps::cbindgen_private

Having private in the name makes it clear that this is ... private,
and cbindgen helps remember that it's generated.
2020-08-25 15:29:48 +02:00
Olivier Goffart
058a91ba75 Fix repeater access to properties within sub components 2020-08-24 08:27:22 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
55888afb1c Implement releasing of graphics resources in C++ via the component destructor 2020-08-13 16:35:04 +02:00
Olivier Goffart
fb5a82b6c7 Fix acessing repeater variable in a nested repeater, and fix array as property 2020-08-13 15:38:28 +02:00
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