diff options
author | Matt Watson <mattdangerw@gmail.com> | 2016-03-06 22:45:27 -0800 |
---|---|---|
committer | Matt Watson <mattdangerw@gmail.com> | 2016-04-08 16:09:30 -0700 |
commit | 50e057e02541151a9de828dc7567042c00f499d1 (patch) | |
tree | 7f46547c3bd3b294aed0669ad09e6c15f15a9128 /gtk/gtkcsstransition.c | |
parent | 511f1383281c3bdf45472fc53f806aebad83ea5d (diff) | |
download | gtk+-50e057e02541151a9de828dc7567042c00f499d1.tar.gz |
csstransition: port to progress tracker
Diffstat (limited to 'gtk/gtkcsstransition.c')
-rw-r--r-- | gtk/gtkcsstransition.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/gtk/gtkcsstransition.c b/gtk/gtkcsstransition.c index 747bac1dc7..c9b319736c 100644 --- a/gtk/gtkcsstransition.c +++ b/gtk/gtkcsstransition.c @@ -22,6 +22,7 @@ #include "gtkcsstransitionprivate.h" #include "gtkcsseasevalueprivate.h" +#include "gtkprogresstrackerprivate.h" G_DEFINE_TYPE (GtkCssTransition, _gtk_css_transition, GTK_TYPE_STYLE_ANIMATION) @@ -33,31 +34,33 @@ gtk_css_transition_set_values (GtkStyleAnimation *animation, GtkCssTransition *transition = GTK_CSS_TRANSITION (animation); GtkCssValue *value, *end; double progress; + GtkProgressState state; end = gtk_css_animated_style_get_intrinsic_value (style, transition->property); - if (transition->start_time >= for_time_us) + gtk_progress_tracker_advance_frame (&transition->tracker, for_time_us); + state = gtk_progress_tracker_get_state (&transition->tracker); + + if (state == GTK_PROGRESS_STATE_BEFORE) value = _gtk_css_value_ref (transition->start); - else if (transition->end_time > for_time_us) + else if (state == GTK_PROGRESS_STATE_DURING) { - progress = (double) (for_time_us - transition->start_time) / (transition->end_time - transition->start_time); + progress = gtk_progress_tracker_get_progress (&transition->tracker, FALSE); progress = _gtk_css_ease_value_transform (transition->ease, progress); value = _gtk_css_value_transition (transition->start, end, transition->property, progress); - if (value == NULL) - value = _gtk_css_value_ref (end); } else - value = NULL; + return; - if (value) - { - gtk_css_animated_style_set_animated_value (style, transition->property, value); - _gtk_css_value_unref (value); - } + if (value == NULL) + value = _gtk_css_value_ref (end); + + gtk_css_animated_style_set_animated_value (style, transition->property, value); + _gtk_css_value_unref (value); } static gboolean @@ -66,7 +69,7 @@ gtk_css_transition_is_finished (GtkStyleAnimation *animation, { GtkCssTransition *transition = GTK_CSS_TRANSITION (animation); - return at_time_us >= transition->end_time; + return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; } static gboolean @@ -75,7 +78,7 @@ gtk_css_transition_is_static (GtkStyleAnimation *animation, { GtkCssTransition *transition = GTK_CSS_TRANSITION (animation); - return at_time_us >= transition->end_time; + return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; } static void @@ -111,22 +114,22 @@ GtkStyleAnimation * _gtk_css_transition_new (guint property, GtkCssValue *start, GtkCssValue *ease, - gint64 start_time_us, - gint64 end_time_us) + gint64 timestamp, + gint64 duration_us, + gint64 delay_us) { GtkCssTransition *transition; g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (ease != NULL, NULL); - g_return_val_if_fail (start_time_us <= end_time_us, NULL); transition = g_object_new (GTK_TYPE_CSS_TRANSITION, NULL); transition->property = property; transition->start = _gtk_css_value_ref (start); transition->ease = _gtk_css_value_ref (ease); - transition->start_time = start_time_us; - transition->end_time = end_time_us; + gtk_progress_tracker_start (&transition->tracker, duration_us, delay_us, 1.0); + gtk_progress_tracker_advance_frame (&transition->tracker, timestamp); return GTK_STYLE_ANIMATION (transition); } |