ecore: remove Ecore_Animator Eo object.
This is only a legacy API.
This commit is contained in:
parent
f6a260e7a9
commit
5cc16b1c29
|
@ -4,7 +4,6 @@
|
|||
ecore_eolian_files_legacy = \
|
||||
lib/ecore/ecore_poller.eo \
|
||||
lib/ecore/ecore_exe.eo \
|
||||
lib/ecore/ecore_animator.eo \
|
||||
lib/ecore/efl_timer.eo
|
||||
|
||||
ecore_eolian_files = \
|
||||
|
|
|
@ -2648,9 +2648,6 @@ typedef Eina_Bool (*Ecore_Timeline_Cb)(void *data, double pos);
|
|||
/*
|
||||
* @since 1.8
|
||||
*/
|
||||
typedef Eo Ecore_Animator; /**< A handle for animators */
|
||||
|
||||
#define _ECORE_ANIMATOR_EO_CLASS_TYPE
|
||||
|
||||
/**
|
||||
* @brief Set the animator call interval in seconds.
|
||||
|
|
|
@ -13,18 +13,6 @@ extern "C" {
|
|||
|
||||
#include "ecore_poller.eo.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup Ecore_Animator_Group
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecore_animator.eo.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,8 @@ EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct _Ecore_Animator Ecore_Animator;
|
||||
|
||||
/**
|
||||
* @brief Add an animator to call @p func at every animation tick during main
|
||||
* loop execution.
|
||||
|
@ -172,8 +174,6 @@ EAPI void ecore_animator_freeze(Ecore_Animator *animator);
|
|||
*/
|
||||
EAPI void ecore_animator_thaw(Ecore_Animator *animator);
|
||||
|
||||
#include "ecore_animator.eo.legacy.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -30,23 +30,12 @@
|
|||
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
#include <Eo.h>
|
||||
|
||||
#include "Ecore.h"
|
||||
#include "ecore_private.h"
|
||||
|
||||
#define MY_CLASS ECORE_ANIMATOR_CLASS
|
||||
|
||||
#define MY_CLASS_NAME "Ecore_Animator"
|
||||
|
||||
#define ECORE_ANIMATOR_CHECK(obj) \
|
||||
if (!eo_isa((obj), ECORE_ANIMATOR_CLASS)) \
|
||||
return
|
||||
|
||||
struct _Ecore_Animator_Data
|
||||
struct _Ecore_Animator
|
||||
{
|
||||
EINA_INLIST;
|
||||
Ecore_Animator *obj;
|
||||
|
||||
Ecore_Task_Cb func;
|
||||
void *data;
|
||||
|
@ -60,13 +49,11 @@ struct _Ecore_Animator_Data
|
|||
Eina_Bool just_added : 1;
|
||||
};
|
||||
|
||||
typedef struct _Ecore_Animator_Data Ecore_Animator_Data;
|
||||
|
||||
static Eina_Bool _do_tick(void);
|
||||
static Eina_Bool _ecore_animator_run(void *data);
|
||||
|
||||
static int animators_delete_me = 0;
|
||||
static Ecore_Animator_Data *animators = NULL;
|
||||
static Ecore_Animator *animators = NULL;
|
||||
static double animators_frametime = 1.0 / 30.0;
|
||||
static unsigned int animators_suspended = 0;
|
||||
|
||||
|
@ -281,7 +268,7 @@ _end_tick(void)
|
|||
static Eina_Bool
|
||||
_do_tick(void)
|
||||
{
|
||||
Ecore_Animator_Data *animator;
|
||||
Ecore_Animator *animator;
|
||||
|
||||
EINA_INLIST_FOREACH(animators, animator)
|
||||
{
|
||||
|
@ -307,23 +294,19 @@ _do_tick(void)
|
|||
}
|
||||
if (animators_delete_me)
|
||||
{
|
||||
Ecore_Animator_Data *l;
|
||||
Ecore_Animator *l;
|
||||
for (l = animators; l; )
|
||||
{
|
||||
animator = l;
|
||||
l = (Ecore_Animator_Data *)EINA_INLIST_GET(l)->next;
|
||||
l = (Ecore_Animator *)EINA_INLIST_GET(l)->next;
|
||||
if (animator->delete_me)
|
||||
{
|
||||
if (animator->suspended) animators_suspended--;
|
||||
animators = (Ecore_Animator_Data *)
|
||||
animators = (Ecore_Animator *)
|
||||
eina_inlist_remove(EINA_INLIST_GET(animators),
|
||||
EINA_INLIST_GET(animator));
|
||||
|
||||
eo_parent_set(animator->obj, NULL);
|
||||
if (eo_destructed_is(animator->obj))
|
||||
eo_manual_free(animator->obj);
|
||||
else
|
||||
eo_manual_free_set(animator->obj, EINA_FALSE);
|
||||
free(animator);
|
||||
|
||||
animators_delete_me--;
|
||||
if (animators_delete_me == 0) break;
|
||||
|
@ -338,48 +321,40 @@ _do_tick(void)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_animator_add(Ecore_Animator *obj,
|
||||
Ecore_Animator_Data *animator,
|
||||
Ecore_Task_Cb func,
|
||||
static Ecore_Animator *
|
||||
_ecore_animator_add(Ecore_Task_Cb func,
|
||||
const void *data)
|
||||
{
|
||||
if (EINA_UNLIKELY(!eina_main_loop_is()))
|
||||
{
|
||||
EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE);
|
||||
}
|
||||
Ecore_Animator *animator;
|
||||
|
||||
animator->obj = obj;
|
||||
eo_manual_free_set(obj, EINA_TRUE);
|
||||
if (EINA_UNLIKELY(!eina_main_loop_is()))
|
||||
{
|
||||
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
|
||||
}
|
||||
|
||||
if (!func)
|
||||
{
|
||||
ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME);
|
||||
return EINA_FALSE;
|
||||
ERR("callback function must be set up for an Ecore_Animator object.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
animator = calloc(1, sizeof (Ecore_Animator));
|
||||
if (!animator) return NULL;
|
||||
|
||||
animator->func = func;
|
||||
animator->data = (void *)data;
|
||||
animator->just_added = EINA_TRUE;
|
||||
animators = (Ecore_Animator_Data *)eina_inlist_append(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
|
||||
animators = (Ecore_Animator *)eina_inlist_append(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
|
||||
_begin_tick();
|
||||
return EINA_TRUE;
|
||||
|
||||
return animator;
|
||||
}
|
||||
|
||||
EAPI Ecore_Animator *
|
||||
ecore_animator_add(Ecore_Task_Cb func,
|
||||
const void *data)
|
||||
{
|
||||
Ecore_Animator *animator = NULL;
|
||||
|
||||
animator = eo_add(MY_CLASS, _ecore_parent, ecore_animator_constructor(eo_self, func, data));
|
||||
return animator;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_animator_constructor(Eo *obj, Ecore_Animator_Data *animator, Ecore_Task_Cb func, const void *data)
|
||||
{
|
||||
_ecore_animator_add(obj, animator, func, data);
|
||||
return _ecore_animator_add(func, data);
|
||||
}
|
||||
|
||||
EAPI Ecore_Animator *
|
||||
|
@ -388,22 +363,20 @@ ecore_animator_timeline_add(double runtime,
|
|||
const void *data)
|
||||
{
|
||||
Ecore_Animator *animator;
|
||||
animator = eo_add(MY_CLASS, _ecore_parent, ecore_animator_timeline_constructor(eo_self, runtime, func, data));
|
||||
return animator;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_animator_timeline_constructor(Eo *obj, Ecore_Animator_Data *animator, double runtime, Ecore_Timeline_Cb func, const void *data)
|
||||
{
|
||||
if (runtime <= 0.0) runtime = 0.0;
|
||||
|
||||
if (!_ecore_animator_add(obj, animator, _ecore_animator_run, NULL)) return;
|
||||
animator = _ecore_animator_add(_ecore_animator_run, NULL);
|
||||
if (!animator)
|
||||
return NULL;
|
||||
|
||||
animator->data = obj;
|
||||
animator->data = animator;
|
||||
animator->run_func = func;
|
||||
animator->run_data = (void *)data;
|
||||
animator->start = ecore_loop_time_get();
|
||||
animator->run = runtime;
|
||||
|
||||
return animator;
|
||||
}
|
||||
|
||||
static double
|
||||
|
@ -650,13 +623,12 @@ ecore_animator_pos_map(double pos,
|
|||
}
|
||||
|
||||
EAPI void *
|
||||
ecore_animator_del(Ecore_Animator *obj)
|
||||
ecore_animator_del(Ecore_Animator *animator)
|
||||
{
|
||||
void *data = NULL;
|
||||
|
||||
if (!obj) return NULL;
|
||||
if (!animator) return NULL;
|
||||
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
|
||||
Ecore_Animator_Data *animator = eo_data_scope_get(obj, MY_CLASS);
|
||||
|
||||
if (!animator) return NULL;
|
||||
if (animator->delete_me)
|
||||
|
@ -670,30 +642,11 @@ ecore_animator_del(Ecore_Animator *obj)
|
|||
data = animator->run_data;
|
||||
else
|
||||
data = animator->data;
|
||||
|
||||
end:
|
||||
return data;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_animator_eo_base_destructor(Eo *obj, Ecore_Animator_Data *pd)
|
||||
{
|
||||
pd->delete_me = EINA_TRUE;
|
||||
animators_delete_me++;
|
||||
|
||||
eo_destructor(eo_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
EOLIAN static Eo *
|
||||
_ecore_animator_eo_base_finalize(Eo *obj, Ecore_Animator_Data *pd)
|
||||
{
|
||||
if (!pd->func)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return eo_finalize(eo_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ecore_animator_frametime_set(double frametime)
|
||||
{
|
||||
|
@ -714,15 +667,9 @@ ecore_animator_frametime_get(void)
|
|||
|
||||
EAPI void
|
||||
ecore_animator_freeze(Ecore_Animator *animator)
|
||||
{
|
||||
ECORE_ANIMATOR_CHECK(animator);
|
||||
eo_event_freeze(animator);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_animator_eo_base_event_freeze(Eo *obj EINA_UNUSED, Ecore_Animator_Data *animator)
|
||||
{
|
||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||
if (!animator) return ;
|
||||
if (animator->delete_me) return ;
|
||||
if (!animator->suspended)
|
||||
{
|
||||
|
@ -734,16 +681,8 @@ _ecore_animator_eo_base_event_freeze(Eo *obj EINA_UNUSED, Ecore_Animator_Data *a
|
|||
|
||||
EAPI void
|
||||
ecore_animator_thaw(Ecore_Animator *animator)
|
||||
{
|
||||
ECORE_ANIMATOR_CHECK(animator);
|
||||
eo_event_thaw(animator);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_animator_eo_base_event_thaw(Eo *obj EINA_UNUSED, Ecore_Animator_Data *animator)
|
||||
{
|
||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||
|
||||
if (animator->delete_me) return;
|
||||
if (animator->suspended)
|
||||
{
|
||||
|
@ -801,21 +740,17 @@ ecore_animator_custom_tick(void)
|
|||
void
|
||||
_ecore_animator_shutdown(void)
|
||||
{
|
||||
Ecore_Animator *animator;
|
||||
|
||||
_timer_tick_quit();
|
||||
_end_tick();
|
||||
while (animators)
|
||||
|
||||
EINA_INLIST_FREE(animators, animator)
|
||||
{
|
||||
Ecore_Animator_Data *animator;
|
||||
|
||||
animator = animators;
|
||||
if (animator->suspended) animators_suspended--;
|
||||
animators = (Ecore_Animator_Data *)eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
|
||||
if (animator->delete_me) animators_delete_me--;
|
||||
|
||||
eo_parent_set(animator->obj, NULL);
|
||||
if (eo_destructed_is(animator->obj))
|
||||
eo_manual_free(animator->obj);
|
||||
else
|
||||
eo_manual_free_set(animator->obj, EINA_FALSE);
|
||||
free(animator);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,9 +769,7 @@ _ecore_animator_run_get(void)
|
|||
static Eina_Bool
|
||||
_ecore_animator_run(void *data)
|
||||
{
|
||||
Ecore_Animator *obj = data;
|
||||
Ecore_Animator_Data *animator = eo_data_scope_get(obj, MY_CLASS);
|
||||
|
||||
Ecore_Animator *animator = data;
|
||||
double pos = 0.0, t;
|
||||
Eina_Bool run_ret;
|
||||
|
||||
|
@ -852,5 +785,3 @@ _ecore_animator_run(void *data)
|
|||
if (t >= (animator->start + animator->run)) run_ret = EINA_FALSE;
|
||||
return run_ret;
|
||||
}
|
||||
|
||||
#include "ecore_animator.eo.c"
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
import ecore_types;
|
||||
|
||||
class Ecore.Animator (Eo.Base)
|
||||
{
|
||||
[[Helper to simplify creating animations.
|
||||
|
||||
Creating an animation is as simple as saying for how long it
|
||||
should be run and having a callback that does the animation.
|
||||
]]
|
||||
|
||||
legacy_prefix: ecore_animator;
|
||||
eo_prefix: ecore_animator;
|
||||
methods {
|
||||
timeline_constructor {
|
||||
[[Timeline constructor.]]
|
||||
legacy: null;
|
||||
params {
|
||||
@in runtime: double; [[Animation runtime in seconds.]]
|
||||
@in func: Ecore_Timeline_Cb; [[Animation callback function.]]
|
||||
@in data: const(void_ptr); [[Private data passed to callback functions.]]
|
||||
}
|
||||
}
|
||||
constructor {
|
||||
[[Constructor.]]
|
||||
legacy: null;
|
||||
params {
|
||||
@in func: Ecore_Task_Cb; [[Animation callback function.]]
|
||||
@in data: const(void_ptr); [[Private data passed to callback functions.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Eo.Base.destructor;
|
||||
Eo.Base.finalize;
|
||||
Eo.Base.event_freeze;
|
||||
Eo.Base.event_thaw;
|
||||
}
|
||||
constructors {
|
||||
.constructor;
|
||||
.timeline_constructor;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
type @extern Ecore_Timeline_Cb: __undefined_type;
|
||||
type @extern Ecore_Task_Cb: __undefined_type;
|
||||
type @extern Ecore_Cb: __undefined_type;
|
||||
|
||||
enum Ecore.Pos_Map
|
||||
{
|
||||
|
|
|
@ -23,14 +23,14 @@ static Eina_Bool _anim_cb(void *data EINA_UNUSED, double pos)
|
|||
|
||||
START_TEST(ecore_test_animators)
|
||||
{
|
||||
Eo *animator;
|
||||
Ecore_Animator *animator;
|
||||
double interval1 = 0.02;
|
||||
double interval2 = 0.01;
|
||||
|
||||
fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
|
||||
|
||||
ecore_animator_frametime_set(interval1);
|
||||
animator = eo_add(ECORE_ANIMATOR_CLASS, NULL, ecore_animator_timeline_constructor(eo_self, 1, _anim_cb, &interval1));
|
||||
animator = ecore_animator_timeline_add(1, _anim_cb, &interval1);
|
||||
|
||||
fail_if(!animator);
|
||||
|
||||
|
@ -38,7 +38,7 @@ START_TEST(ecore_test_animators)
|
|||
|
||||
ecore_animator_frametime_set(interval2);
|
||||
prev = 0;
|
||||
animator = eo_add(ECORE_ANIMATOR_CLASS, NULL, ecore_animator_timeline_constructor(eo_self, 1, _anim_cb, &interval2));
|
||||
animator = ecore_animator_timeline_add(1, _anim_cb, &interval2);
|
||||
fail_if(!animator);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
|
Loading…
Reference in New Issue