aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/efl_animation_group.c
blob: 0aef2eac5158dd589d7bd5540745e7c13b131d17 (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
#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)
{
   if (!animation) return;

   double duration = efl_animation_duration_get(efl_super(eo_obj, MY_CLASS));
   /* 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);
   efl_ref(animation);
}

EOLIAN static void
_efl_animation_group_animation_del(Eo *eo_obj EINA_UNUSED,
                                   Efl_Animation_Group_Data *pd,
                                   Efl_Animation*animation)
{
   Eina_List *list;
   if (!animation) return;

   list = eina_list_data_find_list(pd->animations, animation);
   if (list)
     {
        pd->animations = eina_list_remove_list(pd->animations, list);
        efl_unref(animation);
     }
   else
     {
        ERR("Animation(%p) is not in the group animation.");
     }
}

EOLIAN static Eina_List *
_efl_animation_group_animations_get(Eo *eo_obj EINA_UNUSED,
                                    Efl_Animation_Group_Data *pd)
{
   return pd->animations;
}

EOLIAN static void
_efl_animation_group_efl_animation_duration_set(Eo *eo_obj,
                                                Efl_Animation_Group_Data *pd,
                                                double duration)
{
   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_set(efl_super(eo_obj, MY_CLASS), 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)
{
   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)
{
   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_set(eo_obj, 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_unref(anim);

   efl_destructor(efl_super(eo_obj, MY_CLASS));
}

#include "efl_animation_group.eo.c"