Commit Graph

124 Commits

Author SHA1 Message Date
Emmanuele Bassi
60967127b4 docs: Mention the Timeline::stopped signal in the class description
Now that we have the ::stopped signal, it would be good if the
documentation mentioned it explicitly as the dual of the ::started
signal.
2012-06-13 09:09:56 +01:00
Emmanuele Bassi
e01f9f330d timeline: Emit last ::completed before ::stopped
The ::stopped signal should be emitted at the end of the Timeline, after
the last ::completed signal emission, in order to have a proper
chronological progress of signal emissions:

  started → new-frame → [ ... ] → completed → stopped

This way, ::stopped can perform a proper teardown of the state set up
during ::started, without interfering with the potential cyclical
emission of ::completed.
2012-06-13 08:42:29 +01:00
Emmanuele Bassi
de4d70af69 timeline: Add a new "stopped" signal
The ::stopped signal is emitted when the timeline has been completely
exhausted or when the timeline has been programmatically stopped by
using clutter_timeline_stop(); the notification at the end of the
timeline run allows to write handlers without having to check whether
the current repeat is the last one, like we are forced to do when using
the ::completed signal.

Based on the patch by: Jasper St. Pierre <jstpierre@mecheye.net>

https://bugzilla.gnome.org/show_bug.cgi?id=676854
2012-05-31 09:54:23 +01:00
Emmanuele Bassi
0dd74ca3fb docs: Annotation fixes
The introspection scanner has become slightly more annoying, in the hope
that people start fixing their annotations. As it turns out, it was the
right move.
2012-04-30 17:17:41 +01:00
Emmanuele Bassi
edfe618174 timeline: Add an internal function for advancing a timeline
There are cases when we want to advance a timeline from another time
source. We cannot use _clutter_timeline_do_tick() directly, as that
assumes that the timeline is already playing, so we'll need to create a
wrapper that toggles the playing flag around it.
2012-04-27 12:30:48 +01:00
Emmanuele Bassi
bf12e23199 easing: Add utility functions
We end up copying the same array-of-modes-and-functions code in various
places, so it's better to factor it out.
2012-04-27 12:30:47 +01:00
Emmanuele Bassi
65cf2039d8 timeline: Increment current-repeat after ::completed
The ::completed signal emission is part of the current cycle; repeating,
like the automatic reverse of the timeline's direction, happens after
the ::completed chain of handlers has been called.
2012-03-19 18:07:26 +00:00
Emmanuele Bassi
388f818f41 timeline: Add more state accessors
It should be possible to ask a timeline what is its duration, taking
into account eventual repeats, and which repeat is the one currently
in progress.

These two functions allow writing animations that depend on the current
state of another timeline.
2012-03-15 17:01:13 +00:00
Emmanuele Bassi
2567049ce3 Fix missing/redundant declarations 2012-03-07 12:36:43 +00:00
Emmanuele Bassi
e5f410d4df Fix the progress function scope annotation 2012-02-23 11:23:15 +00:00
Emmanuele Bassi
7ec975ed3d timeline: Add progress functions
The whole progress computation should not be done using a separate
class: it should be part of the Timeline class.
2012-02-23 11:23:15 +00:00
Emmanuele Bassi
97feb06a6f timeline: Add repeat-count
Being able to easily set the number of repeats has been a request for
the animation framework for some time now. The usual way to implement
this is: connect to the ::completed signal, use a static counter, and
stop the timeline when the counter hits a specific spot.

In the same light as the :auto-reverse property, we can make it easier
to implement this common functionality by adding a :repeat-count
property that, when set, limits the amount of loops that a Timeline can
perform before stopping itself.

In fact, we can implement the :loop property in terms of the
:repeat-count property just by using a sentinel value mapping to
"infinity", and map loop=FALSE to repeat-count=0, and loop=TRUE to
repeat-count=-1.
2012-02-13 17:30:22 +00:00
Emmanuele Bassi
4277468928 timeline: Deprecate the clone() method
The clutter_timeline_clone() method was a pretty dumb idea when it was
introduced, back when we still had the ClutterEffectTemplate and the
clutter_effect_* animation API. It has since become an API wart: we
cannot change or add new properties to be cloned without the risk of
breaking existing code. All in all, cloning a GObject is just a matter
of calling g_object_new() with the wanted properties.

Let's deprecate this throwback of the Olden Days™, so that we can remove
it for good once we break for 2.0.
2012-02-13 17:29:45 +00:00
Emmanuele Bassi
1dfc503df1 Fix compiler warnings
When dereferencing GArray.data to a C structure you need a double cast
from guint8* to void*, and then from void* to the actual type. This
avoids compiler warnings, especially when using clang on OSX.
2012-01-16 23:49:49 +00:00
Emmanuele Bassi
24623c43a8 timeline: Add custom parser for "markers"
It should be possible to define markers in ClutterScript when
describing a ClutterTimeline.

The syntax is a trivial:

  "markers" : [
    { "name", <marker-name>, "time" : <msecs> }
  ]

While at it, we should document it inside the API reference, as well
as fleshing out the ClutterTimeline description.
2011-11-27 12:19:39 +00:00
Emmanuele Bassi
c6e487a5c1 Remove CLUTTER_TIMESTAMP debug macro
It's pretty much unused, and it doesn't print out really informative
messages. We should make CLUTTER_NOTE print out a decent timestamp
instead.
2011-11-15 16:07:13 +00:00
Emmanuele Bassi
4255a75940 docs: Fix the ClutterTimeline:auto-reverse link 2011-09-02 15:49:05 +01:00
Emmanuele Bassi
83060b30d1 docs: Remove mentions of "frames" in Timeline
We still have some really old naming lying around.
2011-09-02 13:54:57 +01:00
Emmanuele Bassi
1402c05112 timeline: Cast elapsed time before emitting ::new-frame
When emitting a new-frame signal, priv->elapsed_time is passed as a
parameter. This is a gint64. The closure marshal uses an INT. On some
platforms, this is not received correctly by signal handlers (they
receive 0). One solution is to cast priv->elapsed_time to a gint when
emitting the signal.

We cannot change the signature of the signal without breaking ABI.

https://bugzilla.gnome.org/show_bug.cgi?id=654066
2011-07-18 13:45:55 +01:00
Jasper St. Pierre
0c576c0c33 Remove private helper #define's
Finish off the second half of 09a830d294.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2596
2011-03-03 11:47:49 +00:00
Neil Roberts
5c0aaf50a7 clutter-timeline: Emit the new-frame signal even on the first frame
ClutterTimeline has special handling for the first time do_tick is
called which was not emitting a new-frame signal. This meant that an
application which directly uses the timeline would have to manually
setup the initial state of an animation after starting a timeline to
avoid painting a single frame with the wrong state. It seems to make
more sense to instead emit the new-frame signal so that the
application always sees a new-frame when the progress changes before a
paint.
2011-01-24 11:31:09 +00:00
Chris Lord
bb41cb54cb timeline: Check if the timeline is playing in do_tick
Check that the timeline is still playing before executing in
_clutter_timeline_do_tick. This fixes the possibility of receiving a
new-frame signal when stopping a timeline in response to a different
timeline's signal emission.
2011-01-18 16:23:50 +00:00
Emmanuele Bassi
c444447cd3 timeline: Rename the reverse property to auto-reverse
Other frameworks expose the same functionality as "auto-reverse",
probably to match the cassette tape player. It actually makes sense
for Clutter to follow suit.
2010-12-17 12:07:52 +00:00
Emmanuele Bassi
71a838815f timeline: Add :reverse property
The :reverse property removes the pattern of connecting to the
::completed signal of a Timeline to change the direction.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2408
2010-11-18 15:18:19 +00:00
Emmanuele Bassi
68d7a5e847 Move away from GTimeVal
GLib 2.28 will deprecate GTimeVal and related API in favour of
standardizing on microseconds granularity for all time-based API.

Clutter should switch too.

All of the current users of GTimeVal convert to milliseconds when
doing time operations, and use GTimeVal only as storage. This can
effectively be replaced by a gint64.

The Master Clock uses a microsecond resolution, except when interacting
with the main loop itself, since the main loop has a millisecond
resolution - at least until Ryan Lortie manages to switch that too to
microseconds on Linux.

The clutter_timeline_do_tick() function was erroneously not privatized,
but it was still assumed to be private; we should just remove it from
the public symbols.
2010-11-17 16:19:10 +00:00
Emmanuele Bassi
050e775da2 Move more classes to install_properties() 2010-10-18 11:26:45 +01:00
Emmanuele Bassi
3e74f42f07 introspection: Add annotations
Reduce the amount of warnings coming from g-ir-scanner.
2010-09-03 12:14:50 +01:00
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Emmanuele Bassi
b2c905ff50 Hide the marshallers
The marshallers we use for the signals are declared in a private header,
and it stands to reason that they should also be hidden in the shared
object by using the common '_' prefix. We are also using some direct
g_cclosure_marshal_* symbol from GLib, instead of consistently use the
clutter_marshal_* symbol.
2010-06-11 16:09:36 +01:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
9c8f881878 analysis: ClutterTimeline
Remove an unused variable.
2010-02-12 14:57:50 +00:00
Emmanuele Bassi
9dc012c07d [timeline] Account for clock roll backs between frames
If the system clock rolls back between two frames then we need
to account for the change, to avoid stopping the timeline.

The best option, since a roll back can be any arbitrary amount
of milliseconds, is to skip a frame.

Fixes bug:

  http://bugzilla.moblin.org/show_bug.cgi?id=3839
2009-09-16 11:57:57 +01:00
Emmanuele Bassi
a79d6228aa Remove the last few fixed-point entry points
The last fixed-point entry points are just a few, and trivial. The
end user is expected to do the conversion using the CoglFixed type
and macros.
2009-06-19 16:38:35 +01:00
Neil Roberts
f1000db3ca [timelines] Improve marker hit check and don't fudge the delta
Markers added at the start of the timeline need to be special cased
because we effectively check whether the marker time is greater than
the old frame time or less than or equal to the new frame time but we
never actually emit a frame for the start of the timeline.

If the timeline is looping then it adjusts the position to interpolate
a wrapped around position. However we do not emit a new frame after
setting this position so we need to check for markers again there.

clutter_timeline_get_delta should return the actual wall clock time
between emissions of the new-frame signal - even if the elapsed time
has been fudged at the end of the timeline. To make this work it no
longer directly manipulates priv->msecs_delta but instead passes a
delta value to check_markers.
2009-06-11 12:14:53 +01:00
Neil Roberts
9021aa2909 Revert "[timeline] Don't clamp the elapsed time when a looping tl reaches the end"
This reverts commit 9c5663d671.

The patch was causing problems for applications that expect the
elapsed_time to be at either end of the timeline when the completed
signal is fired. For example test-behave swaps the direction of the
timeline in the completed handler but if the time has overflowed the
end then the timeline would only take a short time to get back the
beginning. This caused the animation to just vibrate around the
beginning.
2009-06-11 11:46:41 +01:00
Neil Roberts
9c5663d671 [timeline] Don't clamp the elapsed time when a looping tl reaches the end
The new-frame signal of a timeline was previously guaranteed to be
emitted with the elapsed_time set to the end before it emits the
completed signal. This doesn't necessarily make sense for looping
timelines because it would cause the elapsed time to be clamped to a
slightly off value whenever the timeline restarts. This patch makes it
perform the wrap around before emitting the new-frame signal so that
the elapsed time always corresponds to the time elapsed since the
timeline was started.

Additionally it no longer fudges the msecs_delta property to make the
marker check work so clutter_timeline_get_delta will always return the
wall clock time since the last frame.
2009-06-10 17:47:33 +01:00
Owen W. Taylor
6705ce6c6a Move elapsed-time calculations into ClutterTimeline
Instead of calculating a delta in the master clock, and passing that
into each timeline, make each timeline individually responsible for
remembering the last time and computing the delta.

This:

 - Fixes a problem where we could spin infinitely processing
   timeline-only frames with < 1msec differences.
 - Makes timelines consistently start timing on the first frame;
   instead of doing different things for the first started timeline
   and other timelines.
 - Improves accuracy of elapsed time computations by avoiding
   accumulating microsecond => millisecond truncation errors.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Owen W. Taylor
ebaec9798e Simplify timeout list handling for the master clock
Instead of keeping a list of all timelines, and connecting to
signals and weak notifies, simply keep a list of running timelines;
this greatly simplifies both the book-keeping, and also determining
if there are any running timelines.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:55 +01:00
Emmanuele Bassi
19c2e66398 [docs] Various gtk-docs fixes 2009-06-09 14:47:36 +01:00
Owen W. Taylor
fd0a490ced Properly adjust msecs_delta when clamping elapsed time
When we complete a timeline, we clamp the elapsed_time variable
to the range of the timeline. We need to adjust msecs_delta so that
when we check for hit markers we have the correct interval.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-08 15:03:16 +01:00
Owen W. Taylor
276952d6f9 Fix stopping a timeline
Correctly apply De Morgan's laws to the short-circuit test in
clutter_timeline_pause(); it was short-circuiting always and
never actually pausing.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-06 13:01:17 +01:00
Neil Roberts
9c7afe0c5b [timeline] Remove the concept of frames from timelines
Timelines no longer work in terms of a frame rate and a number of
frames but instead just have a duration in milliseconds. This better
matches the working of the master clock where if any timelines are
running it will redraw as fast as possible rather than limiting to the
lowest rated timeline.

Most applications will just create animations and expect them to
finish in a certain amount of time without caring about how many
frames are drawn. If a frame is going to be drawn it might as well
update all of the animations to some fraction of the total animation
rather than rounding to the nearest whole frame.

The 'frame_num' parameter of the new-frame signal is now 'msecs' which
is a number of milliseconds progressed along the
timeline. Applications should use clutter_timeline_get_progress
instead of the frame number.

Markers can now only be attached at a time value. The position is
stored in milliseconds rather than at a frame number.

test-timeline-smoothness and test-timeline-dup-frames have been
removed because they no longer make sense.
2009-06-04 13:21:57 +01:00
Emmanuele Bassi
181ba67114 Revert commit 762873e7
The commit 762873e79e is completely
and utterly wrong and I should have never pushed it.

Serves me well for trying to work on three different branches and
on three different things.
2009-06-03 14:05:05 +01:00
Emmanuele Bassi
762873e79e [master clock] Avoid excessive redraws
Currently, the clock source spins a redraw every time there is at
least a timeline running. If the timelines were not advanced in
the previous frame, though, because their interval is larger than
the vblanking interval then this will lead to excessive redraws of
the scenegraph even if nothing has changed.

To avoid this a simple guard should be set by the MasterClock::advance
method in case no timeline was effectively advanced, and checked
before dispatching the stage redraws.
2009-06-03 12:02:56 +01:00
Emmanuele Bassi
7afdfb080b [docs] Document the destructor for Timeline
The rest of the API reference lists the destructor for the class
inside the constructor's return value -- except Timeline.
2009-05-06 16:42:57 +01:00
Neil Roberts
fa9efe4828 Accumulate small deltas
The clutter frame source tries to average out the frame deltas so that
if one frame takes 1 interval plus a little bit of extra time then the
next frame will be 1 interval minus that little bit of extra
time. Therefore the deltas can sometimes be less than the frame
interval. ClutterTimeline should accumulate these small differences
otherwise it will end up missing out frames so the total duration of
the timeline will be a lot longer.

For example this was causing test-actors to appear to run very slow.
2009-05-01 15:12:08 +01:00
Emmanuele Bassi
5be29cf9bc [timeline] Expose the msec advancement
The method of ClutterTimeline that advances the timeline by a
delta (in millisecond) is going to be useful for testing the
timeline's behaviour -- and unbreak the timeline test suite that
was broken by the MasterClock merge.
2009-05-01 15:05:51 +01:00
Emmanuele Bassi
678f99677f Use a single master "clock" to drive timelines
Currently, all timelines install a timeout inside the TimeoutPool
they share. Every time the main loop spins, all the timeouts are
updated. This, in turn, will usually lead to redraws being queued
on the stages.

This behaviour leads to the potential starvation of timelines and
to excessive redraws.

One lesson learned from the games developers is that the scenegraph
should be prepared in its entirety before the GL paint sequence is
initiated. This means making sure that every ::new-frame signal
handler is called before clutter_redraw() is invoked.

In order to do so a TimeoutPool is not enough: we need a master
clock. The clock will be responsible for advancing all the active
timelines created inside a scene, but only when the stage is
being redrawn.

The sequence is:

  + queue_redraw() is invoked on an actor and bubbles up
    to the stage

  + if no redraw() has already been scheduled, install an
    idle handler with a known priority

  + inside the idle handler:

    - advance the master clock, which will in turn advance
      every playing timeline by the amount of milliseconds
      elapsed since the last redraw; this will make every
      playing timeline emit the ::new-frame signal

    - queue a relayout

    - call the redraw() method of the backend

This way we trade multiple timeouts with a single frame source
that only runs if a timeline is playing and queues redraws on
the various stages.
2009-04-24 15:28:15 +01:00
Chris Lord
cc21a4aa5f [ClutterTimeline] Fix clutter_timeline_set_delay
When setting a delay, timeout_add was being used with msecs. timeout_add
takes fps since the fix to bug #1495. Delay now uses g_timeout_add
instead.
2009-03-26 20:29:23 +00: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