summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_animation_object_group.c
blob: 09d45141c22bc4baabaa3172f1055130026581d4 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include "efl_animation_object_group_private.h"

EOLIAN static void
_efl_animation_object_group_object_add(Eo *eo_obj,
                                       Efl_Animation_Object_Group_Data *pd,
                                       Efl_Animation_Object *anim_obj)
{
   if (!anim_obj) return;

   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
   if (target)
     efl_animation_object_target_set(anim_obj, target);

   double duration = efl_animation_object_duration_get(eo_obj);
   /* if group animation object duration is available value, then the duration
    * is propagated to its child. */
   if (duration != EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE)
     efl_animation_object_duration_set(anim_obj, duration);

   Eina_Bool state_keep = efl_animation_object_final_state_keep_get(eo_obj);
   efl_animation_object_final_state_keep_set(anim_obj, state_keep);

   pd->anim_objs = eina_list_append(pd->anim_objs, anim_obj);
}

EOLIAN static void
_efl_animation_object_group_object_del(Eo *eo_obj EINA_UNUSED,
                                       Efl_Animation_Object_Group_Data *pd,
                                       Efl_Animation_Object *anim_obj)
{
   if (!anim_obj) return;

   pd->anim_objs = eina_list_remove(pd->anim_objs, anim_obj);
}

EOLIAN static Eina_List *
_efl_animation_object_group_objects_get(Eo *eo_obj EINA_UNUSED,
                                        Efl_Animation_Object_Group_Data *pd)
{
   return pd->anim_objs;
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_target_set(Eo *eo_obj,
                                                            Efl_Animation_Object_Group_Data *pd,
                                                            Efl_Canvas_Object *target)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_target_set(anim_obj, target);
     }

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

EOLIAN static void
_efl_animation_object_group_efl_animation_object_duration_set(Eo *eo_obj,
                                                              Efl_Animation_Object_Group_Data *pd,
                                                              double duration)
{
   if (duration == EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE) goto end;

   if (duration < 0.0) return;

   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_duration_set(anim_obj, duration);
     }

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

   /* efl_animation_object_total_duration_get() should calculate the new total
    * duration. */
   double total_duration = efl_animation_object_total_duration_get(eo_obj);
   efl_animation_object_total_duration_set(eo_obj, total_duration);
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_final_state_keep_set(Eo *eo_obj,
                                                                      Efl_Animation_Object_Group_Data *pd,
                                                                      Eina_Bool state_keep)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_final_state_keep_set(anim_obj, state_keep);
     }

   efl_animation_object_final_state_keep_set(efl_super(eo_obj, MY_CLASS),
                                             state_keep);
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_interpolator_set(Eo *eo_obj,
                                                                  Efl_Animation_Object_Group_Data *pd,
                                                                  Efl_Interpolator *interpolator)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_interpolator_set(anim_obj, interpolator);
     }

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

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

   pd->anim_objs = NULL;

   //group animation object does not affect its child duration by default.
   efl_animation_object_duration_only_set(efl_super(eo_obj, MY_CLASS),
                                          EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE);

   return eo_obj;
}

EOLIAN static void
_efl_animation_object_group_efl_object_destructor(Eo *eo_obj,
                                                  Efl_Animation_Object_Group_Data *pd)
{
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FREE(pd->anim_objs, anim_obj)
      efl_del(anim_obj);

   efl_destructor(efl_super(eo_obj, MY_CLASS));
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_target_state_save(Eo *eo_obj EINA_UNUSED,
                                                                   Efl_Animation_Object_Group_Data *pd)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_target_state_save(anim_obj);
     }
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_target_state_reset(Eo *eo_obj EINA_UNUSED,
                                                                    Efl_Animation_Object_Group_Data *pd)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_target_state_reset(anim_obj);
     }
}

EOLIAN static void
_efl_animation_object_group_efl_animation_object_target_map_reset(Eo *eo_obj EINA_UNUSED,
                                                                  Efl_Animation_Object_Group_Data *pd)
{
   Eina_List *l;
   Efl_Animation_Object *anim_obj;

   EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj)
     {
        efl_animation_object_target_map_reset(anim_obj);
     }
}

/* Internal EO APIs */

EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_add, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);

EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_group_object_del, EFL_FUNC_CALL(anim_obj), Efl_Animation_Object *anim_obj);

EOAPI EFL_FUNC_BODY(efl_animation_object_group_objects_get, Eina_List *, NULL);

#define EFL_ANIMATION_OBJECT_GROUP_EXTRA_OPS \
   EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_add, _efl_animation_object_group_object_add), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_group_object_del, _efl_animation_object_group_object_del), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_group_objects_get, _efl_animation_object_group_objects_get), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_group_efl_animation_object_target_set), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_duration_set, _efl_animation_object_group_efl_animation_object_duration_set), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_group_efl_animation_object_final_state_keep_set), \
   EFL_OBJECT_OP_FUNC(efl_animation_object_interpolator_set, _efl_animation_object_group_efl_animation_object_interpolator_set)

#include "efl_animation_object_group.eo.c"