GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 168ebb83 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Matthias Clasen

timeline: Add _gtk_timeline_get_elapsed_time()

To get the time in milliseconds since the last frame
parent 170b391e
......@@ -35,6 +35,7 @@ struct GtkTimelinePriv
guint source_id;
GTimer *timer;
gdouble elapsed_time;
gdouble progress;
gdouble last_progress;
......@@ -309,19 +310,18 @@ gtk_timeline_run_frame (GtkTimeline *timeline)
{
GtkTimelinePriv *priv;
gdouble delta_progress, progress;
guint elapsed_time;
/* the user may unref us during the signals, so save ourselves */
g_object_ref (timeline);
priv = timeline->priv;
elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
priv->elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
g_timer_start (priv->timer);
if (priv->animations_enabled)
{
delta_progress = (gdouble) elapsed_time / priv->duration;
delta_progress = (gdouble) priv->elapsed_time / priv->duration;
progress = priv->last_progress;
if (priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD)
......@@ -515,6 +515,25 @@ _gtk_timeline_is_running (GtkTimeline *timeline)
return (priv->source_id != 0);
}
/**
* gtk_timeline_get_elapsed_time:
* @timeline: A #GtkTimeline
*
* Returns the elapsed time since the last GtkTimeline::frame signal
*
* Return Value: elapsed time in milliseconds since the last frame
**/
guint
_gtk_timeline_get_elapsed_time (GtkTimeline *timeline)
{
GtkTimelinePriv *priv;
g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0);
priv = timeline->priv;
return priv->elapsed_time;
}
/**
* gtk_timeline_get_fps:
* @timeline: A #GtkTimeline
......
......@@ -84,6 +84,7 @@ void _gtk_timeline_pause (GtkTimeline
void _gtk_timeline_rewind (GtkTimeline *timeline);
gboolean _gtk_timeline_is_running (GtkTimeline *timeline);
guint _gtk_timeline_get_elapsed_time (GtkTimeline *timeline);
guint _gtk_timeline_get_fps (GtkTimeline *timeline);
void _gtk_timeline_set_fps (GtkTimeline *timeline,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment