elementary - removed deprecated widgets & APIs.
[framework/uifw/elementary.git] / src / lib / elm_pager.c
index 4acb76c..8f1073d 100644 (file)
@@ -1,30 +1,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
-/**
- * @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.
- *
- * Objects can be pushed or popped from the stack or deleted as normal.
- * Pushes and pops will animate (and a pop will delete the object once the
- * animation is finished). Any object in the pager can be promoted to the top
- * (from its current stacking position) as well. Objects are pushed to the
- * top with elm_pager_content_push() and when the top item is no longer
- * wanted, simply pop it with elm_pager_content_pop() and it will also be
- * deleted. Any object you wish to promote to the top that is already in the
- * pager, simply use elm_pager_content_promote(). If an object is no longer
- * needed and is not the top item, just delete it as normal. You can query
- * which objects are the top and bottom with elm_pager_content_bottom_get()
- * and elm_pager_content_top_get().
- *
- * Signals that you can add callbacks for are:
- *
- * "hide,finished" - when the previous page is hided
- *
- */
-
 typedef struct _Widget_Data Widget_Data;
 typedef struct _Item Item;
 
@@ -33,7 +9,6 @@ struct _Widget_Data
    Eina_List *stack;
    Item *top, *oldtop;
    Evas_Object *rect, *clip;
-   Eina_Bool disable_animation: 1;
 };
 
 struct _Item
@@ -48,8 +23,14 @@ static void _del_hook(Evas_Object *obj);
 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
 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 _changed_size_hints(void *data,
+                                Evas *e,
+                                Evas_Object *obj,
+                                void *event_info);
+static void _content_del(void *data,
+                         Evas *e,
+                         Evas_Object *obj,
+                         void *event_info);
 static Eina_List *_item_get(Evas_Object *obj, Evas_Object *content);
 
 static const char SIG_HIDE_FINISHED[] = "hide,finished";
@@ -59,7 +40,6 @@ static const Evas_Smart_Cb_Description _signals[] = {
    {NULL, NULL}
 };
 
-
 static void
 _del_hook(Evas_Object *obj)
 {
@@ -104,7 +84,7 @@ _item_get(Evas_Object *obj, Evas_Object *content)
    Widget_Data *wd = elm_widget_data_get(obj);
    Item *it;
    Eina_List *l;
-   if (!wd) return;
+   if (!wd) return NULL;
 
    EINA_LIST_FOREACH(wd->stack, l, it)
      {
@@ -164,7 +144,6 @@ static void
 _eval_top(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
-   Eina_Bool animate=EINA_TRUE;
    Item *ittop;
    if (!wd) return;
    if (!wd->stack) return;
@@ -177,12 +156,7 @@ _eval_top(Evas_Object *obj)
         if (wd->top)
           {
              o = wd->top->base;
-             if(wd->disable_animation)
-               {
-                  edje_object_signal_emit(o, "elm,action,hide,noanimate", "elm");
-                  wd->stack = eina_list_remove(wd->stack, wd->top);
-               }
-             else if (wd->top->popme)
+             if (wd->top->popme)
                {
                   edje_object_signal_emit(o, "elm,action,pop", "elm");
                   wd->stack = eina_list_remove(wd->stack, wd->top);
@@ -196,22 +170,14 @@ _eval_top(Evas_Object *obj)
                   else if (!strcmp(onhide, "lower")) evas_object_lower(o);
                }
           }
-        else
-          {
-             animate = EINA_FALSE;
-          }
         wd->oldtop = wd->top;
         wd->top = ittop;
         o = wd->top->base;
         evas_object_show(o);
-        if ((!animate)||(wd->disable_animation))
-          {
-             edje_object_signal_emit(o, "elm,action,show,noanimate", "elm");
-          }
-        else if (wd->oldtop)
+        if (wd->oldtop)
           {
              if (elm_object_focus_get(wd->oldtop->content))
-               elm_object_focus(wd->top->content);
+               elm_widget_focused_object_clear(wd->oldtop->content);
              if (wd->oldtop->popme)
                edje_object_signal_emit(o, "elm,action,show", "elm");
              else
@@ -242,23 +208,18 @@ _move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSE
 }
 
 static void
-_sub_del(void *data, Evas_Object *obj __UNUSED__, void *event_info)
+_content_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Widget_Data *wd = elm_widget_data_get(data);
-   Evas_Object *sub = event_info;
    Eina_List *l;
    Item *it;
    if (!wd) return;
-   l = _item_get(obj, sub);
+   l = _item_get(data, obj);
    if (!l) return;
    it = l->data;
-
    wd->stack = eina_list_remove_list(wd->stack, l);
    evas_object_event_callback_del_full
-      (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
-   //TODO: Since the base and content is sub object of pager,
-   //this function (and _item_get) will be called unnecessary.
-   //consider use EVAS_CALLBACK_DEL instead of sub_del callback
+      (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
    evas_object_del(it->base);
    _eval_top(data);
    free(it);
@@ -286,8 +247,13 @@ _signal_hide_finished(void *data, Evas_Object *obj __UNUSED__, const char *emiss
    if (it->popme)
      {
         evas_object_del(it->base);
-        evas_object_event_callback_del_full
-           (content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
+        evas_object_event_callback_del_full(content,
+                                            EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+                                            _changed_size_hints,
+                                            it);
+        evas_object_event_callback_del(content,
+                                       EVAS_CALLBACK_DEL,
+                                       _content_del);
         evas_object_del(content);
         free(it);
      }
@@ -302,14 +268,6 @@ _signal_hide_finished(void *data, Evas_Object *obj __UNUSED__, const char *emiss
     _sizing_eval(obj2);
 }
 
-/**
- * Add a new pager to the parent
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Pager
- */
 EAPI Evas_Object *
 elm_pager_add(Evas_Object *parent)
 {
@@ -340,8 +298,6 @@ elm_pager_add(Evas_Object *parent)
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
 
-   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
-
    evas_object_smart_callbacks_descriptions_set(obj, _signals);
 
    _mirrored_set(obj, elm_widget_mirrored_get(obj));
@@ -349,18 +305,6 @@ elm_pager_add(Evas_Object *parent)
    return obj;
 }
 
-/**
- * Push an object to the top of the pager stack (and show it)
- *
- * The object pushed becomes a child of the pager and will be controlled
- * it and deleted when the pager is deleted.
- *
- * @param obj The pager object
- * @param content The object to push
- *
- * @ingroup Pager
- * @warning It will be failed if the content exists on the stack already.
- */
 EAPI void
 elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
 {
@@ -384,12 +328,24 @@ elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
    evas_object_clip_set(it->base, wd->clip);
    elm_widget_sub_object_add(obj, it->base);
    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);
+   _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);
    evas_object_event_callback_add(it->content,
                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                  _changed_size_hints, it);
+                                  _changed_size_hints,
+                                  it);
+   evas_object_event_callback_add(it->content,
+                                  EVAS_CALLBACK_DEL,
+                                  _content_del,
+                                  obj);
    edje_object_part_swallow(it->base, "elm.swallow.content", it->content);
    edje_object_size_min_calc(it->base, &it->minw, &it->minh);
    evas_object_data_set(it->base, "_elm_leaveme", obj);
@@ -399,17 +355,6 @@ elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
    _sizing_eval(obj);
 }
 
-/**
- * Pop the object that is on top of the stack
- *
- * This pops the object that is on top (visible) in the pager, makes it
- * disappear, then deletes the object. The object that was underneath it
- * on the stack will become visible.
- *
- * @param obj The pager object
- *
- * @ingroup Pager
- */
 EAPI void
 elm_pager_content_pop(Evas_Object *obj)
 {
@@ -457,17 +402,6 @@ _del_job(void *data)
    evas_object_del(obj);
 }
 
-/**
- * Pop to the object that is on the stack
- *
- * This pops the objects that are on the stack, makes them
- * disappear, then deletes the objects. The content will become visible.
- *
- * @param obj The pager object
- * @param content The object to show
- *
- * @ingroup Pager
- */
 EAPI void
 elm_pager_to_content_pop(Evas_Object *obj, Evas_Object *content)
 {
@@ -493,25 +427,13 @@ elm_pager_to_content_pop(Evas_Object *obj, Evas_Object *content)
                }
              else
                break;
-             
+
              ll = ll->prev;
           }
      }
    _eval_top(it->obj);
 }
 
-/**
- * Promote an object already in the pager stack to the top of the stack
- *
- * This will take the indicated object and promote it to the top of the stack
- * as if it had been pushed there. The object must already be inside the
- * pager stack to work.
- *
- * @param obj The pager object
- * @param content The object to promote
- *
- * @ingroup Pager
- */
 EAPI void
 elm_pager_content_promote(Evas_Object *obj, Evas_Object *content)
 {
@@ -529,14 +451,6 @@ elm_pager_content_promote(Evas_Object *obj, Evas_Object *content)
    _eval_top(obj);
 }
 
-/**
- * Return the object at the bottom of the pager stack
- *
- * @param obj The pager object
- * @return The bottom object or NULL if none
- *
- * @ingroup Pager
- */
 EAPI Evas_Object *
 elm_pager_content_bottom_get(const Evas_Object *obj)
 {
@@ -549,14 +463,6 @@ elm_pager_content_bottom_get(const Evas_Object *obj)
    return it->content;
 }
 
-/**
- * Return the object at the top of the pager stack
- *
- * @param obj The pager object
- * @return The top object or NULL if none
- *
- * @ingroup Pager
- */
 EAPI Evas_Object *
 elm_pager_content_top_get(const Evas_Object *obj)
 {
@@ -566,19 +472,3 @@ elm_pager_content_top_get(const Evas_Object *obj)
    if (!wd->top) return NULL;
    return wd->top->content;
 }
-
-/**
- * This disables content animation on push/pop.
- *
- * @param obj The pager object
- * @param disable  if EINA_TRUE animation is disabled.
- *
- * @ingroup Pager
- */
-EAPI void
-elm_pager_animation_disabled_set(Evas_Object *obj, Eina_Bool disable)
-{
-   ELM_CHECK_WIDTYPE(obj, widtype)NULL;
-   Widget_Data *wd = elm_widget_data_get(obj);
-   wd->disable_animation = disable;
-}