Commit graph

253 commits

Author SHA1 Message Date
Olivier Goffart
f80addb6a3 Make the viewer's animation work 2020-06-26 11:07:18 +02:00
Simon Hausmann
36bd645e09 First stab at supporting animations in the interpreter.
The sub-optimal RTTI bits are replaced with a superior solution in the
follow-up commit :-)
2020-06-26 11:07:18 +02:00
Olivier Goffart
1b748792ad Visit the item as Pin
A preparation to have Property::get to take Pin<Self>
2020-06-25 18:50:20 +02:00
Simon Hausmann
c18861125d Small typo fix :-) 2020-06-25 14:22:10 +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
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
fb74a8ddd4 Fix animations for the wasm build
Use the instant crate that has a transparent fall-back to performance.now().
2020-06-25 09:07:04 +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
8675cfb183 Fix animation driver to deal with freed animations
Just skip over those entries.
2020-06-25 08:58:13 +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
Simon Hausmann
ab697ab71d Parse animation declarations into the object tree
So

    animate x { ... }

is basically a short-hand for

    PropertyAnimation {
        ...
    }

    <magically associated that animation with x whenever x is changed>

We could also support a shared animation syntax in the future:

    blah := PropertyAnimation { ... }

    animate x with blah;
    animate y with blah;

This patch also adds a primitive PropertyAnimation struct, which will be
used by the generated code to collect the values specified in the .60
markup.
2020-06-24 17:43:48 +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
Simon Hausmann
d99972a77a Simplify animation driver handling
Instead of passing it through the event loop, make it accessible as a
thread local variable.
2020-06-23 13:03:35 +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
Simon Hausmann
7694337181 Simplify the animation driver API
By making the duration a "property" of the Animated trait, we can reduce
the API surface.
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
f98b18d327 Fix animation integration into the event loop
* Allow closing the window even when animations are still running (*facepalm*)
* Remember to update animations with each frame (*facepalm again*)
2020-06-20 16:24:17 +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
072bff1871 Introduce the animation driver in the event loop
This re-applies commit 1ef269305e but with
an Rc<RefCell<>> to make the borrow checker happy :-)
2020-06-20 16:24:17 +02:00
Olivier Goffart
56a75a69e5 Move the repeater part that is specific to rust within the rust lib 2020-06-19 10:06:13 +02:00
Olivier Goffart
dd3097e23c Fixup 2020-06-17 20:27:18 +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
Simon Hausmann
9df888578f Expose a ComponentWindow type in Rust
This comes with a factory function that re-directs to the backend and a
run member function to replace
sixtyfps_runtime_run_component_with_gl_renderer. For now it's all still
hidden in the generated run() method.
2020-06-17 19:15:18 +02:00
Simon Hausmann
d78c93bfee Revert "Integrate the animation driver into the event loop"
This reverts commit 1ef269305e. Breaks the
wasm build, to be fixed later.
2020-06-17 18:58:32 +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
8f0520f2be Repeater in the viewer 2020-06-17 15:43:57 +02:00
Simon Hausmann
1ef269305e Integrate the animation driver into the event loop 2020-06-17 15:16:46 +02:00
Simon Hausmann
85bf8a195a Improve EventLoop encapsulation
Hide the winit loop and extract it only in the GL renderer
2020-06-17 15:16:46 +02:00
Olivier Goffart
096fd7bbb4 Repeater in C++ 2020-06-17 14:39:33 +02:00
Simon Hausmann
e1455ff4ce Move fn eventloop::run into the eventloop::EventLoop impl 2020-06-17 10:18:36 +02:00
Simon Hausmann
5711f25195 Newtype'ify the event loop
That way it'll be easier to introduce a user event later and control the
public API.
2020-06-17 10:15:03 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +02:00
Simon Hausmann
2b95b344d8 Further cleanups
Move the GraphicsWindow into graphics.rs -- there's not much in that
file otherwise ;-) and now lib.rs is concise again.
2020-06-16 16:38:37 +02:00
Simon Hausmann
4922364c46 Cleanup: move the event loop code into a separate module 2020-06-16 16:26:52 +02:00
Simon Hausmann
405de0b0ca Further separation between window and the event loop
Make it possible to create the window without an event loop and allow mapping
the window later.
2020-06-16 16:09:52 +02:00