[factory, list, store] merge upstream
[framework/uifw/elementary.git] / src / lib / elm_imageslider.c
index 14879ee..3f22bc2 100644 (file)
@@ -1,20 +1,8 @@
-/*
-*
-* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
-*/
 #include <stdio.h>
 #include <math.h>
 #include <Elementary.h>
 #include "elm_priv.h"
 
-/**
-* @defgroup Imageslider Imageslider
-* @ingroup Elementary
-*
-* By flicking images on the screen,
-* you can see the images in specific path.
-*/
-
 typedef struct _Widget_Data Widget_Data;
 
 #define ANI_STEP (14 * elm_scale_get())
@@ -115,8 +103,6 @@ static void _ev_imageslider_move_cb(void *data, Evas * e, Evas_Object *obj, void
 static void
 _del_hook(Evas_Object *obj)
 {
-   int i;
-
    Widget_Data *wd;
 
    wd = elm_widget_data_get(obj);
@@ -142,7 +128,6 @@ _del_hook(Evas_Object *obj)
      }
 
    if (wd) free(wd);
-
 }
 
 // Whenever require processing theme, Call this function
@@ -180,7 +165,6 @@ _sizing_eval(Evas_Object *obj)
 
    _imageslider_move(obj, e, obj, NULL);
    _imageslider_resize(obj, e, obj, NULL);
-
 }
 
 // Whenever MOVE event occurs, Call this function.
@@ -203,7 +187,6 @@ _imageslider_move(void *data, Evas * e __UNUSED__, Evas_Object *obj, void *event
    wd->y = y;
 
    _imageslider_update_pos(wd, wd->x, wd->y, wd->w);
-
 }
 
 // Whenever RESIZE event occurs, Call this fucntion.
@@ -287,7 +270,7 @@ _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left)
         wd->ly[BLOCK_LEFT] = wd->ly[BLOCK_CENTER];
         wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_RIGHT];
         wd->ly[BLOCK_RIGHT] = ly_temp;
-        elm_layout_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
+        elm_object_part_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
      }
    else
      {
@@ -296,7 +279,7 @@ _imageslider_obj_shift(Widget_Data * wd, Eina_Bool left)
         wd->ly[BLOCK_RIGHT] = wd->ly[BLOCK_CENTER];
         wd->ly[BLOCK_CENTER] = wd->ly[BLOCK_LEFT];
         wd->ly[BLOCK_LEFT] = ly_temp;
-        elm_layout_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
+        elm_object_part_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
      }
 }
 
@@ -350,12 +333,10 @@ _imageslider_obj_move(Widget_Data * wd, Evas_Coord step)
 
 // Whenever MOUSE DOWN event occurs, Call this function.
 static void
-_ev_imageslider_down_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj, void *event_info)
+_ev_imageslider_down_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
 {
    Widget_Data *wd = data;
-   Evas_Coord ix = 0, iy = 0, iw = 0, ih = 0;
    Evas_Event_Mouse_Down *ev = event_info;
-   Evas_Object *eo = NULL;
 
    if (wd->ani_lock)
       return;
@@ -363,7 +344,6 @@ _ev_imageslider_down_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj, void
    wd->down_pos = ev->canvas;
    wd->timestamp = ev->timestamp;
    wd->move_cnt = MOVE_STEP;
-
 }
 
 // Whenever MOUSE UP event occurs, Call this function.
@@ -431,28 +411,18 @@ _ev_imageslider_up_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj __UNUSED
              _imageslider_obj_move(wd, step);
           }
      }
-
 }
 
 // Whenever MOUSE MOVE event occurs, Call this
 static void
-_ev_imageslider_move_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj, void *event_info)
+_ev_imageslider_move_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
 {
-   int idx;
-
-   Evas_Object *eo;
-
+   int idx = 0;
    Evas_Coord step;
-
    Widget_Data *wd = data;
-
    Evas_Event_Mouse_Move *ev = event_info;
 
-   Elm_Imageslider_Item *it;
-
-   if (wd->ani_lock)
-      return;
-
+   if (wd->ani_lock) return;
    if (wd->move_cnt == MOVE_STEP)
      {
         wd->move_cnt = 0;
@@ -464,14 +434,12 @@ _ev_imageslider_move_cb(void *data, Evas * e __UNUSED__, Evas_Object *obj, void
                idx = BLOCK_LEFT;
              else
                idx = BLOCK_RIGHT;
-
              wd->move_x = wd->x + ((ev->cur.canvas.x - wd->down_pos.x));
              wd->move_y = wd->y + ((ev->cur.canvas.y - wd->down_pos.y));
              _imageslider_update_pos(wd, wd->move_x, wd->y, wd->w);
           }
      }
    wd->move_cnt++;
-
 }
 
 static inline double
@@ -521,14 +489,14 @@ _check_drag(int state, void *data)
 
    it = eina_list_data_get(l[state]);
 
-   eo = (Evas_Object*)elm_layout_content_get(wd->ly[state], "swl.photo");
+   eo = elm_object_part_content_get(wd->ly[state], "swl.photo");
    if (eo)
      evas_object_geometry_get(eo, &ix, &iy, &iw, &ih);
    edje_object_part_drag_value_get(elm_layout_edje_get(wd->ly[state]), "swl.photo", &dx, &dy);
 
    if ((iw != wd->w) || ((dx != 0) || (dy != 0)))
      {
-        elm_layout_content_set(wd->ly[state], "swl.photo", NULL);
+        elm_object_part_content_set(wd->ly[state], "swl.photo", NULL);
      }
    else
      return 1;
@@ -545,14 +513,16 @@ _timer_cb(void *data)
 
    struct timeval tv;
 
-   int t;
-
-   int ret;
+   int t = 0;
+   int ret = 0;
 
    wd = data;
-   if (wd->ani_lock == EINA_FALSE)
-      return EINA_FALSE;
-
+   if (!wd->ani_lock)
+     {
+        if (wd->anim_timer)
+          wd->anim_timer = NULL;
+        return ECORE_CALLBACK_CANCEL;
+     }
    gettimeofday(&tv, NULL);
 
    t = (tv.tv_sec - wd->tv.tv_sec) * 1000 + (tv.tv_usec - wd->tv.tv_usec) / 1000;
@@ -635,8 +605,7 @@ _imageslider_update(Widget_Data * wd)
 
    Evas_Object *eo;
 
-   if (!wd)
-     return;
+   if (!wd) return;
 
    if (!wd->cur) return;
 
@@ -646,10 +615,10 @@ _imageslider_update(Widget_Data * wd)
 
    for (i = 0; i < BLOCK_MAX; i++)
      {
-        eo = (Evas_Object*)elm_layout_content_get((const Evas_Object*)wd->ly[i], "swl.photo");
+        eo = elm_object_part_content_get((const Evas_Object*)wd->ly[i], "swl.photo");
         if (!l[i])
           {
-             elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
+             elm_object_part_content_set(wd->ly[i], "swl.photo", NULL);
           }
         else
           {
@@ -662,22 +631,13 @@ _imageslider_update(Widget_Data * wd)
                   eo = elm_image_add(wd->obj);
                   //elm_image_prescale_set(eo, wd->w);
                   elm_image_file_set(eo, it->photo_file, NULL);
-                  elm_layout_content_set(wd->ly[i], "swl.photo", eo);
+                  elm_object_part_content_set(wd->ly[i], "swl.photo", eo);
                }
           }
      }
-
    _anim(wd);
 }
 
-/**
-* Add an Image Slider widget
-*
-* @param        parent  The parent object
-* @return       The new Image slider object or NULL if it cannot be created
-*
-* @ingroup Imageslider
-*/
 EAPI Evas_Object *
 elm_imageslider_add(Evas_Object *parent)
 {
@@ -715,28 +675,15 @@ elm_imageslider_add(Evas_Object *parent)
      }
 
    wd->obj = obj;
-
    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _imageslider_resize, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _imageslider_move, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _imageslider_show, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _imageslider_hide, obj);
 
    _sizing_eval(obj);
-
    return obj;
 }
 
-/**
-* Append an Image Slider item
-*
-* @param        obj          The Image Slider object
-* @param        photo_file   photo file path
-* @param        func         callback function
-* @param        data         callback data
-* @return       The Image Slider item handle or NULL
-*
-* @ingroup Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
 {
@@ -759,24 +706,10 @@ elm_imageslider_item_append(Evas_Object *obj, const char *photo_file, Elm_Images
 
    if (!wd->cur)
       wd->cur = wd->its;
-
    _imageslider_update(wd);
-
    return it;
 }
 
-/**
-* Insert an Image Slider item into the Image Slider Widget by using the given index.
-*
-* @param        obj                     The Image Slider object
-* @param        photo_file      photo file path
-* @param        func            callback function
-* @param        index           required position
-* @param        data            callback data
-* @return       The Image Slider item handle or NULL
-*
-* @ingroup      Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, unsigned int index, void *data)
 {
@@ -799,28 +732,15 @@ elm_imageslider_item_append_relative(Evas_Object *obj, const char *photo_file, E
    it->func = func;
    it->data = data;
 
-   wd->its =
-      eina_list_append_relative(wd->its, it, eina_list_nth(wd->its, index - 2));
+   wd->its = eina_list_append_relative(wd->its, it, eina_list_nth(wd->its,
+                                                                  index - 2));
 
    if (!wd->cur)
       wd->cur = wd->its;
-
    _imageslider_update(wd);
-
    return it;
 }
 
-/**
-* Prepend Image Slider item
-*
-* @param        obj          The Image Slider object
-* @param        photo_file   photo file path
-* @param        func         callback function
-* @param        data         callback data
-* @return       The imageslider item handle or NULL
-*
-* @ingroup Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Imageslider_Cb func, void *data)
 {
@@ -838,22 +758,12 @@ elm_imageslider_item_prepend(Evas_Object *obj, const char *photo_file, Elm_Image
    it->data = data;
    it->obj = obj;
    wd->its = eina_list_prepend(wd->its, it);
-
    if (!wd->cur)
       wd->cur = wd->its;
-
    _imageslider_update(wd);
-
    return it;
 }
 
-/**
-* Delete the selected Image Slider item
-*
-* @param it             The selected Image Slider item handle
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_item_del(Elm_Imageslider_Item * it)
 {
@@ -878,19 +788,9 @@ elm_imageslider_item_del(Elm_Imageslider_Item * it)
              break;
           }
      }
-
    _imageslider_update(wd);
-
 }
 
-/**
-* Get the selected Image Slider item
-*
-* @param obj            The Image Slider object
-* @return The selected Image Slider item or NULL
-*
-* @ingroup Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_selected_item_get(Evas_Object *obj)
 {
@@ -906,14 +806,6 @@ elm_imageslider_selected_item_get(Evas_Object *obj)
    return eina_list_data_get(wd->cur);
 }
 
-/**
-* Get whether an Image Slider item is selected or not
-*
-* @param it              the selected Image Slider item
-* @return EINA_TRUE or EINA_FALSE
-*
-* @ingroup Imageslider
-*/
 EAPI Eina_Bool
 elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
 {
@@ -929,16 +821,8 @@ elm_imageslider_item_selected_get(Elm_Imageslider_Item * it)
       return EINA_TRUE;
    else
       return EINA_FALSE;
-
 }
 
-/**
-* Set the selected Image Slider item
-*
-* @param it             The Imaga Slider item
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
 {
@@ -963,25 +847,13 @@ elm_imageslider_item_selected_set(Elm_Imageslider_Item * it)
 
    for (i = 0; i < BLOCK_MAX; i++)
      {
-       eo = (Evas_Object*)elm_layout_content_get(wd->ly[i], "swl.photo");
+       eo = elm_object_part_content_get(wd->ly[i], "swl.photo");
        if (eo)
-          {
-             elm_layout_content_set(wd->ly[i], "swl.photo", NULL);
-          }
+         elm_object_part_content_set(wd->ly[i], "swl.photo", NULL);
      }
-
    _imageslider_update(wd);
-
 }
 
-/**
-* Get the photo file path of given Image Slider item
-*
-* @param it             The Image Slider item
-* @return The photo file path or NULL;
-*
-* @ingroup Imageslider
-*/
 EAPI const char *
 elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
 {
@@ -990,14 +862,6 @@ elm_imageslider_item_photo_file_get(Elm_Imageslider_Item * it)
    return it->photo_file;
 }
 
-/**
-* Sets the photo file path of given Image Slider item
-*
-* @param it         The Image Slider item
-* @param photo_file The photo file path or NULL;
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_item_photo_file_set(Elm_Imageslider_Item *it, const char *photo_file)
 {
@@ -1011,14 +875,6 @@ elm_imageslider_item_photo_file_set(Elm_Imageslider_Item *it, const char *photo_
      }
 }
 
-/**
-* Get the previous Image Slider item
-*
-* @param it             The Image Slider item
-* @return The previous Image Slider item or NULL
-*
-* @ingroup Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_item_prev(Elm_Imageslider_Item * it)
 {
@@ -1041,18 +897,9 @@ elm_imageslider_item_prev(Elm_Imageslider_Item * it)
              return eina_list_data_get(l);
           }
      }
-
    return NULL;
 }
 
-/**
-* Get the next Image Slider item
-*
-* @param it             The Image Slider item
-* @return The next Image Slider item or NULL
-*
-* @ingroup Imageslider
-*/
 EAPI Elm_Imageslider_Item *
 elm_imageslider_item_next(Elm_Imageslider_Item * it)
 {
@@ -1075,17 +922,9 @@ elm_imageslider_item_next(Elm_Imageslider_Item * it)
              return eina_list_data_get(l);
           }
      }
-
    return NULL;
 }
 
-/**
-* Move to the previous Image Slider item
-*
-* @param obj    The Image Slider object
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_prev(Evas_Object *obj)
 {
@@ -1094,20 +933,11 @@ elm_imageslider_prev(Evas_Object *obj)
 
    if (!obj || (!(wd = elm_widget_data_get(obj))))
      return;
-
    if (wd->ani_lock)
      return;
-
    _imageslider_obj_move(wd, -1);
 }
 
-/**
-* Move to the next Image Slider item
-*
-* @param obj The Image Slider object
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_next(Evas_Object * obj)
 {
@@ -1116,21 +946,11 @@ elm_imageslider_next(Evas_Object * obj)
 
    if (!obj || (!(wd = elm_widget_data_get(obj))))
      return;
-
    if (wd->ani_lock)
      return;
-
    _imageslider_obj_move(wd, 1);
-
 }
 
-/**
-* Updates an Image Slider item
-*
-* @param it The Image Slider item
-*
-* @ingroup Imageslider
-*/
 EAPI void
 elm_imageslider_item_update(Elm_Imageslider_Item *it)
 {
@@ -1139,12 +959,12 @@ elm_imageslider_item_update(Elm_Imageslider_Item *it)
    if (!it || (!(wd = elm_widget_data_get(it->obj)))) return;
    ELM_CHECK_WIDTYPE(it->obj, widtype);
 
-   if (wd->ani_lock == EINA_TRUE) return;
+   if (wd->ani_lock) return;
    if (it == eina_list_data_get(eina_list_prev(wd->cur)))
-     elm_layout_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
+     elm_object_part_content_set(wd->ly[BLOCK_LEFT], "swl.photo", NULL);
    else if (it == eina_list_data_get(wd->cur))
-     elm_layout_content_set(wd->ly[BLOCK_CENTER], "swl.photo", NULL);
+     elm_object_part_content_set(wd->ly[BLOCK_CENTER], "swl.photo", NULL);
    else if (it == eina_list_data_get(eina_list_next(wd->cur)))
-     elm_layout_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
+     elm_object_part_content_set(wd->ly[BLOCK_RIGHT], "swl.photo", NULL);
    _imageslider_update(wd);
 }