Implemented circular animation for highlight UI 09/22509/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 5 Mar 2014 08:34:32 +0000 (17:34 +0900)
committershoum.chen@samsung.com <shoum.chen@samsung.com>
Wed, 4 Jun 2014 22:01:00 +0000 (18:01 -0400)
Change-Id: Id28a6d868fc21ea9df1eb21f1c507e1167352c89

scl/gwes/efl/sclanimator-efl.cpp
scl/gwes/efl/sclanimator-efl.h
scl/include/sclanimator.h
scl/sclanimator.cpp
scl/sclkeyfocushandler.cpp

index c03883b..25e9bde 100644 (file)
@@ -34,6 +34,7 @@ CSCLAnimatorImplEfl::CSCLAnimatorImplEfl()
     SCL_DEBUG();
 
     m_highlight_ui_object = NULL;
+    m_highlight_ui_object_alternate = NULL;
 }
 
 /**
@@ -55,6 +56,10 @@ void CSCLAnimatorImplEfl::fini()
         evas_object_del(m_highlight_ui_object);
         m_highlight_ui_object = NULL;
     }
+    if (m_highlight_ui_object_alternate) {
+        evas_object_del(m_highlight_ui_object_alternate);
+        m_highlight_ui_object_alternate = NULL;
+    }
 }
 
 
@@ -90,6 +95,56 @@ CSCLAnimatorImplEfl::animator_timer(SclAnimationState *state)
                     evas_object_raise(m_highlight_ui_object);
                     evas_object_show(m_highlight_ui_object);
 
+                    sclboolean circular = FALSE;
+                    if (state->desc.circular) {
+                        if (m_highlight_ui_object_alternate == NULL) {
+                            Evas_Object *window_object = static_cast<Evas_Object*>(windows->get_base_window());
+                            Evas *evas = evas_object_evas_get(window_object);
+                            m_highlight_ui_object_alternate = evas_object_image_add(evas);
+                            sclchar composed_path[_POSIX_PATH_MAX] = {0,};
+                            utils->get_composed_path(composed_path, IMG_PATH_PREFIX, SCL_HIGHLIGHT_UI_IMAGE);
+                            evas_object_image_file_set(m_highlight_ui_object_alternate, composed_path, NULL);
+                        }
+                        SclWindowContext *winctx = windows->get_window_context(windows->get_base_window());
+                        if (winctx) {
+                            if (rect.x < 0) {
+                                evas_object_move(m_highlight_ui_object_alternate,
+                                    winctx->geometry.width + rect.x, rect.y);
+                                evas_object_image_fill_set(m_highlight_ui_object_alternate,
+                                    0, 0, rect.width, rect.height);
+                                evas_object_resize(m_highlight_ui_object_alternate,
+                                    rect.width, rect.height);
+                                evas_object_raise(m_highlight_ui_object_alternate);
+                                evas_object_show(m_highlight_ui_object_alternate);
+                                circular = TRUE;
+                            } else if (rect.x + rect.width > winctx->geometry.width) {
+                                evas_object_move(m_highlight_ui_object_alternate,
+                                    -(winctx->geometry.width - rect.x), rect.y);
+                                evas_object_image_fill_set(m_highlight_ui_object_alternate,
+                                    0, 0, rect.width, rect.height);
+                                evas_object_resize(m_highlight_ui_object_alternate,
+                                    rect.width, rect.height);
+                                evas_object_raise(m_highlight_ui_object_alternate);
+                                evas_object_show(m_highlight_ui_object_alternate);
+                                circular = TRUE;
+                            }
+                        }
+                    }
+                    if (!circular) {
+                        if (m_highlight_ui_object_alternate) {
+                            evas_object_hide(m_highlight_ui_object_alternate);
+                        }
+                    } else {
+                        if (m_highlight_ui_object_alternate) {
+                            sclint window_layer = 29000;
+                            if (!windows->is_base_window(state->desc.window_from) ||
+                                !windows->is_base_window(state->desc.window_to)) {
+                                    window_layer = 29010;
+                            }
+                            evas_object_layer_set(m_highlight_ui_object_alternate, window_layer + 1);
+                        }
+                    }
+
                     sclint window_layer = 29000;
                     if (!windows->is_base_window(state->desc.window_from) ||
                         !windows->is_base_window(state->desc.window_to)) {
index 362d82e..3732539 100644 (file)
@@ -38,6 +38,7 @@ public :
 
 private:
     Evas_Object *m_highlight_ui_object;
+    Evas_Object *m_highlight_ui_object_alternate;
 };
 } /* End of scl namespace */
 #endif //__SCL_ANIMATOR_EFL_H__
index 33bec13..4a3b6b5 100644 (file)
@@ -49,6 +49,8 @@ typedef struct {
 
     SclRectangle rect_from;
     SclRectangle rect_to;
+
+    sclboolean circular;
 }SclAnimationDesc;
 
 typedef struct {
@@ -105,6 +107,7 @@ public :
 protected :
     CSCLAnimatorImpl* get_scl_animator_impl();
 
+    sclboolean animator_timer_highlight_ui(SclAnimationState *state);
 private :
     CSCLAnimatorImpl* m_impl;
 
index 9f1d3e2..7f60dab 100644 (file)
@@ -270,6 +270,77 @@ CSCLAnimator::stop_animator(sclint id)
 }
 
 sclboolean
+CSCLAnimator::animator_timer_highlight_ui(SclAnimationState *state)
+{
+    sclboolean ret = TRUE;
+
+    CSCLWindows *windows = CSCLWindows::get_instance();
+    if (state && windows) {
+        SclRectangle rect_from = state->desc.rect_from;
+        SclRectangle rect_to = state->desc.rect_to;
+
+        /* Convert popup window coordinates relative to base window */
+        if (!(windows->is_base_window(state->desc.window_from))) {
+            SclWindowContext *base_winctx = windows->get_window_context(windows->get_base_window());
+            SclWindowContext *prev_winctx = windows->get_window_context(state->desc.window_from);
+            if (base_winctx && prev_winctx) {
+                rect_from.x += (prev_winctx->geometry.x - base_winctx->geometry.x);
+                rect_from.y += (prev_winctx->geometry.y - base_winctx->geometry.y);
+            }
+        }
+        if (!(windows->is_base_window(state->desc.window_to))) {
+            SclWindowContext *base_winctx = windows->get_window_context(windows->get_base_window());
+            SclWindowContext *next_winctx = windows->get_window_context(state->desc.window_to);
+            if (base_winctx && next_winctx) {
+                rect_to.x += (next_winctx->geometry.x - base_winctx->geometry.x);
+                rect_to.y += (next_winctx->geometry.y - base_winctx->geometry.y);
+            }
+        }
+
+        sclint delta_x = 0; /* We will calculate the X considering circulation */
+        sclint delta_y = rect_to.y - rect_from.y;
+        sclint delta_width = rect_to.width - rect_from.width;
+        sclint delta_height = rect_to.height - rect_from.height;
+
+        state->rect_cur.y = rect_from.y +
+            ((delta_y) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
+        state->rect_cur.width = rect_from.width +
+            ((delta_width) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
+        state->rect_cur.height = rect_from.height +
+            ((delta_height) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
+
+        if (state->desc.circular) {
+            SclWindowContext *base_winctx = windows->get_window_context(windows->get_base_window());
+            if (base_winctx) {
+                if (rect_from.x > rect_to.x) {
+                    delta_x = rect_to.x;
+                    delta_x += (base_winctx->geometry.width - rect_from.x);
+                } else {
+                    delta_x = -(rect_from.x);
+                    delta_x -= (base_winctx->geometry.width - rect_to.x);
+                }
+
+                state->rect_cur.x = rect_from.x +
+                    ((delta_x) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
+
+                if (state->rect_cur.x + state->rect_cur.width <= 0) {
+                    /* Make the highlight UI come out from the right side of the window */
+                    state->rect_cur.x += base_winctx->geometry.width;
+                } else if (state->rect_cur.x > base_winctx->geometry.width) {
+                    state->rect_cur.x -= base_winctx->geometry.width;
+                }
+            }
+        } else {
+            delta_x = rect_to.x - rect_from.x;
+
+            state->rect_cur.x = rect_from.x +
+                ((delta_x) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
+        }
+    }
+
+    return ret;
+}
+sclboolean
 CSCLAnimator::animator_timer()
 {
     sclboolean destroy_timer = TRUE;
@@ -284,39 +355,9 @@ CSCLAnimator::animator_timer()
                     if (SCL_ANIMATION_TIMER_INTERVAL * state->step >= state->desc.length) {
                         state->active = FALSE;
                     } else {
-                        SclRectangle rect_from = state->desc.rect_from;
-                        SclRectangle rect_to = state->desc.rect_to;
-
-                        /* Convert popup window coordinates relative to base window */
-                        if (!(windows->is_base_window(state->desc.window_from))) {
-                            SclWindowContext *base_winctx = windows->get_window_context(windows->get_base_window());
-                            SclWindowContext *prev_winctx = windows->get_window_context(state->desc.window_from);
-                            if (base_winctx && prev_winctx) {
-                                rect_from.x += (prev_winctx->geometry.x - base_winctx->geometry.x);
-                                rect_from.y += (prev_winctx->geometry.y - base_winctx->geometry.y);
-                            }
+                        if (state->desc.type == ANIMATION_TYPE_HIGHLIGHT_UI) {
+                            animator_timer_highlight_ui(state);
                         }
-                        if (!(windows->is_base_window(state->desc.window_to))) {
-                            SclWindowContext *base_winctx = windows->get_window_context(windows->get_base_window());
-                            SclWindowContext *next_winctx = windows->get_window_context(state->desc.window_to);
-                            if (base_winctx && next_winctx) {
-                                rect_to.x += (next_winctx->geometry.x - base_winctx->geometry.x);
-                                rect_to.y += (next_winctx->geometry.y - base_winctx->geometry.y);
-                            }
-                        }
-
-                        sclint delta_x = rect_to.x - rect_from.x;
-                        sclint delta_y = rect_to.y - rect_from.y;
-                        sclint delta_width = rect_to.width - rect_from.width;
-                        sclint delta_height = rect_to.height - rect_from.height;
-                        state->rect_cur.x = rect_from.x +
-                            ((delta_x) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
-                        state->rect_cur.y = rect_from.y +
-                            ((delta_y) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
-                        state->rect_cur.width = rect_from.width +
-                            ((delta_width) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
-                        state->rect_cur.height = rect_from.height +
-                            ((delta_height) * state->step * SCL_ANIMATION_TIMER_INTERVAL) / state->desc.length;
                     }
 
                     CSCLAnimatorImpl *impl = get_scl_animator_impl();
index fa47a57..3b687ad 100644 (file)
@@ -636,6 +636,18 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
                         SclLayoutKeyCoordinatePointer next_coordinate =
                             sclres_layout_key_coordinate_pointer_frame[layout_to][desc.key_to];
 
+                        /* Let's check if the navigation animation should be in circular movement */
+                        sclboolean circular = FALSE;
+                        /* If our 2 buttons overlap in Y axis */
+                        if (calculate_distance(
+                            prev_coordinate->y, prev_coordinate->y + prev_coordinate->height,
+                            next_coordinate->y, next_coordinate->y + next_coordinate->height) < 0) {
+                                /* And if those 2 buttons are side buttons, let's run the animation in circular mode */
+                                if (prev_coordinate->is_side_button && next_coordinate->is_side_button) {
+                                    circular = TRUE;
+                                }
+                        }
+
                         sclint id = animator->find_animator_by_type(ANIMATION_TYPE_HIGHLIGHT_UI);
                         if (id == NOT_USED) {
                             SclAnimationDesc animdesc;
@@ -647,6 +659,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
 
                             animdesc.window_from = desc.window_from;
                             animdesc.window_to = desc.window_to;
+                            animdesc.circular = circular;
 
                             id = animator->create_animator(&animdesc);
                             animator->start_animator(id);
@@ -660,6 +673,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
                                     copy_rectangle( prev_coordinate, &(state->desc.rect_from) );
                                 }
                                 state->step = 0;
+                                state->desc.circular = circular;
 
                                 copy_rectangle( next_coordinate, &(state->desc.rect_to) );