--- /dev/null
+#include <Elementary.h>\r
+#include "elm_priv.h"\r
+\r
+\r
+#define INIT_ITEM_NUM (2)\r
+#define GROUP_ITEM_NUM (3)\r
+#define PADDING_WIDTH (25)\r
+\r
+#define MULTI_TOUCH_SET (1)\r
+\r
+#define DEFAULT_STATUS 0\r
+#define TRAN_STATUS 1\r
+#define WHITE_DIM_STATUS 2\r
+\r
+typedef struct Widget_Data {\r
+ Evas_Object *obj; \r
+ Evas_Object *sc;\r
+ Evas_Object *tb;\r
+ Evas_Object *rect;\r
+ const char *widget_name;\r
+ int init_num;\r
+ int padding_w;\r
+ Eina_List *list;\r
+ Ecore_Idler *eidler; \r
+ Evas_Coord x, y, w, h;\r
+ int prex; \r
+ int item_type;\r
+ int item_count;\r
+} Widget_Data;\r
+\r
+static void gallery_add(Evas_Object *obj);\r
+static void gallery_del(Evas_Object *obj);\r
+static void gallery_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);\r
+static void gallery_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);\r
+static void gallery_show(Evas_Object *obj);\r
+static void gallery_hide(Evas_Object *obj);\r
+static void gallery_color_set(Evas_Object *obj, int r, int g, int b, int a);\r
+static void gallery_clip_set(Evas_Object *obj, Evas_Object *clip);\r
+static void gallery_clip_unset(Evas_Object *obj);\r
+static Evas_Smart *gallery_smart_get(void);\r
+static Evas_Object *gallery_new(Evas_Object *parent);\r
+static void _update_gallery(Evas_Object *obj);\r
+static void _resize_gallery(Evas_Object *obj);\r
+static void _gallery_scroller_cb(void *data, Evas_Object *obj, void *event_info);\r
+static void _gallery_animate_stop_cb(void *data, Evas_Object *obj, void *event_info);\r
+static void _gallery_move_right_cb(Evas_Object *obj, int index);\r
+static void _gallery_move_left_cb(Evas_Object *obj, int index);\r
+static void _gallery_clear_all_image(Evas_Object *obj);\r
+static void _gallery_add_image(Evas_Object *obj, int index, void *data);\r
+static void _gallery_del_image(void *data);\r
+static void _gallery_del_image_force(void *data);\r
+static int _gallery_idle_handler_cb(void* data);\r
+static void _gallery_auto_blight(Evas_Object *obj);\r
+static void _gallery_set_all_status(Evas_Object *obj,int status);\r
+\r
+ \r
+static void gallery_add(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+\r
+ wd = (Widget_Data *)calloc(1, sizeof(Widget_Data));\r
+ if (!wd) {\r
+ errno = ENOMEM;\r
+ } else {\r
+ evas_object_smart_data_set(obj, wd);\r
+ \r
+ wd->sc = elm_scroller_add(obj);\r
+ evas_object_size_hint_weight_set(wd->sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+ elm_scroller_bounce_set(wd->sc, 1, 0);\r
+ elm_scroller_policy_set(wd->sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);\r
+ evas_object_smart_callback_add(wd->sc, "scroll", _gallery_scroller_cb, wd);\r
+ evas_object_smart_callback_add(wd->sc, "scroll,anim,stop", _gallery_animate_stop_cb, wd);\r
+ \r
+ wd->tb = elm_table_add(obj);\r
+ evas_object_size_hint_weight_set(wd->tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+ evas_object_size_hint_align_set(wd->tb, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ elm_scroller_content_set(wd->sc, wd->tb);\r
+\r
+ wd->widget_name = eina_stringshare_add("gallery");\r
+ wd->init_num = INIT_ITEM_NUM;\r
+ wd->obj = obj;\r
+ wd->eidler = NULL;\r
+ wd->padding_w = PADDING_WIDTH;\r
+ wd->item_type = DEFAULT_STATUS;\r
+ wd->item_count = GROUP_ITEM_NUM;\r
+ }\r
+}\r
+\r
+static void gallery_del(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+\r
+ if(wd->eidler){\r
+ ecore_idler_del(wd->eidler);\r
+ wd->eidler = NULL;\r
+ }\r
+ \r
+ if(wd->sc){\r
+ evas_object_del(wd->sc);\r
+ wd->sc = NULL;\r
+ }\r
+ \r
+ if(wd->list){\r
+ eina_list_free(wd->list);\r
+ wd->list = NULL;\r
+ }\r
+ \r
+ if(wd) free(wd);\r
+}\r
+\r
+static void gallery_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+\r
+ wd->x = x;\r
+ wd->y = y;\r
+ evas_object_move(wd->sc, x, y);\r
+}\r
+\r
+static void gallery_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+\r
+ wd->w = w;\r
+ wd->h = h;\r
+ \r
+ evas_object_resize(wd->sc, w, h); \r
+\r
+ wd->padding_w = (w - ((w-2)/(wd->item_count +1))*wd->item_count )/4;\r
+\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ elm_table_padding_set(wd->tb, wd->padding_w, 0);\r
+ elm_scroller_page_size_set(wd->sc, (wd->w -2)/(wd->item_count +1) + wd->padding_w, wd->h);\r
+ }\r
+ else\r
+ {\r
+ elm_table_padding_set(wd->tb, 0, 0);\r
+ elm_scroller_page_size_set(wd->sc, (wd->w)/(wd->item_count ) , wd->h);\r
+ }\r
+ _resize_gallery(obj);\r
+ _update_gallery(obj); \r
+}\r
+\r
+static void gallery_show(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+\r
+ evas_object_show(wd->tb); \r
+ evas_object_show(wd->sc); \r
+ \r
+ _update_gallery(obj); \r
+\r
+ if(wd->eidler){\r
+ ecore_idler_del(wd->eidler);\r
+ wd->eidler = NULL;\r
+ }\r
+ \r
+ wd->eidler = ecore_idler_add(_gallery_idle_handler_cb, wd); \r
+}\r
+\r
+static void gallery_hide(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+ _gallery_clear_all_image(obj); \r
+ evas_object_hide(wd->sc);\r
+}\r
+\r
+static void gallery_color_set(Evas_Object *obj, int r, int g, int b, int a)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+ evas_object_color_set(wd->sc, r, g, b, a);\r
+}\r
+\r
+\r
+static void gallery_clip_set(Evas_Object *obj, Evas_Object *clip)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+ evas_object_clip_set(wd->sc, clip);\r
+}\r
+\r
+static void gallery_clip_unset(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+ evas_object_clip_unset(wd->sc);\r
+\r
+}\r
+\r
+static Evas_Smart *gallery_smart_get(void)\r
+{\r
+ static Evas_Smart *s = NULL;\r
+ static Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("UI_gallery");\r
+\r
+ if (!s) {\r
+ sc.add = gallery_add;\r
+ sc.del = gallery_del;\r
+ sc.move = gallery_move;\r
+ sc.resize = gallery_resize;\r
+ sc.show = gallery_show;\r
+ sc.hide = gallery_hide;\r
+ sc.color_set = gallery_color_set;\r
+ sc.clip_set = gallery_clip_set;\r
+ sc.clip_unset = gallery_clip_unset;\r
+ s = evas_smart_class_new(&sc);\r
+ }\r
+\r
+ return s;\r
+}\r
+\r
+static Evas_Object *gallery_new(Evas_Object *parent)\r
+{\r
+ Evas_Object *obj;\r
+ Evas *e;\r
+ e = evas_object_evas_get(parent);\r
+ if (!e) {\r
+ errno = EINVAL;\r
+ return NULL;\r
+ } else {\r
+ obj = evas_object_smart_add(e, gallery_smart_get());\r
+ }\r
+ return obj;\r
+}\r
+\r
+static void _gallery_scroller_cb(void *data, Evas_Object *obj, void *event_info)\r
+{\r
+ Widget_Data *wd = (Widget_Data *)data;\r
+ Evas_Coord ix, iy, iw, ih;\r
+\r
+ elm_scroller_region_get(obj, &ix, &iy, &iw, &ih);\r
+\r
+ int index;\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ { \r
+ index = ix/((wd->w -2)/(wd->item_count +1) + wd->padding_w);\r
+ }\r
+ else\r
+ {\r
+ index = ix/((wd->w)/(wd->item_count ) );\r
+ }\r
+\r
+ printf("scroller %d\n",index);\r
+ \r
+ if(wd->prex < ix){\r
+ _gallery_move_right_cb(wd->obj, index);\r
+ }else\r
+ _gallery_move_left_cb(wd->obj, index);\r
+\r
+ wd->prex = ix;\r
+\r
+ if(wd->item_type == WHITE_DIM_STATUS )\r
+ {\r
+ _gallery_auto_blight(wd->obj);\r
+ printf("scroller blight\n");\r
+ }\r
+}\r
+\r
+static int _gallery_idle_handler_cb(void* data)\r
+{\r
+ Widget_Data *wd = (Widget_Data *)data;\r
+ Elm_Gallery_Item *it = NULL;\r
+ Evas_Coord ix, iy, iw, ih;\r
+ \r
+ elm_scroller_region_get(wd->sc, &ix, &iy, &iw, &ih);\r
+\r
+ int index;\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ index = ix/((wd->w -2)/(wd->item_count +1) + wd->padding_w);\r
+ }\r
+ else\r
+ {\r
+ index = ix/((wd->w )/(wd->item_count ));\r
+ }\r
+ \r
+ it = (Elm_Gallery_Item *)eina_list_nth(wd->list, index +2);\r
+ \r
+ if(it != NULL){\r
+ evas_object_smart_callback_call(wd->obj, "select", it);\r
+ }\r
+\r
+ if(wd->eidler){\r
+ ecore_idler_del(wd->eidler);\r
+ wd->eidler = NULL;\r
+ }\r
+ \r
+ return 0; \r
+}\r
+\r
+static void _gallery_animate_stop_cb(void *data, Evas_Object *obj, void *event_info)\r
+{\r
+ Widget_Data *wd = (Widget_Data *)data;\r
+ if (!wd) return;\r
+ \r
+ if(wd->eidler){\r
+ ecore_idler_del(wd->eidler);\r
+ wd->eidler = NULL;\r
+ }\r
+\r
+ wd->eidler = ecore_idler_add(_gallery_idle_handler_cb, wd); \r
+}\r
+\r
+static void _resize_gallery(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ int count = 0;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ if(wd->rect){\r
+ elm_table_unpack(wd->tb, wd->rect);\r
+ evas_object_del(wd->rect);\r
+ wd->rect = NULL;\r
+ }\r
+\r
+ count = eina_list_count(wd->list);\r
+\r
+ wd->rect = evas_object_rectangle_add(evas_object_evas_get(obj));\r
+ \r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ evas_object_size_hint_min_set(wd->rect, ((wd->w -2)/(wd->item_count +1)) *count, 1);\r
+ else evas_object_size_hint_min_set(wd->rect, ((wd->w )/(wd->item_count )) *count, 1);\r
+ \r
+ elm_table_pack(wd->tb, wd->rect, 0, 0, count, 1); \r
+\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ evas_object_size_hint_min_set(wd->tb, ((wd->w -2)/(wd->item_count +1) + wd->padding_w) *count - wd->padding_w, wd->h -2);\r
+ elm_scroller_content_min_limit(wd->sc, ((wd->w -2)/(wd->item_count +1) + wd->padding_w) *count - wd->padding_w, wd->h -2);\r
+ }\r
+ else\r
+ {\r
+ evas_object_size_hint_min_set(wd->tb, ((wd->w )/(wd->item_count ) ) *count, wd->h );\r
+ elm_scroller_content_min_limit(wd->sc, ((wd->w )/(wd->item_count ) ) *count , wd->h);\r
+ }\r
+}\r
+\r
+static void gallery_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
+{\r
+ Elm_Gallery_Item *it = data;\r
+ Evas_Event_Mouse_Down *ev = event_info;\r
+ \r
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)\r
+ it->on_hold = EINA_TRUE;\r
+ else \r
+ it->on_hold = EINA_FALSE;\r
+\r
+\r
+ Widget_Data *wd = evas_object_smart_data_get(it->parent);\r
+ if(wd->item_type == WHITE_DIM_STATUS)\r
+ {\r
+ edje_object_signal_emit(it->ly, "set_show_red_border", "elm");\r
+ }\r
+\r
+ Evas_Coord ix, iy, iw, ih; \r
+ Evas_Coord x, y, w, h;\r
+ evas_object_geometry_get(obj, &x, &y, &w, &h);\r
+ elm_scroller_region_get(wd->sc, &ix, &iy, &iw, &ih);\r
+\r
+ int index;\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ index = (ix+x)/((wd->w -2)/(wd->item_count +1) + wd->padding_w);\r
+ else\r
+ {\r
+ index = (ix+x)/((wd->w )/(wd->item_count)); \r
+ \r
+ printf("select find index %d\n",index);\r
+ if(wd->prex < ix){\r
+ _gallery_move_right_cb(wd->obj, index);\r
+ }else\r
+ _gallery_move_left_cb(wd->obj, index);\r
+ \r
+ printf("all print point : %d %d %d %d %d %d %d %d\n",x,y,w,h,ix,iy,iw,ih);\r
+ if(index>0)\r
+ elm_scroller_region_bring_in(wd->sc,(index-1)*iw/(wd->item_count) ,y,w*(wd->item_count),h);\r
+ }\r
+}\r
+\r
+static void gallery_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
+{\r
+ Elm_Gallery_Item *it = data;\r
+ Evas_Event_Mouse_Move *ev = event_info;\r
+ \r
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)\r
+ {\r
+ if (!it->on_hold) it->on_hold = EINA_TRUE;\r
+ }\r
+}\r
+\r
+static void gallery_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
+{\r
+ Elm_Gallery_Item *it = data;\r
+ Evas_Event_Mouse_Up *ev = event_info;\r
+ Widget_Data *wd = evas_object_smart_data_get(it->parent);\r
+ Evas_Coord x, y, w, h;\r
+ Evas_Coord ix, iy, iw, ih;\r
+ \r
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->on_hold = EINA_TRUE;\r
+ else it->on_hold = EINA_FALSE;\r
+\r
+ if (it->on_hold)\r
+ {\r
+ it->on_hold= EINA_FALSE;\r
+ return;\r
+ }\r
+\r
+ evas_object_geometry_get(obj, &x, &y, &w, &h);\r
+ elm_scroller_region_get(wd->sc, &ix, &iy, &iw, &ih);\r
+\r
+ int index;\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ index = (ix+x)/((wd->w -2)/(wd->item_count +1) + wd->padding_w);\r
+ else index = (ix+x)/((wd->w )/(wd->item_count));\r
+ \r
+ it = (Elm_Gallery_Item *)eina_list_nth(wd->list, index);\r
+ \r
+ if(it != NULL){\r
+ evas_object_smart_callback_call(wd->obj, "select", it);\r
+ }\r
+ \r
+}\r
+\r
+static void _gallery_add_image(Evas_Object *obj, int index, void *data)\r
+{\r
+ Widget_Data *wd = NULL;\r
+ Evas_Object *ly = NULL;\r
+ Evas_Object *ic = NULL;\r
+ int w, h;\r
+ \r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ Elm_Gallery_Item *it = (Elm_Gallery_Item *)data;\r
+\r
+ ly = edje_object_add(evas_object_evas_get(obj));\r
+ _elm_theme_set(ly, "gallery", "base", "default");\r
+ evas_object_size_hint_weight_set(ly, 1.0, 1.0);\r
+ evas_object_show(ly);\r
+ \r
+ ic = evas_object_image_add(evas_object_evas_get(obj));\r
+ if(wd->item_type == WHITE_DIM_STATUS)\r
+ evas_object_image_load_size_set(ic, wd->w/(wd->item_count) , wd->h/(wd->item_count) );\r
+ else evas_object_image_load_size_set(ic, wd->w/(wd->item_count+1) , wd->h/(wd->item_count+1) );\r
+ \r
+ evas_object_image_file_set(ic, it->path, NULL);\r
+ evas_object_image_size_get(ic, &w, &h); \r
+\r
+\r
+ if(w>h){\r
+ evas_object_image_fill_set(ic, 0, 0, (wd->w -2)/(wd->item_count +1), ((wd->w -2)/(wd->item_count +1) )*h/w);\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ evas_object_size_hint_min_set(ly, (wd->w -2)/(wd->item_count+1) , ((wd->w -2)/(wd->item_count+1) )*h/w);\r
+ evas_object_size_hint_max_set(ly, (wd->w -2)/(wd->item_count+1) , ((wd->w -2)/(wd->item_count+1) )*h/w);\r
+ }\r
+ }else{\r
+ if((wd->h -2)*w/h > (wd->w -2)/(wd->item_count +1)){\r
+ evas_object_image_fill_set(ic, 0, 0, (wd->w -2)/(wd->item_count +1), ((wd->w -2)/(wd->item_count +1))*(wd->h -2)/((wd->h -2)*w/h));\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ evas_object_size_hint_min_set(ly, (wd->w -2)/(wd->item_count+1) , ((wd->w -2)/(wd->item_count+1) )*(wd->h -2 )/((wd->h -2)*w/h));\r
+ evas_object_size_hint_max_set(ly, (wd->w -2)/(wd->item_count+1) , ((wd->w -2)/(wd->item_count+1) )*(wd->h -2 )/((wd->h -2)*w/h));\r
+ }\r
+ }else{\r
+ evas_object_image_fill_set(ic, 0, 0, (wd->h -2)*w/h, wd->h -2);\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ {\r
+ evas_object_size_hint_min_set(ly, (wd->h -2)*w/h, wd->h -2);\r
+ evas_object_size_hint_max_set(ly, (wd->h -2)*w/h, wd->h -2);\r
+ }\r
+ }\r
+ }\r
+\r
+ if(wd->item_type == WHITE_DIM_STATUS)\r
+ {\r
+ evas_object_size_hint_min_set(ly, (wd->w )/(wd->item_count ) , ((wd->w )/(wd->item_count ) )*h/w);\r
+ evas_object_size_hint_max_set(ly, (wd->w )/(wd->item_count ), ((wd->w )/(wd->item_count ) )*h/w);\r
+ }\r
+ \r
+ evas_object_image_filled_set(ic, 1);\r
+ edje_object_part_swallow(ly, "contents", ic);\r
+ evas_object_show(ic); \r
+\r
+ evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_DOWN, gallery_down_cb, it);\r
+ evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_MOVE, gallery_move_cb, it);\r
+ evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_UP, gallery_up_cb, it);\r
+ \r
+ it->w = (wd->w -2)/(wd->item_count +1) ;\r
+ it->h = ((wd->w -2)/(wd->item_count +1) )*h/w;\r
+\r
+ it->mw = it->w;\r
+ it->mh = it->h;\r
+\r
+ it->on_highquality = EINA_TRUE;\r
+ it->index = index;\r
+ \r
+ elm_table_pack(wd->tb, ly, index, 1, 1, 1); \r
+\r
+ if(wd->item_type == DEFAULT_STATUS)\r
+ edje_object_signal_emit(ly, "set_bg_default", "elm");\r
+ if(wd->item_type == TRAN_STATUS)\r
+ {\r
+ edje_object_signal_emit(ly, "set_bg_tran", "elm");\r
+ edje_object_signal_emit(ly, "set_border_hide", "elm");\r
+ }\r
+ else // WHITE_DIM_STATUS\r
+ {\r
+ edje_object_signal_emit(ly, "set_bg_default", "elm");\r
+ }\r
+\r
+ it->ly = ly;\r
+ it->obj = ic; \r
+ it->on_show = EINA_TRUE; \r
+}\r
+\r
+\r
+\r
+\r
+static void _gallery_auto_blight(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *it;\r
+ Eina_List *l;\r
+ Evas_Coord x, y, w, h;\r
+ \r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ int start_pos=-1;\r
+ int end_pos=-1;\r
+ int ret_pos = -1;\r
+ int count=0;\r
+ EINA_LIST_FOREACH(wd->list, l, it) \r
+ { \r
+ Elm_Gallery_Item *inner_it = (Elm_Gallery_Item *)it;\r
+ \r
+ if(inner_it->obj) \r
+ {\r
+ evas_object_geometry_get(it->obj, &x, &y, &w, &h);\r
+ if(!((x+w < 0) || (x > wd->w)))\r
+ {\r
+ if(start_pos==-1)\r
+ start_pos=count;\r
+ else end_pos= count;\r
+ }\r
+ } \r
+ count++;\r
+ }\r
+\r
+ if(start_pos!=-1)\r
+ {\r
+ if(end_pos!=-1)\r
+ {\r
+ ret_pos =(start_pos+end_pos)/2;\r
+ }\r
+ else \r
+ {\r
+ ret_pos =start_pos;\r
+ }\r
+ }\r
+ \r
+ count =0;\r
+ EINA_LIST_FOREACH(wd->list, l, it) \r
+ {\r
+ Elm_Gallery_Item *inner_it = (Elm_Gallery_Item *)it;\r
+ if(inner_it->obj) \r
+ {\r
+ if(ret_pos==count)\r
+ {\r
+ edje_object_signal_emit(inner_it->ly, "set_bg_white", "elm");\r
+ printf("auto blight select %d start %d end %d \n",ret_pos,start_pos,end_pos);\r
+ }\r
+ else \r
+ {\r
+ edje_object_signal_emit(inner_it->ly, "set_bg_default", "elm"); \r
+ printf("auto nonblight select %d start %d end %d \n",ret_pos,start_pos,end_pos);\r
+ }\r
+ }\r
+ count++;\r
+ } \r
+ printf("auto blight\n"); \r
+}\r
+\r
+static void _gallery_set_all_status(Evas_Object *obj,int status)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *it;\r
+ Eina_List *l; \r
+ \r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+ \r
+ EINA_LIST_FOREACH(wd->list, l, it) \r
+ { \r
+ Elm_Gallery_Item *inner_it = (Elm_Gallery_Item *)it;\r
+ if(status == DEFAULT_STATUS)\r
+ {\r
+ edje_object_signal_emit(inner_it->ly, "set_bg_default", "elm");\r
+ }\r
+ if(status == TRAN_STATUS)\r
+ {\r
+ edje_object_signal_emit(inner_it->ly, "set_bg_tran", "elm"); \r
+ edje_object_signal_emit(inner_it->ly, "set_border_hide", "elm"); \r
+ } \r
+ }\r
+ if(status == WHITE_DIM_STATUS)\r
+ {\r
+ _gallery_auto_blight(obj);\r
+ printf("blight\n");\r
+ } \r
+}\r
+\r
+\r
+static void _gallery_del_image_force(void *data)\r
+{\r
+ Elm_Gallery_Item *it = (Elm_Gallery_Item *)data;\r
+ Widget_Data *wd = evas_object_smart_data_get(it->parent);\r
+ Evas_Coord x, y, w, h;\r
+\r
+ if(it->on_show == EINA_TRUE){\r
+ if(it->obj) {\r
+ evas_object_geometry_get(it->obj, &x, &y, &w, &h);\r
+\r
+ elm_table_unpack(wd->tb, it->ly);\r
+ evas_object_del(it->ly);\r
+ evas_object_del(it->obj);\r
+ it->obj = NULL;\r
+ it->on_show = EINA_FALSE;\r
+ }\r
+ }\r
+ \r
+}\r
+static void _gallery_del_image(void *data)\r
+{\r
+ Elm_Gallery_Item *it = (Elm_Gallery_Item *)data;\r
+ Widget_Data *wd = evas_object_smart_data_get(it->parent);\r
+ Evas_Coord x, y, w, h;\r
+\r
+ if(it->on_show == EINA_TRUE){\r
+ if(it->obj) {\r
+ evas_object_geometry_get(it->obj, &x, &y, &w, &h);\r
+\r
+ if((x+w < 0) || (x > wd->w)){\r
+ elm_table_unpack(wd->tb, it->ly);\r
+ evas_object_del(it->ly);\r
+ evas_object_del(it->obj);\r
+ it->obj = NULL;\r
+ it->on_show = EINA_FALSE;\r
+ }\r
+ }\r
+ }\r
+ \r
+}\r
+\r
+static void _gallery_clear_all_image(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *it;\r
+ Eina_List *l;\r
+\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ EINA_LIST_FOREACH(wd->list, l, it) \r
+ {\r
+ _gallery_del_image_force(it);\r
+ }\r
+}\r
+\r
+static void _update_gallery(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ Evas_Coord x, y, w, h; \r
+ int i = 0;\r
+ int index = 0;\r
+ \r
+ if (!wd) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+ \r
+ if((wd->w == 1) && (wd->h == 1)) return;\r
+\r
+ for(i =wd->init_num -3; i< wd->init_num + 4; i++)\r
+ {\r
+ Elm_Gallery_Item *it = NULL;\r
+ it = (Elm_Gallery_Item *)eina_list_nth(wd->list, i);\r
+\r
+ if(it != NULL){\r
+ if(it->on_show == EINA_FALSE){ \r
+ _gallery_add_image(obj, i, it);\r
+ }\r
+ }\r
+ }\r
+\r
+ if(wd->init_num > 2)\r
+ index = wd->init_num -2;\r
+ else\r
+ index = 0;\r
+ \r
+ elm_scroller_region_get(wd->sc, &x, &y, &w, &h);\r
+ if(!(wd->item_type == WHITE_DIM_STATUS))\r
+ elm_scroller_region_show(wd->sc, index*((wd->w -2)/(wd->item_count +1) +wd->padding_w), y, w, h); \r
+ else elm_scroller_region_show(wd->sc, index*((wd->w )/(wd->item_count )), y, w, h); \r
+}\r
+\r
+static void _gallery_move_right_cb(Evas_Object *obj, int index)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ Elm_Gallery_Item *nit = NULL;\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + wd->item_count );\r
+ if(nit != NULL){ \r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index + wd->item_count , nit);\r
+ }\r
+ }\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + 2);\r
+ if(nit != NULL){ \r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index + 2, nit);\r
+ }\r
+ }\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + 3);\r
+ if(nit != NULL){ \r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index + 3, nit);\r
+ }\r
+ } \r
+\r
+ if(index > wd->item_count *2){\r
+ Elm_Gallery_Item *pit = NULL;\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - wd->item_count -2);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit);\r
+ }\r
+\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - wd->item_count -3);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit); \r
+ }\r
+\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - wd->item_count -4);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit); \r
+ } \r
+ }\r
+\r
+}\r
+\r
+static void _gallery_move_left_cb(Evas_Object *obj, int index)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ Elm_Gallery_Item *nit = NULL;\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - wd->item_count );\r
+ if(nit != NULL){\r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index - wd->item_count , nit);\r
+ }\r
+ }\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - 2);\r
+ if(nit != NULL){\r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index - 2, nit);\r
+ }\r
+ }\r
+\r
+ nit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index - 3);\r
+ if(nit != NULL){\r
+ if(nit->on_show == EINA_FALSE){\r
+ _gallery_add_image(obj, index - 3, nit);\r
+ }\r
+ }\r
+ \r
+ if(index + wd->item_count + 4 < eina_list_count(wd->list)){\r
+ Elm_Gallery_Item *pit = NULL;\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + wd->item_count +2);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit);\r
+ }\r
+\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + wd->item_count +3);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit);\r
+ }\r
+\r
+ pit = (Elm_Gallery_Item *)eina_list_nth(wd->list, index + wd->item_count +4);\r
+ if(pit != NULL){\r
+ _gallery_del_image(pit);\r
+ } \r
+ }\r
+}\r
+\r
+EAPI Evas_Object *elm_gallery_add(Evas_Object *parent)\r
+{\r
+ Evas_Object *obj;\r
+ Widget_Data *wd;\r
+ if (!parent) {\r
+ errno = EINVAL;\r
+ return NULL;\r
+ }\r
+\r
+ if ((obj = gallery_new(parent))) {\r
+ if (!(wd = evas_object_smart_data_get(obj))) {\r
+ evas_object_del(obj);\r
+ return NULL;\r
+ }\r
+ }\r
+ \r
+ elm_widget_sub_object_add (parent, obj);\r
+ \r
+ return obj;\r
+}\r
+\r
+EAPI Elm_Gallery_Item *elm_gallery_item_append(Evas_Object *obj, const char *photo_file)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *it;\r
+ if (!obj || !(wd = evas_object_smart_data_get(obj))) {\r
+ errno = EINVAL;\r
+ return NULL;\r
+ }\r
+ \r
+ it = (Elm_Gallery_Item *)calloc(1, sizeof(Elm_Gallery_Item));\r
+ it->path = eina_stringshare_add(photo_file);\r
+ it->parent = obj;\r
+ it->obj = NULL; \r
+ it->on_show = EINA_FALSE;\r
+ \r
+ wd->list = eina_list_append(wd->list, it);\r
+\r
+ _resize_gallery(obj);\r
+\r
+ return it;\r
+}\r
+\r
+EAPI Elm_Gallery_Item *elm_gallery_item_prepend(Evas_Object *obj, const char *photo_file)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *it;\r
+ if (!obj || !(wd = evas_object_smart_data_get(obj))) {\r
+ errno = EINVAL;\r
+ return NULL;\r
+ }\r
+\r
+ it = (Elm_Gallery_Item *)calloc(1, sizeof(Elm_Gallery_Item));\r
+ it->path = eina_stringshare_add(photo_file);\r
+ it->parent = obj;\r
+ it->obj = NULL; \r
+ it->on_show = EINA_FALSE;\r
+ \r
+ wd->list = eina_list_prepend(wd->list, it);\r
+ \r
+ _resize_gallery(obj);\r
+ \r
+ return it;\r
+}\r
+\r
+EAPI void elm_gallery_item_del(Elm_Gallery_Item *it)\r
+{\r
+ Widget_Data *wd;\r
+\r
+ if (!it || !(wd = evas_object_smart_data_get(it->parent))) {\r
+ errno = EINVAL;\r
+ return;\r
+ }\r
+\r
+ wd->list = eina_list_remove(wd->list, it);\r
+\r
+ _resize_gallery(wd->obj);\r
+}\r
+\r
+EAPI const char *elm_gallery_item_file_get(Elm_Gallery_Item *it)\r
+{\r
+ if (!it) {\r
+ errno = EINVAL;\r
+ return NULL;\r
+ }\r
+ \r
+ return it->path;\r
+}\r
+\r
+EAPI void elm_gallery_item_show(Elm_Gallery_Item *it)\r
+{\r
+ Widget_Data *wd;\r
+ Elm_Gallery_Item *_it;\r
+ Eina_List *l;\r
+ int index = 0;\r
+ \r
+ if (!it || !it->parent|| (!(wd = evas_object_smart_data_get(it->parent)))) {\r
+ errno = EINVAL;\r
+ return;\r
+ } \r
+ \r
+ EINA_LIST_FOREACH(wd->list, l, _it) \r
+ {\r
+ if (_it == it) {\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ \r
+ wd->init_num = index;\r
+\r
+ _update_gallery(it->parent);\r
+\r
+ if(wd->eidler){\r
+ ecore_idler_del(wd->eidler);\r
+ wd->eidler = NULL;\r
+ }\r
+ \r
+ wd->eidler = ecore_idler_add(_gallery_idle_handler_cb, wd); \r
+}\r
+\r
+EAPI Eina_List *elm_gallery_item_list_get(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return NULL;\r
+ \r
+ return wd->list;\r
+}\r
+\r
+EAPI void elm_gallery_set_type(Evas_Object *obj,int type)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return NULL;\r
+\r
+ wd->item_type = type;\r
+ \r
+ _gallery_set_all_status(obj,type);\r
+}\r
+\r
+EAPI void elm_gallery_set_max_count(Evas_Object *obj,int max_value)\r
+{\r
+ Widget_Data *wd;\r
+ wd = evas_object_smart_data_get(obj);\r
+ if (!wd) return NULL;\r
+\r
+ wd->item_count = max_value;\r
+}\r
+\r
+\r
--- /dev/null
+#include <Elementary.h>\r
+#include "elm_priv.h"\r
+\r
+#define TRUE 1\r
+#define FALSE 0\r
+\r
+//#define LAYOUT_x 240\r
+//#define LAYOUT_y 400\r
+#define LAYOUT_x 480\r
+#define LAYOUT_y 800\r
+\r
+typedef struct _Widget_Data Widget_Data;\r
+\r
+struct _Widget_Data\r
+{\r
+ Evas_Object * viewflipper;\r
+ Evas_Object * left_lay;\r
+ Evas_Object * middle_lay;\r
+ Evas_Object * right_lay;\r
+\r
+ int is_left_show;\r
+ int is_middle_show;\r
+ int is_right_show; \r
+\r
+ int is_can_move;\r
+\r
+ int is_auto_start;\r
+ int is_show_button;\r
+\r
+ int request_direction;\r
+ int request_pos;\r
+ int time_sec;\r
+ Ecore_Timer * auto_timer;\r
+\r
+ int temp_x_down;\r
+ int temp_x_up;\r
+ \r
+ Eina_List *view_list;\r
+ int selected_view;\r
+ int all_count;\r
+};\r
+\r
+Widget_Data * this_pointer=NULL;\r
+\r
+static const char *widtype = NULL;\r
+\r
+static void _set_this(Widget_Data * in_this_pointer);\r
+static void _del_hook(Evas_Object *obj);\r
+static void _theme_hook(Evas_Object *obj);\r
+static void _sizing_eval(Evas_Object *obj);\r
+static int _is_can_move();\r
+static int _is_first_view();\r
+static int _is_last_view();\r
+static void _mouse_flip_cb(int mouse_direction);\r
+static void _mouse_up(void *data, Evas *e, Evas_Object *o, void *event_info);\r
+static void _mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info);\r
+static void _complete_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);\r
+static void _left_button_click(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);\r
+static void _right_button_click(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);\r
+static int _flipping_timer_cb(void *data);\r
+static void _set_layout_each_view(Evas_Object * left,Evas_Object * middle,Evas_Object *right);\r
+static int _setView();\r
+static void _setup_button_show_left_right();\r
+\r
+\r
+\r
+ \r
+static void\r
+_set_this(Widget_Data * in_this_pointer)\r
+{\r
+ this_pointer=in_this_pointer;\r
+}\r
+\r
+Widget_Data * _get_this()\r
+{\r
+ return this_pointer;\r
+}\r
+static void\r
+_del_pre_hook(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd = elm_widget_data_get(obj);\r
+ elm_viewflipper_stopAutoFlipping();\r
+ _set_layout_each_view(NULL,NULL,NULL);\r
+ if(wd->viewflipper!=NULL)\r
+ {\r
+ evas_object_del(wd->viewflipper);\r
+ }\r
+ eina_list_free(wd->view_list);\r
+ wd->view_list=NULL;\r
+}\r
+static void\r
+_del_hook(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd = elm_widget_data_get(obj); \r
+\r
+ if (!wd) return;\r
+ free(wd);\r
+}\r
+\r
+static void\r
+_theme_hook(Evas_Object *obj)\r
+{\r
+ printf("_theme_hook \n");\r
+ \r
+ Widget_Data *wd = elm_widget_data_get(obj);\r
+ if (!wd) return;\r
+\r
+ _sizing_eval(obj);\r
+}\r
+static void\r
+_sizing_eval(Evas_Object *obj)\r
+{\r
+ Widget_Data *wd = elm_widget_data_get(obj);\r
+ Evas_Coord minw = -1, minh = -1;\r
+\r
+ edje_object_size_min_calc(wd->viewflipper, &minw, &minh);\r
+ evas_object_size_hint_min_set(obj, minw, minh);\r
+ evas_object_size_hint_max_set(obj, -1, -1);\r
+ evas_object_resize(wd->viewflipper, minw, minh); \r
+\r
+ printf("_sizing_eval %d %d \n",minw,minh);\r
+\r
+ Eina_List *l;\r
+ Evas_Object * it;\r
+\r
+ EINA_LIST_FOREACH(_get_this()->view_list, l, it)\r
+ {\r
+ evas_object_resize(it, minw, minh); \r
+ } \r
+} \r
+\r
+static int\r
+_is_can_move()\r
+{\r
+ Widget_Data *wd = _get_this();\r
+ return wd->is_can_move;\r
+}\r
+\r
+static int\r
+_is_first_view()\r
+{\r
+ if(elm_viewflipper_getCountChild()==0)\r
+ return FALSE;\r
+\r
+ if(_get_this()->selected_view==0)\r
+ return TRUE;\r
+ return FALSE;\r
+}\r
+\r
+static int\r
+_is_last_view()\r
+{\r
+ if(elm_viewflipper_getCountChild()==0)\r
+ return FALSE;\r
+\r
+ Widget_Data *wd = _get_this();\r
+ if(wd->selected_view==(elm_viewflipper_getCountChild()-1))\r
+ return TRUE;\r
+ return FALSE;\r
+}\r
+\r
+static void\r
+_mouse_flip_cb(int mouse_direction)\r
+{\r
+ if(mouse_direction == DIR_RIGHT)\r
+ elm_viewflipper_setNextView();\r
+ else elm_viewflipper_setPreviousView();\r
+}\r
+\r
+static void\r
+_mouse_up(void *data, Evas *e, Evas_Object *o, void *event_info)\r
+{\r
+ Evas_Event_Mouse_Up *ev = event_info;\r
+ _get_this()->temp_x_up = ev->canvas.x;\r
+ printf("mouse up start\n");\r
+\r
+ int temp_value= _get_this()->temp_x_up - _get_this()->temp_x_down;\r
+ if(temp_value <0)\r
+ temp_value = temp_value * -1;\r
+\r
+ if(temp_value < FLIP_RANGE_X)\r
+ return;\r
+ \r
+ if(_get_this()->temp_x_up>_get_this()->temp_x_down)\r
+ {\r
+ printf("left flip\n");\r
+ _mouse_flip_cb(DIR_LEFT);\r
+ }\r
+ else\r
+ {\r
+ printf("right flip\n");\r
+ _mouse_flip_cb(DIR_RIGHT);\r
+ }\r
+ printf("mouse up end\n");\r
+}\r
+\r
+static void\r
+_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)\r
+{\r
+ Evas_Event_Mouse_Down *ev = event_info;\r
+ _get_this()->temp_x_down = ev->canvas.x; \r
+ printf("mouse down\n");\r
+}\r
+\r
+static void\r
+_complete_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)\r
+{\r
+ _get_this()->is_can_move=TRUE;\r
+ _setView();\r
+}\r
+static void\r
+_left_button_click(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)\r
+{\r
+ elm_viewflipper_setPreviousView();\r
+ printf("_left_button_click\n");\r
+}\r
+static void\r
+_right_button_click(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)\r
+{\r
+ elm_viewflipper_setNextView();\r
+ printf("_right_button_click\n");\r
+}\r
+\r
+static int\r
+_flipping_timer_cb(void *data)\r
+{\r
+ if(elm_viewflipper_isAutoStart()==FALSE)\r
+ return 0;\r
+\r
+ if(_get_this()->request_pos!=EACH_LAST && _get_this()->selected_view ==_get_this()->request_pos)\r
+ {\r
+ printf("_flipping_timer_cb stop using each_last");\r
+ elm_viewflipper_stopAutoFlipping();\r
+ return 0;\r
+ }\r
+\r
+ if(_get_this()->request_direction==DIR_RIGHT)\r
+ elm_viewflipper_setNextView();\r
+ else elm_viewflipper_setPreviousView();\r
+ \r
+ if(_is_last_view()==TRUE)\r
+ { \r
+ printf("_flipping_timer_cb stop");\r
+ elm_viewflipper_stopAutoFlipping();\r
+ return 0;\r
+ } \r
+ printf("_flipping_timer_cb ing");\r
+}\r
+\r
+static void\r
+_set_layout_each_view(Evas_Object * left,Evas_Object * middle,Evas_Object *right)\r
+{\r
+ Widget_Data *wd = _get_this();\r
+ edje_object_signal_emit(_get_this()->viewflipper, "change_default_pos", "elm");\r
+ \r
+ if(wd->left_lay!=NULL)\r
+ {\r
+ edje_object_part_unswallow(wd->viewflipper, wd->left_lay);\r
+ evas_object_hide(wd->left_lay);\r
+ wd->left_lay=NULL; \r
+ } \r
+ if(wd->middle_lay!=NULL)\r
+ {\r
+ edje_object_part_unswallow(wd->viewflipper, wd->middle_lay);\r
+ evas_object_hide(wd->middle_lay);\r
+ wd->middle_lay=NULL; \r
+ }\r
+ if(wd->right_lay!=NULL)\r
+ {\r
+ edje_object_part_unswallow(wd->viewflipper, wd->right_lay); \r
+ evas_object_hide(wd->right_lay);\r
+ wd->right_lay=NULL;\r
+ }\r
+\r
+ if(left==NULL)\r
+ {\r
+ wd->is_left_show = FALSE; \r
+ }\r
+ else \r
+ {\r
+ wd->left_lay=left; \r
+ edje_object_part_swallow(wd->viewflipper, "first_view",left);\r
+ wd->is_left_show = TRUE; \r
+\r
+ printf("_set_layout_each_view 1\n"); \r
+ }\r
+\r
+ if(middle==NULL)\r
+ {\r
+ _get_this()->is_middle_show=FALSE;\r
+ }\r
+ else\r
+ {\r
+ wd->middle_lay=middle; \r
+ edje_object_part_swallow(wd->viewflipper, "second_view",middle );\r
+ _get_this()->is_left_show = TRUE;\r
+ \r
+ printf("_set_layout_each_view 2\n"); \r
+ }\r
+\r
+ if(right==NULL)\r
+ { \r
+ _get_this()->is_right_show=FALSE;\r
+ }\r
+ else\r
+ {\r
+ wd->right_lay=right; \r
+ edje_object_part_swallow(wd->viewflipper, "third_view", right); \r
+ _get_this()->is_right_show = TRUE;\r
+\r
+ printf("_set_layout_each_view 3\n"); \r
+ }\r
+}\r
+static int \r
+_setView()\r
+{\r
+ Widget_Data *wd = _get_this();\r
+ if(elm_viewflipper_getCountChild()==0)\r
+ return ERROR_3;\r
+ if(_is_first_view()==TRUE)\r
+ {\r
+ if(elm_viewflipper_getCountChild()==1)\r
+ {\r
+ _set_layout_each_view(NULL, elm_viewflipper_getChildAt(0),NULL);\r
+ printf("_setView 1\n");\r
+ }\r
+ else//than 1\r
+ {\r
+ _set_layout_each_view(NULL, elm_viewflipper_getChildAt(0), elm_viewflipper_getChildAt(1)); \r
+ printf("_setView 2\n");\r
+ } \r
+ }\r
+ else if(_is_last_view()==TRUE)\r
+ {\r
+ if(elm_viewflipper_getCountChild()==1)\r
+ {\r
+ _set_layout_each_view(NULL, elm_viewflipper_getChildAt(wd->selected_view),NULL);\r
+ printf("_setView 3\n");\r
+ }\r
+ else//than 1\r
+ {\r
+ _set_layout_each_view( elm_viewflipper_getChildAt((wd->selected_view)-1), elm_viewflipper_getChildAt(wd->selected_view),NULL);\r
+ printf("_setView 4\n");\r
+ } \r
+ }\r
+ else\r
+ {\r
+ _set_layout_each_view( elm_viewflipper_getChildAt((wd->selected_view)-1), elm_viewflipper_getChildAt(wd->selected_view), elm_viewflipper_getChildAt((wd->selected_view)+1));\r
+ printf("_setView 5\n");\r
+ }\r
+ _setup_button_show_left_right(); \r
+} \r
+\r
+static void \r
+_setup_button_show_left_right()\r
+{\r
+ if(_get_this()->is_show_button==TRUE)\r
+ {\r
+ if(elm_viewflipper_getCountChild()==0)\r
+ return;\r
+ else if(_is_first_view()==TRUE)\r
+ {\r
+ edje_object_signal_emit(_get_this()->viewflipper, "right_button_show", "elm");\r
+ edje_object_signal_emit(_get_this()->viewflipper, "left_button_hide", "elm");\r
+ }\r
+ else if(_is_last_view()==TRUE)\r
+ {\r
+ edje_object_signal_emit(_get_this()->viewflipper, "left_button_show", "elm");\r
+ edje_object_signal_emit(_get_this()->viewflipper, "right_button_hide", "elm");\r
+ }\r
+ else \r
+ { \r
+ edje_object_signal_emit(_get_this()->viewflipper, "button_show", "elm");\r
+ }\r
+ }\r
+}\r
+\r
+\r
+EAPI Evas_Object * \r
+elm_viewflipper_add(Evas_Object * parent)\r
+{\r
+ Evas_Object *obj;\r
+ Evas *e;\r
+ Widget_Data *wd;\r
+ Evas_Coord w, h;\r
+\r
+ wd = ELM_NEW(Widget_Data);\r
+ e = evas_object_evas_get(parent);\r
+ obj = elm_widget_add(e);\r
+ ELM_SET_WIDTYPE(widtype, "viewflipper");\r
+ elm_widget_type_set(obj, "viewflipper");\r
+ elm_widget_sub_object_add(parent, obj);\r
+ elm_widget_data_set(obj, wd);\r
+ elm_widget_del_pre_hook_set(obj, _del_pre_hook);\r
+ elm_widget_del_hook_set(obj, _del_hook);\r
+ elm_widget_theme_hook_set(obj, _theme_hook);\r
+ \r
+ wd->viewflipper = edje_object_add(evas_object_evas_get(obj));\r
+ _elm_theme_set(wd->viewflipper, "viewflipper", "base", "default");\r
+\r
+\r
+ evas_object_resize(wd->viewflipper, LAYOUT_x, LAYOUT_y);\r
+ evas_object_move(wd->viewflipper,0,0);\r
+ evas_object_show(wd->viewflipper);\r
+ \r
+ evas_object_event_callback_add(wd->viewflipper, EVAS_CALLBACK_MOUSE_DOWN,\r
+ _mouse_down, obj);\r
+ evas_object_event_callback_add(wd->viewflipper, EVAS_CALLBACK_MOUSE_UP,\r
+ _mouse_up, obj);\r
+ \r
+\r
+ edje_object_signal_callback_add(wd->viewflipper, "elm,action,moving", "elm",\r
+ _complete_move, obj);\r
+ edje_object_signal_callback_add(wd->viewflipper, "clicked", "btn_left",\r
+ _left_button_click, obj);\r
+ edje_object_signal_callback_add(wd->viewflipper, "clicked", "btn_right",\r
+ _right_button_click, obj);\r
+\r
+ \r
+ _set_this(wd);\r
+ _get_this()->is_can_move=TRUE;\r
+\r
+ printf("create_viewflipper\n");\r
+ return obj;\r
+}\r
+\r
+\r
+EAPI int \r
+elm_viewflipper_isFlipbutton()\r
+{\r
+ return _get_this()->is_show_button;\r
+}\r
+EAPI \r
+int elm_viewflipper_isAutoStart()\r
+{\r
+ return _get_this()->is_auto_start;\r
+}\r
+EAPI int \r
+elm_viewflipper_isValidPos(int pos)\r
+{\r
+ if(elm_viewflipper_getCountChild()==0)\r
+ return FALSE;\r
+\r
+ if(pos<0 || pos >=elm_viewflipper_getCountChild())\r
+ return FALSE;\r
+\r
+ return TRUE; \r
+}\r
+EAPI int \r
+elm_viewflipper_addChild(Evas_Object * child_layout)\r
+{\r
+ if(_get_this()==NULL)\r
+ return ERROR_2;\r
+ \r
+ if(strncmp(elm_widget_style_get(child_layout),"layout",6)==0)\r
+ return ERROR_1;\r
+ \r
+ _get_this()->view_list = eina_list_append(_get_this()->view_list, child_layout);\r
+ printf("addChild\n");\r
+ return SUCCESS;\r
+}\r
+\r
+EAPI int \r
+elm_viewflipper_removeChild(Evas_Object * child_layout)\r
+{\r
+ if(_get_this()==NULL)\r
+ return ERROR_2;\r
+ \r
+ if(strncmp(elm_widget_style_get(child_layout),"layout",6)==0)\r
+ return ERROR_1;\r
+ \r
+ \r
+ Eina_List *l;\r
+ Evas_Object * it;\r
+\r
+ EINA_LIST_FOREACH(_get_this()->view_list, l, it)\r
+ {\r
+ if (it == child_layout)\r
+ { \r
+ evas_object_hide(child_layout);\r
+ _get_this()->view_list = eina_list_remove_list(_get_this()->view_list, l);\r
+ _setView();\r
+ return SUCCESS;\r
+ }\r
+ } \r
+ return ERROR_0; \r
+}\r
+EAPI int \r
+elm_viewflipper_removeChildAt(int pos)\r
+{\r
+ if(_get_this()==NULL)\r
+ return ERROR_2;\r
+\r
+ if(elm_viewflipper_isValidPos(pos)==FALSE)\r
+ return ERROR_4;\r
+ \r
+ int i=0;\r
+ Eina_List *l;_set_layout_each_view(NULL, elm_viewflipper_getChildAt(0), elm_viewflipper_getChildAt(1)); \r
+ Evas_Object * it;\r
+\r
+ EINA_LIST_FOREACH(_get_this()->view_list, l, it)\r
+ {\r
+ if (i == pos)\r
+ {\r
+ Evas_Object * child_layout = elm_viewflipper_getChildAt(pos);\r
+ if(child_layout!=NULL)//defense code\r
+ evas_object_hide(child_layout);\r
+ _get_this()->view_list = eina_list_remove_list(_get_this()->view_list, l);\r
+ _setView(); \r
+ return SUCCESS;\r
+ }\r
+ i++;\r
+ } \r
+ return ERROR_0; \r
+}\r
+\r
+EAPI int \r
+elm_viewflipper_getPositionChild(Evas_Object * child_layout)\r
+{\r
+ if(_get_this()==NULL)\r
+ return ERROR_2;\r
+ \r
+ if(strncmp(elm_widget_style_get(child_layout),"layout",6)==0)\r
+ return ERROR_1;\r
+\r
+ int i=0;\r
+ Eina_List *l;\r
+ Evas_Object * it;\r
+\r
+ EINA_LIST_FOREACH(_get_this()->view_list, l, it)\r
+ {\r
+ if (it == child_layout)\r
+ {\r
+ return i;\r
+ }\r
+ i++;\r
+ } \r
+ return ERROR_0; \r
+}\r
+EAPI Evas_Object * \r
+elm_viewflipper_getChildAt(int pos)//start 0\r
+{\r
+ if(_get_this()==NULL)\r
+ return NULL;\r
+\r
+ if(elm_viewflipper_isValidPos(pos)==FALSE)\r
+ return NULL;\r
+\r
+ int i=0; \r
+ Eina_List *l;\r
+ Evas_Object *it;\r
+ EINA_LIST_FOREACH(_get_this()->view_list, l, it)\r
+ {\r
+ if (i== pos)\r
+ {\r
+ return it;\r
+ }\r
+ i++;\r
+ } \r
+ return NULL;\r
+}\r
+EAPI int \r
+elm_viewflipper_getCountChild()\r
+{\r
+ if(_get_this()==NULL)\r
+ return ERROR_2;\r
+ \r
+ return eina_list_count(_get_this()->view_list);\r
+}\r
+\r
+EAPI int \r
+elm_viewflipper_setDisplayedChild(int pos)\r
+{\r
+ if(elm_viewflipper_isValidPos(pos)==FALSE)\r
+ return ERROR_4;\r
+\r
+ if(_get_this()->selected_view==pos)\r
+ return ERROR_5;\r
+ \r
+ elm_viewflipper_stopAutoFlipping();\r
+\r
+ if(_get_this()->selected_view>pos)\r
+ {\r
+ elm_viewflipper_startAutoFlippingWithOption(DIR_LEFT,pos);\r
+ }\r
+ else\r
+ {\r
+ elm_viewflipper_startAutoFlippingWithOption(DIR_RIGHT,pos);\r
+ }\r
+ \r
+}\r
+\r
+EAPI int \r
+elm_viewflipper_setNowView()\r
+{\r
+ return _setView(); \r
+}\r
+EAPI int \r
+elm_viewflipper_setNextView()\r
+{\r
+ if(_is_last_view()==TRUE)\r
+ return ERROR_5;\r
+\r
+ if(_get_this()->is_can_move==FALSE)\r
+ return ERROR_6;\r
+\r
+ _get_this()->selected_view = _get_this()->selected_view+1;\r
+ _get_this()->is_can_move=FALSE;\r
+ \r
+ edje_object_signal_emit(_get_this()->viewflipper, "moving_left_pos", "elm");\r
+ printf("elm_viewflipper_setNextView\n");\r
+}\r
+EAPI int \r
+elm_viewflipper_setPreviousView()\r
+{\r
+ if(_is_first_view()==TRUE)\r
+ return ERROR_5;\r
+ \r
+ if(_get_this()->is_can_move==FALSE)\r
+ return ERROR_6;\r
+\r
+ _get_this()->selected_view = _get_this()->selected_view-1;\r
+ _get_this()->is_can_move=FALSE;\r
+ \r
+ edje_object_signal_emit(_get_this()->viewflipper, "moving_right_pos", "elm"); \r
+ printf("elm_viewflipper_setPreviousView\n");\r
+}\r
+\r
+EAPI int \r
+elm_viewflipper_setFlipInterval(int milliseconds) \r
+{\r
+ if(milliseconds<=0)\r
+ return ERROR_7;\r
+\r
+ _get_this()->time_sec=milliseconds;\r
+}\r
+\r
+\r
+\r
+EAPI int \r
+elm_viewflipper_setFlipbutton(int showbutton)\r
+{\r
+ if(showbutton==TRUE)\r
+ {\r
+ _get_this()->is_show_button=TRUE;\r
+ _setup_button_show_left_right();\r
+ }\r
+ else\r
+ {\r
+ _get_this()->is_show_button=FALSE;\r
+ edje_object_signal_emit(_get_this()->viewflipper, "button_hide", "elm"); \r
+ }\r
+}\r
+\r
+\r
+EAPI int \r
+elm_viewflipper_startAutoFlippingWithOption(int drection,int pos)\r
+{ \r
+ if(_get_this()->time_sec==0)\r
+ return ERROR_7;\r
+\r
+ if(elm_viewflipper_isValidPos(pos)==FALSE)\r
+ return ERROR_4;\r
+ \r
+ if(elm_viewflipper_isAutoStart()==TRUE)\r
+ elm_viewflipper_stopAutoFlipping();\r
+\r
+ _get_this()->request_direction= drection;\r
+ _get_this()->request_pos = pos;\r
+\r
+ _get_this()->auto_timer= ecore_timer_add(_get_this()->time_sec , _flipping_timer_cb, NULL);\r
+ _get_this()->is_auto_start=TRUE;\r
+ printf("elm_viewflipper_startAutoFlippingWithOption\n");\r
+}\r
+EAPI int \r
+elm_viewflipper_startAutoFlipping() \r
+{\r
+ if(_get_this()->time_sec==0)\r
+ return ERROR_7;\r
+ \r
+ if(elm_viewflipper_isAutoStart()==TRUE)\r
+ elm_viewflipper_stopAutoFlipping();\r
+\r
+ _get_this()->request_direction= DIR_RIGHT;\r
+ _get_this()->request_pos = EACH_LAST;\r
+\r
+ _get_this()->auto_timer= ecore_timer_add(_get_this()->time_sec , _flipping_timer_cb, NULL);\r
+ _get_this()->is_auto_start=TRUE;\r
+ printf("elm_viewflipper_startAutoFlipping\n");\r
+}\r
+EAPI int \r
+elm_viewflipper_stopAutoFlipping()\r
+{ \r
+ if(elm_viewflipper_isAutoStart()==FALSE)\r
+ return ERROR_5;\r
+\r
+ if(_get_this()->auto_timer)//defense code\r
+ ecore_timer_del(_get_this()->auto_timer);\r
+ _get_this()->auto_timer=NULL;\r
+ _get_this()->is_auto_start=FALSE; \r
+ _get_this()->request_direction= 0;\r
+ _get_this()->request_pos = 0; \r
+ printf("elm_viewflipper_stopAutoFlipping\n");\r
+}\r
+\r
+\r