*
* @ref actionslider_example_page
*
- * @ref elm_animator_example_page_01
- *
* @ref transit_example_01_explained
*
* @ref transit_example_02_explained
*/
/**
- * @page elm_animator_example_page_01 Animator usage
- * @dontinclude animator_example_01.c
- *
- * For this example we will be using a bit of evas, you could animate a
- * elementary widget in much the same way, but to keep things simple we use
- * an evas_object_rectangle.
- *
- * As every other example we start with our include and a simple callback to
- * exit the app when the window is closed:
- * @skipline #include
- * @until }
- *
- * This next callback is the one that actually creates our animation, it
- * changes the size, position and color of a rectangle given to it in @a
- * data:
- * @until }
- *
- * Next we have a callback that prints a string, nothing special:
- * @until }
- *
- * This next callback is a little more interesting, it has a state variable
- * to know if the animation is currently paused or running, and it toogles
- * the state of the animation accordingly:
- * @until }
- * @until }
- * @until }
- *
- * Finally we have a callback to stop the animation:
- * @until }
- *
- * As with every example we need to do a bit of setup before we can actually
- * use an animation, but for the purposes of this example that's not relevant
- * so let's just skip to the good stuff, creating an animator:
- * @skipline animator_add
- * @note Since elm_animator is not a widget we can give it a NULL parent.
- *
- * Now that we have an elm_animator we set it's duration to 1 second:
- * @line duration_set
- *
- * We would also like our animation to be reversible, so:
- * @line reverse_set
- *
- * We also set our animation to repeat as many times as possible, which will
- * mean that _end_cb will only be called after UINT_MAX * 2 seconds(UINT_MAX
- * for the animation running forward and UNIT_MAX for the animation running
- * backwards):
- * @line repeat_set
- *
- * To add some fun to our animation we will use the IN_OUT curve style:
- * @line curve_style
- *
- * To actually animate anything we need an operation callback:
- * @line operation_callback
- *
- * Even though we set our animation to repeat for a very long time we are
- * going to set a end callback to it:
- * @line completion_callback
- * @note Notice that stoping the animation with the stop button will not make
- * _end_cb be called.
- *
- * Now that we have fully set up our animator we can tell it to start
- * animating:
- * @line animate
- *
- * There's a bit more of code that doesn't really matter to use so we skip
- * right down to our last interesting point:
- * @skipline animator_del
- * @note Because we created our animator with no parent we need to delete it
- * ourselves.
- *
- * The example should look like this:
- *
- * @image html screenshots/animator_example_01.png
- * @image latex screenshots/animator_example_01.eps width=\textwidth
- * @n
- * @image html screenshots/animator_example_02.png
- * @image latex screenshots/animator_example_02.eps width=\textwidth
- * @n
- * @image html screenshots/animator_example_03.png
- * @image latex screenshots/animator_example_03.eps width=\textwidth
- *
- * The full source code for this example can be found @ref
- * animator_example_01_c "here"
- */
-
-/**
* @page transit_example_03_c elm_transit - Combined effects and options.
*
* This example shows how to apply the following transition effects:
./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
SRCS = \
actionslider_example_01.c \
anchorblock_example_01.c \
- animator_example_01.c \
bubble_example_01.c \
button_example_01.c \
check_example_01.c \
EAPI double elm_flipselector_interval_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
- * @}
- */
-
- /**
- * @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);
- /**
- * @}
- */
-
- /**
- * @defgroup Calendar Calendar
- * @ingroup Elementary
- *
- * @image html img/widget/calendar/preview-00.png
- * @image latex img/widget/calendar/preview-00.eps
- *
- * A calendar is a widget that displays a regular calendar, one
- * month at a time, to the user, and can allows the user to select a date.
- *
- * It has support to adding check marks (holidays and checks are supported
- * by default theme).
- *
- * Weekday names and the function used to format month and year to
- * be displayed can be set, giving more flexibility to this widget.
- *
- * Smart callbacks one can register to:
- * - "changed" - emitted when the user selects a day or changes the
- * displayed month, what actually changes the selected day as well.
- *
- * Available styles for it:
- * - @c "default"
- *
- * List of examples:
- * @li @ref calendar_example_01
- * @li @ref calendar_example_02
- * @li @ref calendar_example_03
- * @li @ref calendar_example_04
- * @li @ref calendar_example_05
- * @li @ref calendar_example_06
- */
-
- /**
* @addtogroup Calendar
* @{
*/
elc_player.c \
elc_scrolled_entry.c \
elm_actionslider.c \
-elm_animator.c \
elm_bg.c \
elm_box.c \
elm_bubble.c \
+++ /dev/null
-#include <Elementary.h>
-#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;
-}