summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_efl_anim_group_sequential.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/elementary/test_efl_anim_group_sequential.c')
-rw-r--r--src/bin/elementary/test_efl_anim_group_sequential.c82
1 files changed, 24 insertions, 58 deletions
diff --git a/src/bin/elementary/test_efl_anim_group_sequential.c b/src/bin/elementary/test_efl_anim_group_sequential.c
index 3488149..60b3a83 100644
--- a/src/bin/elementary/test_efl_anim_group_sequential.c
+++ b/src/bin/elementary/test_efl_anim_group_sequential.c
@@ -5,33 +5,39 @@
5 5
6typedef struct _App_Data 6typedef struct _App_Data
7{ 7{
8 Efl_Canvas_Animation *sequential_show_anim;
9 Efl_Canvas_Animation *sequential_hide_anim; 8 Efl_Canvas_Animation *sequential_hide_anim;
10 Efl_Canvas_Animation_Player *anim_obj; 9 Elm_Button *button;
11 10
12 Eina_Bool is_btn_visible; 11 Eina_Bool is_btn_visible;
13} App_Data; 12} App_Data;
14 13
15static void 14static void
16_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 15_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
17{ 16{
18 printf("Animation has been started!\n"); 17 Eo *anim = event->info;
19}
20 18
21static void 19 if (anim)
22_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 20 {
23{ 21 printf("Animation has been started!\n");
24 printf("Animation has been ended!\n"); 22 }
23 else
24 {
25 printf("Animation has been ended!\n");
26 }
25} 27}
26 28
27static void 29static void
28_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event) 30_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
29{ 31{
30 Efl_Canvas_Animation_Player_Event_Running *event_running = event->info; 32 double *progress = event->info;
31 double progress = event_running->progress; 33 printf("Animation is running! Current progress(%lf)\n", *progress);
32 printf("Animation is running! Current progress(%lf)\n", progress);
33} 34}
34 35
36EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
37 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
38 {EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
39)
40
35static void 41static void
36_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 42_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
37{ 43{
@@ -42,18 +48,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
42 if (ad->is_btn_visible) 48 if (ad->is_btn_visible)
43 { 49 {
44 //Create Animation Object from Animation 50 //Create Animation Object from Animation
45 efl_animation_player_animation_set(ad->anim_obj, ad->sequential_show_anim); 51 efl_canvas_object_animation_start(ad->button, ad->sequential_hide_anim, -1.0, 0.0);
46 efl_text_set(obj, "Start Sequential Group Animation to hide button"); 52 efl_text_set(obj, "Start Sequential Group Animation to hide button");
47 } 53 }
48 else 54 else
49 { 55 {
50 //Create Animation Object from Animation 56 //Create Animation Object from Animation
51 efl_animation_player_animation_set(ad->anim_obj, ad->sequential_hide_anim); 57 efl_canvas_object_animation_start(ad->button, ad->sequential_hide_anim, 1.0, 0.0);
52 efl_text_set(obj, "Start Sequential Group Animation to show button"); 58 efl_text_set(obj, "Start Sequential Group Animation to show button");
53 } 59 }
54
55 //Let Animation Object start animation
56 efl_player_playing_set(ad->anim_obj, EINA_TRUE);
57} 60}
58 61
59static void 62static void
@@ -81,16 +84,17 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
81 evas_object_resize(btn, 150, 150); 84 evas_object_resize(btn, 150, 150);
82 evas_object_move(btn, 125, 100); 85 evas_object_move(btn, 125, 100);
83 evas_object_show(btn); 86 evas_object_show(btn);
87 efl_event_callback_array_add(btn, animation_stats_cb(), ad);
84 88
85 89
86 /* Animations to hide button */ 90 /* Animations to hide button */
87 //Rotate from 0 to 45 degrees Animation 91 //Rotate from 0 to 45 degrees Animation
88 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win); 92 Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
89 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, 0.5, 0.5); 93 efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, EINA_VECTOR2(0.5, 0.5));
90 94
91 //Scale Animation to zoom in 95 //Scale Animation to zoom in
92 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win); 96 Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
93 efl_animation_scale_set(scale_double_anim, 1.0, 1.0, 2.0, 2.0, NULL, 0.5, 0.5); 97 efl_animation_scale_set(scale_double_anim, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(2.0, 2.0), NULL, EINA_VECTOR2(0.5, 0.5));
94 98
95 //Hide Animation 99 //Hide Animation
96 Efl_Canvas_Animation *hide_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win); 100 Efl_Canvas_Animation *hide_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@@ -106,47 +110,9 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
106 efl_animation_group_animation_add(sequential_hide_anim, scale_double_anim); 110 efl_animation_group_animation_add(sequential_hide_anim, scale_double_anim);
107 efl_animation_group_animation_add(sequential_hide_anim, hide_anim); 111 efl_animation_group_animation_add(sequential_hide_anim, hide_anim);
108 112
109
110 /* Animations to show button */
111 //Show Animation
112 Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
113 efl_animation_alpha_set(show_anim, 0.0, 1.0);
114 efl_animation_duration_set(show_anim, 1.0);
115
116 //Scale Animation to zoom out
117 Efl_Canvas_Animation *scale_half_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
118 efl_animation_scale_set(scale_half_anim, 2.0, 2.0, 1.0, 1.0, NULL, 0.5, 0.5);
119 efl_animation_duration_set(scale_half_anim, 1.0);
120
121 //Rotate from 45 to 0 degrees Animation
122 Efl_Canvas_Animation *ccw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
123 efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5);
124 efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
125
126 //Show Sequential Group Animation
127 Efl_Canvas_Animation *sequential_show_anim = efl_add(EFL_CANVAS_ANIMATION_GROUP_SEQUENTIAL_CLASS, win);
128 efl_animation_final_state_keep_set(sequential_show_anim, EINA_TRUE);
129 //efl_animation_duration_set() is called for each animation not to set the same duration
130
131 //Add animations to group animation
132 //First, parallel_hide_anim is added with duration 0 to set the initial state
133 efl_animation_group_animation_add(sequential_show_anim, show_anim);
134 efl_animation_group_animation_add(sequential_show_anim, scale_half_anim);
135 efl_animation_group_animation_add(sequential_show_anim, ccw_45_degrees_anim);
136
137
138 //Initialize App Data 113 //Initialize App Data
139 ad->sequential_show_anim = sequential_show_anim;
140 ad->sequential_hide_anim = sequential_hide_anim; 114 ad->sequential_hide_anim = sequential_hide_anim;
141 ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win, 115 ad->button = btn;
142 efl_animation_player_target_set(efl_added, btn));
143
144 //Register callback called when animation starts
145 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
146 //Register callback called when animation ends
147 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
148 //Register callback called while animation is executed
149 efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
150 116
151 ad->is_btn_visible = EINA_TRUE; 117 ad->is_btn_visible = EINA_TRUE;
152 118