Commit graph

41 commits

Author SHA1 Message Date
Olivier Goffart
952ddda7c4 Force duration to have an unit 2020-07-14 16:18:12 +02:00
Simon Hausmann
f8024e6658 Add support for looping in animations 2020-07-14 13:22:28 +02:00
Olivier Goffart
e00491811b Get rid of the context in properties/signal 2020-07-13 18:49:06 +02:00
Olivier Goffart
769474a478 Introduce a property listener 2020-07-03 13:02:50 +02:00
Olivier Goffart
b529a021a2 Fix bug in the property linked list
Not having a prev can happen if the property itsalf was destroyed.
2020-07-02 18:08:46 +02:00
Olivier Goffart
90ed79e39f Remove unused code in the animation driver 2020-07-02 17:36:34 +02:00
Olivier Goffart
055a3baf90 Remove the binding when the animation on value is finished. 2020-07-02 17:28:04 +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
Olivier Goffart
6863c3f631 Use scoped_thread_local for the CURRENT_BINDING 2020-06-30 10:11:34 +02:00
Simon Hausmann
b8ca0fe3c9 Add support for animating color properties 2020-06-27 16:51:48 +02:00
Olivier Goffart
2d22bac451 Use Pin<&Self> for Property::get 2020-06-26 13:18:04 +02:00
Simon Hausmann
e6b386ab53 Implement property animations for C++ 2020-06-25 13:38:51 +02:00
Simon Hausmann
a19c9619fa Prepare PropertyAnimationBinding for use with C++
Don't take the binding as a Rust function, take a ready-to-set Rc<dyn
Binding> trait object.
2020-06-25 11:55:24 +02:00
Simon Hausmann
c40840baf9 Property animation binding cleanups for upcoming C++ support
Remove Property::set_binding_object and instead have an associated
helper method on PropertyImpl, as in C++ only we have the inner impl.

Also removed set_notifier_callback() from the Binding trait, as it's not
needed there anymore - we can set up the callback right away at property
animation construction time, so that it also works without a Property<T>
but just an inner.
2020-06-25 11:42:30 +02:00
Simon Hausmann
9bd6fd0808 Naming cleanups in preparation for C++ support
Rename properties::PropertyAnimation to PropertyAnimationBinding -- it's
mostly an internal type anyway. This way
abi::primitives::PropertyAnimation remains the only type with that name
and exposing it to C++ is straight-forward.
2020-06-25 11:41:42 +02:00
Simon Hausmann
ee4b78a132 Delete value animations when they are done
We don't need the binding and animation objects anymore upon completion.
2020-06-25 09:01:26 +02:00
Simon Hausmann
459a8e3b25 Clean up property and animation associated
Set up everything in the construction function of property animation
instead of constructing it and setting up stuff afterwards in Property.
2020-06-25 08:42:27 +02:00
Simon Hausmann
8be058d563 Clean up property binding interface
The trait functions that allowing a binding (animation) to intercept a
new value or binding is not needed anymore since the generated code is
supposed to cover all call sites and pass the appropriate animation at
that point.
2020-06-25 08:26:14 +02:00
Simon Hausmann
e7ba02c85a Fix animation of properties by value in the Rust generator
Don't require an evaluation context when setting up an animated value.
We can find out what the current value is inside evaluate.
2020-06-25 08:20:37 +02:00
Simon Hausmann
3a5ebd86e0 Prepare to connect Property with PropertyAnimation
This patch replaces the 'install()' approach for property animations
with explicit set_animated_value() and set_animated_binding() functions
in Property -- to be called from generated code.

This requires a little dance-around for the time being that
PropertyAnimation is designed to act automatically on value transitions,
but that can be removed later without changing the interface.

Also the animation details are copied right away. This is sub-optimal,
we should somehow keep a reference to the properties or get notified
when they change, for example perhaps through a simple property binding.
2020-06-24 17:54:25 +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
Simon Hausmann
197a900331 Fix drop for PropertyAnimation
Get rid of the constructor function, stick to Default and provide a
setter for the duration instead.
2020-06-23 13:56:10 +02:00
Simon Hausmann
90766f0f82 Simplify PropertyAnimation
Remove the animation_driver member and fetch it on-demand instead.
2020-06-23 13:51:26 +02:00
Simon Hausmann
4f761960f0 Remove stray debug output 2020-06-23 13:40:52 +02:00
Simon Hausmann
688f111563 Added simple linear property animation class 2020-06-23 13:27:09 +02:00
Olivier Goffart
32c230e840 Property: small refactor to improve reasoning about the safety
Improve the safety by explicitly borrowing both inner and the value
and putting all the (non-ffi) unsafe in only two functions
2020-06-23 11:41:41 +02:00
Olivier Goffart
4ee86a9bef Add a generic T to Binding and PropertyImpl
(This also removes one heap allocation per binding)
2020-06-23 11:16:11 +02:00
Simon Hausmann
264dfa3148 Add support for animations to Property<T>
This is done by extending the Binding trait to allow intercepting any
newly set values or bindings and reporting back to the property.
2020-06-22 20:01:07 +02:00
Simon Hausmann
5762f5b065 Small naming cleanups
* Renamed PropertyNotify::notify to register_current_binding_as_dependency
  as the implementor doesn't actively notify anybody, it merely results
  in registering the currently evaluating binding as a dependency.
  Also fixed the docs that I added a short while ago -- I got it the
  wrong way around :)

* Renamed CURRENT_PROPERTY to CURRENT_BINDING to reflect that this is
  about the currently evaluating binding (that'll become a dependency to
  notify)
2020-06-22 19:27:15 +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
Simon Hausmann
db6b130570 Prepare for animations as temporary bindings
By allowing the binding of a property to be a reference-counted trait
object, instead of just a plain function pointer.
2020-06-20 16:24:17 +02:00
Simon Hausmann
c0e3f6c250 Fix build
The parent commit erroneously removed the trait, which was because of a
local conflict with further changes.
2020-06-17 18:52:49 +02:00
Simon Hausmann
9df8b5da1a Add some documentation for the PropertyNotify trait 2020-06-17 18:49:10 +02:00
Olivier Goffart
54f81d4d29 C++ Only link against the backend library
For some raison, not all symbols gets exported,
add some dummy code which seems to do the trick
2020-06-17 18:38:47 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Olivier Goffart
74898a1386 Make property conneciton binding in the C++
(somehow plus/minus is not working yet)
2020-05-28 14:52:43 +02:00
Simon Hausmann
f2df9293a9 Fix the C++ build
Remove the Optional from the evaluation context passing for property
evaluation. Unfortunately there are nullptr uses left on the C++ side,
that need to be replaced with passing through.
2020-05-28 12:07:11 +02:00
Simon Hausmann
daf23f8736 Pass the evaluation context through the binding closure 2020-05-28 09:20:11 +02:00
Simon Hausmann
c4dd857e0d Add an evaluation context to property evaluations
The context is not used yet or passed on to the binding closure.
2020-05-28 09:20:11 +02:00
Olivier Goffart
8ec6fd5237 Change the representation of the Property to be more FFI friendly 2020-05-19 15:09:45 +02:00
Olivier Goffart
cdeb3a4312 Import of a basic property system 2020-05-19 12:47:52 +02:00