1 /*
2 * Copyright © 2012 Red Hat Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <otte@gnome.org>
18 */
19
20 #include "config.h"
21
22 #include "gtkstyleanimationprivate.h"
23
G_DEFINE_ABSTRACT_TYPE(GtkStyleAnimation,_gtk_style_animation,G_TYPE_OBJECT)24 G_DEFINE_ABSTRACT_TYPE (GtkStyleAnimation, _gtk_style_animation, G_TYPE_OBJECT)
25
26 static GtkStyleAnimation *
27 gtk_style_animation_real_advance (GtkStyleAnimation *animation,
28 gint64 timestamp)
29 {
30 return NULL;
31 }
32
33 static void
gtk_style_animation_real_apply_values(GtkStyleAnimation * animation,GtkCssAnimatedStyle * style)34 gtk_style_animation_real_apply_values (GtkStyleAnimation *animation,
35 GtkCssAnimatedStyle *style)
36 {
37 }
38
39 static gboolean
gtk_style_animation_real_is_finished(GtkStyleAnimation * animation)40 gtk_style_animation_real_is_finished (GtkStyleAnimation *animation)
41 {
42 return TRUE;
43 }
44
45 static gboolean
gtk_style_animation_real_is_static(GtkStyleAnimation * animation)46 gtk_style_animation_real_is_static (GtkStyleAnimation *animation)
47 {
48 return FALSE;
49 }
50
51 static void
_gtk_style_animation_class_init(GtkStyleAnimationClass * klass)52 _gtk_style_animation_class_init (GtkStyleAnimationClass *klass)
53 {
54 klass->advance = gtk_style_animation_real_advance;
55 klass->apply_values = gtk_style_animation_real_apply_values;
56 klass->is_finished = gtk_style_animation_real_is_finished;
57 klass->is_static = gtk_style_animation_real_is_static;
58 }
59
60 static void
_gtk_style_animation_init(GtkStyleAnimation * animation)61 _gtk_style_animation_init (GtkStyleAnimation *animation)
62 {
63 }
64
65 GtkStyleAnimation *
_gtk_style_animation_advance(GtkStyleAnimation * animation,gint64 timestamp)66 _gtk_style_animation_advance (GtkStyleAnimation *animation,
67 gint64 timestamp)
68 {
69 GtkStyleAnimationClass *klass;
70
71 g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), NULL);
72
73 klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
74
75 return klass->advance (animation, timestamp);
76 }
77
78 void
_gtk_style_animation_apply_values(GtkStyleAnimation * animation,GtkCssAnimatedStyle * style)79 _gtk_style_animation_apply_values (GtkStyleAnimation *animation,
80 GtkCssAnimatedStyle *style)
81 {
82 GtkStyleAnimationClass *klass;
83
84 g_return_if_fail (GTK_IS_STYLE_ANIMATION (animation));
85 g_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
86
87 klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
88
89 klass->apply_values (animation, style);
90 }
91
92 gboolean
_gtk_style_animation_is_finished(GtkStyleAnimation * animation)93 _gtk_style_animation_is_finished (GtkStyleAnimation *animation)
94 {
95 GtkStyleAnimationClass *klass;
96
97 g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
98
99 klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
100
101 return klass->is_finished (animation);
102 }
103
104 /**
105 * _gtk_style_animation_is_static:
106 * @animation: The animation to query
107 * @at_time_us: The timestamp to query for
108 *
109 * Checks if @animation will not change its values anymore after
110 * @at_time_us. This happens for example when the animation has reached its
111 * final value or when it has been paused.
112 *
113 * Returns: %TRUE if @animation will not change anymore after @at_time_us
114 **/
115 gboolean
_gtk_style_animation_is_static(GtkStyleAnimation * animation)116 _gtk_style_animation_is_static (GtkStyleAnimation *animation)
117 {
118 GtkStyleAnimationClass *klass;
119
120 g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
121
122 klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
123
124 return klass->is_static (animation);
125 }
126