summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_animation_group_parallel.c
blob: fc98c0a02d6f2a5dbf3136decc08d9ef925b2272 (plain)
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
#include "efl_animation_group_parallel_private.h"

EOLIAN static void
_efl_animation_group_parallel_efl_animation_group_animation_add(Eo *eo_obj,
                                                                Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED,
                                                                Efl_Animation *animation)
{
   if (!animation) return;

   efl_animation_group_animation_add(efl_super(eo_obj, MY_CLASS),
                                     animation);

   /* Total duration is calculated in efl_animation_total_duration_get() based
    * on the current group animation list.
    * Therefore, the calculated total duration should be set to update 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_parallel_efl_animation_group_animation_del(Eo *eo_obj,
                                                                Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED,
                                                                Efl_Animation *animation)
{
   if (!animation) return;

   efl_animation_group_animation_del(efl_super(eo_obj, MY_CLASS),
                                     animation);

   /* Total duration is calculated in efl_animation_total_duration_get() based
    * on the current group animation list.
    * Therefore, the calculated total duration should be set to update total
    * duration. */
   double total_duration =
      efl_animation_total_duration_get(eo_obj);
   efl_animation_total_duration_set(eo_obj, total_duration);
}

EOLIAN static double
_efl_animation_group_parallel_efl_animation_total_duration_get(Eo *eo_obj,
                                                               Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED)
{
   Eina_List *animations =
      efl_animation_group_animations_get(eo_obj);
   if (!animations) return 0.0;

   double total_duration = 0.0;
   Eina_List *l;
   Efl_Animation *anim;
   EINA_LIST_FOREACH(animations, l, anim)
     {
        double child_total_duration = efl_animation_total_duration_get(anim);

        double start_delay = efl_animation_start_delay_get(anim);
        if (start_delay > 0.0)
          child_total_duration += start_delay;

        int child_repeat_count = efl_animation_repeat_count_get(anim);
        if (child_repeat_count > 0)
          child_total_duration *= (child_repeat_count + 1);

        if (child_total_duration > total_duration)
          total_duration = child_total_duration;
     }
   return total_duration;
}

EOLIAN static Efl_Animation_Object *
_efl_animation_group_parallel_efl_animation_object_create(Eo *eo_obj,
                                                          Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED)
{
   Efl_Animation_Object_Group_Parallel *group_anim_obj
      = efl_add(EFL_ANIMATION_OBJECT_GROUP_PARALLEL_CLASS, NULL);

   Eina_List *animations = efl_animation_group_animations_get(eo_obj);
   Eina_List *l;
   Efl_Animation *child_anim;
   Efl_Animation_Object *child_anim_obj;

   EINA_LIST_FOREACH(animations, l, child_anim)
     {
        child_anim_obj = efl_animation_object_create(child_anim);
        efl_animation_object_group_object_add(group_anim_obj, child_anim_obj);
     }

   Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
   if (target)
     efl_animation_object_target_set(group_anim_obj, target);

   Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
   efl_animation_object_final_state_keep_set(group_anim_obj, state_keep);

   double duration = efl_animation_duration_get(eo_obj);
   efl_animation_object_duration_set(group_anim_obj, duration);

   double total_duration = efl_animation_total_duration_get(eo_obj);
   efl_animation_object_total_duration_set(group_anim_obj, total_duration);

   double start_delay_time = efl_animation_start_delay_get(eo_obj);
   efl_animation_object_start_delay_set(group_anim_obj, start_delay_time);

   Efl_Animation_Object_Repeat_Mode repeat_mode =
      (Efl_Animation_Object_Repeat_Mode)efl_animation_repeat_mode_get(eo_obj);
   efl_animation_object_repeat_mode_set(group_anim_obj, repeat_mode);

   int repeat_count = efl_animation_repeat_count_get(eo_obj);
   efl_animation_object_repeat_count_set(group_anim_obj, repeat_count);

   Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj);
   efl_animation_object_interpolator_set(group_anim_obj, interpolator);

   return group_anim_obj;
}

#include "efl_animation_group_parallel.eo.c"