How to do animations in 1.16



Hello,

I am trying to get right how animations should be done in Clutter 1.16, but not everything is clear right now. So, can you help me solve the puzzle?

BTW, I am using python.

Classes I should care of are: Timeline, value intervals, Animatable, (Property|Keyframe)?Transition and TransitionGroup. ClutterAnimation should be left alone as deprecated.

I'll try to schematize what I understand and what not.

* All the classes above are not actors. Animatable is an interface, Transition is an abstract class.
* A Timeline is just a class that will generate ticks for a certain duration. This is where easing and various animation modes are set, or in general where event timings are managed.
* Value intervals are helpers that allows to interpolate between two given values (with a custom function if necessary).
* Transitions are timelines with a transition in them.
* Property transitions are transitions that refers to a single property of an actor.
* Keyframe transitions extend property transitions to introduce keyframes, so you can place different keyframes in [0,1] distributed not necessarily evenly and the class will interpolate them as needed.
* Transition group is pretty clear.

Things I do not get:

* ClutterAnimation is deprecated, but ClutterAnimatable is not. But in the manual it say that "ClutterAnimatable is an interface that allows a GObject class to control how a ClutterAnimation will animate a property".
I miss to understand how I should use Animatable without Animation...
Pheraps is the Transition class that somewhat replaces Animation?
Because, Animatable are used in ClutterTransition and its children, but...

* ...I fail to understand how ClutterTransition is used.
I can't see where on the documentation it says that Transition is an abstract class, but in Python when instancing it, it gives me:
TypeError: cannot create instance of abstract (non-instantiable) type `ClutterTransition'
So, I tried subclassing the transition like this:

class PosTrans(clu.Transition):
    def __init__(self):
        super(PosTrans, self).__init__()
    def attached(self, animatable):
        print("Attached to object", animatable)
    def detached(self, animatable):
        print("Detached from object", animatable)
    def compute_value(self, animatable, interval, progress):
        print("Progress", progress)

and use it like this:

    transition = PosTrans()
    transition.set_from(0)
    transition.set_to(50)
    transition.set_duration(2000)
    transition.set_animatable(actor) # a simple Actor
    transition.start()

But none of the above methods is called (nothing printed).

* As a marginal issue, I do not understand why in ClutterAnimatable there is a get_initial_state, but not a get_final_state, and vice-versa with the set method. I can't understand how those methods are used.

* So, I tried using PropertyTransition, like this:
    transition = clu.PropertyTransition.new('position')
    transition.set_animatable(actor)
    transition.set_duration(1000)
    transition.set_from(0)
    transition.set_to(100)
    transition.start()

but, again, nothing is happening.

I do not know where to go from here.
Can someone please help me?

Thanks for your time!
~Ale


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]