[elm_pager] merge with latest EFL
authorSohyun Kim <anna1014.kim@samsung.com>
Wed, 19 May 2010 07:01:21 +0000 (16:01 +0900)
committerSohyun Kim <anna1014.kim@samsung.com>
Wed, 19 May 2010 07:01:21 +0000 (16:01 +0900)
src/lib/Elementary.h.in
src/lib/elm_pager.c [changed mode: 0644->0755]

index 4f9c8ce..727c9e9 100755 (executable)
@@ -1158,7 +1158,8 @@ extern "C" {
    EAPI void         elm_pager_content_promote(Evas_Object *obj, Evas_Object *content);
    EAPI Evas_Object *elm_pager_content_bottom_get(const Evas_Object *obj);
    EAPI Evas_Object *elm_pager_content_top_get(const Evas_Object *obj);
-   /* available item styles:
+   EAPI void         elm_pager_animation_set(Evas_Object *obj, Eina_Bool animation);
+  /* available item styles:
     * default
     * fade
     * fade_translucide
old mode 100644 (file)
new mode 100755 (executable)
index b1c0299..bbdc981
@@ -5,7 +5,7 @@
  * @defgroup Pager Pager
  *
  * The pager is an object that allows flipping (with animation) between 1 or
- * more “pages” of objects, much like a stack of windows within the window.
+ * more ?\9cpages??of objects, much like a stack of windows within the window.
  *
  * Objects can be pushed or popped from he stack or deleted as normal.
  * Pushes and pops will animate (and a pop will delete the object once the
@@ -37,12 +37,14 @@ struct _Item
    Eina_Bool popme : 1;
 };
 
+static Eina_Bool ani = EINA_TRUE;
 static const char *widtype = NULL;
 static void _del_hook(Evas_Object *obj);
 static void _theme_hook(Evas_Object *obj);
 static void _sizing_eval(Evas_Object *obj);
 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
+static void _signal_hide_finished(void *data, Evas_Object *obj, const char *emission, const char *source);
 
 static void
 _del_hook(Evas_Object *obj)
@@ -95,23 +97,57 @@ _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
    _sizing_eval(it->obj);
 }
 
+static void 
+_complete_cb( void* data )
+{
+       Item *it = data;
+       Evas_Object *obj = it->obj;
+
+       evas_object_hide(it->base);
+       edje_object_signal_emit(it->base, "elm,action,reset", "elm");
+       evas_object_smart_callback_call(obj, "hide,finished", it->content);
+       edje_object_message_signal_process(it->base);
+       if (it->popme) evas_object_del(it->content);
+       _sizing_eval(obj);
+}
+
 static void
 _eval_top(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
-   Item *ittop;
+   Item *it, *ittop;
+
    if (!wd) return;
    if (!wd->stack) return;
    ittop = eina_list_last(wd->stack)->data;
    if (ittop != wd->top)
      {
-       Evas_Object *o;
+       Evas_Object *o= NULL, *prev_o = NULL;
        const char *onshow, *onhide;
+       Eina_Bool pop = EINA_FALSE;
+       Evas_Coord w, y;
+       Elm_Transit *transit;
+
+       transit = elm_transit_add(obj);
+       evas_object_geometry_get( obj, NULL, &y, &w, NULL );
 
        if (wd->top)
          {
+            it = wd->top;
             o = wd->top->base;
-            edje_object_signal_emit(o, "elm,action,hide", "elm");
+
+            if (wd->top->popme) pop = EINA_TRUE;
+            if (ani) 
+               {
+                 if (pop) elm_transit_fx_insert( transit, elm_fx_transfer_add(o , 0, y, w, y));
+                 else elm_transit_fx_insert( transit, elm_fx_transfer_add(o , 0, y, -w, y));
+                 elm_transit_completion_set( transit, _complete_cb, it);
+               }
+            else 
+               {
+                 _signal_hide_finished(wd->top, o, "elm,action,hide,finished", "");
+               }       
+                
             onhide = edje_object_data_get(o, "onhide");
             if (onhide)
               {
@@ -120,14 +156,23 @@ _eval_top(Evas_Object *obj)
               }
          }
        wd->top = ittop;
-       o = wd->top->base;
-       evas_object_show(o);
-       edje_object_signal_emit(o, "elm,action,show", "elm");
-       onshow = edje_object_data_get(o, "onshow");
+       prev_o = wd->top->base;
+       evas_object_show(prev_o);
+       
+       //add show/hide transition direction & animation on/off. 10.04.14 sohyun
+       if (ani && o) 
+         {
+           if (pop) elm_transit_fx_insert( transit, elm_fx_transfer_add(prev_o, -w, y, 0, y));
+           else elm_transit_fx_insert( transit, elm_fx_transfer_add(prev_o, w, y, 0, y));
+           elm_transit_run( transit, 0.3 );
+         }
+       elm_transit_del( transit ); 
+
+       onshow = edje_object_data_get(prev_o, "onshow");
        if (onshow)
          {
-            if (!strcmp(onshow, "raise")) evas_object_raise(o);
-            else if (!strcmp(onshow, "lower")) evas_object_lower(o);
+            if (!strcmp(onshow, "raise")) evas_object_raise(prev_o);
+            else if (!strcmp(onshow, "lower")) evas_object_lower(prev_o);
          }
      }
 }
@@ -265,7 +310,7 @@ elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
    evas_object_resize(it->base, w, h);
    evas_object_clip_set(it->base, wd->clip);
    elm_widget_sub_object_add(obj, it->base);
-   elm_widget_sub_object_add(obj, it->content);
+   if (it->content) elm_widget_sub_object_add(obj, it->content);
    _elm_theme_object_set(obj, it->base,  "pager", "base", elm_widget_style_get(obj));
    edje_object_signal_callback_add(it->base, "elm,action,hide,finished", "", 
                                    _signal_hide_finished, it);
@@ -313,7 +358,20 @@ elm_pager_content_pop(Evas_Object *obj)
 
             wd->top = it;
             o = wd->top->base;
-            edje_object_signal_emit(o, "elm,action,hide", "elm");
+            if (ani) 
+              {
+                 Elm_Effect *transit;
+                 Evas_Coord w, y;
+      
+                 transit = elm_transit_add(obj);
+                 evas_object_geometry_get(obj, NULL, &y, &w, NULL);
+                 elm_transit_fx_insert(transit, elm_fx_transfer_add(o , 0, y, w, y));
+                 elm_transit_completion_set(transit, _complete_cb, it);
+                 elm_transit_run(transit, 0.3 );
+                 elm_transit_del(transit); 
+               }
+            else _signal_hide_finished(wd->top, o, "elm,action,hide,finished", "");
+
             onhide = edje_object_data_get(o, "onhide");
             if (onhide)
               {
@@ -402,3 +460,17 @@ elm_pager_content_top_get(const Evas_Object *obj)
    return it->content;
 }
 
+/**
+ * set animation on/off for content transition effect
+ *
+ * @param obj The pager object
+ * @param animation transition when contents are changed (default value : TRUE)
+ *
+ * @ingroup Pager
+ */
+EAPI void
+elm_pager_animation_set(Evas_Object *obj, Eina_Bool animation)
+{
+       ani = animation;
+}
+