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

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

#define MY_CLASS EFL_ANIMATION_ALPHA_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)

#define EFL_ANIMATION_ALPHA_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_ALPHA_DATA_GET(o, pd) \
   Evas_Object_Animation_Alpha_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_ALPHA_CLASS)

typedef struct _Evas_Object_Animation_Alpha_Property
{
   double alpha;
} Evas_Object_Animation_Alpha_Property;

struct _Evas_Object_Animation_Alpha_Data
{
   Evas_Object_Animation_Alpha_Property from;
   Evas_Object_Animation_Alpha_Property to;
};

EOLIAN static void
_efl_animation_alpha_alpha_set(Eo *eo_obj, Evas_Object_Animation_Alpha_Data *pd, double from_alpha, double to_alpha)
{
   EFL_ANIMATION_ALPHA_CHECK_OR_RETURN(eo_obj);

   pd->from.alpha = from_alpha;
   pd->to.alpha = to_alpha;
}

EOLIAN static void
_efl_animation_alpha_alpha_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Animation_Alpha_Data *pd, double *from_alpha, double *to_alpha)
{
   EFL_ANIMATION_ALPHA_CHECK_OR_RETURN(eo_obj);

   if (from_alpha)
     *from_alpha = pd->from.alpha;
   if (to_alpha)
     *to_alpha = pd->to.alpha;
}

EOLIAN static Efl_Animation *
_efl_animation_alpha_efl_animation_dup(Eo *eo_obj, Evas_Object_Animation_Alpha_Data *pd)
{
   EFL_ANIMATION_ALPHA_CHECK_OR_RETURN(eo_obj, NULL);

   Efl_Animation_Alpha *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_ALPHA_DATA_GET(animation, new_pd);

   new_pd->from.alpha = pd->from.alpha;
   new_pd->to.alpha = pd->to.alpha;

   return animation;
}

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

   pd->from.alpha = 1.0;
   pd->to.alpha = 1.0;

   return eo_obj;
}

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

#include "efl_animation_alpha.eo.c"