Add the reorder feature when the more panel is shown.
[framework/uifw/elementary.git] / src / lib / elm_transit.c
index 3cb86ea..70c7d83 100644 (file)
@@ -31,22 +31,25 @@ struct _Elm_Transit
    Elm_Transit *prev_chain_transit;
    Eina_List *next_chain_transits;
    Elm_Transit_Tween_Mode tween_mode;
-   struct {
-      Elm_Transit_Del_Cb func;
-      void *arg;
-   } del_data;
-   struct {
-      double delayed;
-      double paused;
-      double duration;
-      double begin;
-      double current;
-   } time;
-   struct {
-      int count;
-      int current;
-      Eina_Bool reverse;
-   } repeat;
+   struct
+     {
+        Elm_Transit_Del_Cb func;
+        void *arg;
+     } del_data;
+   struct
+     {
+        double delayed;
+        double paused;
+        double duration;
+        double begin;
+        double current;
+     } time;
+   struct
+     {
+        int count;
+        int current;
+        Eina_Bool reverse;
+     } repeat;
    double progress;
    unsigned int effects_pending_del;
    int walking;
@@ -78,7 +81,7 @@ struct _Elm_Transit_Obj_State
 struct _Elm_Transit_Obj_Data
 {
    struct _Elm_Transit_Obj_State *state;
-   Eina_Bool pass_events : 1;
+   Eina_Bool freeze_events : 1;
 };
 
 typedef struct _Elm_Transit_Effect_Module Elm_Transit_Effect_Module;
@@ -92,8 +95,9 @@ static void _transit_obj_remove_cb(void *data, Evas *e __UNUSED__, Evas_Object *
 static void _transit_obj_remove(Elm_Transit *transit, Evas_Object *obj);
 static void _transit_effect_del(Elm_Transit *transit, Elm_Transit_Effect_Module *effect_module);
 static void _transit_remove_dead_effects(Elm_Transit *transit);
+static void _transit_chain_go(Elm_Transit *transit);
 static void _transit_del(Elm_Transit *transit);
-static void _transit_animate_op(Elm_Transit *transit, double progress);
+static Eina_Bool _transit_animate_op(Elm_Transit *transit, double progress);
 static Eina_Bool _transit_animate_cb(void *data);
 
 static char *_transit_key= "_elm_transit_key";
@@ -106,7 +110,7 @@ _transit_obj_data_update(Elm_Transit *transit, Evas_Object *obj)
    if (!obj_data)
      obj_data = ELM_NEW(Elm_Transit_Obj_Data);
 
-   obj_data->pass_events = evas_object_pass_events_get(obj);
+   obj_data->freeze_events = evas_object_freeze_events_get(obj);
 
    if ((!transit->state_keep) && (obj_data->state))
      {
@@ -144,7 +148,7 @@ _remove_obj_from_list(Elm_Transit *transit, Evas_Object *obj)
 {
    //Remove duplicated objects
    //TODO: Need to consider about optimizing here
-   while(1)
+   while (1)
      {
         if (!eina_list_data_find_list(transit->objs, obj))
           break;
@@ -179,7 +183,7 @@ _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
    obj_data = evas_object_data_get(obj, _transit_key);
    if (!obj_data) return;
    evas_object_data_del(obj, _transit_key);
-   evas_object_pass_events_set(obj, obj_data->pass_events);
+   evas_object_freeze_events_set(obj, obj_data->freeze_events);
    state = obj_data->state;
    if (state)
      {
@@ -191,12 +195,8 @@ _transit_obj_data_recover(Elm_Transit *transit, Evas_Object *obj)
              evas_object_color_set(obj, state->r, state->g, state->b, state->a);
              if (state->visible) evas_object_show(obj);
              else evas_object_hide(obj);
-             if (state->map_enabled)
-               evas_object_map_enable_set(obj, EINA_TRUE);
-             else
-               evas_object_map_enable_set(obj, EINA_FALSE);
-             if (state->map)
-               evas_object_map_set(obj, state->map);
+             evas_object_map_enable_set(obj, state->map_enabled);
+             evas_object_map_set(obj, state->map);
           }
         free(state);
      }
@@ -235,6 +235,14 @@ _transit_remove_dead_effects(Elm_Transit *transit)
 }
 
 static void
+_transit_chain_go(Elm_Transit *transit)
+{
+   ELM_TRANSIT_CHECK_OR_RETURN(transit);
+   elm_transit_go(transit);
+   _transit_animate_cb(transit);
+}
+
+static void
 _transit_del(Elm_Transit *transit)
 {
    Elm_Transit_Effect_Module *effect_module;
@@ -273,7 +281,8 @@ _transit_del(Elm_Transit *transit)
    if (transit->finished && transit->next_chain_transits)
      {
         EINA_LIST_FOREACH_SAFE(transit->next_chain_transits, elist, elist_next, chain_transit)
-          elm_transit_go(chain_transit);
+          _transit_chain_go(chain_transit);
+
      }
 
    eina_list_free(transit->next_chain_transits);
@@ -282,7 +291,8 @@ _transit_del(Elm_Transit *transit)
    free(transit);
 }
 
-static void
+//If the transit is deleted then EINA_FALSE is retruned.
+static Eina_Bool
 _transit_animate_op(Elm_Transit *transit, double progress)
 {
    Elm_Transit_Effect_Module *effect_module;
@@ -296,10 +306,17 @@ _transit_animate_op(Elm_Transit *transit, double progress)
      }
    transit->walking--;
 
-   if (transit->walking) return;
+   if (transit->walking) return EINA_TRUE;
+
+   if (transit->deleted)
+     {
+        _transit_del(transit);
+        return EINA_FALSE;
+     }
 
-   if (transit->deleted) _transit_del(transit);
    else if (transit->effects_pending_del) _transit_remove_dead_effects(transit);
+
+   return EINA_TRUE;
 }
 
 static Eina_Bool
@@ -318,23 +335,37 @@ _transit_animate_cb(void *data)
    transit->progress = elapsed_time / duration;
    switch (transit->tween_mode)
      {
+      case ELM_TRANSIT_TWEEN_MODE_LINEAR:
+         transit->progress = ecore_animator_pos_map(transit->progress,
+                                                    ECORE_POS_MAP_LINEAR,
+                                                    0, 0);
       case ELM_TRANSIT_TWEEN_MODE_ACCELERATE:
-        transit->progress = 1.0 - sin((ELM_PI / 2.0) + (transit->progress * ELM_PI / 2.0));
-        break;
+         transit->progress = ecore_animator_pos_map(transit->progress,
+                                                    ECORE_POS_MAP_ACCELERATE,
+                                                    0, 0);
+         break;
       case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
-        transit->progress = sin(transit->progress * ELM_PI / 2.0);
-        break;
+         transit->progress = ecore_animator_pos_map(transit->progress,
+                                                    ECORE_POS_MAP_DECELERATE,
+                                                    0, 0);
+         break;
       case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
-        transit->progress = (1.0 - cos(transit->progress * ELM_PI)) / 2.0;
-        break;
+         transit->progress = ecore_animator_pos_map(transit->progress,
+                                                    ECORE_POS_MAP_SINUSOIDAL,
+                                                    0, 0);
+         break;
       default:
-        break;
+         break;
      }
 
    /* Reverse? */
    if (transit->repeat.reverse) transit->progress = 1 - transit->progress;
 
-   if (transit->time.duration > 0) _transit_animate_op(transit, transit->progress);
+   if (transit->time.duration > 0)
+     {
+        if (!_transit_animate_op(transit, transit->progress))
+          return ECORE_CALLBACK_CANCEL;
+     }
 
    /* Not end. Keep going. */
    if (elapsed_time < duration) return ECORE_CALLBACK_RENEW;
@@ -362,6 +393,52 @@ _transit_animate_cb(void *data)
    return ECORE_CALLBACK_RENEW;
 }
 
+static void
+_recover_image_uv_by_y(Evas_Map *map, int iw, int ih)
+{
+   evas_map_point_image_uv_set(map, 0, iw, 0);
+   evas_map_point_image_uv_set(map, 1, 0, 0);
+   evas_map_point_image_uv_set(map, 2, 0, ih);
+   evas_map_point_image_uv_set(map, 3, iw, ih);
+}
+
+static void
+_recover_image_uv_by_x(Evas_Map *map, int iw, int ih)
+{
+   evas_map_point_image_uv_set(map, 0, 0, ih);
+   evas_map_point_image_uv_set(map, 1, iw, ih);
+   evas_map_point_image_uv_set(map, 2, iw, 0);
+   evas_map_point_image_uv_set(map, 3, 0, 0);
+}
+
+static Eina_Bool
+_recover_image_uv(Evas_Object *obj, Evas_Map *map, Eina_Bool revert, Eina_Bool by_x)
+{
+   //Since the map is not proper for all types of objects,
+   //Need to handle uvs only for image objects
+   int iw, ih;
+   const char *type = evas_object_type_get(obj);
+   if ((!type) || (strcmp(type, "image"))) return EINA_FALSE;
+
+   evas_object_image_size_get(obj, &iw, &ih);
+
+   if (revert)
+     {
+        if (by_x)
+          _recover_image_uv_by_x(map, iw, ih);
+        else
+          _recover_image_uv_by_y(map, iw, ih);
+     }
+   else
+     {
+        evas_map_point_image_uv_set(map, 0, 0, 0);
+        evas_map_point_image_uv_set(map, 1, iw, 0);
+        evas_map_point_image_uv_set(map, 2, iw, ih);
+        evas_map_point_image_uv_set(map, 3, 0, ih);
+     }
+   return EINA_TRUE;
+}
+
 EAPI Elm_Transit *
 elm_transit_add(void)
 {
@@ -453,7 +530,7 @@ elm_transit_object_add(Elm_Transit *transit, Evas_Object *obj)
         if (!evas_object_data_get(obj, _transit_key))
           {
              _transit_obj_data_update(transit, obj);
-             evas_object_pass_events_set(obj, EINA_TRUE);
+             evas_object_freeze_events_set(obj, EINA_TRUE);
           }
      }
 
@@ -494,7 +571,7 @@ elm_transit_event_enabled_set(Elm_Transit *transit, Eina_Bool enabled)
    if (!transit->animator) return;
 
    EINA_LIST_FOREACH(transit->objs, list, obj)
-     evas_object_pass_events_set(obj, enabled);
+     evas_object_freeze_events_set(obj, enabled);
 }
 
 EAPI Eina_Bool
@@ -591,7 +668,7 @@ elm_transit_go(Elm_Transit *transit)
    if (!transit->event_enabled)
      {
         EINA_LIST_FOREACH(transit->objs, elist, obj)
-          evas_object_pass_events_set(obj, EINA_TRUE);
+          evas_object_freeze_events_set(obj, EINA_TRUE);
      }
 
    transit->time.paused = 0;
@@ -693,7 +770,7 @@ elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
 
    if (chain_transit->prev_chain_transit != transit)
      {
-        WRN("These two transit does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
+        WRN("A pair of transits does not have the chain relationship! : transit=%p, chain_transit=%p", transit, chain_transit);
         return;
      }
 
@@ -701,16 +778,6 @@ elm_transit_chain_transit_del(Elm_Transit *transit, Elm_Transit *chain_transit)
    transit->next_chain_transits = eina_list_remove(transit->next_chain_transits, chain_transit);
 }
 
-/**
- * Get the current chain transit list.
- *
- * @note @p transit can not be NULL.
- *
- * @param transit The transit object.
- * @return chain transit list.
- *
- * @ingroup Transit
- */
 EAPI Eina_List *
 elm_transit_chain_transits_get(const Elm_Transit * transit)
 {
@@ -961,7 +1028,9 @@ _transit_effect_zoom_op(Elm_Transit_Effect *effect, Elm_Transit *transit , doubl
         evas_object_geometry_get(obj, &x, &y, &w, &h);
         evas_map_util_points_populate_from_object_full(map, obj, zoom->from +
                                                        (progress * zoom->to));
-        evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0, _TRANSIT_FOCAL);
+        _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
+        evas_map_util_3d_perspective(map, x + (w / 2), y + (h / 2), 0,
+                                     _TRANSIT_FOCAL);
         evas_object_map_set(obj, map);
         evas_object_map_enable_set(obj, EINA_TRUE);
      }
@@ -1085,11 +1154,16 @@ _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double
           {
              if ((degree >= 90) || (degree <= -90))
                {
-                  evas_map_point_image_uv_set(map, 0, w, 0);
-                  evas_map_point_image_uv_set(map, 1, 0, 0);
-                  evas_map_point_image_uv_set(map, 2, 0, h);
-                  evas_map_point_image_uv_set(map, 3, w, h);
+                  if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
+                    {
+                       evas_map_point_image_uv_set(map, 0, w, 0);
+                       evas_map_point_image_uv_set(map, 1, 0, 0);
+                       evas_map_point_image_uv_set(map, 2, 0, h);
+                       evas_map_point_image_uv_set(map, 3, w, h);
+                    }
                }
+             else
+               _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
              evas_map_util_3d_rotate(map, 0, degree,
                                      0, x + half_w, y + half_h, 0);
           }
@@ -1097,11 +1171,16 @@ _transit_effect_flip_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double
           {
              if ((degree >= 90) || (degree <= -90))
                {
-                  evas_map_point_image_uv_set(map, 0, 0, h);
-                  evas_map_point_image_uv_set(map, 1, w, h);
-                  evas_map_point_image_uv_set(map, 2, w, 0);
-                  evas_map_point_image_uv_set(map, 3, 0, 0);
+                  if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
+                    {
+                       evas_map_point_image_uv_set(map, 0, 0, h);
+                       evas_map_point_image_uv_set(map, 1, w, h);
+                       evas_map_point_image_uv_set(map, 2, w, 0);
+                       evas_map_point_image_uv_set(map, 3, 0, 0);
+                    }
                }
+             else
+               _recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE);
              evas_map_util_3d_rotate(map, degree,
                                      0, 0, x + half_w, y + half_h, 0);
           }
@@ -1239,9 +1318,9 @@ _resizable_flip_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_ResizableFl
 }
 
 static void
-_set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
+_set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
 {
-   if ((degree >= 90) || (degree <= -90))
+   if (revert)
      {
         evas_map_point_image_uv_set(map, 0,
                                     (flip->from_size.x * 2) + flip->to_size.x,
@@ -1264,9 +1343,9 @@ _set_image_uv_by_axis_y(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *fl
 }
 
 static void
-_set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, float degree)
+_set_image_uv_by_axis_x(Evas_Map *map, Elm_Transit_Effect_ResizableFlip_Node *flip, Eina_Bool revert)
 {
-   if ((degree >= 90) || (degree <= -90))
+   if (revert)
      {
         evas_map_point_image_uv_set(map, 0, 0,
                                     (flip->from_size.y * 2) + flip->to_size.y);
@@ -1377,18 +1456,41 @@ _transit_effect_resizable_flip_op(Elm_Transit_Effect *effect, Elm_Transit *trans
 
         if (resizable_flip->axis == ELM_TRANSIT_EFFECT_FLIP_AXIS_Y)
           {
-             _set_image_uv_by_axis_y(map, resizable_flip_node, degree);
+             if ((degree >= 90) || (degree <= -90))
+                {
+                   if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_FALSE))
+                     _set_image_uv_by_axis_y(map, resizable_flip_node,
+                                             EINA_TRUE);
+                }
+             else
+               {
+                  if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_FALSE))
+                    _set_image_uv_by_axis_y(map, resizable_flip_node,
+                                            EINA_FALSE);
+               }
              evas_map_util_3d_rotate(map, 0, degree,
                                      0, x + half_w, y + half_h, 0);
           }
         else
           {
-             _set_image_uv_by_axis_x(map, resizable_flip_node, degree);
+             if ((degree >= 90) || (degree <= -90))
+                {
+                   if (!_recover_image_uv(obj, map, EINA_TRUE, EINA_TRUE))
+                     _set_image_uv_by_axis_x(map, resizable_flip_node,
+                                             EINA_TRUE);
+                }
+             else
+               {
+                   if (!_recover_image_uv(obj, map, EINA_FALSE, EINA_TRUE))
+                     _set_image_uv_by_axis_x(map, resizable_flip_node,
+                                             EINA_FALSE);
+               }
              evas_map_util_3d_rotate(map, degree, 0,
                                      0, x + half_w, y + half_h, 0);
           }
 
-        evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0, _TRANSIT_FOCAL);
+        evas_map_util_3d_perspective(map, x + half_w, y + half_h, 0,
+                                     _TRANSIT_FOCAL);
         evas_object_map_enable_set(resizable_flip_node->front, EINA_TRUE);
         evas_object_map_enable_set(resizable_flip_node->back, EINA_TRUE);
         evas_object_map_set(obj, map);
@@ -1592,14 +1694,22 @@ _transit_effect_wipe_op(Elm_Transit_Effect *effect, Elm_Transit *transit, double
    Evas_Coord _x, _y, _w, _h;
    Eina_List *elist;
    Evas_Object *obj;
+   const char *type;
 
    map = evas_map_new(4);
    if (!map) return;
 
    EINA_LIST_FOREACH(transit->objs, elist, obj)
      {
-        evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
-
+        type = evas_object_type_get(obj);
+        if ((!type) || (strcmp(type, "image")))
+          evas_object_geometry_get(obj, &_x, &_y, &_w, &_h);
+        else
+          {
+             evas_object_image_size_get(obj, &_w, &_h);
+             _x = 0;
+             _y = 0;
+          }
         if (wipe->type == ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW)
           _elm_fx_wipe_show(map, wipe->dir, _x, _y, _w, _h, (float)progress);
         else
@@ -2210,7 +2320,7 @@ _transit_effect_image_animation_op(Elm_Transit_Effect *effect, Elm_Transit *tran
 
    EINA_LIST_FOREACH(transit->objs, elist, obj)
      {
-        if (elm_widget_type_check(obj, type))
+        if (elm_widget_type_check(obj, type, __func__))
           elm_icon_file_set(obj,
                             eina_list_nth(image_animation->images, count), NULL);
      }