[tab] Added dim hide.
[framework/uifw/elementary.git] / src / lib / elm_tab.c
1 /*\r
2  * SLP\r
3  * Copyright (c) 2009 Samsung Electronics, Inc.\r
4  * All rights reserved.\r
5  *\r
6  * This software is a confidential and proprietary information\r
7  * of Samsung Electronics, Inc. ("Confidential Information").  You\r
8  * shall not disclose such Confidential Information and shall use\r
9  * it only in accordance with the terms of the license agreement\r
10  * you entered into with Samsung Electronics.\r
11  */\r
12 \r
13 \r
14 /**\r
15  * @addtogroup Tab Tab\r
16  * @ingroup Elementary\r
17  *\r
18  * This is a Tab. It can contain label and icon objects.\r
19  * You can change the location of items.\r
20  */\r
21 \r
22 \r
23 #include <string.h>\r
24 #include <stdbool.h>\r
25 #include <math.h>\r
26 \r
27 #include <Elementary.h>\r
28 #include "elm_priv.h"\r
29 \r
30 #ifndef EAPI\r
31 #define EAPI __attribute__ ((visibility("default")))\r
32 #endif\r
33 \r
34 #define MAX_ITEM 8\r
35 #define BASIC_SLOT_NUMBER 3\r
36 #define KEYDOWN_INTERVAL        0.6\r
37 \r
38 #define PORTRAIT                0\r
39 #define LANDSCAPE               1\r
40 #define LANDSCAPE_GAP   10\r
41 \r
42 #define MAX_ARGS        512\r
43 \r
44 #define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)\r
45 #define ELM_MAX(v1, v2)    (((v1) > (v2)) ? (v1) : (v2))\r
46 \r
47 \r
48 // internal data structure of tab object\r
49 typedef struct _Widget_Data Widget_Data;\r
50 \r
51 struct _Widget_Data\r
52 {\r
53         Evas *evas;\r
54         Evas_Object *object;\r
55         Evas_Object *parent;\r
56         Evas_Object *edje;\r
57         Evas_Object *moving_obj;\r
58         Evas_Object *box[MAX_ITEM];\r
59         Evas_Object *ebx;\r
60 \r
61         Evas_Coord x, y, w, h;\r
62 \r
63         int cur_first_slot;\r
64         int mode;\r
65         int view_slot_num;\r
66         int tab_down_x;\r
67         int tab_down_y;\r
68         int num;\r
69         int edit_from;\r
70         int edit_to;\r
71         double time;\r
72 \r
73         Eina_List *items;\r
74 \r
75         Ecore_Timer *timer;\r
76         Eina_Bool flag;\r
77         Eina_Bool edit_disable;\r
78 \r
79         Ecore_Event_Handler *move_event;\r
80         Ecore_Event_Handler *up_event;\r
81 };\r
82 \r
83 struct _Elm_Tab_Item\r
84   {\r
85         Evas_Object *obj;\r
86         Evas_Object *base;\r
87         Evas_Object *icon;\r
88         const char *label;\r
89         int slot;\r
90         int badge;\r
91         void (*func)(void *data, Evas_Object *obj, void *event_info);\r
92         const void *data;\r
93         Eina_Bool selected : 1;\r
94   };\r
95 \r
96 static void _del_hook(Evas_Object *obj);\r
97 static void _theme_hook(Evas_Object *obj);\r
98 static void _sizing_eval(Evas_Object *obj);\r
99 static void _sub_del(void *data, Evas_Object *obj, void *event_info);\r
100 \r
101 static void _tab_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info);\r
102 static void _tab_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);\r
103 static void _tab_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info);\r
104 static void _tab_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);\r
105 \r
106 static void light_check(Widget_Data *wd);\r
107 static void select_check(Widget_Data *wd);\r
108 static void edit_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);\r
109 static int _selected_box(Elm_Tab_Item *it);\r
110 static int _move_obj_to_left(Widget_Data *wd);\r
111 static int _move_obj_to_right(Widget_Data *wd);\r
112 static void item_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);\r
113 static void press_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);\r
114 static void press_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);\r
115 static void press_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);\r
116 void tab_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source);\r
117 \r
118 static void\r
119 _del_hook(Evas_Object *obj)\r
120 {\r
121         Widget_Data *wd = elm_widget_data_get(obj);\r
122         Elm_Tab_Item *item;\r
123 \r
124         if (!wd) return;\r
125 \r
126         if (wd->edje) {\r
127                 evas_object_smart_member_del(wd->edje);\r
128                 evas_object_del(wd->edje);\r
129                 wd->edje = NULL;\r
130         }\r
131 \r
132         EINA_LIST_FREE(wd->items, item){\r
133                 eina_stringshare_del(item->label);\r
134                 if (item->icon) evas_object_del(item->icon);\r
135                 if(item->base) evas_object_del(item->base);\r
136                 free(item);\r
137         }\r
138 \r
139         if (wd->ebx) {\r
140                 evas_object_smart_member_del(wd->ebx);\r
141                 evas_object_del(wd->ebx);\r
142                 wd->ebx = NULL;\r
143         }\r
144 \r
145         free(wd);\r
146 }\r
147 \r
148 static void\r
149 _theme_hook(Evas_Object *obj)\r
150 {\r
151         const Eina_List *l;\r
152         Elm_Tab_Item *item;\r
153         char buf[MAX_ARGS];\r
154         Widget_Data *wd = elm_widget_data_get(obj);\r
155         if (!wd) return;\r
156 \r
157         if(wd->mode == PORTRAIT){\r
158                 snprintf(buf, sizeof(buf), "bg_portrait_%d", wd->view_slot_num);\r
159         }else if(wd->mode == LANDSCAPE){\r
160                 snprintf(buf, sizeof(buf), "bg_landscape_%d", wd->view_slot_num);\r
161         }\r
162         _elm_theme_object_set(obj, wd->edje, "tab", buf, elm_widget_style_get(obj));\r
163 \r
164         EINA_LIST_FOREACH(wd->items, l, item){\r
165                 _elm_theme_object_set(obj, item->base, "tab", "item", elm_widget_style_get(item->obj));\r
166                 if (item->label){\r
167                         edje_object_part_text_set(item->base, "elm.text", item->label);\r
168                 }\r
169 \r
170                 if (item->icon){\r
171         //              int ms = 0;\r
172 \r
173         //              ms = ((double)wd->icon_size * _elm_config->scale);\r
174                         evas_object_size_hint_min_set(item->icon, 24, 24);\r
175                         evas_object_size_hint_max_set(item->icon, 40, 40);\r
176                         edje_object_part_swallow(item->base, "elm.swallow.icon", item->icon);\r
177                         evas_object_show(item->icon);\r
178                         elm_widget_sub_object_add(obj, item->icon);\r
179                 }\r
180 \r
181                 if (item->label && item->icon){\r
182                         edje_object_signal_emit(item->base, "elm,state,icon_text", "elm");\r
183                 }\r
184         }\r
185         select_check(wd);\r
186 }\r
187 \r
188 static void\r
189 _sub_del(void *data, Evas_Object *obj, void *event_info)\r
190 {\r
191         Widget_Data *wd = elm_widget_data_get(obj);\r
192         //Evas_Object *sub = event_info;\r
193         if (!wd) return;\r
194         /*\r
195            if (sub == wd->icon)\r
196            {\r
197            edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");\r
198            evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,\r
199            _changed_size_hints, obj);\r
200            wd->icon = NULL;\r
201            edje_object_message_signal_process(wd->btn);\r
202            _sizing_eval(obj);\r
203            }\r
204            */\r
205 }\r
206 \r
207 static void\r
208 _sizing_eval(Evas_Object *obj)\r
209 {\r
210         Widget_Data *wd = elm_widget_data_get(obj);\r
211 \r
212         if (!wd) return;\r
213 \r
214         DBG("[%s]\n", __func__);\r
215 \r
216         _tab_object_move(obj, NULL, obj, NULL);\r
217         _tab_object_resize(obj, NULL, obj, NULL);\r
218 }\r
219 \r
220 /**\r
221  * Add a new tab object\r
222  *\r
223  * @param parent The parent object\r
224  * @return The new object or NULL if it cannot be created\r
225  *\r
226  * @ingroup Tab\r
227  */\r
228 EAPI Evas_Object *elm_tab_add(Evas_Object *parent) {\r
229         Evas_Object *obj = NULL;\r
230         Widget_Data *wd = NULL;\r
231         Evas_Coord x, y, w, h;\r
232         char buf[MAX_ARGS];\r
233 \r
234         wd = ELM_NEW(Widget_Data);\r
235         wd->evas = evas_object_evas_get(parent);\r
236         if (wd->evas == NULL) return NULL;\r
237         obj = elm_widget_add(wd->evas);\r
238         if(obj == NULL) return NULL;\r
239         elm_widget_type_set(obj, "tab");\r
240         elm_widget_sub_object_add(parent, obj);\r
241         elm_widget_data_set(obj, wd);\r
242         elm_widget_del_hook_set(obj, _del_hook);\r
243         elm_widget_theme_hook_set(obj, _theme_hook);\r
244 \r
245         // initialization\r
246         wd->parent = parent;\r
247         evas_object_geometry_get(parent, &x, &y, &w, &h);\r
248         wd->object = obj;\r
249         wd->x = x;\r
250         wd->y = y;\r
251         wd->w = w;\r
252         wd->h = h;\r
253         wd->num = 0;\r
254         wd->edit_disable = EINA_FALSE;\r
255         wd->cur_first_slot = 1;\r
256         //wd->view_slot_num = BASIC_SLOT_NUMBER;\r
257         wd->view_slot_num = 3;\r
258 \r
259         // initialization\r
260         // edit box\r
261         wd->ebx = edje_object_add(wd->evas);\r
262         if(wd->ebx == NULL)\r
263                 return NULL;\r
264         _elm_theme_object_set(obj, wd->ebx, "tab", "dim", "default");\r
265         evas_object_resize(wd->ebx, wd->w, wd->h);\r
266         evas_object_move(wd->ebx, wd->x, wd->y);\r
267         evas_object_hide(wd->ebx);\r
268         evas_object_event_callback_add(wd->ebx, EVAS_CALLBACK_MOUSE_UP, edit_up_cb, wd);\r
269 \r
270         // initialization\r
271         /* load background edj */\r
272         wd->edje = edje_object_add(wd->evas);\r
273         snprintf(buf, sizeof(buf), "bg_portrait_%d", wd->view_slot_num);\r
274         _elm_theme_object_set(obj, wd->edje, "tab", buf, "default");\r
275         if(wd->edje == NULL) {\r
276                 printf("Cannot load bg edj\n");\r
277                 return NULL;\r
278         }\r
279         // initialization\r
280         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_DOWN,  press_down_cb, wd);\r
281         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_UP,  press_up_cb, wd);\r
282         evas_object_show(wd->edje);\r
283 \r
284         // initialization\r
285         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE, _tab_object_resize, obj);\r
286         evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _tab_object_move, obj);\r
287         evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _tab_object_show, obj);\r
288         evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _tab_object_hide, obj);\r
289 \r
290         // initialization\r
291         //FIXME\r
292         //      evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);\r
293 \r
294         evas_object_smart_member_add(wd->ebx, obj);\r
295         elm_widget_resize_object_set(obj, wd->edje);\r
296 \r
297         // initialization\r
298         _sizing_eval(obj);\r
299 \r
300         return obj;\r
301 }\r
302 \r
303 \r
304 /**\r
305  * Set the mode of tab object\r
306  *\r
307  * @param obj The tab object\r
308  * @param mode The mode of tab\r
309  *\r
310  * @ingroup Tab\r
311  */\r
312 EAPI void elm_tab_set(Evas_Object *obj, int mode)\r
313 {\r
314         int i = 1;\r
315         char buf[MAX_ARGS];\r
316         Widget_Data *wd;\r
317         const Eina_List *l;\r
318         Elm_Tab_Item *item;\r
319 \r
320         if(obj == NULL) {\r
321                 printf("Invalid argument: tab object is NULL\n");\r
322                 return;\r
323         }\r
324         wd = elm_widget_data_get(obj);\r
325         if(wd == NULL) {\r
326                 printf("Cannot get smart data\n");\r
327                 return;\r
328         }\r
329 \r
330         EINA_LIST_FOREACH(wd->items, l, item){\r
331                 edje_object_part_unswallow(wd->edje, item->base);\r
332         }\r
333 \r
334         evas_object_del(wd->edje);\r
335 \r
336         evas_object_smart_member_del(wd->ebx);\r
337 //      elm_widget_resize_object_set(obj, wd->edje);\r
338 \r
339         // load edj\r
340         if(mode >= ELM_TAB_PORTRAIT_2 && mode <= ELM_TAB_PORTRAIT_4){\r
341                 snprintf(buf, sizeof(buf), "bg_portrait_%d", mode);\r
342         }else if(mode >= ELM_TAB_LANDSCAPE_2 && mode <= ELM_TAB_LANDSCAPE_5){\r
343                 snprintf(buf, sizeof(buf), "bg_landscape_%d", mode - LANDSCAPE_GAP);\r
344         }\r
345         wd->edje = edje_object_add(wd->evas);\r
346         if(wd->edje == NULL) {\r
347                 printf("Cannot load bg edj\n");\r
348                 return;\r
349         }\r
350 \r
351         _elm_theme_object_set(obj, wd->edje, "tab", buf, elm_widget_style_get(obj));\r
352 \r
353         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_DOWN,  press_down_cb, wd);\r
354         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_UP,  press_up_cb, wd);\r
355         evas_object_show(wd->edje);\r
356 \r
357         evas_object_smart_member_add(wd->ebx, obj);\r
358         elm_widget_resize_object_set(obj, wd->edje);\r
359 \r
360         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE, _tab_object_resize, obj);\r
361         evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _tab_object_move, obj);\r
362         evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _tab_object_show, obj);\r
363         evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _tab_object_hide, obj);\r
364 \r
365         EINA_LIST_FOREACH(wd->items, l, item){\r
366                 snprintf(buf, sizeof(buf), "slot_%d", item->slot);\r
367                 edje_object_part_swallow(wd->edje, buf, item->base);\r
368                 i++;\r
369         }\r
370 \r
371         // set current mode\r
372         if(mode < 10) wd->mode = PORTRAIT;\r
373         else wd->mode = LANDSCAPE;\r
374 \r
375         wd->view_slot_num = mode % LANDSCAPE_GAP;\r
376 \r
377         light_check(wd);\r
378 \r
379         evas_object_resize(wd->edje, wd->w, wd->h);\r
380 }\r
381 \r
382 /**\r
383  * Add new item\r
384  *\r
385  * @param obj The tab object\r
386  * @param       icon The icon of item\r
387  * @param       label The label of item\r
388  * @param       func Callback function of item\r
389  * @param       data The data of callback function\r
390  * @return The item of tab\r
391  *\r
392  * @ingroup Tab\r
393  */\r
394 EAPI Elm_Tab_Item *elm_tab_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)\r
395 {\r
396         char buf[MAX_ARGS];\r
397         Elm_Tab_Item *it;\r
398         Widget_Data *wd;\r
399 \r
400         if(obj == NULL) {\r
401                 printf("Invalid argument: tab object is NULL\n");\r
402                 return NULL;\r
403         }\r
404         wd = elm_widget_data_get(obj);\r
405         if(wd == NULL) {\r
406                 printf("Cannot get smart data\n");\r
407                 return NULL;\r
408         }\r
409 \r
410         it = ELM_NEW(Elm_Tab_Item);\r
411         if(it == NULL) {\r
412                 printf("Cannot add item");\r
413                 return NULL;\r
414         }\r
415         wd->items = eina_list_append(wd->items, it);\r
416         it->obj = obj;\r
417         it->label = eina_stringshare_add(label);\r
418         it->icon = icon;\r
419         it->badge = 0;\r
420         it->func = func;\r
421         it->data = data;\r
422         it->base = edje_object_add(evas_object_evas_get(obj));\r
423         if(it->base == NULL) {\r
424                 printf("Cannot load bg edj\n");\r
425                 return NULL;\r
426         }\r
427         _elm_theme_object_set(obj, it->base, "tab", "item", elm_widget_style_get(obj));\r
428         elm_widget_sub_object_add(obj, it->base);\r
429 \r
430         edje_object_signal_callback_add(it->base, "elm,action,click", "elm", tab_item_cb, (void *)it);\r
431 \r
432         if (it->label){\r
433                 edje_object_part_text_set(it->base, "elm.text", it->label);\r
434         }\r
435 \r
436         if (it->icon){\r
437                 //              int ms = 0;\r
438 \r
439                 //              ms = ((double)wd->icon_size * _elm_config->scale);\r
440                 evas_object_size_hint_min_set(it->icon, 24, 24);\r
441                 evas_object_size_hint_max_set(it->icon, 40, 40);\r
442                 edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);\r
443                 evas_object_show(it->icon);\r
444                 elm_widget_sub_object_add(obj, it->icon);\r
445         }\r
446 \r
447         if (it->label && it->icon){\r
448                 edje_object_signal_emit(it->base, "elm,state,icon_text", "elm");\r
449         }\r
450 \r
451         wd->num += 1;\r
452         it->slot = wd->num;\r
453         snprintf(buf, sizeof(buf), "slot_%d", wd->num);\r
454         edje_object_part_swallow(wd->edje, buf, it->base);\r
455 \r
456         light_check(wd);\r
457 \r
458         return it;\r
459 }\r
460 \r
461 /**\r
462  * Delete item from tab by index\r
463  *\r
464  * @param       it The item of tab\r
465 \r
466  * @ingroup Tab\r
467  */\r
468 EAPI void elm_tab_item_del(Elm_Tab_Item *it)\r
469 {\r
470         int check = 0;\r
471         int i = 1;\r
472         char buf[MAX_ARGS];\r
473         Widget_Data *wd;\r
474         const Eina_List *l;\r
475         Elm_Tab_Item *item;\r
476 \r
477         if(it->obj == NULL) {\r
478                 printf("Invalid argument: tab object is NULL\n");\r
479                 return;\r
480         }\r
481         wd = elm_widget_data_get(it->obj);\r
482         if(wd == NULL) {\r
483                 printf("Cannot get smart data\n");\r
484                 return;\r
485         }\r
486 \r
487         edje_object_part_unswallow(wd->edje, it->base);\r
488 \r
489         EINA_LIST_FOREACH(wd->items, l, item){\r
490                 if(check){\r
491                         edje_object_part_unswallow(wd->edje, item->base);\r
492                         snprintf(buf, sizeof(buf), "slot_%d", i-1);\r
493                         edje_object_part_swallow(wd->edje, buf, item->base);\r
494                 }\r
495                 if(it == item){\r
496                         check = 1;\r
497                 }\r
498                 i++;\r
499         }\r
500 \r
501         eina_stringshare_del(it->label);\r
502         if (it->icon) evas_object_del(it->icon);\r
503         evas_object_del(it->base);\r
504         wd->items = eina_list_remove(wd->items, it);\r
505         wd->num = wd->num - 1;\r
506 }\r
507 \r
508 /**\r
509  * Select item in tab\r
510  *\r
511  * @param       it The item of tab\r
512 \r
513  * @ingroup Tab\r
514  */\r
515 EAPI void elm_tab_item_select(Elm_Tab_Item *it)\r
516 {\r
517         _selected_box(it);\r
518 }\r
519 \r
520 /**\r
521  * Get the icon of item\r
522  *\r
523  * @param       it The item of tab\r
524  * @return The icon object\r
525  *\r
526  * @ingroup Tab\r
527  */\r
528 EAPI Evas_Object *elm_tab_item_icon_get(Elm_Tab_Item *it)\r
529 {\r
530         return it->icon;\r
531 }\r
532 \r
533 /**\r
534  * Get the label of item\r
535  *\r
536  * @param       it The item of tab\r
537  * @return the label of item\r
538  *\r
539  * @ingroup Tab\r
540  */\r
541 EAPI const char *elm_tab_item_label_get(Elm_Tab_Item *it)\r
542 {\r
543         return it->label;\r
544 }\r
545 \r
546 /**\r
547  * Set the label of item\r
548  *\r
549  * @param       it The item of tab\r
550  * @param       label The label of item\r
551  *\r
552  * @ingroup Tab\r
553  */\r
554 EAPI void elm_tab_item_label_set(Elm_Tab_Item *it, const char *label)\r
555 {\r
556         if(!it->base) return;\r
557 \r
558         edje_object_part_text_set(it->base, "elm.text", label);\r
559 }\r
560 \r
561 /**\r
562  * Set the badge of item.\r
563  *\r
564  * @param       it The item of tab\r
565  * @param       badge The number in item badge. If -1, badge is not visible. Otherwise, it is just number.\r
566  *\r
567  * @ingroup Tab\r
568  */\r
569 EAPI void elm_tab_item_badge_set(Elm_Tab_Item *it, const int badge)\r
570 {\r
571         char buf[MAX_ARGS];\r
572 \r
573         if(!it->base) return;\r
574 \r
575         if(it->badge == badge) return;\r
576 \r
577         if(badge < -1) {\r
578                 printf("elm_tab_item_badge_set : second parameter range not availble. (-1 <= badge < 1000)\n");\r
579                 return;\r
580         }\r
581 \r
582         it->badge = badge;\r
583 \r
584         if(badge == -1){\r
585                 edje_object_signal_emit(it->base, "elm,badge,unvisible", "elm");\r
586         }else{\r
587                 if(it->badge > 1000) {\r
588                         printf("Badge Number is too large. ( badge < 1000)\n");\r
589                         return;\r
590                 }\r
591 \r
592                 snprintf(buf, sizeof(buf), "%d", it->badge);\r
593                 edje_object_part_text_set(it->base, "elm.text.badge", buf);\r
594 \r
595                 if(it->badge > 100){\r
596                         edje_object_signal_emit(it->base, "elm,badge,text_normal", "elm");\r
597                 }else{\r
598                         edje_object_signal_emit(it->base, "elm,badge,text_small", "elm");\r
599                 }\r
600                 edje_object_signal_emit(it->base, "elm,badge,visible", "elm");\r
601         }\r
602 }\r
603 \r
604 /**\r
605  * Get the selected item.\r
606  *\r
607  * @param       obj The tab object\r
608  *\r
609  * @ingroup Tab\r
610  */\r
611 EAPI Elm_Tab_Item *elm_tab_selected_item_get(Evas_Object *obj)\r
612 {\r
613         const Eina_List *l;\r
614         Elm_Tab_Item *item;\r
615 \r
616         if(obj == NULL) return NULL;\r
617 \r
618         Widget_Data *wd = elm_widget_data_get(obj);\r
619         if(!wd || !wd->items) return NULL;\r
620 \r
621         EINA_LIST_FOREACH(wd->items, l, item){\r
622                 if(item->selected) return item;\r
623         }\r
624 \r
625         return NULL;\r
626 }\r
627 \r
628 /**\r
629  * Get the first item.\r
630  *\r
631  * @param       obj The tab object\r
632  *\r
633  * @ingroup Tab\r
634  */\r
635 EAPI Elm_Tab_Item *elm_tab_first_item_get(Evas_Object *obj)\r
636 {\r
637         if(obj == NULL) return NULL;\r
638 \r
639         Widget_Data *wd = elm_widget_data_get(obj);\r
640         if(!wd || !wd->items) return NULL;\r
641 \r
642         return eina_list_data_get(wd->items);\r
643 }\r
644 \r
645 /**\r
646  * Get the last item.\r
647  *\r
648  * @param       obj The tab object\r
649  *\r
650  * @ingroup Tab\r
651  */\r
652 EAPI Elm_Tab_Item *elm_tab_last_item_get(Evas_Object *obj)\r
653 {\r
654         if(obj == NULL) return NULL;\r
655 \r
656         Widget_Data *wd = elm_widget_data_get(obj);\r
657         if(!wd || !wd->items) return NULL;\r
658 \r
659         return eina_list_data_get(eina_list_last(wd->items));\r
660 }\r
661 \r
662 /**\r
663  * Get the items.\r
664  *\r
665  * @param       obj The tab object\r
666  *\r
667  * @ingroup Tab\r
668  */\r
669 EAPI Eina_List *elm_tab_items_get(Evas_Object *obj)\r
670 {\r
671         if(obj == NULL) return NULL;\r
672 \r
673         Widget_Data *wd = elm_widget_data_get(obj);\r
674         if(!wd || !wd->items) return NULL;\r
675 \r
676         return wd->items;\r
677 }\r
678 \r
679 /**\r
680  * Get the previous item.\r
681  *\r
682  * @param       it The item of tab\r
683  * @return      The previous item of the parameter item\r
684  *\r
685  * @ingroup Tab\r
686  */\r
687 EAPI Elm_Tab_Item *elm_tab_item_prev(Elm_Tab_Item *it)\r
688 {\r
689         const Eina_List *l;\r
690         Elm_Tab_Item *item;\r
691 \r
692         if(it->obj == NULL) return NULL;\r
693 \r
694         Widget_Data *wd = elm_widget_data_get(it->obj);\r
695         if(!wd || !wd->items) return NULL;\r
696 \r
697         EINA_LIST_FOREACH(wd->items, l, item){\r
698                 if(it == item){\r
699                         l = eina_list_prev(l);\r
700                         if(!l) return NULL;\r
701                         return eina_list_data_get(l);\r
702                 }\r
703         }\r
704 \r
705         return NULL;\r
706 }\r
707 \r
708 /**\r
709  * Get the next item.\r
710  *\r
711  * @param       obj The tab object\r
712  * @return      The next item of the parameter item\r
713  *\r
714  * @ingroup Tab\r
715  */\r
716 EAPI Elm_Tab_Item *elm_tab_item_next(Elm_Tab_Item *it)\r
717 {\r
718         const Eina_List *l;\r
719         Elm_Tab_Item *item;\r
720 \r
721         if(it->obj == NULL) return NULL;\r
722 \r
723         Widget_Data *wd = elm_widget_data_get(it->obj);\r
724         if(!wd || !wd->items) return NULL;\r
725 \r
726         EINA_LIST_FOREACH(wd->items, l, item){\r
727                 if(it == item){\r
728                         l = eina_list_next(l);\r
729                         if(!l) return NULL;\r
730                         return eina_list_data_get(l);\r
731                 }\r
732         }\r
733 \r
734         return NULL;\r
735 }\r
736 \r
737 /**\r
738  * Move the tab object\r
739  *\r
740  * @param       obj The tab object\r
741  * @param       direction the direction of movement\r
742  *\r
743  * @ingroup Tab\r
744  */\r
745 EAPI void elm_tab_move(Evas_Object *obj, int direction)\r
746 {\r
747         Widget_Data *wd;\r
748 \r
749         if(obj == NULL) {\r
750                 printf("Invalid argument: tab object is NULL\n");\r
751                 return;\r
752         }\r
753         wd = elm_widget_data_get(obj);\r
754         if(wd == NULL) {\r
755                 printf("Cannot get smart data\n");\r
756                 return;\r
757         }\r
758 \r
759         if(direction == ELM_TAB_MOVE_LEFT){\r
760                 _move_obj_to_left(wd);\r
761         }else if(direction == ELM_TAB_MOVE_RIGHT){\r
762                 _move_obj_to_right(wd);\r
763         }\r
764 }\r
765 \r
766 /**\r
767  * Set the edit mode of the tab disable\r
768  *\r
769  * @param       obj The tab object\r
770  * @param       disable if 1, edit mode is disable.\r
771  *\r
772  * @ingroup Tab\r
773  */\r
774 EAPI void elm_tab_edit_disable_set(Evas_Object *obj, Eina_Bool disable)\r
775 {\r
776         Widget_Data *wd;\r
777 \r
778         if(obj == NULL) {\r
779                 printf("Invalid argument: tab object is NULL\n");\r
780                 return;\r
781         }\r
782         wd = elm_widget_data_get(obj);\r
783         if(wd == NULL) {\r
784                 printf("Cannot get smart data\n");\r
785                 return;\r
786         }\r
787 \r
788         wd->edit_disable = disable;\r
789 }\r
790 \r
791 /**\r
792  * Get the availability for the edit mode of the tab\r
793  *\r
794  * @param       obj The tab object\r
795  * @return  disable or not\r
796  *\r
797  * @ingroup Tab\r
798  */\r
799 EAPI Eina_Bool elm_tab_edit_disable_get(Evas_Object *obj)\r
800 {\r
801         Widget_Data *wd;\r
802 \r
803         if(obj == NULL) {\r
804                 printf("Invalid argument: tab object is NULL\n");\r
805                 return -1;\r
806         }\r
807 \r
808         wd = elm_widget_data_get(obj);\r
809         if(wd == NULL) {\r
810                 printf("Cannot get smart data\n");\r
811                 return -1;\r
812         }\r
813 \r
814         return wd->edit_disable;\r
815 }\r
816 \r
817 \r
818 \r
819 ///////////////////////////////////////////////////////////////////\r
820 //\r
821 //  basic utility function\r
822 //\r
823 ////////////////////////////////////////////////////////////////////\r
824 \r
825 static void light_check(Widget_Data *wd)\r
826 {\r
827         edje_object_signal_emit(wd->edje, "off_light", "light");\r
828 \r
829         if(wd->view_slot_num > wd->num) return;\r
830 \r
831         if(wd->cur_first_slot > 1){\r
832                 edje_object_signal_emit(wd->edje, "left", "light");\r
833         }\r
834         if(wd->cur_first_slot + wd->view_slot_num - 1 != wd->num){\r
835                 edje_object_signal_emit(wd->edje, "right", "light");\r
836         }\r
837 }\r
838 \r
839 static void select_check(Widget_Data *wd)\r
840 {\r
841         int i = 1;\r
842         int selected = -1;\r
843         const Eina_List *l;\r
844         Elm_Tab_Item *item;\r
845 \r
846         EINA_LIST_FOREACH(wd->items, l, item){\r
847                 if(wd->cur_first_slot <= i && wd->cur_first_slot + wd->view_slot_num > i){\r
848                         if(item->selected){\r
849                                 edje_object_signal_emit(item->base, "selected", "elm");\r
850                         \r
851                         }\r
852 //                              selected = i;\r
853 //                      }else{\r
854 //                              snprintf(buf, sizeof(buf), "show_partition_%d_%d", i, i+1);\r
855 //                              edje_object_signal_emit(wd->edje, buf, "elm");\r
856 //                      }\r
857                 }else{\r
858                         edje_object_signal_emit(item->base, "unselected", "elm");\r
859                 }\r
860                 i++;\r
861         }\r
862 \r
863 //      snprintf(buf, sizeof(buf), "hide_partition_%d_%d", selected, selected+1);\r
864 //      edje_object_signal_emit(wd->edje, buf, "elm");\r
865 //      snprintf(buf, sizeof(buf), "hide_partition_%d_%d", selected-1, selected);\r
866 //      edje_object_signal_emit(wd->edje, buf, "elm");\r
867 }\r
868 \r
869 static int _selected_box(Elm_Tab_Item *it)\r
870 {\r
871         int i = 1;\r
872         int check = 0;\r
873         Evas_Object *icon;\r
874         char buf[MAX_ARGS];\r
875         const Eina_List *l;\r
876         Elm_Tab_Item *item;\r
877         Widget_Data *wd = elm_widget_data_get(it->obj);\r
878 \r
879         EINA_LIST_FOREACH(wd->items, l, item){\r
880                 edje_object_signal_emit(item->base, "unselected", "elm");\r
881                 item->selected = EINA_FALSE;\r
882 \r
883                 icon = edje_object_part_swallow_get(item->base, "elm.swallow.icon");\r
884                 if(icon){\r
885                         if(strcmp(evas_object_type_get(icon), "edje") == 0){\r
886                                 edje_object_signal_emit(icon, "elm,state,unselected", "elm");\r
887                         }else{\r
888                                 if(_EDJ(icon))\r
889                                         edje_object_signal_emit(_EDJ(icon), "elm,state,unselected", "elm");\r
890                         }\r
891                 }\r
892 \r
893                 if(it == item){\r
894                         edje_object_signal_emit(it->base, "selected", "elm");\r
895                         snprintf(buf, sizeof(buf), "selected_%d", i);\r
896                         edje_object_signal_emit(wd->edje, buf, "elm");\r
897 \r
898                         if(icon){\r
899                                 if(strcmp(evas_object_type_get(icon), "edje") == 0){\r
900                                         edje_object_signal_emit(icon, "elm,state,selected", "elm");\r
901                                 }else{\r
902                                         if(_EDJ(icon))\r
903                                                 edje_object_signal_emit(_EDJ(icon), "elm,state,selected", "elm");\r
904                                 }\r
905                         }\r
906                         item->selected = EINA_TRUE;\r
907 \r
908                         check = 1;\r
909                 }\r
910                 i++;\r
911         }\r
912 \r
913         if(!check) return EXIT_FAILURE;\r
914 \r
915         if (it->func) it->func((void *)(it->data), it->obj, it);\r
916         evas_object_smart_callback_call(it->obj, "clicked", it);\r
917 \r
918 //      select_check(wd);\r
919 \r
920         return EXIT_SUCCESS;\r
921 }\r
922 \r
923 ///////////////////////////////////////////////////////////////////\r
924 //\r
925 //  general function\r
926 //\r
927 ////////////////////////////////////////////////////////////////////\r
928 \r
929 static int _move_obj_to_left(Widget_Data *wd)\r
930 {\r
931         char buf[MAX_ARGS];\r
932         int first_slot;\r
933 \r
934         first_slot = wd->cur_first_slot + wd->view_slot_num;\r
935         if(first_slot + wd->view_slot_num > wd->num){\r
936                 first_slot = wd->num - wd->view_slot_num +1;\r
937         }\r
938 \r
939         snprintf(buf, sizeof(buf), "step_%d", first_slot);\r
940         edje_object_signal_emit(wd->edje, buf, "elm");\r
941         wd->cur_first_slot = first_slot;\r
942 \r
943         select_check(wd);\r
944 \r
945         light_check(wd);\r
946 \r
947         return EXIT_SUCCESS;\r
948 }\r
949 \r
950 static int _move_obj_to_right(Widget_Data *wd)\r
951 {\r
952         char buf[MAX_ARGS];\r
953         int first_slot;\r
954 \r
955         first_slot = wd->cur_first_slot - wd->view_slot_num;\r
956         if(first_slot < 1){\r
957                 first_slot = 1;\r
958         }\r
959 \r
960         snprintf(buf, sizeof(buf), "step_%d", first_slot);\r
961         edje_object_signal_emit(wd->edje, buf, "elm");\r
962         wd->cur_first_slot = first_slot;\r
963 \r
964         select_check(wd);\r
965 \r
966         light_check(wd);\r
967 \r
968         return EXIT_SUCCESS;\r
969 }\r
970 \r
971 static void edit_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)\r
972 {\r
973         char buf[MAX_ARGS];\r
974         Evas_Object *icon;\r
975         Widget_Data *wd = (Widget_Data *)data;\r
976         const Eina_List *l;\r
977         Elm_Tab_Item *item;\r
978 \r
979         EINA_LIST_FOREACH(wd->items, l, item){\r
980                 if(item->selected){\r
981                         edje_object_signal_emit(item->base, "selected", "elm");\r
982                         icon = edje_object_part_swallow_get(item->base, "elm.swallow.icon");\r
983                         if(icon){\r
984                                 if(strcmp(evas_object_type_get(icon), "edje") == 0){\r
985                                         edje_object_signal_emit(icon, "elm,state,selected", "elm");\r
986                                 }else{\r
987                                         if(_EDJ(icon))\r
988                                                 edje_object_signal_emit(_EDJ(icon), "elm,state,selected", "elm");\r
989                                 }\r
990                         }\r
991                 }\r
992                 edje_object_signal_callback_add(item->base, "elm,action,click", "elm", tab_item_cb, item);\r
993                 evas_object_event_callback_del(item->base, EVAS_CALLBACK_MOUSE_DOWN,  item_down_cb);\r
994         }\r
995 \r
996         evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_DOWN,  press_down_cb);\r
997         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_DOWN,  press_down_cb, wd);\r
998         evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_UP,  press_up_cb);\r
999         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_UP,  press_up_cb, wd);\r
1000 \r
1001         snprintf(buf, sizeof(buf), "step_%d", wd->cur_first_slot);\r
1002         edje_object_signal_emit(wd->edje, buf, "elm");\r
1003 \r
1004         light_check(wd);\r
1005         evas_object_hide(wd->ebx);\r
1006 }\r
1007 \r
1008 static int item_move_cb(void *data, int type, void *event_info)\r
1009 {\r
1010         Evas_Object *obj;\r
1011         Ecore_Event_Mouse_Move *ev = event_info;\r
1012         Evas_Coord x, y, w, h, mx, my, mw, mh, ex, ey;\r
1013         Widget_Data *wd = (Widget_Data *)data;\r
1014 \r
1015         obj = wd->moving_obj;\r
1016 \r
1017         evas_object_geometry_get(obj, NULL, NULL ,&w, &h);\r
1018         evas_object_geometry_get(wd->edje, &ex, &ey , NULL, NULL);\r
1019         edje_object_part_geometry_get(wd->edje, "bg_b", &mx, &my ,&mw, &mh);\r
1020 \r
1021         if(ev->x < ex + mx + w/2) x = ex + mx;\r
1022         else if(ev->x > ex + mx + mw - w/2) x = ex + mx + mw - w;\r
1023         else x = ev->x - w/2;\r
1024 \r
1025         if(ev->y < ey + my + h) y = ey + my;\r
1026         else if(ev->y > ey + my + mh) y = ey + my + mh - h;\r
1027         else y = ev->y - h;\r
1028 \r
1029         evas_object_move(obj, x, y);\r
1030 \r
1031         return 1;\r
1032 }\r
1033 \r
1034 static int sort_cb(const void *d1, const void *d2)\r
1035 {\r
1036         Elm_Tab_Item *item1, *item2;\r
1037 \r
1038         item1 = (Elm_Tab_Item *)d1;\r
1039         item2 = (Elm_Tab_Item *)d2;\r
1040 \r
1041         return item1->slot > item2->slot ? 1 : -1;\r
1042 }\r
1043 \r
1044 static int item_up_cb(void *data, int type, void *event_info)\r
1045 {\r
1046         Evas_Object *obj;\r
1047         Ecore_Event_Mouse_Button *ev = event_info;\r
1048         char buf[MAX_ARGS];\r
1049         Evas_Coord x, y, w, h;\r
1050         int i = 0;\r
1051         const Eina_List *l;\r
1052         Elm_Tab_Item *item;\r
1053         Elm_Tab_Item *edit_to_item, *edit_from_item;\r
1054         Widget_Data *wd = (Widget_Data *)data;\r
1055 \r
1056         obj = wd->moving_obj;\r
1057 \r
1058         wd->edit_to = 0;\r
1059         EINA_LIST_FOREACH(wd->items, l, item){\r
1060                 i++;\r
1061                 if(item->base == obj) continue;\r
1062                 evas_object_geometry_get(item->base, &x, &y, &w, &h);\r
1063                 if(x < ev->x && ev->x < x+w && y < ev->y && ev->y < y+h){\r
1064                         wd->edit_to = i;\r
1065                 }\r
1066         }\r
1067 \r
1068         if(wd->edit_to > 0 && wd->edit_to <= wd->num){\r
1069 \r
1070                 edit_to_item = eina_list_nth(wd->items, wd->edit_to-1);\r
1071                 edit_from_item = eina_list_nth(wd->items, wd->edit_from-1);\r
1072 \r
1073                 edje_object_part_unswallow(wd->edje, edit_to_item->base);\r
1074                 snprintf(buf, sizeof(buf), "slot_%d", wd->edit_from);\r
1075                 edje_object_part_swallow(wd->edje, buf, edit_to_item->base);\r
1076                 edit_to_item->slot = wd->edit_from;\r
1077 \r
1078                 snprintf(buf, sizeof(buf), "slot_%d", wd->edit_to);\r
1079                 edje_object_part_swallow(wd->edje, buf, edit_from_item->base);\r
1080                 edit_from_item->slot = wd->edit_to;\r
1081 \r
1082                 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);\r
1083 \r
1084         }else{\r
1085                 wd->edit_to = wd->edit_from;\r
1086                 snprintf(buf, sizeof(buf), "slot_%d", wd->edit_from);\r
1087                 edje_object_part_swallow(wd->edje, buf, obj);\r
1088         }\r
1089 \r
1090         ecore_event_handler_del(wd->move_event);\r
1091         wd->move_event = NULL;\r
1092         ecore_event_handler_del(wd->up_event);\r
1093         wd->up_event = NULL;\r
1094 \r
1095         return EXIT_SUCCESS;\r
1096 }\r
1097 \r
1098 static void item_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)\r
1099 {\r
1100         Evas_Event_Mouse_Down *ev = event_info;\r
1101         Evas_Coord x, y, w, h;\r
1102         Widget_Data *wd = (Widget_Data *)data;\r
1103         const Eina_List *l;\r
1104         Elm_Tab_Item *item;\r
1105 \r
1106         wd->moving_obj = obj;\r
1107 \r
1108         EINA_LIST_FOREACH(wd->items, l, item){\r
1109                 if(item->base == obj) wd->edit_from = item->slot;\r
1110         }\r
1111 \r
1112         edje_object_part_unswallow(wd->edje, obj);\r
1113         evas_object_geometry_get(obj, &x, &y, &w, &h);\r
1114         evas_object_move(obj, ev->output.x - w/2 , ev->output.y - h);\r
1115         edje_object_signal_emit(obj, "edit", "elm");\r
1116 \r
1117         wd->up_event = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, item_up_cb, (void *)wd);\r
1118         wd->move_event = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, item_move_cb, (void *)wd);\r
1119 }\r
1120 \r
1121 static void edit_mode(void *data)\r
1122 {\r
1123         Evas_Object *icon;\r
1124         const Eina_List *l;\r
1125         Elm_Tab_Item *item;\r
1126         Widget_Data *wd = (Widget_Data *)data;\r
1127 \r
1128         edje_object_signal_emit(wd->edje, "edit", "elm");\r
1129 \r
1130         if((int)(wd->num/wd->view_slot_num) < 2){\r
1131                 edje_object_signal_emit(wd->edje, "edit_2", "elm");\r
1132         }else{\r
1133                 edje_object_signal_emit(wd->edje, "edit_3", "elm");\r
1134         }\r
1135 \r
1136         // delete normal mode callback & add normal mode callback\r
1137         EINA_LIST_FOREACH(wd->items, l, item){\r
1138                 edje_object_signal_emit(item->base, "unselected", "elm");\r
1139                 icon = edje_object_part_swallow_get(item->base, "elm.swallow.icon");\r
1140                 if(icon){\r
1141                         if(strcmp(evas_object_type_get(icon), "edje") == 0){\r
1142                                 edje_object_signal_emit(icon, "elm,state,unselected", "elm");\r
1143                         }else{\r
1144                                 if(_EDJ(icon))\r
1145                                         edje_object_signal_emit(_EDJ(icon), "elm,state,unselected", "elm");\r
1146                         }\r
1147                 }\r
1148                 edje_object_signal_callback_del(item->base, "elm,action,click", "elm", tab_item_cb);\r
1149                 evas_object_event_callback_add(item->base, EVAS_CALLBACK_MOUSE_DOWN, item_down_cb, wd);\r
1150         }\r
1151         evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_DOWN,  press_down_cb);\r
1152         evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_UP,  press_up_cb);\r
1153         evas_object_show(wd->ebx);\r
1154 \r
1155         edje_object_signal_emit(wd->edje, "off_light", "light");\r
1156 }\r
1157 \r
1158 \r
1159 static int tab_timer_cb(void* data)\r
1160 {\r
1161         Widget_Data *wd = (Widget_Data *)data;\r
1162 \r
1163         if(wd->time > KEYDOWN_INTERVAL){\r
1164                 evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_MOVE,  press_move_cb);\r
1165 \r
1166                 if(!wd->edit_disable) edit_mode(wd);\r
1167 \r
1168                 if(wd->timer){\r
1169                         ecore_timer_del(wd->timer);\r
1170                         wd->timer = NULL;\r
1171                 }\r
1172 \r
1173         } else {\r
1174                 wd->time += 0.1;\r
1175         }\r
1176 \r
1177         return EXIT_FAILURE;\r
1178 }\r
1179 \r
1180 static void press_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)\r
1181 {\r
1182         Evas_Event_Mouse_Down *ev = event_info;\r
1183         Widget_Data *wd = (Widget_Data *)data;\r
1184 \r
1185         if(abs(wd->tab_down_x-ev->output.x) > 10 || abs(wd->tab_down_y-ev->output.y) > 10){\r
1186                 if(wd->timer){\r
1187                         ecore_timer_del(wd->timer);\r
1188                         wd->timer = NULL;\r
1189                 }\r
1190         }\r
1191 }\r
1192 \r
1193 static void press_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)\r
1194 {\r
1195         Evas_Event_Mouse_Down *ev = event_info;\r
1196         Widget_Data *wd = (Widget_Data *)data;\r
1197 \r
1198         wd->flag = true;\r
1199         wd->tab_down_x = ev->output.x;\r
1200         wd->tab_down_y = ev->output.y;\r
1201 \r
1202         wd->time = 0;\r
1203         wd->timer = ecore_timer_add(0.1, tab_timer_cb, wd);\r
1204 \r
1205         evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOUSE_MOVE,  press_move_cb, wd);\r
1206 }\r
1207 \r
1208 static void press_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)\r
1209 {\r
1210         Evas_Event_Mouse_Up *ev = event_info;\r
1211         Widget_Data *wd = (Widget_Data *)data;\r
1212         Evas_Coord x, y, w, h;\r
1213 \r
1214         evas_object_event_callback_del(wd->edje, EVAS_CALLBACK_MOUSE_MOVE,  press_move_cb);\r
1215 \r
1216         if(wd->time < KEYDOWN_INTERVAL){\r
1217                 if(wd->timer){\r
1218                         ecore_timer_del(wd->timer);\r
1219                         wd->timer = NULL;\r
1220                 }\r
1221         } else {\r
1222                 return;\r
1223         }\r
1224 \r
1225         evas_object_geometry_get(wd->edje, &x, &y, &w, &h);\r
1226 \r
1227         if(ev->output.y > y+(h*1.5) && abs(ev->output.x - wd->tab_down_x) < wd->w/10){\r
1228                 if(!wd->edit_disable) edit_mode(wd);\r
1229         }else{\r
1230                 // return if dont need to move\r
1231                 if(wd->num <= wd->view_slot_num) return;\r
1232 \r
1233                 if(wd->flag == true){\r
1234                         if(abs(wd->tab_down_y - ev->output.y) < wd->h){\r
1235                                 if((wd->tab_down_x - ev->output.x ) > wd->w / 4){\r
1236                                         _move_obj_to_left(wd);\r
1237                                 }else if((ev->output.x - wd->tab_down_x) > wd->w / 4){\r
1238                                         _move_obj_to_right(wd);\r
1239                                 }\r
1240                         }\r
1241                 }\r
1242         }\r
1243         wd->flag = false;\r
1244 }\r
1245 \r
1246 void tab_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)\r
1247 {\r
1248         Elm_Tab_Item *it = (Elm_Tab_Item *)data;\r
1249         if(it->obj == NULL)\r
1250                 return;\r
1251         Widget_Data *wd = elm_widget_data_get(it->obj);\r
1252         if(wd == NULL)\r
1253                 return;\r
1254 \r
1255         if(wd->time > KEYDOWN_INTERVAL) return;\r
1256         _selected_box(it);\r
1257 }\r
1258 \r
1259 ///////////////////////////////////////////////////////////////////\r
1260 //\r
1261 //  Smart Object basic function\r
1262 //\r
1263 ////////////////////////////////////////////////////////////////////\r
1264 \r
1265 static void _tab_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
1266 {\r
1267         DBG("%s", __func__);\r
1268 \r
1269         Widget_Data *wd;\r
1270         Evas_Coord x, y;\r
1271 \r
1272         if(!data) return;\r
1273         wd = elm_widget_data_get((Evas_Object *)data);\r
1274         if(!wd) return;\r
1275 \r
1276         evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);\r
1277 \r
1278         wd->x = x;\r
1279         wd->y = y;\r
1280 \r
1281         evas_object_move(wd->edje, x, y);\r
1282 }\r
1283 \r
1284 \r
1285 static void _tab_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
1286 {\r
1287         DBG("%s", __func__);\r
1288 \r
1289         Widget_Data *wd;\r
1290         Evas_Coord w, h;\r
1291 \r
1292         if(!data) return;\r
1293         wd = elm_widget_data_get((Evas_Object *)data);\r
1294         if(!wd) return;\r
1295 \r
1296         evas_object_geometry_get(wd->edje, NULL, NULL, &w, &h);\r
1297 \r
1298         wd->w = w;\r
1299         wd->h = h;\r
1300 \r
1301         evas_object_resize(wd->edje, w, h);\r
1302 \r
1303         evas_object_geometry_get(wd->parent, NULL, NULL, &w, &h);\r
1304         evas_object_resize(wd->ebx, w, h);\r
1305 }\r
1306 \r
1307 \r
1308 static void _tab_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
1309 {\r
1310         DBG("%s", __func__);\r
1311 \r
1312         Widget_Data *wd;\r
1313 \r
1314         if(!data) return;\r
1315         wd = elm_widget_data_get((Evas_Object *)data);\r
1316         if(!wd) return;\r
1317 \r
1318         evas_object_show(wd->edje);\r
1319 }\r
1320 \r
1321 \r
1322 \r
1323 static void _tab_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)\r
1324 {\r
1325     DBG("%s", __func__);\r
1326 \r
1327         Widget_Data *wd;\r
1328 \r
1329         if(!data) return;\r
1330         wd = elm_widget_data_get((Evas_Object *)data);\r
1331         if(!wd) return;\r
1332 \r
1333         evas_object_hide(wd->edje);\r
1334         evas_object_hide(wd->ebx);\r
1335 }\r
1336 \r