summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_animation_group.c
blob: dd2b30a20e370bdfaf0ad802b217746a00f886f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "efl_animation_group_private.h"

EOLIAN static void
_efl_animation_group_animation_add(Eo *eo_obj,
                                   Efl_Animation_Group_Data *pd,
                                   Efl_Animation *animation)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   if (!animation) return;

   Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
   if (target)
     efl_animation_target_set(animation, target);

   double duration = efl_animation_duration_get(eo_obj);
   /* if group animation duration is available value, then the duration is
    * propagated to its child. */
   if (duration != EFL_ANIMATION_GROUP_DURATION_NONE)
     efl_animation_duration_set(animation, duration);

   Eina_Bool keep_final_state = efl_animation_final_state_keep_get(eo_obj);
   efl_animation_final_state_keep_set(animation, keep_final_state);

   pd->animations = eina_list_append(pd->animations, animation);
}

EOLIAN static void
_efl_animation_group_animation_del(Eo *eo_obj,
                                   Efl_Animation_Group_Data *pd,
                                   Efl_Animation*animation)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   if (!animation) return;

   pd->animations = eina_list_remove(pd->animations, animation);
}

EOLIAN static Eina_List *
_efl_animation_group_animations_get(Eo *eo_obj,
                                    Efl_Animation_Group_Data *pd)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj, NULL);

   return pd->animations;
}

EOLIAN static void
_efl_animation_group_efl_animation_target_set(Eo *eo_obj,
                                              Efl_Animation_Group_Data *pd,
                                              Efl_Canvas_Object *target)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   Eina_List *l;
   Efl_Animation *anim;
   EINA_LIST_FOREACH(pd->animations, l, anim)
     {
        efl_animation_target_set(anim, target);
     }

   efl_animation_target_set(efl_super(eo_obj, MY_CLASS), target);
}

EOLIAN static void
_efl_animation_group_efl_animation_duration_set(Eo *eo_obj,
                                                Efl_Animation_Group_Data *pd,
                                                double duration)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   if (duration == EFL_ANIMATION_GROUP_DURATION_NONE) goto end;

   if (duration < 0.0) return;

   Eina_List *l;
   Efl_Animation *anim;
   EINA_LIST_FOREACH(pd->animations, l, anim)
     {
        efl_animation_duration_set(anim, duration);
     }

end:
   efl_animation_duration_only_set(efl_super(eo_obj, MY_CLASS), duration);

   //efl_animation_total_duration_get() should calculate the new total duration.
   double total_duration = efl_animation_total_duration_get(eo_obj);
   efl_animation_total_duration_set(eo_obj, total_duration);
}

EOLIAN static void
_efl_animation_group_efl_animation_final_state_keep_set(Eo *eo_obj,
                                                        Efl_Animation_Group_Data *pd,
                                                        Eina_Bool keep_final_state)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   Eina_List *l;
   Efl_Animation *anim;
   EINA_LIST_FOREACH(pd->animations, l, anim)
     {
        efl_animation_final_state_keep_set(anim, keep_final_state);
     }

   efl_animation_final_state_keep_set(efl_super(eo_obj, MY_CLASS), keep_final_state);
}

EOLIAN static void
_efl_animation_group_efl_animation_interpolator_set(Eo *eo_obj,
                                                    Efl_Animation_Group_Data *pd,
                                                    Efl_Interpolator *interpolator)
{
   EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj);

   Eina_List *l;
   Efl_Animation *anim;
   EINA_LIST_FOREACH(pd->animations, l, anim)
     {
        efl_animation_interpolator_set(anim, interpolator);
     }

   efl_animation_interpolator_set(efl_super(eo_obj, MY_CLASS), interpolator);
}

EOLIAN static Efl_Object *
_efl_animation_group_efl_object_constructor(Eo *eo_obj,
                                            Efl_Animation_Group_Data *pd)
{
   eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));

   pd->animations = NULL;

   //group animation does not affect its child duration by default.
   efl_animation_duration_only_set(efl_super(eo_obj, MY_CLASS),
                                   EFL_ANIMATION_GROUP_DURATION_NONE);

   return eo_obj;
}

EOLIAN static void
_efl_animation_group_efl_object_destructor(Eo *eo_obj,
                                           Efl_Animation_Group_Data *pd)
{
   Efl_Animation *anim;

   EINA_LIST_FREE(pd->animations, anim)
      efl_del(anim);

   efl_destructor(efl_super(eo_obj, MY_CLASS));
}

#include "efl_animation_group.eo.c"