mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-07 01:00:28 +00:00
animation: Add _gtk_style_animation_is_static()
This will be useful to not trigger updates all the time when nothing is happening (ie due to animations being paused or due to them having reached their final value).
This commit is contained in:
parent
229b6fe17a
commit
7224f897d6
@ -143,6 +143,18 @@ gtk_css_animation_is_finished (GtkStyleAnimation *style_animation,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_animation_is_static (GtkStyleAnimation *style_animation,
|
||||
gint64 at_time_us)
|
||||
{
|
||||
GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
|
||||
double iteration;
|
||||
|
||||
iteration = gtk_css_animation_get_iteration (animation, at_time_us);
|
||||
|
||||
return iteration >= animation->iteration_count;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_animation_finalize (GObject *object)
|
||||
{
|
||||
@ -165,6 +177,7 @@ _gtk_css_animation_class_init (GtkCssAnimationClass *klass)
|
||||
|
||||
animation_class->set_values = gtk_css_animation_set_values;
|
||||
animation_class->is_finished = gtk_css_animation_is_finished;
|
||||
animation_class->is_static = gtk_css_animation_is_static;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -68,6 +68,15 @@ gtk_css_transition_is_finished (GtkStyleAnimation *animation,
|
||||
return at_time_us >= transition->end_time;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_transition_is_static (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us)
|
||||
{
|
||||
GtkCssTransition *transition = GTK_CSS_TRANSITION (animation);
|
||||
|
||||
return at_time_us >= transition->end_time;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_transition_finalize (GObject *object)
|
||||
{
|
||||
@ -90,6 +99,7 @@ _gtk_css_transition_class_init (GtkCssTransitionClass *klass)
|
||||
|
||||
animation_class->set_values = gtk_css_transition_set_values;
|
||||
animation_class->is_finished = gtk_css_transition_is_finished;
|
||||
animation_class->is_static = gtk_css_transition_is_static;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -39,11 +39,19 @@ gtk_style_animation_real_is_finished (GtkStyleAnimation *animation,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_style_animation_real_is_static (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_style_animation_class_init (GtkStyleAnimationClass *klass)
|
||||
{
|
||||
klass->set_values = gtk_style_animation_real_set_values;
|
||||
klass->is_finished = gtk_style_animation_real_is_finished;
|
||||
klass->is_static = gtk_style_animation_real_is_static;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -80,3 +88,26 @@ _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
|
||||
return klass->is_finished (animation, at_time_us);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_style_animation_is_static:
|
||||
* @animation: The animation to query
|
||||
* @at_time_us: The timestamp to query for
|
||||
*
|
||||
* Checks if @animation will not change its values anymore after
|
||||
* @at_time_us. This happens for example when the animation has reached its
|
||||
* final value or when it has been paused.
|
||||
*
|
||||
* Returns: %TRUE if @animation will not change anymore after @at_time_us
|
||||
**/
|
||||
gboolean
|
||||
_gtk_style_animation_is_static (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us)
|
||||
{
|
||||
GtkStyleAnimationClass *klass;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
|
||||
|
||||
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
|
||||
|
||||
return klass->is_static (animation, at_time_us);
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ struct _GtkStyleAnimationClass
|
||||
|
||||
gboolean (* is_finished) (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us);
|
||||
gboolean (* is_static) (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us);
|
||||
GtkBitmask * (* set_values) (GtkStyleAnimation *animation,
|
||||
GtkBitmask *changed,
|
||||
gint64 for_time_us,
|
||||
@ -60,6 +62,8 @@ GtkBitmask * _gtk_style_animation_set_values (GtkStyleAnimation
|
||||
GtkCssComputedValues *values) G_GNUC_WARN_UNUSED_RESULT;
|
||||
gboolean _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us);
|
||||
gboolean _gtk_style_animation_is_static (GtkStyleAnimation *animation,
|
||||
gint64 at_time_us);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user