Commit Graph

64 Commits

Author SHA1 Message Date
Emmanuele Bassi
be8f53f229 animation: Fix a typo
This will teach me to check before compiling a version-dependent branch
that I'm actually using my jhbuild environment and not the system
libraries.
2010-02-25 12:01:03 +00:00
Emmanuele Bassi
26e22b2ede Conditionally use G_VALUE_COLLECT_INIT() macro
GLib 2.24 (but starting from the 2.23.2 unstable release) added a new
macro for collecting GValues from a va_list.

The newly added G_VALUE_COLLECT_INIT() macro should be used in place
of initializing the GValue and calling G_VALUE_COLLECT(), and improves
the collection performances by avoiding multiple checks, free and
initialization calls.
2010-02-25 10:22:36 +00:00
Emmanuele Bassi
89191e8bbc docs: Mention signal-swapped-after modifier
The signal-swapped-after:: modifier for signal connection inside the
clutter_actor_animate* variadic arguments functions is not mentioned in
the documentation.
2010-02-15 11:44:02 +00:00
Emmanuele Bassi
6dc0e9632c analysis: ClutterAnimation
• Remove one unused variable.

• We ignore the result of get_timeline_internal() so we need to tell
  the compiler that - though a better solution would be to split the
  timeline implicit creation into its own function.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
09f91ff6ea script: Use a node when resolving an animation mode
Instead of taking a string and duplicating the "is it a string or an
integer" check in both Alpha and Animation, the function in
ClutterScript that resolves the animation mode values should take a
JsonNode and do all the checks it needs.
2010-02-08 15:45:43 +00:00
Emmanuele Bassi
7073e69b4e animation: Verify internal state
Be more drastic if the internal state is broken, and assert() if the
expected Alpha and Timeline instances we need are not valid. This
usually implies a library bug or a massive heap corruption.
2010-01-22 21:42:55 +00:00
Emmanuele Bassi
8daa3035e5 docs: Fix the Animation:object property
There is a typo in the Animation:object property gtk-doc declaration.
2010-01-22 21:42:10 +00:00
Emmanuele Bassi
0788aa43b2 animation: Add more debug annotations
We need some better tracking of the Animation's lifetime.
2010-01-22 21:41:33 +00:00
Emmanuele Bassi
7fa7c4a1b6 animation: Transform if necessary
The Animation code does transformation of values between type A and A'
after checking for compatibility using g_value_type_compatible(). This
is incorrect: compatibility means that the two types can be copied. The
correct conversion should follow:

        if (compatible (type (A), type (A')))
          copy (A, A');
        else
          if (transformable (type (A), type (A')))
            transform (A, A');
          else
            error("Unable to trasform type A in A'");

The transformation might still fail, so we need to check for errors
there as well as a fall-through case.
2010-01-22 21:36:41 +00:00
Emmanuele Bassi
94249efff7 animation: Check for value transformability
We should not just check for compatibility, but also for the ability to
transform a GValue of type A into another of type A'.

Usually compatibility is enough, especially if types can be
introspected beforehand; some times, though, we also need to check for
transformability as a type can provide the transformation functions
necessary for the operation.
2010-01-22 21:33:28 +00:00
Emmanuele Bassi
328ce370e7 animation: Keep a weak reference on actors
Actors, unlike objects, can effectively go away whilst being
animated - usually because of an explicit destoy().

The Animation created by clutter_actor_animate() and friends
should keep a weak reference on the actor and eventually
get rid of the animation itself in case the actor goes away
whilst being animated.
2009-11-24 16:59:24 +00:00
Emmanuele Bassi
49cd887aab docs: Document the AnimationMode definition
Both ClutterAlpha:mode and ClutterAnimation:mode can be defined using:

  • an integer id
  • the "nick" field of the AnimationMode GEnumValue
  • a custom, tweener-like string

All these methods should be documented.
2009-11-13 15:01:17 +00:00
Emmanuele Bassi
d54f4e944c Whitespace fixes 2009-11-13 15:01:17 +00:00
Emmanuele Bassi
9bae553564 animation: Override parsing :mode
Like in ClutterAlpha, ClutterAnimation:mode must be overridden when
parsing a Script definition, as we accept both a numeric id and the
string id for easing modes.
2009-11-13 15:01:17 +00:00
Neil Roberts
c69209a253 [animation] Move the check for the 'signal::' prefix into a separate function
The old code checked whether the property began with 'signal-' and
then checked for 'signal-swapped' and 'signal-after'. This prevented
you from animating a property called for example 'signal-strength'.

The check for the prefix is now in a separate function which also adds
a 'signal-swapped-after' prefix for completeness.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1798
2009-09-07 12:44:06 +01:00
Emmanuele Bassi
95a6e1c925 Fix the warnings for Animation::update_interval()
The bindings for update_interval() were copied from bind().
2009-08-25 12:18:32 +01:00
Emmanuele Bassi
899f051cd9 [animation] Add Animation::update()
Currently, to update a property inside an animation you have to
get the interval for that property and then call the set_final_value()
method.

We can provide a simpler, bind()-like method for the convenience of
the developers that just validates everything and then calls the
Interval.set_final_value().
2009-08-25 12:16:41 +01:00
Jonas Bonn
3761e9cd47 Check timeline direction when forcing final state
If the timeline is running backwards, the completed signal handler should
set the final state from the interval's initial value.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-08-19 14:57:07 +01:00
Emmanuele Bassi
8a794a8533 [docs] Fix the examples for animate()
Update the examples to reference to existing easing modes and to
make sure to use floating point values for floating point properties.
2009-08-13 16:13:55 +01:00
Emmanuele Bassi
57baa2f0bc [animation] Fix variable use
Instead of using the proper typed variables we were overwriting
the gpointer for the Interval's final value.
2009-07-28 13:21:57 +01:00
Emmanuele Bassi
fa3728126f [animation] Force the final state inside ::completed
In case we are skipping too many frames, we should force the animation
instance to apply the final state of the animated interval inside the
::completed signal handler.
2009-07-28 11:43:05 +01:00
Jakub Higersberger
efc16a4d90 Use correct signal detail
The Animation should connect to the notify::alpha signal, not to
the non-existing notify::value signal.

Fixes bugs:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1674
  http://bugzilla.openedhand.com/show_bug.cgi?id=1688

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-07-12 01:32:24 +01:00
Tim Horton
e9d277609d Add element-type annotations for animate*v functions
Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1653

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-22 12:27:17 +01:00
Emmanuele Bassi
9799750c03 [animation] Rework animation chaining
In order to chain up animations using clutter_actor_animate() and
friends you have to use an idle handler that guarantees that the
main loop spins at least once after the animation pointer has been
detached from the actor.

This has several drawbacks, first and foremost the fact that the
slice of the main loop for the idle handler might be starved by
other operations, like redrawing. This inevitably leads to tricks
with priorities and the like, contributing to the overall complexity.

Instead, we should guarantee that the animation instance created by
clutter_actor_animate() is valid for the ::completed signal until
it reaches its default handler; after that, the animation is detached
from the actor and destroyed. This means that it's possible to
create a new animation after the first is complete by simply using
g_signal_connect_after().

This unfortunately makes it impossible to keep a reference to the
animation pointer attached to the actor by using g_object_ref(); a
way to "fix" this would be to have a clutter_animation_attach()
and a clutter_animation_detach() pair of methods that allow attaching
any animation to an actor. This might overcomplicate what it is
the simple animation API, though, so it's currently not implemented
and left for future versions.

The test-easing interactive demo has been modified to show how
the animation queuing works by adding a command line switch that
recenters the animated actor once the first animation has ended.
2009-06-15 11:49:33 +01:00
Emmanuele Bassi
612d1cded7 [animation] Allow swapped/after signal variants
Continuing in the tradition on making clutter_actor_animate() the
next g_object_connect(), here's the addition of the signal-after::
and signal-swapped:: modifiers for the automagic signal connection
arguments.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1646
2009-06-15 11:48:42 +01:00
Emmanuele Bassi
fd19d33746 [animation] Keep a reference during notify::alpha
The Animation should be referenced during the notification of the
alpha value, since the callback is invoked depending on the Alpha
and it won't vivify the Animation instance for us.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1537
2009-06-08 14:42:22 +01:00
Bastian Winkler
6f7afdf553 Broken fixed:: arguments
The commit 2c95b378 prevents clutter_animation_setup_property from being
called with fixed:: property names. This patch adds a additional
parameter "is_fixed" to clutter_animation_setup_property instead of
searching for "fixed::" in property_name.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-06 12:58:00 +01:00
Jonas Bonn
faec5c468b Freeze notifiers around property setters
Notifications should be fired off from both the internal timeline and
the wrapping animation here, so notifiers should be frozen around these
property setters.

Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-29 16:22:46 +01:00
Jonas Bonn
1187972e45 [animation] Final cleanups to new Animation model
Just a couple of final cleanups after the reimplementation of the
Animation model.

i)  _set_mode does not need to set the timeline on the alpha
ii) freeze notifications around the setting of a new alpha

Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-29 16:22:27 +01:00
Emmanuele Bassi
7b75f93db1 [docs] Fixes for the API reference
* Add unused symbols

* Document and sync argument names with their gtk-doc counterpart

* Add missing descriptions
2009-05-28 17:18:13 +01:00
Emmanuele Bassi
ccd3b4c886 [animation] Simplify the Animation code
After long deliberation, the Animation class handling of the
:mode, :duration and :loop properties, as well as the conditions
for creating the Alpha and Timeline instances, came out as far too
complicated for their own good.

This is a rework of the API/parameters matrix and behaviour:

  - :mode accessors will create an Alpha, if needed
  - :duration and :loop accessors will create an Alpha and a Timeline
    if needed
  - :alpha will set or unset the Alpha
  - :timeline will set or unset the Timeline

Plus, more documentation on the Animation class itself.

Many thanks to Jonas Bonn <jonas@southpole.se> for the feedback
and the ideas.
2009-05-27 18:28:37 +01:00
Emmanuele Bassi
6fff1bcdc6 [animatable] Allow validation in ::animate_property
The Animatable interface implementation will always have the computed
value applied, whilst the non-Animatable objects go through the
interval validation first to avoid incurring in assertions and
warnings.

The Animatable::animate_property() should also be able to validate the
property it's supposed to interpolate, and eventually discard it. This
requires adding a return value to the virtual function (and its wrapper
function).

The Animation code will then apply the computed value only if the
animate_property() returns TRUE -- unifying the code path with the
non-Animatable objects.
2009-05-27 13:01:31 +01:00
Emmanuele Bassi
7edaf8ece8 [animation] Proxy properties whenever possible
The Animation class should proxy the :mode, :duration and :loop
properties whenever possible, to avoid them going out of sync when
changed using the Alpha and Timeline instances directly.

Currently, if Timeline:duration is changed, querying Animation:duration
will yield the old value, but the animation itself (being driven by
the Timeline) will use the Timeline's :duration new value. This holds
for the :loop and :mode properties as well.

Instead, the getters for the Animation's :duration, :loop and
:mode properties should ask the relevant object -- if any. The
loop, duration and mode values inside AnimationPrivate should only
be used if no Timeline or no Alpha instances are available, or
when creating new instances.
2009-05-27 12:12:11 +01:00
Emmanuele Bassi
1f44c3584c [animation] Defer the timeline handling to the Alpha
The Animation should not directly manipulate a Timeline instance,
but it should defer to the Alpha all handling of the timeline.

This means that:

  - set_duration() and set_loop() will either create a Timeline or
    will set the :duration and :loop properties on the Timeline; if
    the Timeline must be created, and no Alpha instance is available,
    then a new Alpha instance will be created as well and the newly
    create Timeline will be assigned to the Alpha

  - if set_mode() on an Animation instance without an Alpha, the
    Alpha will be created; a Timeline will also be created

  - set_alpha() will replace the Alpha; if the new Alpha does not
    have a Timeline associated then a Timeline will be created using
    the current :duration and :loop properties of Animation; otherwise,
    if the replaced Alpha had a timeline, the timeline will be
    transferred to the new one
2009-05-27 11:52:40 +01:00
Emmanuele Bassi
081813fd61 [animation] Do not leak timelines
The timeline created when calling set_timeline(NULL) is referenced
even though we implicitly own it. When the Animation is destroyed,
the timeline is then leaked.

Thanks to: Richard Heatley <richard.heatley@starleaf.com>

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1548
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
ab1dcb8033 [animation] Remove InitiallyUnowned from Animation
ClutterAnimation currently inherits the initial floating reference
semantics from GInitiallyUnowned. An Animation is, though, meant to
be used as a top-level object, like a Timeline or a Behaviour, and
not "owned" by another object. For this reason, the initial floating
reference does not make any sense.
2009-05-06 17:01:44 +01:00
Emmanuele Bassi
d6d208da7d Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.

ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.

So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:

  - we have to maintain twice the amount of entry points in ClutterActor
  - we still do an integer-to-float implicit conversion
  - we introduce a weird impedance between pixels and "pixels with
    fractionary bits"
  - language bindings will have to choose what to bind, and resort
    to manually overriding the API
    + *except* for language bindings based on GObject-Introspection, as
      they cannot do manual overrides, thus will replicate the entire
      set of entry points

For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:

  void clutter_actor_set_x (ClutterActor *self,
                            gfloat        x);
  void clutter_actor_get_size (ClutterActor *self,
                               gfloat       *width,
                               gfloat       *height);
  gfloat clutter_actor_get_height (ClutterActor *self);

etc.

The issues I have identified are:

  - we'll have a two cases of compiler warnings:
    - printf() format of the return values from %d to %f
    - clutter_actor_get_size() taking floats instead of unsigned ints
  - we'll have a problem with varargs when passing an integer instead
    of a floating point value, except on 64bit platforms where the
    size of a float is the same as the size of an int

To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:

  - we remove ambiguity in the API with regard to pixels and units
  - we remove entry points we get to maintain for the whole 1.0
    version of the API
  - we make things simpler to bind for both manual language bindings
    and automatic (gobject-introspection based) ones
  - we have the simplest API possible while still exposing the
    capabilities of the underlying GL implementation
2009-05-06 16:44:47 +01:00
Emmanuele Bassi
a1cc1f57ac [animation] Do not connect to ::completed multiple times
The clutter_actor_animate*() family of functions should only connect
to the Animation::completed signal once, during the construction of
the Animation object attached to the Actor. Otherwise, the completed
signal handler will be run multiple times, and will try to unref()
the Animation for each call -- leading to a segmentation fault.
2009-04-05 20:32:15 +01:00
Emmanuele Bassi
6bf883da6c [animation] Add the ::started signal
The Animation class is missing a ::started signal matching the
::completed one. A ::started signal is useful for debugging,
initial state set up, and checks.
2009-04-03 14:19:20 +01:00
Emmanuele Bassi
df738d0a8c [animation] Do not unref on ::complete by default
Bug 1535 - Complete animation always unrefs ClutterAnimation (even
           after g_object_ref_sink)

Animations created through clutter_animation_new() should not
automagically unref themselves by default on ::complete. We
only want that behaviour for Animations created by the
clutter_actor_animate* family of functions, since those provide
the automagic memory management.
2009-04-03 12:47:21 +01:00
Bastian Winkler
34467e5c6a [docs] Fix some inconsistency in Animation
For some examples of clutter_actor_animate the parameters of @mode and
@duration are swapped.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 17:34:07 +01:00
Øyvind Kolås
f6d938a0db [animation] add varargs support for signal::completed
Added support for registering a handler for the completed signal
directly amongst the varargs making it easier to attach code
to be executed when animations complete.
2009-03-30 12:10:41 +01:00
Emmanuele Bassi
ccca24ab76 Remove usage of the grave accent as quotation mark
See:

  http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This should make Thomas happy.
2009-03-17 14:13:31 +00:00
Emmanuele Bassi
567a96c96a [docs] More information on animation queueing
Queuing an animation on an actor cannot be done from within the
::completed signal handler, because we guarantee that the Animation
instance is valid and attached to the actor it animates for the
whole duration of the signal emission chain.

In order to queue animations you have to install an idle handler
on the main loop, and call clutter_actor_animate() inside it.

The documentation should be more clear about this caveat in the
memory management of ClutterAnimations created by the animate()
family of functions.
2009-03-16 18:20:58 +00:00
Emmanuele Bassi
216373047b [animation] Enhance consistency of the Animation API
The Animation API should follow this pattern:

  - functions with an Interval as part of the arguments should have
    "interval" inside their name, e.g.:

      clutter_animation_bind_interval
      clutter_animation_update_interval

  - functions dealing with property names should have "property"
    inside their name, e.g.:

      clutter_animation_has_property
      clutter_animation_unbind_property

    - unless -

  - functions dealing with a property and its value should not
    have any modifier, e.g.:

      clutter_animation_bind

The change from update_property() to update_interval() frees up
clutter_animation_update(), to be added at a later date.
2009-03-16 14:16:18 +00:00
Colin Walters
0cb0a841cc [animation] Enhance the bind API
Bug 1419 - Add clutter_animation_bind, rename clutter_animation_bind_interval

This is a different approach from the clutter_actor_animatev
vector variant.  The single call should be even easier on
automatic bindings, since calls can be chained like:

  new Clutter.Animation({object: myactor}).bind("x", 42).bind("y", 43);

Note clutter_animation_bind_property which took a ClutterInterval
is renamed to clutter_animation_bind_interval for clarity, and to
discourage use since there are friendlier APIs about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
156589fe3f [animation] Add Animation getter
If we are animating an actor using the clutter_actor_animate*() family
of functions we might want to expose a getter for the Animation instance
we are using, to avoid excessing bookkeeping.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
44d0733665 [animation] Add an emitter for ::completed
The ::completed signal requires an emitter in case we want to stop
the animation and safely dispose it inside application code without
breaking invariants.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
a5c88e62f2 [docs] Clarify Animation memory management
The memory management of the ClutterAnimation instances should be
heavily documented, given its "automagical" nature, so that other
people might understand it and avoid breaking it in the future.
2009-03-16 12:13:55 +00:00
Geoff Gustafson
2c95b378a5 [animation] Broken fixed:: properties
This commit yesterday:

89e3e3a4cc
[animation] Add vector variants for ::animate()

broke the "fixed::" attribute on properties in clutter_actor_animate(),
because the fixed:: part is still on the string when it checks to see if
it's a valid property the class knows about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-11 22:09:05 +00:00