From 80dc78ff1e647c5307e16d7af170bd7831eabbc4 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 14 Nov 2011 15:54:54 +0900 Subject: [PATCH] [animator] remove --- po/POTFILES.in | 1 - src/lib/Elementary.h.in | 229 ------------------------------------ src/lib/Makefile.am | 1 - src/lib/elm_animator.c | 305 ------------------------------------------------ 4 files changed, 536 deletions(-) delete mode 100644 src/lib/elm_animator.c diff --git a/po/POTFILES.in b/po/POTFILES.in index e7d0131..6723917 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -102,7 +102,6 @@ ./src/lib/elc_fileselector_entry.c ./src/lib/elc_hoversel.c ./src/lib/elm_actionslider.c -./src/lib/elm_animator.c ./src/lib/elm_bg.c ./src/lib/elm_box.c ./src/lib/elm_bubble.c diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index cb279c2..1e0bf7c 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -25067,235 +25067,6 @@ extern "C" { */ /** - * @addtogroup Animator Animator - * @ingroup Elementary - * - * @brief Functions to ease creation of animations. - * - * elm_animator is designed to provide an easy way to create animations. - * Creating an animation with elm_animator is as simple as setting a - * duration, an operating callback and telling it to run the animation. - * However that is not the full extent of elm_animator's ability, animations - * can be paused and resumed, reversed and the animation need not be linear. - * - * To run an animation you must specify at least a duration and operation - * callback, not setting any other properties will create a linear animation - * that runs once and is not reversed. - * - * @ref elm_animator_example_page_01 "This" example should make all of that - * very clear. - * - * @warning elm_animator is @b not a widget. - * @{ - */ - /** - * @brief Type of curve desired for animation. - * - * The speed in which an animation happens doesn't have to be linear, some - * animations will look better if they're accelerating or decelerating, so - * elm_animator provides four options in this regard: - * @image html elm_animator_curve_style.png - * @image latex elm_animator_curve_style.eps width=\textwidth - * As can be seen in the image the speed of the animation will be: - * @li ELM_ANIMATOR_CURVE_LINEAR constant - * @li ELM_ANIMATOR_CURVE_IN_OUT start slow, speed up and then slow down - * @li ELM_ANIMATOR_CURVE_IN start slow and then speed up - * @li ELM_ANIMATOR_CURVE_OUT start fast and then slow down - */ - typedef enum - { - ELM_ANIMATOR_CURVE_LINEAR, - ELM_ANIMATOR_CURVE_IN_OUT, - ELM_ANIMATOR_CURVE_IN, - ELM_ANIMATOR_CURVE_OUT - } Elm_Animator_Curve_Style; - typedef struct _Elm_Animator Elm_Animator; - /** - * Called back per loop of an elementary animators cycle - * @param data user-data given to elm_animator_operation_callback_set() - * @param animator the animator being run - * @param double the position in the animation - */ - typedef void (*Elm_Animator_Operation_Cb) (void *data, Elm_Animator *animator, double frame); - /** - * Called back when an elementary animator finishes - * @param data user-data given to elm_animator_completion_callback_set() - */ - typedef void (*Elm_Animator_Completion_Cb) (void *data); - - /** - * @brief Create a new animator. - * - * @param[in] parent Parent object - * - * The @a parent argument can be set to NULL for no parent. If a parent is set - * there is no need to call elm_animator_del(), when the parent is deleted it - * will delete the animator. - * @deprecated Use @ref Transit instead. - - */ - EINA_DEPRECATED EAPI Elm_Animator* elm_animator_add(Evas_Object *parent); - /** - * Deletes the animator freeing any resources it used. If the animator was - * created with a NULL parent this must be called, otherwise it will be - * automatically called when the parent is deleted. - * - * @param[in] animator Animator object - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_del(Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Set the duration of the animation. - * - * @param[in] animator Animator object - * @param[in] duration Duration in second - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_duration_set(Elm_Animator *animator, double duration) EINA_ARG_NONNULL(1); - /** - * @brief Set the callback function for animator operation. - * - * @param[in] animator Animator object - * @param[in] func @ref Elm_Animator_Operation_Cb "Callback" function pointer - * @param[in] data Callback function user argument - * - * The @p func callback will be called with a frame value in range [0, 1] which - * indicates how far along the animation should be. It is the job of @p func to - * actually change the state of any object(or objects) that are being animated. - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_operation_callback_set(Elm_Animator *animator, Elm_Animator_Operation_Cb func, void *data) EINA_ARG_NONNULL(1); - /** - * Set the callback function for the when the animation ends. - * - * @param[in] animator Animator object - * @param[in] func Callback function pointe - * @param[in] data Callback function user argument - * - * @warning @a func will not be executed if elm_animator_stop() is called. - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_completion_callback_set(Elm_Animator *animator, Elm_Animator_Completion_Cb func, void *data) EINA_ARG_NONNULL(1); - /** - * @brief Stop animator. - * - * @param[in] animator Animator object - * - * If called before elm_animator_animate() it does nothing. If there is an - * animation in progress the animation will be stopped(the operation callback - * will not be executed again) and it can't be restarted using - * elm_animator_resume(). - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_stop(Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Set the animator repeat count. - * - * @param[in] animator Animator object - * @param[in] repeat_cnt Repeat count - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_repeat_set(Elm_Animator *animator, unsigned int repeat_cnt) EINA_ARG_NONNULL(1); - /** - * @brief Start animation. - * - * @param[in] animator Animator object - * - * This function starts the animation if the nescessary properties(duration - * and operation callback) have been set. Once started the animation will - * run until complete or elm_animator_stop() is called. - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_animate(Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Sets the animation @ref Elm_Animator_Curve_Style "acceleration style". - * - * @param[in] animator Animator object - * @param[in] cs Curve style. Default is ELM_ANIMATOR_CURVE_LINEAR - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_curve_style_set(Elm_Animator *animator, Elm_Animator_Curve_Style cs) EINA_ARG_NONNULL(1); - /** - * Gets the animation @ref Elm_Animator_Curve_Style "acceleration style". - * - * @param[in] animator Animator object - * @param[in] cs Curve style. Default is ELM_ANIMATOR_CURVE_LINEAR - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI Elm_Animator_Curve_Style elm_animator_curve_style_get(const Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * @brief Sets wether the animation should be automatically reversed. - * - * @param[in] animator Animator object - * @param[in] reverse Reverse or not - * - * This controls wether the animation will be run on reverse imediately after - * running forward. When this is set together with repetition the animation - * will run in reverse once for each time it ran forward.@n - * Runnin an animation in reverse is accomplished by calling the operation - * callback with a frame value starting at 1 and diminshing until 0. - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_auto_reverse_set(Elm_Animator *animator, Eina_Bool reverse) EINA_ARG_NONNULL(1); - /** - * Gets wether the animation will automatically reversed - * - * @param[in] animator Animator object - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI Eina_Bool elm_animator_auto_reverse_get(const Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Gets the status for the animator operation. The status of the animator @b - * doesn't take in to account elm_animator_pause() or elm_animator_resume(), it - * only informs if the animation was started and has not ended(either normally - * or through elm_animator_stop()). - * - * @param[in] animator Animator object - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI Eina_Bool elm_animator_operating_get(const Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Gets how many times the animation will be repeated - * - * @param[in] animator Animator object - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI unsigned int elm_animator_repeat_get(const Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * Pause the animator. - * - * @param[in] animator Animator object - * - * This causes the animation to be temporarily stopped(the operation callback - * will not be called). If the animation is not yet running this is a no-op. - * Once an animation has been paused with this function it can be resumed - * using elm_animator_resume(). - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_pause(Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * @brief Resumes the animator. - * - * @param[in] animator Animator object - * - * Resumes an animation that was paused using elm_animator_pause(), after - * calling this function calls to the operation callback will happen - * normally. If an animation is stopped by means of elm_animator_stop it - * @b can't be restarted with this function.@n - * - * @warning When an animation is resumed it doesn't start from where it was paused, it - * will go to where it would have been if it had not been paused. If an - * animation with a duration of 3 seconds is paused after 1 second for 1 second - * it will resume as if it had ben animating for 2 seconds, the operating - * callback will be called with a frame value of aproximately 2/3. - * @deprecated Use @ref Transit instead. - */ - EINA_DEPRECATED EAPI void elm_animator_resume(Elm_Animator *animator) EINA_ARG_NONNULL(1); - /** - * @} - */ - - /** * @addtogroup Calendar * @{ */ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 3e3e840..ee0c915 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -56,7 +56,6 @@ elc_navigationbar_ex.c\ elc_player.c \ elc_scrolled_entry.c \ elm_actionslider.c \ -elm_animator.c \ elm_bg.c \ elm_box.c \ elm_bubble.c \ diff --git a/src/lib/elm_animator.c b/src/lib/elm_animator.c deleted file mode 100644 index 5808495..0000000 --- a/src/lib/elm_animator.c +++ /dev/null @@ -1,305 +0,0 @@ -#include -#include "elm_priv.h" - -#define ELM_ANIMATOR_CHECK_OR_RETURN(animator, ...) \ - do { \ - if (!animator) { \ - CRITICAL("Elm_Animator " # animator " is NULL!"); \ - return __VA_ARGS__; \ - } \ - if (!EINA_MAGIC_CHECK(animator, ELM_ANIMATOR_MAGIC)) { \ - EINA_MAGIC_FAIL(animator, ELM_ANIMATOR_MAGIC); \ - return __VA_ARGS__; \ - } \ - } while (0) - - -struct _Elm_Animator -{ -#define ELM_ANIMATOR_MAGIC 0x40777770 - EINA_MAGIC; - - Evas_Object *parent; - Ecore_Animator *animator; - double begin_time; - double cur_time; - double duration; - unsigned int repeat_cnt; - unsigned int cur_repeat_cnt; - void (*animator_op) (void *data, Elm_Animator *animator, double frame); - void *animator_arg; - void (*completion_op) (void *data); - void *completion_arg; - Elm_Animator_Curve_Style curve_style; - Eina_Bool auto_reverse:1; - Eina_Bool on_animating:1; -}; - -static double _animator_curve_linear(double frame); -static double _animator_curve_in_out(double frame); -static double _animator_curve_in(double frame); -static double _animator_curve_out(double frame); -static unsigned int _animator_compute_reverse_repeat_count(unsigned int cnt); -static unsigned int _animator_compute_no_reverse_repeat_count(unsigned int cnt); -static Eina_Bool _animator_animate_cb(void *data); -static void _delete_animator(Elm_Animator *animator); -static void _animator_parent_del(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__); - -static unsigned int -_animator_compute_reverse_repeat_count(unsigned int cnt) -{ - return ((cnt + 1) * 2) - 1; -} - -static unsigned int -_animator_compute_no_reverse_repeat_count(unsigned int cnt) -{ - return cnt / 2; -} - -static double -_animator_curve_linear(double frame) -{ - return frame; -} - -static double -_animator_curve_in_out(double frame) -{ - if (frame < 0.5) return _animator_curve_in(frame * 2) * 0.5; - else return (_animator_curve_out(frame * 2 - 1) * 0.5) + 0.5; -} - -static double -_animator_curve_in(double frame) -{ - return 1 - sqrt(1 - pow(frame, 2)); -} - -static double -_animator_curve_out(double frame) -{ - return sqrt(1 - pow(frame - 1, 2)); -} - -static void -_delete_animator(Elm_Animator *animator) -{ - if (!animator->animator) return; - ecore_animator_del(animator->animator); - animator->animator = NULL; -} - -static Eina_Bool -_animator_animate_cb(void *data) -{ - double elapsed_time, frame; - Elm_Animator *animator = (Elm_Animator *) data; - - animator->cur_time = ecore_loop_time_get(); - elapsed_time = animator->cur_time - animator->begin_time; - if (elapsed_time > animator->duration) elapsed_time = animator->duration; - - //Compute current frame - switch (animator->curve_style) - { - case ELM_ANIMATOR_CURVE_IN_OUT: - frame = _animator_curve_in_out(elapsed_time / animator->duration); - break; - case ELM_ANIMATOR_CURVE_IN: - frame = _animator_curve_in(elapsed_time / animator->duration); - break; - case ELM_ANIMATOR_CURVE_OUT: - frame = _animator_curve_out(elapsed_time / animator->duration); - break; - default: - frame = _animator_curve_linear(elapsed_time / animator->duration); - break; - } - - //Reverse? - if (animator->auto_reverse) - { - if (!(animator->cur_repeat_cnt % 2)) frame = 1 - frame; - } - - if (animator->duration > 0) - animator->animator_op(animator->animator_arg, animator, frame); - //Not end. Keep going. - if (elapsed_time < animator->duration) return ECORE_CALLBACK_RENEW; - - //Repeat and reverse and time done! - if (!animator->cur_repeat_cnt) - { - animator->on_animating = EINA_FALSE; - _delete_animator(animator); - if (animator->completion_op) - animator->completion_op(animator->completion_arg); - return ECORE_CALLBACK_CANCEL; - } - - //Repeat Case - animator->cur_repeat_cnt--; - animator->begin_time = ecore_loop_time_get(); - - return ECORE_CALLBACK_RENEW; -} - -static void -_animator_parent_del(void *data, Evas *evas __UNUSED__, - Evas_Object *obj __UNUSED__, void *event __UNUSED__) -{ - elm_animator_del(data); -} - -EAPI Eina_Bool -elm_animator_auto_reverse_get(const Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator, EINA_FALSE); - return animator->auto_reverse; -} - -EAPI unsigned int -elm_animator_repeat_get(const Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator, 0); - return animator->repeat_cnt; -} - -EAPI Elm_Animator_Curve_Style -elm_animator_curve_style_get(const Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator, ELM_ANIMATOR_CURVE_LINEAR); - return animator->curve_style; -} - -EAPI void -elm_animator_auto_reverse_set(Elm_Animator *animator, Eina_Bool reverse) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (animator->auto_reverse == reverse) return; - animator->auto_reverse = reverse; - if (reverse) - animator->repeat_cnt = - _animator_compute_reverse_repeat_count(animator->repeat_cnt); - else - animator->repeat_cnt = - _animator_compute_no_reverse_repeat_count(animator->repeat_cnt); -} - -EAPI void -elm_animator_curve_style_set(Elm_Animator *animator, - Elm_Animator_Curve_Style cs) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - animator->curve_style = cs; -} -EAPI void -elm_animator_duration_set(Elm_Animator *animator, double duration) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (animator->on_animating) return; - animator->duration = duration; -} - -EAPI void -elm_animator_operation_callback_set(Elm_Animator *animator, - Elm_Animator_Operation_Cb func, - void *data) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (animator->on_animating) return; - animator->animator_op = func; - animator->animator_arg = data; -} - -EAPI Elm_Animator * -elm_animator_add(Evas_Object *parent) -{ - Elm_Animator *animator = ELM_NEW(Elm_Animator); - if (!animator) return NULL; - EINA_MAGIC_SET(animator, ELM_ANIMATOR_MAGIC); - animator->parent = parent; - elm_animator_auto_reverse_set(animator, EINA_FALSE); - elm_animator_curve_style_set(animator, ELM_ANIMATOR_CURVE_LINEAR); - if (parent) - evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL, - _animator_parent_del, animator); - return animator; -} - -EAPI Eina_Bool -elm_animator_operating_get(const Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator, EINA_FALSE); - return animator->on_animating; -} - -EAPI void -elm_animator_del(Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - _delete_animator(animator); - if (animator->parent) - evas_object_event_callback_del(animator->parent, EVAS_CALLBACK_DEL, - _animator_parent_del); - - EINA_MAGIC_SET(animator, EINA_MAGIC_NONE); - free(animator); -} - -EAPI void -elm_animator_completion_callback_set(Elm_Animator *animator, - Elm_Animator_Completion_Cb func, - void *data) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (animator->on_animating) return; - animator->completion_op = func; - animator->completion_arg = data; -} - -EAPI void -elm_animator_pause(Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (!animator->on_animating) return; - ecore_animator_freeze(animator->animator); -} - -EAPI void -elm_animator_resume(Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (!animator->on_animating) return; - ecore_animator_thaw(animator->animator); -} - -EAPI void -elm_animator_stop(Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - animator->on_animating = EINA_FALSE; - _delete_animator(animator); -} - -EAPI void -elm_animator_repeat_set(Elm_Animator *animator, unsigned int repeat_cnt) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (!animator->auto_reverse) animator->repeat_cnt = repeat_cnt; - else - animator->repeat_cnt = _animator_compute_reverse_repeat_count(repeat_cnt); -} - -EAPI void -elm_animator_animate(Elm_Animator *animator) -{ - ELM_ANIMATOR_CHECK_OR_RETURN(animator); - if (!animator->animator_op) return; - animator->begin_time = ecore_loop_time_get(); - animator->cur_repeat_cnt = animator->repeat_cnt; - if (!animator->animator) - animator->animator = ecore_animator_add(_animator_animate_cb, animator); - if (animator->animator) animator->on_animating = EINA_TRUE; -} -- 2.7.4