summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_animation_scale.c
blob: f625a8aa7fd6a6080de2115c7d32b16b48504c1f (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
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
#define EFL_ANIMATION_PROTECTED

#include "evas_common_private.h"
#include "evas_private.h"

#define MY_CLASS EFL_ANIMATION_SCALE_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)

#define EFL_ANIMATION_SCALE_CHECK_OR_RETURN(anim, ...) \
   do { \
      if (!anim) { \
         CRI("Efl_Animation " # anim " is NULL!"); \
         return __VA_ARGS__; \
      } \
      if (efl_animation_is_deleted(anim)) { \
         ERR("Efl_Animation " # anim " has already been deleted!"); \
         return __VA_ARGS__; \
      } \
   } while (0)

#define EFL_ANIMATION_SCALE_DATA_GET(o, pd) \
   Evas_Object_Animation_Scale_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_SCALE_CLASS)

typedef struct _Evas_Object_Animation_Scale_Property
{
   double scale_x, scale_y, scale_z;
} Evas_Object_Animation_Scale_Property;

struct _Evas_Object_Animation_Scale_Data
{
   Evas_Object_Animation_Scale_Property from;
   Evas_Object_Animation_Scale_Property to;
};

EOLIAN static void
_efl_animation_scale_scale_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_scale, double to_scale)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   pd->from.scale_x = from_scale;
   pd->from.scale_y = from_scale;
   pd->from.scale_z = from_scale;

   pd->to.scale_x = to_scale;
   pd->to.scale_y = to_scale;
   pd->to.scale_z = to_scale;
}

EOLIAN static void
_efl_animation_scale_scale_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_scale, double *to_scale)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   if (from_scale)
     *from_scale = pd->from.scale_x;

   if (to_scale)
     *to_scale = pd->to.scale_x;
}

EOLIAN static void
_efl_animation_scale_scale_x_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_x, double to_x)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   pd->from.scale_x = from_x;

   pd->to.scale_x = to_x;
}

EOLIAN static void
_efl_animation_scale_scale_x_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_x, double *to_x)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   if (from_x)
     *from_x = pd->from.scale_x;

   if (to_x)
     *to_x = pd->to.scale_x;
}

EOLIAN static void
_efl_animation_scale_scale_y_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_y, double to_y)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   pd->from.scale_y = from_y;

   pd->to.scale_y = to_y;
}

EOLIAN static void
_efl_animation_scale_scale_y_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_y, double *to_y)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   if (from_y)
     *from_y = pd->from.scale_y;

   if (to_y)
     *to_y = pd->to.scale_y;
}

EOLIAN static void
_efl_animation_scale_scale_z_set(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double from_z, double to_z)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   pd->from.scale_z = from_z;

   pd->to.scale_z = to_z;
}

EOLIAN static void
_efl_animation_scale_scale_z_get(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd, double *from_z, double *to_z)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);

   if (from_z)
     *from_z = pd->from.scale_z;

   if (to_z)
     *to_z = pd->to.scale_z;
}

EOLIAN static Efl_Animation *
_efl_animation_scale_efl_animation_dup(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj, NULL);

   Efl_Animation_Scale *animation = efl_add(MY_CLASS, NULL);

   double duration = efl_animation_duration_get(eo_obj);
   efl_animation_duration_set(animation, duration);

   Eo *target = efl_animation_target_get(eo_obj);
   efl_animation_target_set(animation, target);

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

   EFL_ANIMATION_SCALE_DATA_GET(animation, new_pd);

   new_pd->from.scale_x = pd->from.scale_x;
   new_pd->from.scale_y = pd->from.scale_y;
   new_pd->from.scale_z = pd->from.scale_z;

   new_pd->to.scale_x = pd->to.scale_x;
   new_pd->to.scale_y = pd->to.scale_y;
   new_pd->to.scale_z = pd->to.scale_z;

   return animation;
}

EOLIAN static Efl_Animation_Instance *
_efl_animation_scale_efl_animation_instance_create(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd)
{
   EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj, NULL);

   Efl_Animation_Instance_Scale *instance
      = efl_add(EFL_ANIMATION_INSTANCE_SCALE_CLASS, NULL);

   Eo *target = efl_animation_target_get(eo_obj);
   efl_animation_instance_target_set(instance, target);

   Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
   efl_animation_instance_final_state_keep_set(instance, state_keep);

   double duration = efl_animation_duration_get(eo_obj);
   efl_animation_instance_duration_set(instance, duration);

   efl_animation_instance_scale_x_set(instance,
                                      pd->from.scale_x, pd->to.scale_x);

   efl_animation_instance_scale_y_set(instance,
                                      pd->from.scale_y, pd->from.scale_y);

   efl_animation_instance_scale_z_set(instance,
                                      pd->from.scale_z, pd->to.scale_z);

   return instance;
}

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

   pd->from.scale_x = 1.0;
   pd->from.scale_y = 1.0;
   pd->from.scale_z = 1.0;

   return eo_obj;
}

EOLIAN static void
_efl_animation_scale_efl_object_destructor(Eo *eo_obj, Evas_Object_Animation_Scale_Data *pd EINA_UNUSED)
{
   efl_destructor(efl_super(eo_obj, MY_CLASS));
}

#include "efl_animation_scale.eo.c"