27 #define EV_TIMELINE_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_TIMELINE, EvTimelinePriv))
28 #define MSECS_PER_SEC 1000
29 #define FRAME_INTERVAL(nframes) (MSECS_PER_SEC / nframes)
30 #define DEFAULT_FPS 30
97 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
115 g_value_set_uint (value, priv->
fps);
118 g_value_set_uint (value, priv->
duration);
121 g_value_set_boolean (value, priv->
loop);
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
141 g_timer_destroy (priv->
timer);
143 G_OBJECT_CLASS (ev_timeline_parent_class)->finalize (
object);
153 gdk_threads_enter ();
157 elapsed_time = (guint) (g_timer_elapsed (priv->
timer, NULL) * 1000);
158 progress = (gdouble) elapsed_time / priv->
duration;
159 progress = CLAMP (progress, 0., 1.);
163 if (progress >= 1.0) {
177 gdk_threads_leave ();
191 g_timer_continue (priv->
timer);
193 priv->
timer = g_timer_new ();
196 g_assert (priv->
fps > 0);
209 GObjectClass *object_class = G_OBJECT_CLASS (
class);
217 g_object_class_install_property (object_class,
219 g_param_spec_uint (
"fps",
221 "Frames per second for the timeline",
226 G_PARAM_STATIC_STRINGS));
227 g_object_class_install_property (object_class,
229 g_param_spec_uint (
"duration",
230 "Animation Duration",
231 "Animation Duration",
236 G_PARAM_STATIC_STRINGS));
237 g_object_class_install_property (object_class,
239 g_param_spec_boolean (
"loop",
241 "Whether the timeline loops or not",
244 G_PARAM_STATIC_STRINGS));
246 g_signal_new (
"started",
247 G_TYPE_FROM_CLASS (object_class),
251 g_cclosure_marshal_VOID__VOID,
255 g_signal_new (
"paused",
256 G_TYPE_FROM_CLASS (object_class),
260 g_cclosure_marshal_VOID__VOID,
264 g_signal_new (
"finished",
265 G_TYPE_FROM_CLASS (object_class),
269 g_cclosure_marshal_VOID__VOID,
273 g_signal_new (
"frame",
274 G_TYPE_FROM_CLASS (object_class),
278 g_cclosure_marshal_VOID__DOUBLE,
289 "duration", duration,
313 g_timer_stop (priv->
timer);
329 g_timer_destroy (priv->
timer);
332 priv->
timer = g_timer_new ();
380 g_object_notify (G_OBJECT (timeline),
"fps");
405 g_object_notify (G_OBJECT (timeline),
"loop");
420 g_object_notify (G_OBJECT (timeline),
"duration");
449 elapsed_time = (guint) (g_timer_elapsed (priv->
timer, NULL) * 1000);
450 progress = (gdouble) elapsed_time / priv->
duration;
452 return CLAMP (progress, 0., 1.);