Commit graph

463 commits

Author SHA1 Message Date
Simon Hausmann
1f091cb1c0 Rename Rectangle.color to Rectangle.background
Add support for built-in property aliases and rename `color` to
`background` - in preparation for it also changing to type brush.

Right now the alias is silent, a deprecation and overall change
will come in a subsequent change.
2021-02-02 17:01:12 +01:00
Olivier Goffart
ad1e18764a Make angle its own type 2021-02-01 14:49:25 +01:00
Olivier Goffart
2d12e118ac Resolve linear gradients 2021-02-01 14:25:27 +01:00
Olivier Goffart
e2db0e49dc Fix explicit size in box layouts using for
Fixes #147
2021-01-29 16:35:59 +01:00
Olivier Goffart
c099ac98da Fix some invalid identation 2021-01-26 17:25:55 +01:00
Olivier Goffart
e0e3a1aaad Fix parent_item()
We need to skip over the DynamicItem
2021-01-26 17:05:30 +01:00
Olivier Goffart
a4abb86782 Don't return the ItemWeak by value
It is not working in C++ because ItemWeak has a destructor
2021-01-26 13:17:24 +01:00
Olivier Goffart
c2982d9ab3 Add ability to get the parent item from the vtable
(still untested)
2021-01-26 10:36:37 +01:00
Olivier Goffart
5a21f1bd81 Rename emit_ to call_ for callback
Signal was renamed to Callback, but one does not emit a callback, one calls it
2021-01-25 15:59:10 +01:00
Olivier Goffart
c2dc0cef2c Finish return statement handling 2021-01-25 15:32:00 +01:00
Simon Hausmann
b22bbb1c0f WIP: Implement the return statement 2021-01-25 15:32:00 +01:00
Simon Hausmann
f7ea2a9dce Forward focus() calls on items that have initial-focus defined
This also makes the focus() method available as a member function on any
item, but the resolve_element_reference_in_set_focus_calls() pass will
check if the elements are valid.

The check for `has-focus` to determine a focusable item was replaced
with an annotation on the built-in elements, so that `has-focus` can
later be implemented as a built-in function through the run-time,
without the need for a boolean property.
2021-01-20 14:31:01 +01:00
Simon Hausmann
5f265ffc09 Split up ComponentWindow::run() into show(), hide() and sixtyfps::run_event_loop()
This allows creating multiple windows for example, and it will allow for
showing windows in those tests that require a mapped window.

As a bonus, the run() function on generated components is not consuming
anymore.
2021-01-19 09:50:22 +01:00
Simon Hausmann
58768bf70a Add default bindings for width/height for Image and Text to their implicit size 2021-01-15 17:58:32 +01:00
Olivier Goffart
16f5a03c14 Run cargo fmt 2020-12-18 10:29:15 +01:00
Olivier Goffart
dfa25b96f7 Rename SharedArray to SharedVector 2020-12-18 10:26:07 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Olivier Goffart
7f78bea8b5 Fix a bunch of cargo clippy warnings in the compiler 2020-12-07 12:54:38 +01:00
Olivier Goffart
2a751fcdc8 Remove debug output 2020-12-07 11:39:27 +01:00
Olivier Goffart
f9dc2af9f1 Small style change 2020-12-05 17:48:02 +01:00
Olivier Goffart
d81145e436 Fix native global component
Make sure the native style is tested on the CI
2020-12-05 17:00:38 +01:00
Simon Hausmann
4670854500 Remove as_ref from the public API of the generated Rust component
This was only needed in our tests.
2020-12-03 13:31:58 +01:00
Simon Hausmann
d6291a83b8 Fix warnings about case naming
Do not generate a public interfaces for internal components
2020-12-03 09:50:25 +01:00
Simon Hausmann
de603635db Silcene warning about dead code
It's okay of the public as_ref() function isn't used in the imported/inline
app code
2020-12-03 09:49:17 +01:00
Simon Hausmann
bfa2078ea2 Clean up internal component naming in the Rust generator
Use InnerFoo for the struct that's pinned and Foo for the public
type that wraps the VRc<InnerFoo>.
2020-12-03 09:35:37 +01:00
Simon Hausmann
47152eee89 Remove the sixtyfps::Component trait
It is not needed anymore
2020-12-03 09:16:20 +01:00
Simon Hausmann
866ad62ef2 Cleanup in the rust generator
Have only one implementation of the public property/signal interface
again
2020-12-03 09:05:23 +01:00
Simon Hausmann
83191c82cc Remove ComponentHandle and ComponentWeakHandle 2020-12-03 08:13:40 +01:00
Simon Hausmann
7047856d4e Replace FooRc with Foo and without ComponentHandle in examples and tests 2020-12-03 08:13:24 +01:00
Simon Hausmann
e83c50e6e4 Use the new API also for internally created components 2020-12-03 08:13:15 +01:00
Simon Hausmann
dd64226dc1 Implement sixtyfps::Weak
This is the counter-part to the strongly referencing type the compiler
generates for components.
2020-12-03 08:13:15 +01:00
Simon Hausmann
ff1d752bc6 First step towards a wrapping public component API without ComponentHandle
For now the compiler also generates FooRc next to Foo, which wraps a
strong reference (VRc) to Foo.

This is an intermediate step and at the end of the series FooRc should
replace Foo and sixtyfps::ComponentHandle.
2020-12-03 08:13:15 +01:00
Olivier Goffart
bff55d4f1b Return value for signal 2020-12-01 18:52:51 +01:00
Olivier Goffart
276e11a101 More work on signals with return value 2020-12-01 18:47:49 +01:00
Olivier Goffart
7bfa998f00 Popup positioning 2020-11-30 18:39:41 +01:00
Olivier Goffart
b0a9d65f55 More Popup WIP 2020-11-30 18:39:41 +01:00
Olivier Goffart
852eeb1c11 WIP popup 2020-11-30 15:20:51 +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
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
091a0834d3 Transitions in rust (C++ and interpreter not implemented yet) 2020-11-20 10:30:17 +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
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
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
f9ced44188 Rust: Simplify window access code
We don't need to do the parent dance anymore, use _self.window directly.
2020-11-16 16:55:29 +01:00
Simon Hausmann
7d5131afc8 Rust: Make the window a member of each struct
This avoids the parent dance in the Drop implementation
2020-11-16 15:56:13 +01:00
Olivier Goffart
dd4435fe5d Add round/ceil/floor 2020-11-16 12:52:01 +01:00