summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_canvas_animation_player.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-09-24 10:11:26 -0400
committerCedric Bail <cedric.bail@free.fr>2019-09-24 15:23:13 -0700
commit89bee7a11a61d08cc758b061fd2f5e705d1f9029 (patch)
tree57aa57a904d08688cbdf5430862241b26fd91949 /src/lib/evas/canvas/efl_canvas_animation_player.c
parent9b0197e2afbfca7ffa94f09ff5cac8fa9c7fe413 (diff)
efl/player: merge start+stop methods into 'playing' property
this has some overlap with the existing 'play' property which will soon be renamed. the intent here is that there is a property for controlling the 'playing' state and then another property for managing 'pausing' the play state ref T7877 Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10113
Diffstat (limited to 'src/lib/evas/canvas/efl_canvas_animation_player.c')
-rw-r--r--src/lib/evas/canvas/efl_canvas_animation_player.c73
1 files changed, 41 insertions, 32 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.c b/src/lib/evas/canvas/efl_canvas_animation_player.c
index ea4929789c..981ece8b80 100644
--- a/src/lib/evas/canvas/efl_canvas_animation_player.c
+++ b/src/lib/evas/canvas/efl_canvas_animation_player.c
@@ -61,7 +61,7 @@ _efl_canvas_animation_player_animation_set(Eo *eo_obj,
61 61
62 if (pd->animation) 62 if (pd->animation)
63 { 63 {
64 efl_player_stop(eo_obj); 64 efl_player_playing_set(eo_obj, EINA_FALSE);
65 efl_unref(pd->animation); 65 efl_unref(pd->animation);
66 } 66 }
67 pd->animation = anim; 67 pd->animation = anim;
@@ -147,7 +147,7 @@ _animator_cb(void *data)
147 147
148 return ECORE_CALLBACK_RENEW; 148 return ECORE_CALLBACK_RENEW;
149 } 149 }
150 efl_player_stop(eo_obj); 150 efl_player_playing_set(eo_obj, EINA_FALSE);
151 151
152 return ECORE_CALLBACK_CANCEL; 152 return ECORE_CALLBACK_CANCEL;
153} 153}
@@ -188,30 +188,6 @@ _start_delay_timer_cb(void *data)
188 return ECORE_CALLBACK_CANCEL; 188 return ECORE_CALLBACK_CANCEL;
189} 189}
190 190
191EOLIAN static void
192_efl_canvas_animation_player_efl_player_start(Eo *eo_obj,
193 Efl_Canvas_Animation_Player_Data *pd)
194{
195 double start_delay;
196 EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
197
198 if (!efl_playable_get(eo_obj)) return;
199 pd->is_play = EINA_TRUE;
200 //TODO: check this case is correct
201 if (pd->start_delay_timer) return;
202
203 pd->progress = 0.0;
204 start_delay = efl_animation_start_delay_get(anim);
205 if (start_delay > 0.0)
206 {
207 pd->start_delay_timer = ecore_timer_add(start_delay,
208 _start_delay_timer_cb, eo_obj);
209 return;
210 }
211
212 _start(eo_obj, pd);
213}
214
215static Eina_Bool 191static Eina_Bool
216_is_final_state(Efl_Canvas_Animation *anim, double progress) 192_is_final_state(Efl_Canvas_Animation *anim, double progress)
217{ 193{
@@ -240,12 +216,9 @@ _is_final_state(Efl_Canvas_Animation *anim, double progress)
240 return EINA_FALSE; 216 return EINA_FALSE;
241} 217}
242 218
243EOLIAN static void 219static void
244_efl_canvas_animation_player_efl_player_stop(Eo *eo_obj, 220_player_stop(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Efl_Canvas_Animation *anim)
245 Efl_Canvas_Animation_Player_Data *pd)
246{ 221{
247 EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
248
249 //Reset the state of the target to the initial state 222 //Reset the state of the target to the initial state
250 efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj)); 223 efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj));
251 224
@@ -281,6 +254,42 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
281 if (pd->auto_del) efl_del(eo_obj); 254 if (pd->auto_del) efl_del(eo_obj);
282} 255}
283 256
257EOLIAN static Eina_Bool
258_efl_canvas_animation_player_efl_player_playing_set(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Eina_Bool playing)
259{
260 double start_delay;
261 EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
262
263 if (!efl_playable_get(eo_obj)) return EINA_FALSE;
264 if ((!playing) && (!pd->is_play)) return EINA_TRUE;
265 if ((playing) && (pd->is_play)) return EINA_TRUE;
266 pd->is_play = !!playing;
267 if (!playing)
268 {
269 _player_stop(eo_obj, pd, anim);
270 return EINA_TRUE;
271 }
272 //TODO: check this case is correct
273 if (pd->start_delay_timer) return EINA_TRUE;
274
275 pd->progress = 0.0;
276 start_delay = efl_animation_start_delay_get(anim);
277 if (start_delay > 0.0)
278 {
279 pd->start_delay_timer = ecore_timer_add(start_delay,
280 _start_delay_timer_cb, eo_obj);
281 }
282 else
283 _start(eo_obj, pd);
284 return EINA_TRUE;
285}
286
287EOLIAN static Eina_Bool
288_efl_canvas_animation_player_efl_player_playing_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd)
289{
290 return pd->is_play;
291}
292
284EOLIAN static void 293EOLIAN static void
285_efl_canvas_animation_player_efl_player_play_set(Eo *eo_obj, 294_efl_canvas_animation_player_efl_player_play_set(Eo *eo_obj,
286 Efl_Canvas_Animation_Player_Data *pd, 295 Efl_Canvas_Animation_Player_Data *pd,
@@ -425,7 +434,7 @@ _efl_canvas_animation_player_efl_object_destructor(Eo *eo_obj,
425 pd->animator = NULL; 434 pd->animator = NULL;
426 435
427 //Reset the state of the target to the initial state 436 //Reset the state of the target to the initial state
428 efl_player_stop(eo_obj); 437 efl_player_playing_set(eo_obj, EINA_FALSE);
429 438
430 efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL); 439 efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
431 } 440 }