efl_animation: Add rotate animation object
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 25 Aug 2017 02:26:09 +0000 (11:26 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Thu, 12 Oct 2017 12:03:49 +0000 (21:03 +0900)
13 files changed:
src/Makefile_Elementary.am
src/Makefile_Evas.am
src/bin/elementary/Makefile.am
src/bin/elementary/test.c
src/bin/elementary/test_efl_anim_rotate.c [new file with mode: 0644]
src/lib/evas/Evas_Common.h
src/lib/evas/Evas_Eo.h
src/lib/evas/Evas_Internal.h
src/lib/evas/canvas/efl_animation_object_rotate.c [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_object_rotate.eo [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_object_rotate_private.h [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_rotate.c
src/lib/evas/canvas/efl_animation_rotate.eo

index 7e98233..f8c8b7e 100644 (file)
@@ -798,6 +798,7 @@ bin/elementary/test_disable.c \
 bin/elementary/test_diskselector.c \
 bin/elementary/test_dnd.c \
 bin/elementary/test_efl_anim_alpha.c \
+bin/elementary/test_efl_anim_rotate.c \
 bin/elementary/test_eio.c \
 bin/elementary/test_entry.c \
 bin/elementary/test_entry_anchor.c \
index 87cc6ea..3fcb08b 100644 (file)
@@ -49,6 +49,7 @@ evas_eolian_pub_files = \
        lib/evas/canvas/efl_animation_rotate.eo \
        lib/evas/canvas/efl_animation_object.eo \
        lib/evas/canvas/efl_animation_object_alpha.eo \
+       lib/evas/canvas/efl_animation_object_rotate.eo \
        $(NULL)
 
 evas_eolian_legacy_files = \
@@ -131,7 +132,8 @@ lib/evas/canvas/efl_animation_private.h \
 lib/evas/canvas/efl_animation_alpha_private.h \
 lib/evas/canvas/efl_animation_rotate_private.h \
 lib/evas/canvas/efl_animation_object_private.h \
-lib/evas/canvas/efl_animation_object_alpha_private.h
+lib/evas/canvas/efl_animation_object_alpha_private.h \
+lib/evas/canvas/efl_animation_object_rotate_private.h
 
 # Linebreak
 
@@ -222,6 +224,7 @@ lib/evas/canvas/efl_animation_alpha.c \
 lib/evas/canvas/efl_animation_rotate.c \
 lib/evas/canvas/efl_animation_object.c \
 lib/evas/canvas/efl_animation_object_alpha.c \
+lib/evas/canvas/efl_animation_object_rotate.c \
 $(NULL)
 
 EXTRA_DIST2 += \
index 5dc6479..9eb701a 100644 (file)
@@ -33,6 +33,7 @@ test_access.c \
 test_actionslider.c \
 test_anim.c \
 test_efl_anim_alpha.c \
+test_efl_anim_rotate.c \
 test_application_server.c \
 test_bg.c \
 test_box.c \
index 215d3ec..265044c 100644 (file)
@@ -323,6 +323,9 @@ void test_efl_gfx_map(void *data, Edje_Object *obj, void *event_info);
 void test_ui_textpath(void *data, Edje_Object *obj, void *event_info);
 
 void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info);
+void test_efl_anim_rotate(void *data, Evas_Object *obj, void *event_info);
+void test_efl_anim_rotate_relative(void *data, Evas_Object *obj, void *event_info);
+void test_efl_anim_rotate_absolute(void *data, Evas_Object *obj, void *event_info);
 
 Evas_Object *win, *tbx; // TODO: refactoring
 void *tt;
@@ -793,6 +796,9 @@ add_tests:
    ADD_TEST(NULL, "Effects", "Flip Page (EO API)", test_flip_page_eo);
    ADD_TEST(NULL, "Effects", "Animation", test_anim);
    ADD_TEST(NULL, "Effects", "Efl Animation Alpha", test_efl_anim_alpha);
+   ADD_TEST(NULL, "Effects", "Efl Animation Rotate", test_efl_anim_rotate);
+   ADD_TEST(NULL, "Effects", "Efl Animation Rotate Relative", test_efl_anim_rotate_relative);
+   ADD_TEST(NULL, "Effects", "Efl Animation Rotate Absolute", test_efl_anim_rotate_absolute);
 
    //------------------------------//
    ADD_TEST(NULL, "Edje External", "ExtButton", test_external_button);
diff --git a/src/bin/elementary/test_efl_anim_rotate.c b/src/bin/elementary/test_efl_anim_rotate.c
new file mode 100644 (file)
index 0000000..7fda359
--- /dev/null
@@ -0,0 +1,252 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+typedef struct _App_Data
+{
+   Efl_Animation        *cw_45_degrees_anim;
+   Efl_Animation        *ccw_45_degrees_anim;
+   Efl_Animation_Object *anim_obj;
+
+   Eina_Bool             is_btn_rotated;
+} App_Data;
+
+static void
+_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
+{
+   printf("Animation has been started!\n");
+}
+
+static void
+_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
+{
+   App_Data *ad = data;
+
+   printf("Animation has been ended!\n");
+
+   ad->anim_obj = NULL;
+}
+
+static void
+_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+   Efl_Animation_Object_Running_Event_Info *event_info = event->info;
+   double progress = event_info->progress;
+   printf("Animation is running! Current progress(%lf)\n", progress);
+}
+
+static void
+_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = data;
+
+   if (ad->anim_obj)
+     efl_animation_object_cancel(ad->anim_obj);
+
+   ad->is_btn_rotated = !(ad->is_btn_rotated);
+
+   if (ad->is_btn_rotated)
+     {
+        //Create Animation Object from Animation
+        ad->anim_obj = efl_animation_object_create(ad->cw_45_degrees_anim);
+        elm_object_text_set(obj, "Start Rotate Animation from 45 to 0 degrees");
+     }
+   else
+     {
+        //Create Animation Object from Animation
+        ad->anim_obj = efl_animation_object_create(ad->ccw_45_degrees_anim);
+        elm_object_text_set(obj, "Start Rotate Animation from 0 to 45 degrees");
+     }
+
+   //Register callback called when animation starts
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, NULL);
+
+   //Register callback called when animation ends
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad);
+
+   //Register callback called while animation is executed
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL);
+
+   //Let Animation Object start animation
+   efl_animation_object_start(ad->anim_obj);
+}
+
+static void
+_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = data;
+   free(ad);
+}
+
+void
+test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = calloc(1, sizeof(App_Data));
+   if (!ad) return;
+
+   Evas_Object *win = elm_win_add(NULL, "Efl Animation Rotate", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Efl Animation Rotate");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+   //Button to be animated
+   Evas_Object *btn = elm_button_add(win);
+   elm_object_text_set(btn, "Target");
+   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn, 150, 150);
+   evas_object_move(btn, 125, 100);
+   evas_object_show(btn);
+
+   //Rotate from 0 to 45 degrees Animation
+   Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, NULL, 0.5, 0.5);
+   efl_animation_duration_set(cw_45_degrees_anim, 1.0);
+   efl_animation_target_set(cw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
+
+   //Rotate from 45 to 0 degrees Animation
+   Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, NULL, 0.5, 0.5);
+   efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
+   efl_animation_target_set(ccw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
+
+   //Initialize App Data
+   ad->cw_45_degrees_anim = cw_45_degrees_anim;
+   ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
+   ad->anim_obj = NULL;
+   ad->is_btn_rotated = EINA_FALSE;
+
+   //Button to start animation
+   Evas_Object *btn2 = elm_button_add(win);
+   elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
+   evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
+   evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn2, 300, 50);
+   evas_object_move(btn2, 50, 300);
+   evas_object_show(btn2);
+
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
+
+void
+test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = calloc(1, sizeof(App_Data));
+   if (!ad) return;
+
+   Evas_Object *win = elm_win_add(NULL, "Efl Animation Relative Rotate", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Efl Animation Relative Rotate");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+   //Button to be animated
+   Evas_Object *btn = elm_button_add(win);
+   elm_object_text_set(btn, "Target");
+   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn, 150, 150);
+   evas_object_move(btn, 125, 100);
+   evas_object_show(btn);
+
+   //Pivot to be center of the rotation
+   Evas_Object *pivot = elm_button_add(win);
+   elm_object_text_set(pivot, "Pivot");
+   evas_object_size_hint_weight_set(pivot, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(pivot, 50, 50);
+   evas_object_move(pivot, 350, 150);
+   evas_object_show(pivot);
+
+   //Rotate from 0 to 45 degrees Animation
+   Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_set(cw_45_degrees_anim, 0.0, 45.0, pivot, 0.5, 0.5);
+   efl_animation_duration_set(cw_45_degrees_anim, 1.0);
+   efl_animation_target_set(cw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
+
+   //Rotate from 45 to 0 degrees Animation
+   Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_set(ccw_45_degrees_anim, 45.0, 0.0, pivot, 0.5, 0.5);
+   efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
+   efl_animation_target_set(ccw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
+
+   //Initialize App Data
+   ad->cw_45_degrees_anim = cw_45_degrees_anim;
+   ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
+   ad->anim_obj = NULL;
+   ad->is_btn_rotated = EINA_FALSE;
+
+   //Button to start animation
+   Evas_Object *btn2 = elm_button_add(win);
+   elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
+   evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
+   evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn2, 300, 50);
+   evas_object_move(btn2, 50, 300);
+   evas_object_show(btn2);
+
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
+
+void
+test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = calloc(1, sizeof(App_Data));
+   if (!ad) return;
+
+   Evas_Object *win = elm_win_add(NULL, "Efl Animation Absolute Rotate", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Efl Animation Absolute Rotate");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+   //Button to be animated
+   Evas_Object *btn = elm_button_add(win);
+   elm_object_text_set(btn, "Target");
+   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn, 150, 150);
+   evas_object_move(btn, 125, 100);
+   evas_object_show(btn);
+
+   //Absolute coordinate (0, 0) to be center of the rotation
+   Evas_Object *abs_center = elm_button_add(win);
+   elm_object_text_set(abs_center, "(0, 0)");
+   evas_object_size_hint_weight_set(abs_center, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(abs_center, 50, 50);
+   evas_object_move(abs_center, 0, 0);
+   evas_object_show(abs_center);
+
+   //Rotate from 0 to 45 degrees Animation
+   Efl_Animation *cw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_absolute_set(cw_45_degrees_anim, 0.0, 45.0, 0, 0);
+   efl_animation_duration_set(cw_45_degrees_anim, 1.0);
+   efl_animation_target_set(cw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(cw_45_degrees_anim, EINA_TRUE);
+
+   //Rotate from 45 to 0 degrees Animation
+   Efl_Animation *ccw_45_degrees_anim = efl_add(EFL_ANIMATION_ROTATE_CLASS, NULL);
+   efl_animation_rotate_absolute_set(ccw_45_degrees_anim, 45.0, 0.0, 0, 0);
+   efl_animation_duration_set(ccw_45_degrees_anim, 1.0);
+   efl_animation_target_set(ccw_45_degrees_anim, btn);
+   efl_animation_final_state_keep_set(ccw_45_degrees_anim, EINA_TRUE);
+
+   //Initialize App Data
+   ad->cw_45_degrees_anim = cw_45_degrees_anim;
+   ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
+   ad->anim_obj = NULL;
+   ad->is_btn_rotated = EINA_FALSE;
+
+   //Button to start animation
+   Evas_Object *btn2 = elm_button_add(win);
+   elm_object_text_set(btn2, "Start Rotate Animation from 0 to 45 degrees");
+   evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
+   evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn2, 300, 50);
+   evas_object_move(btn2, 50, 300);
+   evas_object_show(btn2);
+
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
index 47fe1d7..fd5c591 100644 (file)
@@ -3365,6 +3365,13 @@ typedef Eo Efl_Animation_Object_Alpha;
 
 #endif
 
+#ifndef _EFL_ANIMATION_OBJECT_ROTATE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_OBJECT_ROTATE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Object_Rotate;
+
+#endif
+
 struct _Efl_Animation_Object_Running_Event_Info
 {
    double progress;
index 811f252..d0d0cac 100644 (file)
@@ -60,6 +60,7 @@
 #include "canvas/efl_animation_rotate.eo.h"
 #include "canvas/efl_animation_object.eo.h"
 #include "canvas/efl_animation_object_alpha.eo.h"
+#include "canvas/efl_animation_object_rotate.eo.h"
 
 #endif /* EFL_EO_API_SUPPORT */
 
index 88cbded..99cb769 100644 (file)
@@ -102,6 +102,14 @@ EOAPI void efl_animation_object_alpha_set(Eo *obj, double from_alpha, double to_
 EOAPI void efl_animation_object_alpha_get(const Eo *obj, double *from_alpha, double *to_alpha);
 /* Efl.Animation.Object.Alpha END */
 
+/* Efl.Animation.Object.Rotate */
+EOAPI void efl_animation_object_rotate_set(Eo *obj, double from_degree, double to_degree, Efl_Canvas_Object *pivot, double cx, double cy);
+EOAPI void efl_animation_object_rotate_get(const Eo *obj, double *from_degree, double *to_degree, Efl_Canvas_Object **pivot, double *cx, double *cy);
+
+EOAPI void efl_animation_object_rotate_absolute_set(Eo *obj, double from_degree, double to_degree, int cx, int cy);
+EOAPI void efl_animation_object_rotate_absolute_get(const Eo *obj, double *from_degree, double *to_degree, int *cx, int *cy);
+/* Efl.Animation.Object.Rotate END */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate.c b/src/lib/evas/canvas/efl_animation_object_rotate.c
new file mode 100644 (file)
index 0000000..7fbcc25
--- /dev/null
@@ -0,0 +1,253 @@
+#include "efl_animation_object_rotate_private.h"
+
+EOLIAN static void
+_efl_animation_object_rotate_rotate_set(Eo *eo_obj,
+                                        Efl_Animation_Object_Rotate_Data *pd,
+                                        double from_degree,
+                                        double to_degree,
+                                        Efl_Canvas_Object *pivot,
+                                        double cx,
+                                        double cy)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+   pd->from.degree = from_degree;
+   pd->to.degree = to_degree;
+
+   pd->rel_pivot.obj = pivot;
+   pd->rel_pivot.cx = cx;
+   pd->rel_pivot.cy = cy;
+
+   //Update absolute pivot based on relative pivot
+   Evas_Coord x = 0;
+   Evas_Coord y = 0;
+   Evas_Coord w = 0;
+   Evas_Coord h = 0;
+
+   if (pivot)
+     evas_object_geometry_get(pivot, &x, &y, &w, &h);
+   else
+     {
+        Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+        if (target)
+          evas_object_geometry_get(target, &x, &y, &w, &h);
+     }
+
+   pd->abs_pivot.cx = x + (w * cx);
+   pd->abs_pivot.cy = y + (h * cy);
+
+   pd->use_rel_pivot = EINA_TRUE;
+}
+
+EOLIAN static void
+_efl_animation_object_rotate_rotate_get(Eo *eo_obj,
+                                        Efl_Animation_Object_Rotate_Data *pd,
+                                        double *from_degree,
+                                        double *to_degree,
+                                        Efl_Canvas_Object **pivot,
+                                        double *cx,
+                                        double *cy)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+   //Update relative pivot based on absolute pivot
+   if (!pd->use_rel_pivot)
+     {
+        Evas_Coord x = 0;
+        Evas_Coord y = 0;
+        Evas_Coord w = 0;
+        Evas_Coord h = 0;
+
+        Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+        if (target)
+          evas_object_geometry_get(target, &x, &y, &w, &h);
+
+        if (w != 0)
+          pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w;
+        else
+          pd->rel_pivot.cx = 0.0;
+
+        if (h != 0)
+          pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h;
+        else
+          pd->rel_pivot.cy = 0.0;
+     }
+
+   if (from_degree)
+     *from_degree = pd->from.degree;
+
+   if (to_degree)
+     *to_degree = pd->to.degree;
+
+   if (pivot)
+     *pivot = pd->rel_pivot.obj;
+
+   if (cx)
+     *cx = pd->rel_pivot.cx;
+
+   if (cy)
+     *cy = pd->rel_pivot.cy;
+}
+
+EOLIAN static void
+_efl_animation_object_rotate_rotate_absolute_set(Eo *eo_obj,
+                                                 Efl_Animation_Object_Rotate_Data *pd,
+                                                 double from_degree,
+                                                 double to_degree,
+                                                 Evas_Coord cx,
+                                                 Evas_Coord cy)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+   pd->from.degree = from_degree;
+   pd->to.degree = to_degree;
+
+   pd->abs_pivot.cx = cx;
+   pd->abs_pivot.cy = cy;
+
+   //Update relative pivot based on absolute pivot
+   Evas_Coord x = 0;
+   Evas_Coord y = 0;
+   Evas_Coord w = 0;
+   Evas_Coord h = 0;
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+   if (target)
+     evas_object_geometry_get(target, &x, &y, &w, &h);
+
+   pd->rel_pivot.obj = NULL;
+
+   if (w != 0)
+     pd->rel_pivot.cx = (double)(cx - x) / w;
+   else
+     pd->rel_pivot.cx = 0.0;
+
+   if (h != 0)
+     pd->rel_pivot.cy = (double)(cy - y) / h;
+   else
+     pd->rel_pivot.cy = 0.0;
+
+   pd->use_rel_pivot = EINA_FALSE;
+}
+
+EOLIAN static void
+_efl_animation_object_rotate_rotate_absolute_get(Eo *eo_obj,
+                                                 Efl_Animation_Object_Rotate_Data *pd,
+                                                 double *from_degree,
+                                                 double *to_degree,
+                                                 Evas_Coord *cx,
+                                                 Evas_Coord *cy)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+   //Update absolute pivot based on relative pivot
+   if (pd->use_rel_pivot)
+     {
+        Evas_Coord x = 0;
+        Evas_Coord y = 0;
+        Evas_Coord w = 0;
+        Evas_Coord h = 0;
+
+        if (pd->rel_pivot.obj)
+          evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h);
+        else
+          {
+             Efl_Canvas_Object *target
+                = efl_animation_object_target_get(eo_obj);
+             if (target)
+               evas_object_geometry_get(target, &x, &y, &w, &h);
+          }
+
+        pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx);
+        pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy);
+     }
+
+   if (from_degree)
+     *from_degree = pd->from.degree;
+
+   if (to_degree)
+     *to_degree = pd->to.degree;
+
+   if (cx)
+     *cx = pd->abs_pivot.cx;
+
+   if (cy)
+     *cy = pd->abs_pivot.cy;
+}
+
+static void
+_progress_set(Eo *eo_obj, double progress)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_DATA_GET(eo_obj, pd);
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+   if (!target) return;
+
+   double degree =
+      (pd->from.degree * (1.0 - progress)) + (pd->to.degree * progress);
+
+   if (pd->use_rel_pivot)
+     {
+        efl_gfx_map_rotate(target,
+                           degree,
+                           pd->rel_pivot.obj,
+                           pd->rel_pivot.cx, pd->rel_pivot.cy);
+     }
+   else
+     {
+        efl_gfx_map_rotate_absolute(target,
+                                    degree,
+                                    pd->abs_pivot.cx, pd->abs_pivot.cy);
+     }
+}
+
+EOLIAN static void
+_efl_animation_object_rotate_efl_animation_object_progress_set(Eo *eo_obj,
+                                                               Efl_Animation_Object_Rotate_Data *pd EINA_UNUSED,
+                                                               double progress)
+{
+   EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+   if ((progress < 0.0) || (progress > 1.0)) return;
+
+   _progress_set(eo_obj, progress);
+
+   efl_animation_object_progress_set(efl_super(eo_obj, MY_CLASS), progress);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_object_rotate_efl_object_constructor(Eo *eo_obj,
+                                                    Efl_Animation_Object_Rotate_Data *pd)
+{
+   eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+   pd->from.degree = 0.0;
+   pd->to.degree = 0.0;
+
+   pd->rel_pivot.obj = NULL;
+   pd->rel_pivot.cx = 0.5;
+   pd->rel_pivot.cy = 0.5;
+
+   pd->abs_pivot.cx = 0;
+   pd->abs_pivot.cy = 0;
+
+   pd->use_rel_pivot = EINA_TRUE;
+
+   return eo_obj;
+}
+
+/* Internal EO APIs */
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_rotate_set, EFL_FUNC_CALL(from_degree, to_degree, pivot, cx, cy), double from_degree, double to_degree, Efl_Canvas_Object *pivot, double cx, double cy);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_rotate_get, EFL_FUNC_CALL(from_degree, to_degree, pivot, cx, cy), double *from_degree, double *to_degree, Efl_Canvas_Object **pivot, double *cx, double *cy);
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_rotate_absolute_set, EFL_FUNC_CALL(from_degree, to_degree, cx, cy), double from_degree, double to_degree, int cx, int cy);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_rotate_absolute_get, EFL_FUNC_CALL(from_degree, to_degree, cx, cy), double *from_degree, double *to_degree, int *cx, int *cy);
+
+#define EFL_ANIMATION_OBJECT_ROTATE_EXTRA_OPS \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_set, _efl_animation_object_rotate_rotate_set), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_get, _efl_animation_object_rotate_rotate_get), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_absolute_set, _efl_animation_object_rotate_rotate_absolute_set), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_rotate_absolute_get, _efl_animation_object_rotate_rotate_absolute_get)
+
+#include "efl_animation_object_rotate.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate.eo b/src/lib/evas/canvas/efl_animation_object_rotate.eo
new file mode 100644 (file)
index 0000000..4cf898b
--- /dev/null
@@ -0,0 +1,11 @@
+import efl_animation_types;
+
+class Efl.Animation.Object.Rotate (Efl.Animation.Object)
+{
+   [[Efl rotate animation object class]]
+   data: Efl_Animation_Object_Rotate_Data;
+   implements {
+      Efl.Object.constructor;
+      Efl.Animation.Object.progress_set;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_animation_object_rotate_private.h b/src/lib/evas/canvas/efl_animation_object_rotate_private.h
new file mode 100644 (file)
index 0000000..b58860a
--- /dev/null
@@ -0,0 +1,49 @@
+#define EFL_ANIMATION_OBJECT_PROTECTED
+#define EFL_ANIMATION_OBJECT_ROTATE_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_OBJECT_ROTATE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_OBJECT_ROTATE_CHECK_OR_RETURN(anim_obj, ...) \
+   do { \
+      if (!anim_obj) { \
+         CRI("Efl_Animation_Object " # anim_obj " is NULL!"); \
+         return __VA_ARGS__; \
+      } \
+      if (efl_animation_object_is_deleted(anim_obj)) { \
+         ERR("Efl_Animation_Object " # anim_obj " has already been deleted!"); \
+         return __VA_ARGS__; \
+      } \
+   } while (0)
+
+#define EFL_ANIMATION_OBJECT_ROTATE_DATA_GET(o, pd) \
+   Efl_Animation_Object_Rotate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_ROTATE_CLASS)
+
+typedef struct _Efl_Animation_Object_Rotate_Property
+{
+   double degree;
+} Efl_Animation_Object_Rotate_Property;
+
+typedef struct _Efl_Animation_Object_Rotate_Absolute_Pivot
+{
+   Evas_Coord cx, cy;
+} Efl_Animation_Object_Rotate_Absolute_Pivot;
+
+typedef struct _Efl_Animation_Object_Rotate_Relative_Pivot
+{
+   Efl_Canvas_Object *obj;
+   double             cx, cy;
+} Efl_Animation_Object_Rotate_Relative_Pivot;
+
+typedef struct _Efl_Animation_Object_Rotate_Data
+{
+   Efl_Animation_Object_Rotate_Property       from;
+   Efl_Animation_Object_Rotate_Property       to;
+
+   Efl_Animation_Object_Rotate_Absolute_Pivot abs_pivot;
+   Efl_Animation_Object_Rotate_Relative_Pivot rel_pivot;
+
+   Eina_Bool use_rel_pivot;
+} Efl_Animation_Object_Rotate_Data;
index 31b590f..d92cf2f 100644 (file)
@@ -174,6 +174,45 @@ _efl_animation_rotate_rotate_absolute_get(Eo *eo_obj,
      *cy = pd->abs_pivot.cy;
 }
 
+EOLIAN static Efl_Animation_Object *
+_efl_animation_rotate_efl_animation_object_create(Eo *eo_obj,
+                                                  Efl_Animation_Rotate_Data *pd)
+{
+   EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj, NULL);
+
+   Efl_Animation_Object_Rotate *anim_obj
+      = efl_add(EFL_ANIMATION_OBJECT_ROTATE_CLASS, NULL);
+
+   Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+   efl_animation_object_target_set(anim_obj, target);
+
+   Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
+   efl_animation_object_final_state_keep_set(anim_obj, state_keep);
+
+   double duration = efl_animation_duration_get(eo_obj);
+   efl_animation_object_duration_set(anim_obj, duration);
+
+   if (pd->use_rel_pivot)
+     {
+        efl_animation_object_rotate_set(anim_obj,
+                                        pd->from.degree,
+                                        pd->to.degree,
+                                        pd->rel_pivot.obj,
+                                        pd->rel_pivot.cx,
+                                        pd->rel_pivot.cy);
+     }
+   else
+     {
+        efl_animation_object_rotate_absolute_set(anim_obj,
+                                                 pd->from.degree,
+                                                 pd->to.degree,
+                                                 pd->abs_pivot.cx,
+                                                 pd->abs_pivot.cy);
+     }
+
+   return anim_obj;
+}
+
 EOLIAN static Efl_Object *
 _efl_animation_rotate_efl_object_constructor(Eo *eo_obj,
                                              Efl_Animation_Rotate_Data *pd)
index d42415e..aef24fd 100644 (file)
@@ -33,5 +33,6 @@ class Efl.Animation.Rotate (Efl.Animation)
    }
    implements {
       Efl.Object.constructor;
+      Efl.Animation.object_create;
    }
 }