3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
6 #include "els_scroller.h"
8 #include "elm_genlist.h"
10 #define SWIPE_MOVES 12
11 #define MAX_ITEMS_PER_BLOCK 32
12 #define REORDER_EFFECT_TIME 0.5
14 #define ELM_GEN_SETUP(wd) \
15 (wd)->calc_cb = (Ecore_Cb)_calc_job; \
16 (wd)->clear_cb = (Ecore_Cb)_clear_cb; \
17 (wd)->sizing_cb = (Ecore_Cb)_sizing_eval
20 #define ELM_GEN_ITEM_SETUP(it) \
21 (it)->del_cb = (Ecore_Cb)_item_del; \
22 (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
23 (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
24 (it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
25 (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
27 typedef struct _Item_Block Item_Block;
28 typedef struct _Item_Cache Item_Cache;
30 struct Elm_Gen_Item_Type
35 Evas_Coord w, h, minw, minh;
36 Elm_Gen_Item *group_item;
37 Elm_Genlist_Item_Flags flags;
38 Eina_List *mode_labels, *mode_contents, *mode_states, *mode_content_objs;
39 Ecore_Timer *swipe_timer;
40 Evas_Coord scrl_x, scrl_y, old_scrl_y;
43 Evas_Object *mode_view;
49 Eina_Bool want_realize : 1;
50 Eina_Bool expanded : 1;
51 Eina_Bool mincalcd : 1;
54 Eina_Bool updateme : 1;
55 Eina_Bool nocache : 1;
56 Eina_Bool stacking_even : 1;
57 Eina_Bool nostacking : 1;
58 Eina_Bool move_effect_enabled : 1;
63 Eina_Inlist_Sorted_State *state;
64 Evas_Object *obj; /* the genlist object */
65 Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
66 Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
68 Eina_List *group_items; /* list of groups index items */
69 Eina_Inlist *items; /* inlist of all items */
70 Elm_Gen_Item *reorder_it; /* item currently being repositioned */
71 Elm_Gen_Item *last_selected_item;
72 Pan *pan; /* pan_smart object's smart data */
75 int item_width, item_height;
76 int group_item_width, group_item_height;
79 Evas_Coord pan_x, pan_y;
80 Eina_Bool reorder_mode : 1; /* a flag for reorder mode enable/disable */
81 Eina_Bool on_hold : 1;
82 Eina_Bool multi : 1; /* a flag for item multi selection */
83 Eina_Bool no_select : 1;
84 Eina_Bool wasselected : 1;
85 Eina_Bool always_select : 1;
86 Eina_Bool clear_me : 1;
87 Eina_Bool h_bounce : 1;
88 Eina_Bool v_bounce : 1;
89 Ecore_Cb del_cb, calc_cb, sizing_cb;
91 ////////////////////////////////////
92 Eina_Inlist *blocks; /* inlist of all blocks. a block consists of a certain number of items. maximum number of items in a block is 'max_items_per_block'. */
93 Evas_Coord reorder_old_pan_y, w, h, realminw, prev_viewport_w;
94 Ecore_Job *update_job;
95 Ecore_Idle_Enterer *queue_idle_enterer;
96 Ecore_Idler *must_recalc_idler;
98 Elm_Gen_Item *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
99 Eina_Inlist *item_cache; /* an inlist of edje object it cache. */
101 Evas_Coord reorder_start_y; /* reorder it's initial y coordinate in the pan. */
103 Ecore_Timer *multi_timer, *scr_hold_timer;
104 Ecore_Animator *reorder_move_animator;
105 const char *mode_type;
106 const char *mode_item_style;
107 unsigned int start_time;
108 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
109 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
110 Eina_Bool mouse_down : 1;
111 Eina_Bool multi_down : 1;
112 Eina_Bool multi_timeout : 1;
113 Eina_Bool multitouched : 1;
114 Eina_Bool longpressed : 1;
115 Eina_Bool bring_in : 1;
116 Eina_Bool compress : 1;
117 Eina_Bool height_for_width : 1;
118 Eina_Bool homogeneous : 1;
120 Eina_Bool reorder_pan_move : 1;
121 Eina_Bool auto_scroll_enabled : 1;
122 Eina_Bool pan_resized : 1;
126 } history[SWIPE_MOVES];
128 int item_cache_count;
129 int item_cache_max; /* maximum number of cached items */
131 int max_items_per_block; /* maximum number of items per block */
132 double longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
143 Evas_Coord x, y, w, h, minw, minh;
144 Eina_Bool want_unrealize : 1;
145 Eina_Bool realized : 1;
146 Eina_Bool changed : 1;
147 Eina_Bool updateme : 1;
148 Eina_Bool showme : 1;
149 Eina_Bool must_recalc : 1;
156 Evas_Object *base_view, *spacer;
158 const char *item_style; // it->itc->item_style
159 Eina_Bool tree : 1; // it->group
160 Eina_Bool compress : 1; // it->wd->compress
162 Eina_Bool selected : 1; // it->selected
163 Eina_Bool disabled : 1; // it->disabled
164 Eina_Bool expanded : 1; // it->item->expanded
167 static const char *widtype = NULL;
168 static void _item_cache_zero(Widget_Data *wd);
169 static void _del_hook(Evas_Object *obj);
170 static void _mirrored_set(Evas_Object *obj,
172 static void _theme_hook(Evas_Object *obj);
173 static void _show_region_hook(void *data,
175 static void _sizing_eval(Evas_Object *obj);
176 static void _item_realize(Elm_Gen_Item *it,
179 static void _item_unrealize_cb(Elm_Gen_Item *it);
180 static void _item_block_unrealize(Item_Block *itb);
181 static void _calc_job(void *data);
182 static void _on_focus_hook(void *data,
184 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
185 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
186 static Eina_Bool _item_single_select_up(Widget_Data *wd);
187 static Eina_Bool _item_single_select_down(Widget_Data *wd);
188 static Eina_Bool _event_hook(Evas_Object *obj,
190 Evas_Callback_Type type,
192 static void _signal_emit_hook(Evas_Object *obj,
193 const char *emission,
195 static Eina_Bool _deselect_all_items(Widget_Data *wd);
196 static void _pan_calculate(Evas_Object *obj);
197 static void _pan_max_get(Evas_Object *obj,
200 static void _item_position(Elm_Gen_Item *it,
204 static void _mode_item_realize(Elm_Gen_Item *it);
205 static void _mode_item_unrealize(Elm_Gen_Item *it);
206 static void _item_mode_set(Elm_Gen_Item *it);
207 static void _item_mode_unset(Widget_Data *wd);
208 static void _group_items_recalc(void *data);
209 static void _item_move_after(Elm_Gen_Item *it,
210 Elm_Gen_Item *after);
211 static void _item_move_before(Elm_Gen_Item *it,
212 Elm_Gen_Item *before);
213 static void _item_auto_scroll(Widget_Data *wd);
215 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
217 static const char SIG_ACTIVATED[] = "activated";
218 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
219 static const char SIG_SELECTED[] = "selected";
220 static const char SIG_UNSELECTED[] = "unselected";
221 static const char SIG_EXPANDED[] = "expanded";
222 static const char SIG_CONTRACTED[] = "contracted";
223 static const char SIG_EXPAND_REQUEST[] = "expand,request";
224 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
225 static const char SIG_REALIZED[] = "realized";
226 static const char SIG_UNREALIZED[] = "unrealized";
227 static const char SIG_DRAG_START_UP[] = "drag,start,up";
228 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
229 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
230 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
231 static const char SIG_DRAG_STOP[] = "drag,stop";
232 static const char SIG_DRAG[] = "drag";
233 static const char SIG_LONGPRESSED[] = "longpressed";
234 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
235 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
236 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
237 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
238 static const char SIG_EDGE_TOP[] = "edge,top";
239 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
240 static const char SIG_EDGE_LEFT[] = "edge,left";
241 static const char SIG_EDGE_RIGHT[] = "edge,right";
242 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
243 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
244 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
245 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
246 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
247 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
248 static const char SIG_SWIPE[] = "swipe";
249 static const char SIG_MOVED[] = "moved";
251 static const Evas_Smart_Cb_Description _signals[] = {
252 {SIG_CLICKED_DOUBLE, ""},
255 {SIG_UNSELECTED, ""},
257 {SIG_CONTRACTED, ""},
258 {SIG_EXPAND_REQUEST, ""},
259 {SIG_CONTRACT_REQUEST, ""},
261 {SIG_UNREALIZED, ""},
262 {SIG_DRAG_START_UP, ""},
263 {SIG_DRAG_START_DOWN, ""},
264 {SIG_DRAG_START_LEFT, ""},
265 {SIG_DRAG_START_RIGHT, ""},
268 {SIG_LONGPRESSED, ""},
269 {SIG_SCROLL_ANIM_START, ""},
270 {SIG_SCROLL_ANIM_STOP, ""},
271 {SIG_SCROLL_DRAG_START, ""},
272 {SIG_SCROLL_DRAG_STOP, ""},
274 {SIG_EDGE_BOTTOM, ""},
276 {SIG_EDGE_RIGHT, ""},
277 {SIG_MULTI_SWIPE_LEFT, ""},
278 {SIG_MULTI_SWIPE_RIGHT, ""},
279 {SIG_MULTI_SWIPE_UP, ""},
280 {SIG_MULTI_SWIPE_DOWN, ""},
281 {SIG_MULTI_PINCH_OUT, ""},
282 {SIG_MULTI_PINCH_IN, ""},
288 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
289 static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
292 _event_hook(Evas_Object *obj,
293 Evas_Object *src __UNUSED__,
294 Evas_Callback_Type type,
297 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
298 Evas_Event_Key_Down *ev = event_info;
299 Widget_Data *wd = elm_widget_data_get(obj);
300 Evas_Coord pan_max_x = 0, pan_max_y = 0;
301 if (!wd) return EINA_FALSE;
302 if (!wd->items) return EINA_FALSE;
303 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
304 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
306 Elm_Gen_Item *it = NULL;
309 Evas_Coord step_x = 0;
310 Evas_Coord step_y = 0;
313 Evas_Coord page_x = 0;
314 Evas_Coord page_y = 0;
316 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
317 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
318 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
319 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
321 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
325 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
329 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
331 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
332 (_item_multi_select_up(wd)))
333 || (_item_single_select_up(wd)))
335 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
341 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
343 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
344 (_item_multi_select_down(wd)))
345 || (_item_single_select_down(wd)))
347 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
353 else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
355 it = elm_genlist_first_item_get(obj);
356 elm_genlist_item_bring_in(it);
357 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
360 else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
362 it = elm_genlist_last_item_get(obj);
363 elm_genlist_item_bring_in(it);
364 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
367 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
370 y -= -(page_y * v_h) / 100;
374 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
377 y += -(page_y * v_h) / 100;
381 else if (!strcmp(ev->keyname, "Escape"))
383 if (!_deselect_all_items(wd)) return EINA_FALSE;
384 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
387 else if (((!strcmp(ev->keyname, "Return")) ||
388 (!strcmp(ev->keyname, "KP_Enter")) ||
389 (!strcmp(ev->keyname, "space")))
390 && (!wd->multi) && (wd->selected))
392 it = elm_genlist_selected_item_get(obj);
393 elm_genlist_item_expanded_set(it,
394 !elm_genlist_item_expanded_get(it));
395 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
397 else return EINA_FALSE;
399 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
400 _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
402 if (x > pan_max_x) x = pan_max_x;
404 if (y > pan_max_y) y = pan_max_y;
405 elm_smart_scroller_child_pos_set(wd->scr, x, y);
410 _deselect_all_items(Widget_Data *wd)
412 if (!wd->selected) return EINA_FALSE;
414 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
420 _item_multi_select_up(Widget_Data *wd)
422 if (!wd->selected) return EINA_FALSE;
423 if (!wd->multi) return EINA_FALSE;
425 Elm_Gen_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
426 if (!prev) return EINA_TRUE;
428 if (elm_genlist_item_selected_get(prev))
430 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
431 wd->last_selected_item = prev;
432 elm_genlist_item_show(wd->last_selected_item);
436 elm_genlist_item_selected_set(prev, EINA_TRUE);
437 elm_genlist_item_show(prev);
443 _item_multi_select_down(Widget_Data *wd)
445 if (!wd->selected) return EINA_FALSE;
446 if (!wd->multi) return EINA_FALSE;
448 Elm_Gen_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
449 if (!next) return EINA_TRUE;
451 if (elm_genlist_item_selected_get(next))
453 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
454 wd->last_selected_item = next;
455 elm_genlist_item_show(wd->last_selected_item);
459 elm_genlist_item_selected_set(next, EINA_TRUE);
460 elm_genlist_item_show(next);
466 _item_single_select_up(Widget_Data *wd)
471 prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
472 while ((prev) && (prev->delete_me))
473 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
475 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
477 if (!prev) return EINA_FALSE;
479 _deselect_all_items(wd);
481 elm_genlist_item_selected_set(prev, EINA_TRUE);
482 elm_genlist_item_show(prev);
487 _item_single_select_down(Widget_Data *wd)
492 next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
493 while ((next) && (next->delete_me))
494 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
496 else next = elm_genlist_item_next_get(wd->last_selected_item);
498 if (!next) return EINA_FALSE;
500 _deselect_all_items(wd);
502 elm_genlist_item_selected_set(next, EINA_TRUE);
503 elm_genlist_item_show(next);
508 _on_focus_hook(void *data __UNUSED__,
511 Widget_Data *wd = elm_widget_data_get(obj);
513 if (elm_widget_focus_get(obj))
515 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
516 evas_object_focus_set(wd->obj, EINA_TRUE);
517 if ((wd->selected) && (!wd->last_selected_item))
518 wd->last_selected_item = eina_list_data_get(wd->selected);
522 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
523 evas_object_focus_set(wd->obj, EINA_FALSE);
528 _del_hook(Evas_Object *obj)
530 Widget_Data *wd = elm_widget_data_get(obj);
532 _item_cache_zero(wd);
533 if (wd->calc_job) ecore_job_del(wd->calc_job);
534 if (wd->update_job) ecore_job_del(wd->update_job);
535 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
536 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
537 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
538 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
539 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
544 _del_pre_hook(Evas_Object *obj)
546 Widget_Data *wd = elm_widget_data_get(obj);
548 elm_genlist_clear(obj);
549 evas_object_del(wd->pan_smart);
550 wd->pan_smart = NULL;
554 _mirrored_set(Evas_Object *obj,
557 Widget_Data *wd = elm_widget_data_get(obj);
559 _item_cache_zero(wd);
560 elm_smart_scroller_mirrored_set(wd->scr, rtl);
564 _theme_hook(Evas_Object *obj)
566 Widget_Data *wd = elm_widget_data_get(obj);
569 evas_event_freeze(evas_object_evas_get(wd->obj));
570 _item_cache_zero(wd);
571 _elm_widget_mirrored_reload(obj);
572 _mirrored_set(obj, elm_widget_mirrored_get(obj));
573 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
574 elm_widget_style_get(obj));
575 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
576 wd->item_width = wd->item_height = 0;
577 wd->group_item_width = wd->group_item_height = 0;
578 wd->minw = wd->minh = wd->realminw = 0;
579 EINA_INLIST_FOREACH(wd->blocks, itb)
584 if (itb->realized) _item_block_unrealize(itb);
585 EINA_LIST_FOREACH(itb->items, l, it)
586 it->item->mincalcd = EINA_FALSE;
588 itb->changed = EINA_TRUE;
590 if (wd->calc_job) ecore_job_del(wd->calc_job);
591 wd->calc_job = ecore_job_add(_calc_job, wd);
593 evas_event_thaw(evas_object_evas_get(wd->obj));
594 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
598 _show_region_hook(void *data,
601 Widget_Data *wd = elm_widget_data_get(data);
602 Evas_Coord x, y, w, h;
604 elm_widget_show_region_get(obj, &x, &y, &w, &h);
605 //x & y are screen coordinates, Add with pan coordinates
608 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
612 _translate_hook(Evas_Object *obj)
614 evas_object_smart_callback_call(obj, "language,changed", NULL);
618 _sizing_eval(Evas_Object *obj)
620 Widget_Data *wd = elm_widget_data_get(obj);
621 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
623 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
624 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
626 if (wd->height_for_width)
630 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
631 if ((vw != 0) && (vw != wd->prev_viewport_w))
635 wd->prev_viewport_w = vw;
636 EINA_INLIST_FOREACH(wd->blocks, itb)
638 itb->must_recalc = EINA_TRUE;
640 if (wd->calc_job) ecore_job_del(wd->calc_job);
641 wd->calc_job = ecore_job_add(_calc_job, wd);
644 if (wd->mode == ELM_LIST_LIMIT)
650 edje_object_size_min_calc
651 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
658 edje_object_size_min_calc
659 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
663 evas_object_size_hint_min_set(obj, minw, minh);
664 evas_object_size_hint_max_set(obj, maxw, maxh);
668 _signal_emit_hook(Evas_Object *obj,
669 const char *emission,
672 Widget_Data *wd = elm_widget_data_get(obj);
673 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
678 _item_highlight(Elm_Gen_Item *it)
680 const char *selectraise;
681 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
682 (it->disabled) || (it->display_only) || (it->item->mode_view))
684 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
685 selectraise = edje_object_data_get(VIEW(it), "selectraise");
686 if ((selectraise) && (!strcmp(selectraise, "on")))
688 evas_object_raise(VIEW(it));
689 if ((it->item->group_item) && (it->item->group_item->realized))
690 evas_object_raise(it->item->VIEW(group_item));
692 it->highlighted = EINA_TRUE;
696 _item_unhighlight(Elm_Gen_Item *it)
698 if ((it->delete_me) || (!it->highlighted)) return;
699 edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
700 if (!it->item->nostacking)
702 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even) evas_object_lower(VIEW(it));
703 else evas_object_raise(VIEW(it));
705 it->highlighted = EINA_FALSE;
709 _item_block_del(Elm_Gen_Item *it)
712 Item_Block *itb = it->item->block;
714 itb->items = eina_list_remove(itb->items, it);
716 itb->changed = EINA_TRUE;
717 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
718 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
721 il = EINA_INLIST_GET(itb);
722 Item_Block *itbn = (Item_Block *)(il->next);
724 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
726 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
728 if (itbn) itbn->changed = EINA_TRUE;
732 if (itb->count < itb->wd->max_items_per_block/2)
734 il = EINA_INLIST_GET(itb);
735 Item_Block *itbp = (Item_Block *)(il->prev);
736 Item_Block *itbn = (Item_Block *)(il->next);
737 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
741 EINA_LIST_FREE(itb->items, it2)
743 it2->item->block = itbp;
744 itbp->items = eina_list_append(itbp->items, it2);
746 itbp->changed = EINA_TRUE;
748 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
749 EINA_INLIST_GET(itb));
752 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
756 Eina_List *last = eina_list_last(itb->items);
757 Elm_Gen_Item *it2 = last->data;
759 it2->item->block = itbn;
760 itb->items = eina_list_remove_list(itb->items, last);
761 itbn->items = eina_list_prepend(itbn->items, it2);
763 itbn->changed = EINA_TRUE;
766 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
774 _item_del(Elm_Gen_Item *it)
776 Evas_Object *obj = WIDGET(it);
778 evas_event_freeze(evas_object_evas_get(obj));
779 elm_genlist_item_subitems_clear(it);
780 if (it->wd->show_item == it) it->wd->show_item = NULL;
781 if (it->realized) elm_gen_item_unrealize(it, EINA_FALSE);
782 if (it->item->block) _item_block_del(it);
783 if (it->item->queued)
784 it->wd->queue = eina_list_remove(it->wd->queue, it);
785 if (it->wd->anchor_item == it)
787 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
788 if (!it->wd->anchor_item)
789 it->wd->anchor_item = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
792 it->parent->item->items = eina_list_remove(it->parent->item->items, it);
793 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
794 elm_gen_item_del_serious(it);
795 evas_event_thaw(evas_object_evas_get(obj));
796 evas_event_thaw_eval(evas_object_evas_get(obj));
800 _clear_cb(Widget_Data *wd)
802 wd->anchor_item = NULL;
805 Item_Block *itb = (Item_Block *)(wd->blocks);
807 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
808 if (itb->items) eina_list_free(itb->items);
811 if (wd->queue_idle_enterer)
813 ecore_idle_enterer_del(wd->queue_idle_enterer);
814 wd->queue_idle_enterer = NULL;
816 if (wd->must_recalc_idler)
818 ecore_idler_del(wd->must_recalc_idler);
819 wd->must_recalc_idler = NULL;
821 if (wd->queue) wd->queue = eina_list_free(wd->queue);
822 if (wd->reorder_move_animator)
824 ecore_animator_del(wd->reorder_move_animator);
825 wd->reorder_move_animator = NULL;
827 wd->show_item = NULL;
828 wd->reorder_old_pan_y = 0;
832 _item_unselect(Elm_Gen_Item *it)
834 if ((it->delete_me) || (!it->selected)) return;
835 it->selected = EINA_FALSE;
836 it->wd->selected = eina_list_remove(it->wd->selected, it);
837 evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
841 _mouse_move(void *data,
842 Evas *evas __UNUSED__,
846 Elm_Gen_Item *it = data;
847 Evas_Event_Mouse_Move *ev = event_info;
848 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
849 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
851 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
853 if (!it->wd->on_hold)
855 it->wd->on_hold = EINA_TRUE;
856 if (!it->wd->wasselected)
858 _item_unhighlight(it);
863 if (it->wd->multitouched)
865 it->wd->cur_x = ev->cur.canvas.x;
866 it->wd->cur_y = ev->cur.canvas.y;
869 if ((it->dragging) && (it->down))
871 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
874 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
875 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
876 if (abs((it->wd->history[it->wd->movements].x -
877 it->wd->history[0].x)) > 40)
878 it->wd->swipe = EINA_TRUE;
884 ecore_timer_del(it->long_timer);
885 it->long_timer = NULL;
887 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
890 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
894 ecore_timer_del(it->long_timer);
895 it->long_timer = NULL;
897 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
899 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
900 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
902 if (!it->wd->reorder_start_y)
903 it->wd->reorder_start_y = it->item->block->y + it->y;
907 else if (it_scrl_y + it->wd->reorder_it->item->h > oy + oh)
908 y_pos = oy + oh - it->wd->reorder_it->item->h;
912 _item_position(it, VIEW(it), it->item->scrl_x, y_pos);
914 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
915 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
919 if (!it->display_only)
920 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
921 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
922 x = ev->cur.canvas.x - x;
923 y = ev->cur.canvas.y - y;
926 if (adx < 0) adx = -dx;
929 if (ady < 0) ady = -dy;
932 if ((adx > minw) || (ady > minh))
934 it->dragging = EINA_TRUE;
937 ecore_timer_del(it->long_timer);
938 it->long_timer = NULL;
940 if (!it->wd->wasselected)
942 _item_unhighlight(it);
948 evas_object_smart_callback_call(WIDGET(it),
949 SIG_DRAG_START_UP, it);
953 evas_object_smart_callback_call(WIDGET(it),
954 SIG_DRAG_START_LEFT, it);
956 evas_object_smart_callback_call(WIDGET(it),
957 SIG_DRAG_START_RIGHT, it);
963 evas_object_smart_callback_call(WIDGET(it),
964 SIG_DRAG_START_DOWN, it);
968 evas_object_smart_callback_call(WIDGET(it),
969 SIG_DRAG_START_LEFT, it);
971 evas_object_smart_callback_call(WIDGET(it),
972 SIG_DRAG_START_RIGHT, it);
979 _long_press(void *data)
981 Elm_Gen_Item *it = data, *it_tmp;
984 it->long_timer = NULL;
985 if ((it->disabled) || (it->dragging) || (it->display_only))
986 return ECORE_CALLBACK_CANCEL;
987 it->wd->longpressed = EINA_TRUE;
988 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
989 if ((it->wd->reorder_mode) && (!it->group))
991 it->wd->reorder_it = it;
992 it->wd->reorder_start_y = 0;
994 evas_object_raise(VIEW(it));
995 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
996 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
998 list = elm_genlist_realized_items_get(it->wd->obj);
999 EINA_LIST_FOREACH(list, l, it_tmp)
1001 if (it != it_tmp) _item_unselect(it_tmp);
1003 if (elm_genlist_item_expanded_get(it))
1005 elm_genlist_item_expanded_set(it, EINA_FALSE);
1006 return ECORE_CALLBACK_RENEW;
1008 edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
1010 return ECORE_CALLBACK_CANCEL;
1014 _swipe(Elm_Gen_Item *it)
1019 if ((it->display_only) || (it->disabled)) return;
1020 it->wd->swipe = EINA_FALSE;
1021 for (i = 0; i < it->wd->movements; i++)
1023 sum += it->wd->history[i].x;
1024 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1027 sum /= it->wd->movements;
1028 if (abs(sum - it->wd->history[0].x) <= 10) return;
1029 evas_object_smart_callback_call(WIDGET(it), SIG_SWIPE, it);
1033 _swipe_cancel(void *data)
1035 Elm_Gen_Item *it = data;
1037 if (!it) return ECORE_CALLBACK_CANCEL;
1038 it->wd->swipe = EINA_FALSE;
1039 it->wd->movements = 0;
1040 return ECORE_CALLBACK_RENEW;
1044 _multi_cancel(void *data)
1046 Widget_Data *wd = data;
1048 if (!wd) return ECORE_CALLBACK_CANCEL;
1049 wd->multi_timeout = EINA_TRUE;
1050 return ECORE_CALLBACK_RENEW;
1054 _multi_touch_gesture_eval(void *data)
1056 Elm_Gen_Item *it = data;
1058 it->wd->multitouched = EINA_FALSE;
1059 if (it->wd->multi_timer)
1061 ecore_timer_del(it->wd->multi_timer);
1062 it->wd->multi_timer = NULL;
1064 if (it->wd->multi_timeout)
1066 it->wd->multi_timeout = EINA_FALSE;
1070 Evas_Coord minw = 0, minh = 0;
1071 Evas_Coord off_x, off_y, off_mx, off_my;
1073 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1074 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1075 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1076 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1077 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1079 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1081 if ((off_x + off_mx) > (off_y + off_my))
1083 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1084 evas_object_smart_callback_call(WIDGET(it),
1085 SIG_MULTI_SWIPE_RIGHT, it);
1086 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1087 evas_object_smart_callback_call(WIDGET(it),
1088 SIG_MULTI_SWIPE_LEFT, it);
1089 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1090 evas_object_smart_callback_call(WIDGET(it),
1091 SIG_MULTI_PINCH_OUT, it);
1093 evas_object_smart_callback_call(WIDGET(it),
1094 SIG_MULTI_PINCH_IN, it);
1098 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1099 evas_object_smart_callback_call(WIDGET(it),
1100 SIG_MULTI_SWIPE_DOWN, it);
1101 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1102 evas_object_smart_callback_call(WIDGET(it),
1103 SIG_MULTI_SWIPE_UP, it);
1104 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1105 evas_object_smart_callback_call(WIDGET(it),
1106 SIG_MULTI_PINCH_OUT, it);
1108 evas_object_smart_callback_call(WIDGET(it),
1109 SIG_MULTI_PINCH_IN, it);
1112 it->wd->multi_timeout = EINA_FALSE;
1116 _multi_down(void *data,
1117 Evas *evas __UNUSED__,
1118 Evas_Object *obj __UNUSED__,
1121 Elm_Gen_Item *it = data;
1122 Evas_Event_Multi_Down *ev = event_info;
1124 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1125 it->wd->multi_device = ev->device;
1126 it->wd->multi_down = EINA_TRUE;
1127 it->wd->multitouched = EINA_TRUE;
1128 it->wd->prev_mx = ev->canvas.x;
1129 it->wd->prev_my = ev->canvas.y;
1130 if (!it->wd->wasselected)
1132 _item_unhighlight(it);
1135 it->wd->wasselected = EINA_FALSE;
1136 it->wd->longpressed = EINA_FALSE;
1139 ecore_timer_del(it->long_timer);
1140 it->long_timer = NULL;
1144 it->dragging = EINA_FALSE;
1145 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1147 if (it->item->swipe_timer)
1149 ecore_timer_del(it->item->swipe_timer);
1150 it->item->swipe_timer = NULL;
1152 if (it->wd->on_hold)
1154 it->wd->swipe = EINA_FALSE;
1155 it->wd->movements = 0;
1156 it->wd->on_hold = EINA_FALSE;
1161 _multi_up(void *data,
1162 Evas *evas __UNUSED__,
1163 Evas_Object *obj __UNUSED__,
1166 Elm_Gen_Item *it = data;
1167 Evas_Event_Multi_Up *ev = event_info;
1169 if (it->wd->multi_device != ev->device) return;
1170 it->wd->multi_device = 0;
1171 it->wd->multi_down = EINA_FALSE;
1172 if (it->wd->mouse_down) return;
1173 _multi_touch_gesture_eval(data);
1177 _multi_move(void *data,
1178 Evas *evas __UNUSED__,
1179 Evas_Object *obj __UNUSED__,
1182 Elm_Gen_Item *it = data;
1183 Evas_Event_Multi_Move *ev = event_info;
1185 if (it->wd->multi_device != ev->device) return;
1186 it->wd->cur_mx = ev->cur.canvas.x;
1187 it->wd->cur_my = ev->cur.canvas.y;
1191 _mouse_down(void *data,
1192 Evas *evas __UNUSED__,
1196 Elm_Gen_Item *it = data;
1197 Evas_Event_Mouse_Down *ev = event_info;
1200 if (ev->button != 1) return;
1201 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1203 it->wd->on_hold = EINA_TRUE;
1206 it->down = EINA_TRUE;
1207 it->dragging = EINA_FALSE;
1208 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1209 it->dx = ev->canvas.x - x;
1210 it->dy = ev->canvas.y - y;
1211 it->wd->mouse_down = EINA_TRUE;
1212 if (!it->wd->multitouched)
1214 it->wd->prev_x = ev->canvas.x;
1215 it->wd->prev_y = ev->canvas.y;
1216 it->wd->multi_timeout = EINA_FALSE;
1217 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1218 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1220 it->wd->longpressed = EINA_FALSE;
1221 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1222 else it->wd->on_hold = EINA_FALSE;
1223 if (it->wd->on_hold) return;
1224 it->wd->wasselected = it->selected;
1225 _item_highlight(it);
1226 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1227 if ((!it->disabled) && (!it->display_only))
1229 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1230 evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
1232 if (it->long_timer) ecore_timer_del(it->long_timer);
1233 if (it->item->swipe_timer) ecore_timer_del(it->item->swipe_timer);
1234 it->item->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1236 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1239 it->long_timer = NULL;
1240 it->wd->swipe = EINA_FALSE;
1241 it->wd->movements = 0;
1245 _mouse_up(void *data,
1246 Evas *evas __UNUSED__,
1247 Evas_Object *obj __UNUSED__,
1250 Elm_Gen_Item *it = data;
1251 Evas_Event_Mouse_Up *ev = event_info;
1252 Eina_Bool dragged = EINA_FALSE;
1254 if (ev->button != 1) return;
1255 it->down = EINA_FALSE;
1256 it->wd->mouse_down = EINA_FALSE;
1257 if (it->wd->multitouched)
1259 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1260 if (it->wd->multi_down) return;
1261 _multi_touch_gesture_eval(data);
1264 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1265 else it->wd->on_hold = EINA_FALSE;
1268 ecore_timer_del(it->long_timer);
1269 it->long_timer = NULL;
1273 it->dragging = EINA_FALSE;
1274 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
1277 if (it->item->swipe_timer)
1279 ecore_timer_del(it->item->swipe_timer);
1280 it->item->swipe_timer = NULL;
1282 if (it->wd->multi_timer)
1284 ecore_timer_del(it->wd->multi_timer);
1285 it->wd->multi_timer = NULL;
1286 it->wd->multi_timeout = EINA_FALSE;
1288 if (it->wd->on_hold)
1290 if (it->wd->swipe) _swipe(data);
1291 it->wd->longpressed = EINA_FALSE;
1292 it->wd->on_hold = EINA_FALSE;
1295 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1297 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1299 if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
1301 if (it_scrl_y <= it->wd->reorder_rel->item->scrl_y)
1302 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1304 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1308 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1309 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1311 edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
1312 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1313 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1314 elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
1316 if (it->wd->longpressed)
1318 it->wd->longpressed = EINA_FALSE;
1319 if (!it->wd->wasselected)
1321 _item_unhighlight(it);
1324 it->wd->wasselected = EINA_FALSE;
1329 if (it->want_unrealize)
1331 elm_gen_item_unrealize(it, EINA_FALSE);
1332 if (it->item->block->want_unrealize)
1333 _item_block_unrealize(it->item->block);
1336 if ((it->disabled) || (dragged) || (it->display_only)) return;
1337 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1342 _item_highlight(it);
1347 _item_unhighlight(it);
1355 Widget_Data *wd = it->wd;
1358 while (wd->selected)
1360 _item_unhighlight(wd->selected->data);
1361 _item_unselect(wd->selected->data);
1367 const Eina_List *l, *l_next;
1370 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1373 _item_unhighlight(it2);
1374 _item_unselect(it2);
1376 //_item_highlight(it);
1379 _item_highlight(it);
1385 _signal_expand_toggle(void *data,
1386 Evas_Object *obj __UNUSED__,
1387 const char *emission __UNUSED__,
1388 const char *source __UNUSED__)
1390 Elm_Gen_Item *it = data;
1392 if (it->item->expanded)
1393 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1395 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1399 _signal_expand(void *data,
1400 Evas_Object *obj __UNUSED__,
1401 const char *emission __UNUSED__,
1402 const char *source __UNUSED__)
1404 Elm_Gen_Item *it = data;
1406 if (!it->item->expanded)
1407 evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
1411 _signal_contract(void *data,
1412 Evas_Object *obj __UNUSED__,
1413 const char *emission __UNUSED__,
1414 const char *source __UNUSED__)
1416 Elm_Gen_Item *it = data;
1418 if (it->item->expanded)
1419 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
1423 _scr_hold_timer_cb(void *data)
1425 if (!data) return ECORE_CALLBACK_CANCEL;
1426 Widget_Data *wd = data;
1427 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1428 wd->scr_hold_timer = NULL;
1429 return ECORE_CALLBACK_CANCEL;
1433 _mode_finished_signal_cb(void *data,
1435 const char *emission __UNUSED__,
1436 const char *source __UNUSED__)
1440 Elm_Gen_Item *it = data;
1441 if ((it->delete_me) || (!it->realized) || (!it->item->mode_view)) return;
1443 Evas *te = evas_object_evas_get(obj);
1445 evas_event_freeze(te);
1446 it->item->nocache = EINA_FALSE;
1447 _mode_item_unrealize(it);
1448 if (it->item->group_item)
1449 evas_object_raise(it->item->VIEW(group_item));
1450 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1451 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1452 evas_event_thaw(te);
1453 evas_event_thaw_eval(te);
1457 _item_cache_clean(Widget_Data *wd)
1459 evas_event_freeze(evas_object_evas_get(wd->obj));
1460 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1464 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1465 wd->item_cache = eina_inlist_remove(wd->item_cache,
1466 wd->item_cache->last);
1467 wd->item_cache_count--;
1468 if (itc->spacer) evas_object_del(itc->spacer);
1469 if (itc->base_view) evas_object_del(itc->base_view);
1470 if (itc->item_style) eina_stringshare_del(itc->item_style);
1473 evas_event_thaw(evas_object_evas_get(wd->obj));
1474 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1478 _item_cache_zero(Widget_Data *wd)
1480 int pmax = wd->item_cache_max;
1481 wd->item_cache_max = 0;
1482 _item_cache_clean(wd);
1483 wd->item_cache_max = pmax;
1487 _item_cache_add(Elm_Gen_Item *it)
1491 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1492 if (it->wd->item_cache_max <= 0)
1494 evas_object_del(VIEW(it));
1496 evas_object_del(it->spacer);
1498 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1499 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1503 it->wd->item_cache_count++;
1504 itc = calloc(1, sizeof(Item_Cache));
1505 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1506 EINA_INLIST_GET(itc));
1507 itc->spacer = it->spacer;
1509 itc->base_view = VIEW(it);
1511 evas_object_hide(itc->base_view);
1512 evas_object_move(itc->base_view, -9999, -9999);
1513 itc->item_style = eina_stringshare_add(it->itc->item_style);
1514 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1515 itc->compress = (it->wd->compress);
1516 itc->selected = it->selected;
1517 itc->disabled = it->disabled;
1518 itc->expanded = it->item->expanded;
1521 ecore_timer_del(it->long_timer);
1522 it->long_timer = NULL;
1524 if (it->item->swipe_timer)
1526 ecore_timer_del(it->item->swipe_timer);
1527 it->item->swipe_timer = NULL;
1529 // FIXME: other callbacks?
1530 edje_object_signal_callback_del_full(itc->base_view,
1531 "elm,action,expand,toggle",
1532 "elm", _signal_expand_toggle, it);
1533 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1535 _signal_expand, it);
1536 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1537 "elm", _signal_contract, it);
1538 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1540 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1542 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1544 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1546 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1548 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1550 _item_cache_clean(it->wd);
1551 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1552 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1556 _item_cache_find(Elm_Gen_Item *it)
1561 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1562 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1564 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1566 if ((itc->tree == tree) &&
1567 (itc->compress == it->wd->compress) &&
1568 (!strcmp(it->itc->item_style, itc->item_style)))
1570 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1571 EINA_INLIST_GET(itc));
1572 it->wd->item_cache_count--;
1580 _elm_genlist_item_odd_even_update(Elm_Gen_Item *it)
1582 if (!it->item->nostacking)
1584 if ((it->item->order_num_in & 0x1) ^ it->item->stacking_even)
1585 evas_object_lower(VIEW(it));
1587 evas_object_raise(VIEW(it));
1590 if (it->item->order_num_in & 0x1)
1591 edje_object_signal_emit(VIEW(it), "elm,state,odd", "elm");
1593 edje_object_signal_emit(VIEW(it), "elm,state,even", "elm");
1597 _elm_genlist_item_state_update(Elm_Gen_Item *it, Item_Cache *itc)
1601 if (it->selected != itc->selected)
1604 edje_object_signal_emit(VIEW(it),
1605 "elm,state,selected", "elm");
1607 if (it->disabled != itc->disabled)
1610 edje_object_signal_emit(VIEW(it),
1611 "elm,state,disabled", "elm");
1613 if (it->item->expanded != itc->expanded)
1615 if (it->item->expanded)
1616 edje_object_signal_emit(VIEW(it),
1617 "elm,state,expanded", "elm");
1623 edje_object_signal_emit(VIEW(it),
1624 "elm,state,selected", "elm");
1626 edje_object_signal_emit(VIEW(it),
1627 "elm,state,disabled", "elm");
1628 if (it->item->expanded)
1629 edje_object_signal_emit(VIEW(it),
1630 "elm,state,expanded", "elm");
1635 _item_cache_free(Item_Cache *itc)
1637 if (itc->spacer) evas_object_del(itc->spacer);
1638 if (itc->base_view) evas_object_del(itc->base_view);
1639 if (itc->item_style) eina_stringshare_del(itc->item_style);
1644 _item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1646 Elm_Gen_Item *it = event_info;
1648 if (it->wd->last_selected_item == it)
1649 it->wd->last_selected_item = NULL;
1653 _item_label_realize(Elm_Gen_Item *it,
1654 Evas_Object *target,
1658 if (it->itc->func.label_get)
1663 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1664 EINA_LIST_FOREACH(*source, l, key)
1666 if (parts && fnmatch(parts, key, FNM_PERIOD))
1669 char *s = it->itc->func.label_get
1670 ((void *)it->base.data, WIDGET(it), key);
1674 edje_object_part_text_set(target, key, s);
1679 edje_object_part_text_set(target, key, "");
1686 _item_content_unrealize(Elm_Gen_Item *it,
1687 Evas_Object *target,
1691 Eina_List *res = it->content_objs;
1693 if (it->itc->func.content_get)
1697 Evas_Object *ic = NULL;
1699 EINA_LIST_FOREACH(*source, l, key)
1701 if (parts && fnmatch(parts, key, FNM_PERIOD))
1704 ic = edje_object_part_swallow_get(target, key);
1707 res = eina_list_remove(res, ic);
1708 edje_object_part_unswallow(target, ic);
1709 evas_object_del(ic);
1718 _item_content_realize(Elm_Gen_Item *it,
1719 Evas_Object *target,
1723 Eina_List *res = NULL;
1725 if (it->itc->func.content_get)
1729 Evas_Object *ic = NULL;
1731 *source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
1733 if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
1734 res = it->content_objs;
1736 EINA_LIST_FOREACH(*source, l, key)
1738 if (parts && fnmatch(parts, key, FNM_PERIOD))
1741 if (it->itc->func.content_get)
1742 ic = it->itc->func.content_get
1743 ((void *)it->base.data, WIDGET(it), key);
1746 res = eina_list_append(res, ic);
1747 edje_object_part_swallow(target, key, ic);
1748 evas_object_show(ic);
1749 elm_widget_sub_object_add(WIDGET(it), ic);
1751 elm_widget_disabled_set(ic, EINA_TRUE);
1760 _item_state_realize(Elm_Gen_Item *it,
1761 Evas_Object *target,
1765 if (it->itc->func.state_get)
1771 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1772 EINA_LIST_FOREACH(*source, l, key)
1774 if (parts && fnmatch(parts, key, FNM_PERIOD))
1777 Eina_Bool on = it->itc->func.state_get
1778 ((void *)it->base.data, WIDGET(it), key);
1782 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1783 edje_object_signal_emit(target, buf, "elm");
1787 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1788 edje_object_signal_emit(target, buf, "elm");
1795 _item_realize(Elm_Gen_Item *it,
1800 const char *treesize;
1802 int depth, tsize = 20;
1803 Item_Cache *itc = NULL;
1805 if (it->delete_me) return;
1806 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1809 if (it->item->order_num_in != in)
1811 it->item->order_num_in = in;
1812 _elm_genlist_item_odd_even_update(it);
1813 _elm_genlist_item_state_update(it, NULL);
1815 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1816 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1819 it->item->order_num_in = in;
1821 if (it->item->nocache)
1822 it->item->nocache = EINA_FALSE;
1824 itc = _item_cache_find(it);
1827 VIEW(it) = itc->base_view;
1828 itc->base_view = NULL;
1829 it->spacer = itc->spacer;
1834 const char *stacking_even;
1835 const char *stacking;
1837 VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
1838 edje_object_scale_set(VIEW(it),
1839 elm_widget_scale_get(WIDGET(it)) *
1840 _elm_config->scale);
1841 evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
1842 elm_widget_sub_object_add(WIDGET(it), VIEW(it));
1844 if (it->item->flags & ELM_GENLIST_ITEM_SUBITEMS)
1845 strncpy(buf, "tree", sizeof(buf));
1846 else strncpy(buf, "item", sizeof(buf));
1847 if (it->wd->compress)
1848 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1850 strncat(buf, "/", sizeof(buf) - strlen(buf));
1851 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1853 _elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
1854 elm_widget_style_get(WIDGET(it)));
1856 stacking_even = edje_object_data_get(VIEW(it), "stacking_even");
1857 if (!stacking_even) stacking_even = "above";
1858 it->item->stacking_even = !!strcmp("above", stacking_even);
1860 stacking = edje_object_data_get(VIEW(it), "stacking");
1861 if (!stacking) stacking = "yes";
1862 it->item->nostacking = !!strcmp("yes", stacking);
1864 edje_object_mirrored_set(VIEW(it),
1865 elm_widget_mirrored_get(WIDGET(it)));
1867 evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1868 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1869 elm_widget_sub_object_add(WIDGET(it), it->spacer);
1872 _elm_genlist_item_odd_even_update(it);
1874 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1876 if (!it2->parent->group) depth += 1;
1878 it->item->expanded_depth = depth;
1879 treesize = edje_object_data_get(VIEW(it), "treesize");
1880 if (treesize) tsize = atoi(treesize);
1881 evas_object_size_hint_min_set(it->spacer,
1882 (depth * tsize) * _elm_config->scale, 1);
1883 edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
1886 edje_object_signal_callback_add(VIEW(it),
1887 "elm,action,expand,toggle",
1888 "elm", _signal_expand_toggle, it);
1889 edje_object_signal_callback_add(VIEW(it), "elm,action,expand",
1890 "elm", _signal_expand, it);
1891 edje_object_signal_callback_add(VIEW(it), "elm,action,contract",
1892 "elm", _signal_contract, it);
1893 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1895 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1897 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1899 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_DOWN,
1901 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_UP,
1903 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
1906 _elm_genlist_item_state_update(it, itc);
1909 if ((calc) && (it->wd->homogeneous) &&
1910 ((it->wd->item_width) ||
1911 ((it->wd->item_width) && (it->wd->group_item_width))))
1913 /* homogenous genlist shortcut */
1914 if (!it->item->mincalcd)
1918 it->item->w = it->item->minw = it->wd->group_item_width;
1919 it->item->h = it->item->minh = it->wd->group_item_height;
1923 it->item->w = it->item->minw = it->wd->item_width;
1924 it->item->h = it->item->minh = it->wd->item_height;
1926 it->item->mincalcd = EINA_TRUE;
1931 /* FIXME: If you see that assert, please notify us and we
1932 will clean our mess */
1933 assert(eina_list_count(it->content_objs) == 0);
1935 _item_label_realize(it, VIEW(it), &it->labels, NULL);
1936 it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
1937 _item_state_realize(it, VIEW(it), &it->states, NULL);
1939 if (!it->item->mincalcd)
1941 Evas_Coord mw = -1, mh = -1;
1943 if (!it->display_only)
1944 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1945 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1946 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
1948 if (!it->display_only)
1949 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1950 it->item->w = it->item->minw = mw;
1951 it->item->h = it->item->minh = mh;
1952 it->item->mincalcd = EINA_TRUE;
1954 if ((!it->wd->group_item_width) && (it->group))
1956 it->wd->group_item_width = mw;
1957 it->wd->group_item_height = mh;
1959 else if ((!it->wd->item_width) && (it->item->flags == ELM_GENLIST_ITEM_NONE))
1961 it->wd->item_width = mw;
1962 it->wd->item_height = mh;
1965 if (!calc) evas_object_show(VIEW(it));
1968 if (it->tooltip.content_cb)
1970 elm_widget_item_tooltip_content_cb_set(it,
1971 it->tooltip.content_cb,
1972 it->tooltip.data, NULL);
1973 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1974 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
1977 if (it->mouse_cursor)
1978 elm_widget_item_cursor_set(it, it->mouse_cursor);
1980 it->realized = EINA_TRUE;
1981 it->want_unrealize = EINA_FALSE;
1983 if (itc) _item_cache_free(itc);
1984 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1985 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1987 evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1988 edje_object_message_signal_process(VIEW(it));
1992 _item_unrealize_cb(Elm_Gen_Item *it)
1994 if (it->item->nocache)
1996 evas_object_del(VIEW(it));
1998 evas_object_del(it->spacer);
2003 edje_object_mirrored_set(VIEW(it),
2004 elm_widget_mirrored_get(WIDGET(it)));
2005 edje_object_scale_set(VIEW(it),
2006 elm_widget_scale_get(WIDGET(it))
2007 * _elm_config->scale);
2008 _item_cache_add(it);
2011 _mode_item_unrealize(it);
2013 it->realized = EINA_FALSE;
2014 it->want_unrealize = EINA_FALSE;
2018 _item_block_recalc(Item_Block *itb,
2024 Evas_Coord minw = 0, minh = 0;
2025 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2028 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2030 EINA_LIST_FOREACH(itb->items, l, it)
2032 if (it->delete_me) continue;
2033 showme |= it->item->showme;
2038 if (!it->item->mincalcd) changed = EINA_TRUE;
2041 _item_realize(it, in, EINA_TRUE);
2042 elm_gen_item_unrealize(it, EINA_TRUE);
2047 _item_realize(it, in, EINA_TRUE);
2048 elm_gen_item_unrealize(it, EINA_TRUE);
2052 _item_realize(it, in, EINA_FALSE);
2053 minh += it->item->minh;
2054 if (minw < it->item->minw) minw = it->item->minw;
2062 itb->changed = EINA_FALSE;
2063 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2064 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2069 _item_block_realize(Item_Block *itb)
2071 if (itb->realized) return;
2072 itb->realized = EINA_TRUE;
2073 itb->want_unrealize = EINA_FALSE;
2077 _item_block_unrealize(Item_Block *itb)
2081 Eina_Bool dragging = EINA_FALSE;
2083 if (!itb->realized) return;
2084 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2085 EINA_LIST_FOREACH(itb->items, l, it)
2091 dragging = EINA_TRUE;
2092 it->want_unrealize = EINA_TRUE;
2095 elm_gen_item_unrealize(it, EINA_FALSE);
2100 itb->realized = EINA_FALSE;
2101 itb->want_unrealize = EINA_TRUE;
2104 itb->want_unrealize = EINA_FALSE;
2105 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2106 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2110 _get_space_for_reorder_item(Elm_Gen_Item *it)
2112 Evas_Coord rox, roy, row, roh, oy, oh;
2113 Eina_Bool top = EINA_FALSE;
2114 Elm_Gen_Item *reorder_it = it->wd->reorder_it;
2115 if (!reorder_it) return 0;
2117 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2118 evas_object_geometry_get(it->wd->VIEW(reorder_it), &rox, &roy, &row, &roh);
2120 if ((it->wd->reorder_start_y < it->item->block->y) &&
2121 (roy - oy + (roh / 2) >= it->item->block->y - it->wd->pan_y))
2123 it->item->block->reorder_offset = it->wd->reorder_it->item->h * -1;
2124 if (it->item->block->count == 1)
2125 it->wd->reorder_rel = it;
2127 else if ((it->wd->reorder_start_y >= it->item->block->y) &&
2128 (roy - oy + (roh / 2) <= it->item->block->y - it->wd->pan_y))
2130 it->item->block->reorder_offset = it->wd->reorder_it->item->h;
2133 it->item->block->reorder_offset = 0;
2135 it->item->scrl_y += it->item->block->reorder_offset;
2137 top = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2138 rox, roy + (roh / 2), row, 1));
2141 it->wd->reorder_rel = it;
2142 it->item->scrl_y += it->wd->reorder_it->item->h;
2143 return it->wd->reorder_it->item->h;
2150 _reorder_move_animator_cb(void *data)
2152 Elm_Gen_Item *it = data;
2153 Eina_Bool down = EINA_FALSE;
2155 int y, dy = it->item->h / 10 * _elm_config->scale, diff;
2157 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2159 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2162 diff = abs(it->item->old_scrl_y - it->item->scrl_y);
2163 if (diff > it->item->h) y = diff / 2;
2165 if (it->item->old_scrl_y < it->item->scrl_y)
2167 it->item->old_scrl_y += y;
2170 else if (it->item->old_scrl_y > it->item->scrl_y)
2172 it->item->old_scrl_y -= y;
2175 _item_position(it, VIEW(it), it->item->scrl_x, it->item->old_scrl_y);
2176 _group_items_recalc(it->wd);
2178 if ((it->wd->reorder_pan_move) ||
2179 (down && it->item->old_scrl_y >= it->item->scrl_y) ||
2180 (!down && it->item->old_scrl_y <= it->item->scrl_y))
2182 it->item->old_scrl_y = it->item->scrl_y;
2183 it->item->move_effect_enabled = EINA_FALSE;
2184 it->wd->reorder_move_animator = NULL;
2185 return ECORE_CALLBACK_CANCEL;
2187 return ECORE_CALLBACK_RENEW;
2191 _item_position(Elm_Gen_Item *it,
2199 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2200 evas_object_resize(view, it->item->w, it->item->h);
2201 evas_object_move(view, it_x, it_y);
2202 evas_object_show(view);
2203 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2204 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2208 _item_block_position(Item_Block *itb,
2214 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2215 Eina_Bool vis = EINA_FALSE;
2217 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2218 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2219 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2221 EINA_LIST_FOREACH(itb->items, l, it)
2223 if (it->delete_me) continue;
2224 else if (it->wd->reorder_it == it) continue;
2227 it->item->w = itb->w;
2228 it->item->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2229 it->item->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2231 vis = (ELM_RECTS_INTERSECT(it->item->scrl_x, it->item->scrl_y, it->item->w, it->item->h,
2232 cvx, cvy, cvw, cvh));
2235 if ((itb->realized) && (!it->realized))
2237 if (vis) _item_realize(it, in, EINA_FALSE);
2243 if (it->wd->reorder_mode)
2244 y += _get_space_for_reorder_item(it);
2245 git = it->item->group_item;
2248 if (git->item->scrl_y < oy)
2249 git->item->scrl_y = oy;
2250 if ((git->item->scrl_y + git->item->h) > (it->item->scrl_y + it->item->h))
2251 git->item->scrl_y = (it->item->scrl_y + it->item->h) - git->item->h;
2252 git->item->want_realize = EINA_TRUE;
2254 if ((it->wd->reorder_it) && (it->item->old_scrl_y != it->item->scrl_y))
2256 if (!it->item->move_effect_enabled)
2258 it->item->move_effect_enabled = EINA_TRUE;
2259 it->wd->reorder_move_animator =
2261 _reorder_move_animator_cb, it);
2264 if (!it->item->move_effect_enabled)
2266 if (it->item->mode_view)
2267 _item_position(it, it->item->mode_view, it->item->scrl_x,
2270 _item_position(it, VIEW(it), it->item->scrl_x,
2272 it->item->old_scrl_y = it->item->scrl_y;
2277 if (!it->dragging) elm_gen_item_unrealize(it, EINA_FALSE);
2284 if (vis) it->item->want_realize = EINA_TRUE;
2288 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2289 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2293 _group_items_recalc(void *data)
2295 Widget_Data *wd = data;
2299 evas_event_freeze(evas_object_evas_get(wd->obj));
2300 EINA_LIST_FOREACH(wd->group_items, l, git)
2302 if (git->item->want_realize)
2305 _item_realize(git, 0, EINA_FALSE);
2306 evas_object_resize(VIEW(git), wd->minw, git->item->h);
2307 evas_object_move(VIEW(git), git->item->scrl_x, git->item->scrl_y);
2308 evas_object_show(VIEW(git));
2309 evas_object_raise(VIEW(git));
2311 else if (!git->item->want_realize && git->realized)
2314 elm_gen_item_unrealize(git, EINA_FALSE);
2317 evas_event_thaw(evas_object_evas_get(wd->obj));
2318 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2322 _must_recalc_idler(void *data)
2324 Widget_Data *wd = data;
2325 if (wd->calc_job) ecore_job_del(wd->calc_job);
2326 wd->calc_job = ecore_job_add(_calc_job, wd);
2327 wd->must_recalc_idler = NULL;
2328 return ECORE_CALLBACK_CANCEL;
2332 _calc_job(void *data)
2334 Widget_Data *wd = data;
2335 Item_Block *itb, *chb = NULL;
2336 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2338 Eina_Bool minw_change = EINA_FALSE;
2339 Eina_Bool did_must_recalc = EINA_FALSE;
2342 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2346 evas_event_freeze(evas_object_evas_get(wd->obj));
2347 EINA_INLIST_FOREACH(wd->blocks, itb)
2349 Eina_Bool showme = EINA_FALSE;
2352 showme = itb->showme;
2353 itb->showme = EINA_FALSE;
2356 if (itb->realized) _item_block_unrealize(itb);
2358 if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
2360 if (itb->must_recalc)
2364 EINA_LIST_FOREACH(itb->items, l, it)
2365 if (it->item->mincalcd) it->item->mincalcd = EINA_FALSE;
2366 itb->changed = EINA_TRUE;
2367 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2368 itb->must_recalc = EINA_FALSE;
2370 if (itb->realized) _item_block_unrealize(itb);
2371 showme = _item_block_recalc(itb, in, EINA_FALSE);
2377 if (minw == -1) minw = itb->minw;
2378 else if ((!itb->must_recalc) && (minw < itb->minw))
2381 minw_change = EINA_TRUE;
2387 if ((showme) && (wd->show_item) && (!wd->show_item->item->queued))
2389 wd->show_item->item->showme = EINA_FALSE;
2391 elm_smart_scroller_region_bring_in(wd->scr,
2393 wd->show_item->item->block->x,
2395 wd->show_item->item->block->y,
2396 wd->show_item->item->block->w,
2397 wd->show_item->item->h);
2399 elm_smart_scroller_child_region_show(wd->scr,
2401 wd->show_item->item->block->x,
2403 wd->show_item->item->block->y,
2404 wd->show_item->item->block->w,
2405 wd->show_item->item->h);
2406 wd->show_item = NULL;
2411 EINA_INLIST_FOREACH(wd->blocks, itb)
2417 if ((chb) && (EINA_INLIST_GET(chb)->next))
2419 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2421 if (itb->realized) _item_block_unrealize(itb);
2424 wd->realminw = minw;
2425 if (minw < wd->w) minw = wd->w;
2426 if ((minw != wd->minw) || (minh != wd->minh))
2430 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2431 _sizing_eval(wd->obj);
2432 if ((wd->anchor_item) && (wd->anchor_item->item->block) && (!wd->auto_scroll_enabled))
2437 it = wd->anchor_item;
2438 it_y = wd->anchor_y;
2439 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2440 it->item->block->y + it->y + it_y);
2441 wd->anchor_item = it;
2442 wd->anchor_y = it_y;
2445 if (did_must_recalc)
2447 if (!wd->must_recalc_idler)
2448 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2450 wd->calc_job = NULL;
2451 evas_object_smart_changed(wd->pan_smart);
2452 evas_event_thaw(evas_object_evas_get(wd->obj));
2453 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2457 _update_job(void *data)
2459 Widget_Data *wd = data;
2463 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2465 wd->update_job = NULL;
2468 evas_event_freeze(evas_object_evas_get(wd->obj));
2469 EINA_INLIST_FOREACH(wd->blocks, itb)
2471 Evas_Coord itminw, itminh;
2478 _item_block_position(itb, num);
2482 recalc = EINA_FALSE;
2483 EINA_LIST_FOREACH(itb->items, l2, it)
2485 if (it->item->updateme)
2487 itminw = it->item->minw;
2488 itminh = it->item->minh;
2490 it->item->updateme = EINA_FALSE;
2493 elm_gen_item_unrealize(it, EINA_FALSE);
2494 _item_realize(it, num, EINA_FALSE);
2495 position = EINA_TRUE;
2499 _item_realize(it, num, EINA_TRUE);
2500 elm_gen_item_unrealize(it, EINA_TRUE);
2502 if ((it->item->minw != itminw) || (it->item->minh != itminh))
2507 itb->updateme = EINA_FALSE;
2510 position = EINA_TRUE;
2511 itb->changed = EINA_TRUE;
2512 _item_block_recalc(itb, num0, EINA_FALSE);
2513 _item_block_position(itb, num0);
2518 if (wd->calc_job) ecore_job_del(wd->calc_job);
2519 wd->calc_job = ecore_job_add(_calc_job, wd);
2521 evas_event_thaw(evas_object_evas_get(wd->obj));
2522 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2526 _pan_set(Evas_Object *obj,
2530 Pan *sd = evas_object_smart_data_get(obj);
2534 // Evas_Coord ow, oh;
2535 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2536 // ow = sd->wd->minw - ow;
2537 // if (ow < 0) ow = 0;
2538 // oh = sd->wd->minh - oh;
2539 // if (oh < 0) oh = 0;
2540 // if (x < 0) x = 0;
2541 // if (y < 0) y = 0;
2542 // if (x > ow) x = ow;
2543 // if (y > oh) y = oh;
2544 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2548 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2550 if ((itb->y + itb->h) > y)
2555 EINA_LIST_FOREACH(itb->items, l2, it)
2557 if ((itb->y + it->y) >= y)
2559 sd->wd->anchor_item = it;
2560 sd->wd->anchor_y = -(itb->y + it->y - y);
2567 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2571 _pan_get(Evas_Object *obj,
2575 Pan *sd = evas_object_smart_data_get(obj);
2578 if (x) *x = sd->wd->pan_x;
2579 if (y) *y = sd->wd->pan_y;
2583 _pan_max_get(Evas_Object *obj,
2587 Pan *sd = evas_object_smart_data_get(obj);
2591 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2592 ow = sd->wd->minw - ow;
2594 oh = sd->wd->minh - oh;
2601 _pan_min_get(Evas_Object *obj __UNUSED__,
2610 _pan_child_size_get(Evas_Object *obj,
2614 Pan *sd = evas_object_smart_data_get(obj);
2617 if (w) *w = sd->wd->minw;
2618 if (h) *h = sd->wd->minh;
2622 _pan_add(Evas_Object *obj)
2625 Evas_Object_Smart_Clipped_Data *cd;
2628 cd = evas_object_smart_data_get(obj);
2631 sd->__clipped_data = *cd;
2633 evas_object_smart_data_set(obj, sd);
2637 _pan_del(Evas_Object *obj)
2639 Pan *sd = evas_object_smart_data_get(obj);
2644 ecore_job_del(sd->resize_job);
2645 sd->resize_job = NULL;
2651 _pan_resize_job(void *data)
2655 _sizing_eval(sd->wd->obj);
2656 sd->resize_job = NULL;
2660 _pan_resize(Evas_Object *obj,
2664 Pan *sd = evas_object_smart_data_get(obj);
2668 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2669 if ((ow == w) && (oh == h)) return;
2670 if ((sd->wd->height_for_width) && (ow != w))
2673 if (sd->resize_job) ecore_job_del(sd->resize_job);
2674 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2676 sd->wd->pan_resized = EINA_TRUE;
2677 evas_object_smart_changed(obj);
2678 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2679 sd->wd->calc_job = NULL;
2681 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2682 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2687 _pan_calculate(Evas_Object *obj)
2689 Pan *sd = evas_object_smart_data_get(obj);
2691 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2697 evas_event_freeze(evas_object_evas_get(obj));
2699 if (sd->wd->pan_resized)
2702 sd->wd->pan_resized = EINA_FALSE;
2705 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2706 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2707 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2709 git->item->want_realize = EINA_FALSE;
2711 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2713 itb->w = sd->wd->minw;
2714 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2715 itb->y - sd->wd->pan_y + oy,
2717 cvx, cvy, cvw, cvh))
2719 if ((!itb->realized) || (itb->changed))
2720 _item_block_realize(itb);
2721 _item_block_position(itb, in);
2725 if (itb->realized) _item_block_unrealize(itb);
2729 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2730 _group_items_recalc(sd->wd);
2731 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2733 if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
2734 sd->wd->reorder_pan_move = EINA_TRUE;
2735 else sd->wd->reorder_pan_move = EINA_FALSE;
2736 evas_object_raise(sd->wd->VIEW(reorder_it));
2737 sd->wd->reorder_old_pan_y = sd->wd->pan_y;
2738 sd->wd->start_time = ecore_loop_time_get();
2740 _item_auto_scroll(sd->wd);
2741 evas_event_thaw(evas_object_evas_get(obj));
2742 evas_event_thaw_eval(evas_object_evas_get(obj));
2746 _pan_move(Evas_Object *obj,
2747 Evas_Coord x __UNUSED__,
2748 Evas_Coord y __UNUSED__)
2750 Pan *sd = evas_object_smart_data_get(obj);
2753 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2754 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2758 _hold_on(void *data __UNUSED__,
2760 void *event_info __UNUSED__)
2762 Widget_Data *wd = elm_widget_data_get(obj);
2764 elm_smart_scroller_hold_set(wd->scr, 1);
2768 _hold_off(void *data __UNUSED__,
2770 void *event_info __UNUSED__)
2772 Widget_Data *wd = elm_widget_data_get(obj);
2774 elm_smart_scroller_hold_set(wd->scr, 0);
2778 _freeze_on(void *data __UNUSED__,
2780 void *event_info __UNUSED__)
2782 Widget_Data *wd = elm_widget_data_get(obj);
2784 elm_smart_scroller_freeze_set(wd->scr, 1);
2788 _freeze_off(void *data __UNUSED__,
2790 void *event_info __UNUSED__)
2792 Widget_Data *wd = elm_widget_data_get(obj);
2794 elm_smart_scroller_freeze_set(wd->scr, 0);
2798 _scr_anim_start(void *data,
2799 Evas_Object *obj __UNUSED__,
2800 void *event_info __UNUSED__)
2802 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
2806 _scr_anim_stop(void *data,
2807 Evas_Object *obj __UNUSED__,
2808 void *event_info __UNUSED__)
2810 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
2814 _scr_drag_start(void *data,
2815 Evas_Object *obj __UNUSED__,
2816 void *event_info __UNUSED__)
2818 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2822 _scr_drag_stop(void *data,
2823 Evas_Object *obj __UNUSED__,
2824 void *event_info __UNUSED__)
2826 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2830 _edge_left(void *data,
2831 Evas_Object *scr __UNUSED__,
2832 void *event_info __UNUSED__)
2834 Evas_Object *obj = data;
2835 evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
2839 _edge_right(void *data,
2840 Evas_Object *scr __UNUSED__,
2841 void *event_info __UNUSED__)
2843 Evas_Object *obj = data;
2844 evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
2848 _edge_top(void *data,
2849 Evas_Object *scr __UNUSED__,
2850 void *event_info __UNUSED__)
2852 Evas_Object *obj = data;
2853 evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
2857 _edge_bottom(void *data,
2858 Evas_Object *scr __UNUSED__,
2859 void *event_info __UNUSED__)
2861 Evas_Object *obj = data;
2862 evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
2866 _mode_item_realize(Elm_Gen_Item *it)
2870 if ((it->item->mode_view) || (it->delete_me)) return;
2872 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2873 it->item->mode_view = edje_object_add(evas_object_evas_get(WIDGET(it)));
2874 edje_object_scale_set(it->item->mode_view,
2875 elm_widget_scale_get(WIDGET(it)) *
2876 _elm_config->scale);
2877 evas_object_smart_member_add(it->item->mode_view, it->wd->pan_smart);
2878 elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
2880 strncpy(buf, "item", sizeof(buf));
2881 if (it->wd->compress)
2882 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2884 if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2885 strncat(buf, "/", sizeof(buf) - strlen(buf));
2886 strncat(buf, it->wd->mode_item_style, sizeof(buf) - strlen(buf));
2888 _elm_theme_object_set(WIDGET(it), it->item->mode_view, "genlist", buf,
2889 elm_widget_style_get(WIDGET(it)));
2890 edje_object_mirrored_set(it->item->mode_view,
2891 elm_widget_mirrored_get(WIDGET(it)));
2893 /* signal callback add */
2894 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2896 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_UP,
2898 evas_object_event_callback_add(it->item->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2901 /* label_get, content_get, state_get */
2902 /* FIXME: If you see that assert, please notify us and we
2903 will clean our mess */
2904 assert(eina_list_count(it->item->mode_content_objs) == 0);
2906 _item_label_realize(it, it->item->mode_view, &it->item->mode_labels, NULL);
2907 it->item->mode_content_objs =
2908 _item_content_realize(it, it->item->mode_view,
2909 &it->item->mode_contents, NULL);
2910 _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
2912 edje_object_part_swallow(it->item->mode_view,
2913 edje_object_data_get(it->item->mode_view, "mode_part"),
2916 it->want_unrealize = EINA_FALSE;
2917 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2918 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2922 _mode_item_unrealize(Elm_Gen_Item *it)
2924 Widget_Data *wd = it->wd;
2925 Evas_Object *content;
2926 if (!it->item->mode_view) return;
2928 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2929 elm_widget_stringlist_free(it->item->mode_labels);
2930 it->item->mode_labels = NULL;
2931 elm_widget_stringlist_free(it->item->mode_contents);
2932 it->item->mode_contents = NULL;
2933 elm_widget_stringlist_free(it->item->mode_states);
2935 EINA_LIST_FREE(it->item->mode_content_objs, content)
2936 evas_object_del(content);
2938 edje_object_part_unswallow(it->item->mode_view, VIEW(it));
2939 evas_object_smart_member_add(VIEW(it), wd->pan_smart);
2940 evas_object_del(it->item->mode_view);
2941 it->item->mode_view = NULL;
2943 if (wd->mode_item == it)
2944 wd->mode_item = NULL;
2945 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2946 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2950 _item_mode_set(Elm_Gen_Item *it)
2953 Widget_Data *wd = it->wd;
2958 it->item->nocache = EINA_TRUE;
2960 if (wd->scr_hold_timer)
2962 ecore_timer_del(wd->scr_hold_timer);
2963 wd->scr_hold_timer = NULL;
2965 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2966 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2968 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2969 _mode_item_realize(it);
2970 if (it->item->group_item)
2971 evas_object_raise(it->item->VIEW(group_item));
2972 _item_position(it, it->item->mode_view, it->item->scrl_x, it->item->scrl_y);
2973 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2974 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2976 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2977 edje_object_signal_emit(it->item->mode_view, buf, "elm");
2981 _item_mode_unset(Widget_Data *wd)
2984 if (!wd->mode_item) return;
2985 char buf[1024], buf2[1024];
2989 it->item->nocache = EINA_TRUE;
2991 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2992 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2994 edje_object_signal_emit(it->item->mode_view, buf, "elm");
2995 edje_object_signal_callback_add(it->item->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2997 wd->mode_item = NULL;
3001 _item_auto_scroll(Widget_Data *wd)
3006 Evas_Coord ox, oy, ow, oh;
3008 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3010 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3011 if (wd->expanded_item->item->scrl_y > (oh + oy) / 2)
3013 EINA_LIST_FOREACH(wd->expanded_item->item->items, l, it)
3014 elm_genlist_item_bring_in(it);
3016 wd->auto_scroll_enabled = EINA_FALSE;
3021 elm_genlist_add(Evas_Object *parent)
3026 Evas_Coord minw, minh;
3027 static Evas_Smart *smart = NULL;
3031 static Evas_Smart_Class sc;
3033 evas_object_smart_clipped_smart_set(&_pan_sc);
3035 sc.name = "elm_genlist_pan";
3036 sc.version = EVAS_SMART_CLASS_VERSION;
3039 sc.resize = _pan_resize;
3040 sc.move = _pan_move;
3041 sc.calculate = _pan_calculate;
3042 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3045 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3047 ELM_SET_WIDTYPE(widtype, "genlist");
3049 elm_widget_type_set(obj, "genlist");
3050 elm_widget_sub_object_add(parent, obj);
3051 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3052 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3053 elm_widget_data_set(obj, wd);
3054 elm_widget_del_hook_set(obj, _del_hook);
3055 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3056 elm_widget_theme_hook_set(obj, _theme_hook);
3057 elm_widget_can_focus_set(obj, EINA_TRUE);
3058 elm_widget_event_hook_set(obj, _event_hook);
3059 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3060 elm_widget_translate_hook_set(obj, _translate_hook);
3062 wd->scr = elm_smart_scroller_add(e);
3063 elm_smart_scroller_widget_set(wd->scr, obj);
3064 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3065 elm_widget_style_get(obj));
3066 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3067 _elm_config->thumbscroll_bounce_enable);
3068 elm_widget_resize_object_set(obj, wd->scr);
3070 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3071 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3072 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3073 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3074 evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
3075 evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
3076 evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
3077 evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
3080 wd->mode = ELM_LIST_SCROLL;
3081 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3082 wd->item_cache_max = wd->max_items_per_block * 2;
3083 wd->longpress_timeout = _elm_config->longpress_timeout;
3085 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3086 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3087 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3088 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3090 wd->pan_smart = evas_object_smart_add(e, smart);
3091 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3094 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3095 _pan_set, _pan_get, _pan_max_get,
3096 _pan_min_get, _pan_child_size_get);
3098 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3100 evas_object_size_hint_min_set(obj, minw, minh);
3102 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3104 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3109 static Elm_Gen_Item *
3110 _item_new(Widget_Data *wd,
3111 const Elm_Genlist_Item_Class *itc,
3113 Elm_Gen_Item *parent,
3114 Elm_Genlist_Item_Flags flags,
3116 const void *func_data)
3120 it = elm_gen_item_new(wd, itc, data, parent, func, func_data);
3121 if (!it) return NULL;
3122 it->item = ELM_NEW(Elm_Gen_Item_Type);
3123 it->item->flags = flags;
3124 if (flags & ELM_GENLIST_ITEM_GROUP) it->group++;
3125 it->item->expanded_depth = 0;
3126 elm_widget_item_del_cb_set(it, _item_del_hook);
3127 ELM_GEN_ITEM_SETUP(it);
3130 if (it->parent->group)
3131 it->item->group_item = parent;
3132 else if (it->parent->item->group_item)
3133 it->item->group_item = it->parent->item->group_item;
3139 _item_block_add(Widget_Data *wd,
3142 Item_Block *itb = NULL;
3149 itb = calloc(1, sizeof(Item_Block));
3152 if (!it->item->rel->item->block)
3155 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3156 itb->items = eina_list_append(itb->items, it);
3160 if (it->item->before)
3162 wd->blocks = eina_inlist_prepend_relative
3163 (wd->blocks, EINA_INLIST_GET(itb),
3164 EINA_INLIST_GET(it->item->rel->item->block));
3166 eina_list_prepend_relative(itb->items, it, it->item->rel);
3170 wd->blocks = eina_inlist_append_relative
3171 (wd->blocks, EINA_INLIST_GET(itb),
3172 EINA_INLIST_GET(it->item->rel->item->block));
3174 eina_list_append_relative(itb->items, it, it->item->rel);
3180 if (it->item->before)
3184 itb = (Item_Block *)(wd->blocks);
3185 if (itb->count >= wd->max_items_per_block)
3187 itb = calloc(1, sizeof(Item_Block));
3191 eina_inlist_prepend(wd->blocks,
3192 EINA_INLIST_GET(itb));
3197 itb = calloc(1, sizeof(Item_Block));
3201 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3203 itb->items = eina_list_prepend(itb->items, it);
3209 itb = (Item_Block *)(wd->blocks->last);
3210 if (itb->count >= wd->max_items_per_block)
3212 itb = calloc(1, sizeof(Item_Block));
3216 eina_inlist_append(wd->blocks,
3217 EINA_INLIST_GET(itb));
3222 itb = calloc(1, sizeof(Item_Block));
3226 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3228 itb->items = eina_list_append(itb->items, it);
3234 itb = it->item->rel->item->block;
3235 if (!itb) goto newblock;
3236 if (it->item->before)
3237 itb->items = eina_list_prepend_relative(itb->items, it, it->item->rel);
3239 itb->items = eina_list_append_relative(itb->items, it, it->item->rel);
3242 itb->changed = EINA_TRUE;
3243 it->item->block = itb;
3244 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3245 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3248 it->item->rel->relcount--;
3249 if ((it->item->rel->delete_me) && (!it->item->rel->relcount))
3250 _item_del(it->item->rel);
3251 it->item->rel = NULL;
3253 if (itb->count > itb->wd->max_items_per_block)
3259 newc = itb->count / 2;
3260 itb2 = calloc(1, sizeof(Item_Block));
3264 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3265 EINA_INLIST_GET(itb));
3266 itb2->changed = EINA_TRUE;
3267 while ((itb->count > newc) && (itb->items))
3271 l = eina_list_last(itb->items);
3273 itb->items = eina_list_remove_list(itb->items, l);
3276 itb2->items = eina_list_prepend(itb2->items, it2);
3277 it2->item->block = itb2;
3284 _queue_process(Widget_Data *wd)
3287 Eina_Bool showme = EINA_FALSE;
3290 t0 = ecore_time_get();
3291 //evas_event_freeze(evas_object_evas_get(wd->obj));
3292 for (n = 0; (wd->queue) && (n < 128); n++)
3296 it = wd->queue->data;
3297 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3298 it->item->queued = EINA_FALSE;
3299 _item_block_add(wd, it);
3301 _item_block_realize(it->item->block);
3302 t = ecore_time_get();
3303 if (it->item->block->changed)
3305 showme = _item_block_recalc(it->item->block, it->item->block->num, EINA_TRUE);
3306 it->item->block->changed = 0;
3308 if (showme) it->item->block->showme = EINA_TRUE;
3309 if (eina_inlist_count(wd->blocks) > 1)
3311 if ((t - t0) > (ecore_animator_frametime_get())) break;
3314 //evas_event_thaw(evas_object_evas_get(wd->obj));
3315 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3320 _idle_process(void *data, Eina_Bool *wakeup)
3322 Widget_Data *wd = data;
3325 //static double q_start = 0.0;
3326 //if (q_start == 0.0) q_start = ecore_time_get();
3328 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3332 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3334 return ECORE_CALLBACK_CANCEL;
3336 return ECORE_CALLBACK_RENEW;
3340 _item_idle_enterer(void *data)
3342 Widget_Data *wd = data;
3343 Eina_Bool wakeup = EINA_FALSE;
3344 Eina_Bool ok = _idle_process(data, &wakeup);
3349 if (wd->calc_job) ecore_job_del(wd->calc_job);
3350 wd->calc_job = ecore_job_add(_calc_job, wd);
3352 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3357 _item_queue(Widget_Data *wd,
3360 if (it->item->queued) return;
3361 it->item->queued = EINA_TRUE;
3362 wd->queue = eina_list_append(wd->queue, it);
3363 // FIXME: why does a freeze then thaw here cause some genlist
3364 // elm_genlist_item_append() to be much much slower?
3365 // evas_event_freeze(evas_object_evas_get(wd->obj));
3366 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3368 if (wd->queue_idle_enterer)
3370 ecore_idle_enterer_del(wd->queue_idle_enterer);
3371 wd->queue_idle_enterer = NULL;
3375 // evas_event_thaw(evas_object_evas_get(wd->obj));
3376 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3377 if (!wd->queue_idle_enterer)
3378 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3382 _elm_genlist_item_compare_data(const void *data, const void *data1)
3384 const Elm_Gen_Item *it = data;
3385 const Elm_Gen_Item *item1 = data1;
3387 return _elm_genlist_item_compare_data_cb(it->base.data, item1->base.data);
3391 _elm_genlist_item_compare(const void *data, const void *data1)
3393 const Elm_Gen_Item *it, *item1;
3394 it = ELM_GEN_ITEM_FROM_INLIST(data);
3395 item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
3396 return _elm_genlist_item_compare_cb(it, item1);
3400 _elm_genlist_item_list_compare(const void *data, const void *data1)
3402 const Elm_Gen_Item *it = data;
3403 const Elm_Gen_Item *item1 = data1;
3404 return _elm_genlist_item_compare_cb(it, item1);
3408 _item_move_after(Elm_Gen_Item *it, Elm_Gen_Item *after)
3413 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3414 _item_block_del(it);
3416 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3417 it->item->rel = after;
3418 it->item->rel->relcount++;
3419 it->item->before = EINA_FALSE;
3420 if (after->item->group_item) it->item->group_item = after->item->group_item;
3421 _item_queue(it->wd, it);
3423 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3427 _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
3430 if (!before) return;
3432 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3433 _item_block_del(it);
3434 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3435 it->item->rel = before;
3436 it->item->rel->relcount++;
3437 it->item->before = EINA_TRUE;
3438 if (before->item->group_item) it->item->group_item = before->item->group_item;
3439 _item_queue(it->wd, it);
3441 evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
3445 elm_genlist_item_append(Evas_Object *obj,
3446 const Elm_Genlist_Item_Class *itc,
3448 Elm_Gen_Item *parent,
3449 Elm_Genlist_Item_Flags flags,
3451 const void *func_data)
3453 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3454 Widget_Data *wd = elm_widget_data_get(obj);
3455 if (!wd) return NULL;
3456 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3458 if (!it) return NULL;
3462 wd->group_items = eina_list_append(wd->group_items, it);
3463 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3464 it->item->rel = NULL;
3468 Elm_Gen_Item *it2 = NULL;
3469 Eina_List *ll = eina_list_last(it->parent->item->items);
3470 if (ll) it2 = ll->data;
3471 it->parent->item->items = eina_list_append(it->parent->item->items, it);
3472 if (!it2) it2 = it->parent;
3474 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3475 EINA_INLIST_GET(it2));
3476 it->item->rel = it2;
3477 it->item->rel->relcount++;
3479 it->item->before = EINA_FALSE;
3480 _item_queue(wd, it);
3485 elm_genlist_item_prepend(Evas_Object *obj,
3486 const Elm_Genlist_Item_Class *itc,
3488 Elm_Gen_Item *parent,
3489 Elm_Genlist_Item_Flags flags,
3491 const void *func_data)
3493 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3494 Widget_Data *wd = elm_widget_data_get(obj);
3495 if (!wd) return NULL;
3496 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3498 if (!it) return NULL;
3502 wd->group_items = eina_list_prepend(wd->group_items, it);
3503 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3504 it->item->rel = NULL;
3508 Elm_Gen_Item *it2 = NULL;
3509 Eina_List *ll = it->parent->item->items;
3510 if (ll) it2 = ll->data;
3511 it->parent->item->items = eina_list_prepend(it->parent->item->items, it);
3512 if (!it2) it2 = it->parent;
3514 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3515 EINA_INLIST_GET(it2));
3516 it->item->rel = it2;
3517 it->item->rel->relcount++;
3519 it->item->before = EINA_TRUE;
3520 _item_queue(wd, it);
3525 elm_genlist_item_insert_after(Evas_Object *obj,
3526 const Elm_Genlist_Item_Class *itc,
3528 Elm_Gen_Item *parent,
3529 Elm_Gen_Item *after,
3530 Elm_Genlist_Item_Flags flags,
3532 const void *func_data)
3534 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3535 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3536 Widget_Data *wd = elm_widget_data_get(obj);
3537 if (!wd) return NULL;
3538 /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3539 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3541 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3543 if (!it) return NULL;
3548 wd->group_items = eina_list_append_relative(wd->group_items, it,
3553 it->parent->item->items = eina_list_append_relative(it->parent->item->items, it,
3556 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3557 EINA_INLIST_GET(after));
3558 it->item->rel = after;
3559 it->item->rel->relcount++;
3560 it->item->before = EINA_FALSE;
3561 _item_queue(wd, it);
3566 elm_genlist_item_insert_before(Evas_Object *obj,
3567 const Elm_Genlist_Item_Class *itc,
3569 Elm_Gen_Item *parent,
3570 Elm_Gen_Item *before,
3571 Elm_Genlist_Item_Flags flags,
3573 const void *func_data)
3575 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3576 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3577 Widget_Data *wd = elm_widget_data_get(obj);
3578 if (!wd) return NULL;
3579 /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
3580 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3582 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3584 if (!it) return NULL;
3587 if (it->group && before->group)
3588 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
3593 it->parent->item->items = eina_list_prepend_relative(it->parent->item->items, it,
3596 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3597 EINA_INLIST_GET(before));
3598 it->item->rel = before;
3599 it->item->rel->relcount++;
3600 it->item->before = EINA_TRUE;
3601 _item_queue(wd, it);
3606 elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3607 const Elm_Genlist_Item_Class *itc,
3609 Elm_Gen_Item *parent,
3610 Elm_Genlist_Item_Flags flags,
3611 Eina_Compare_Cb comp,
3613 const void *func_data)
3615 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3616 Widget_Data *wd = elm_widget_data_get(obj);
3617 if (!wd) return NULL;
3618 Elm_Gen_Item *rel = NULL;
3619 Elm_Gen_Item *it = _item_new(wd, itc, data, parent, flags, func,
3621 if (!it) return NULL;
3623 _elm_genlist_item_compare_cb = comp;
3630 l = eina_list_search_sorted_near_list(it->parent->item->items,
3631 _elm_genlist_item_list_compare, it,
3634 rel = eina_list_data_get(l);
3638 if (cmp_result >= 0)
3640 it->parent->item->items = eina_list_prepend_relative_list(it->parent->item->items, it, l);
3641 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3642 it->item->before = EINA_FALSE;
3644 else if (cmp_result < 0)
3646 it->parent->item->items = eina_list_append_relative_list(it->parent->item->items, it, l);
3647 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3648 it->item->before = EINA_TRUE;
3655 wd->state = eina_inlist_sorted_state_new();
3656 eina_inlist_sorted_state_init(wd->state, wd->items);
3660 wd->group_items = eina_list_append(wd->group_items, it);
3662 wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
3663 _elm_genlist_item_compare, wd->state);
3665 if (EINA_INLIST_GET(it)->next)
3667 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3668 it->item->before = EINA_TRUE;
3670 else if (EINA_INLIST_GET(it)->prev)
3672 rel = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3673 it->item->before = EINA_FALSE;
3679 it->item->rel = rel;
3680 it->item->rel->relcount++;
3683 _item_queue(wd, it);
3689 elm_genlist_item_sorted_insert(Evas_Object *obj,
3690 const Elm_Genlist_Item_Class *itc,
3692 Elm_Gen_Item *parent,
3693 Elm_Genlist_Item_Flags flags,
3694 Eina_Compare_Cb comp,
3696 const void *func_data)
3698 _elm_genlist_item_compare_data_cb = comp;
3700 return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
3701 _elm_genlist_item_compare_data, func, func_data);
3705 elm_genlist_clear(Evas_Object *obj)
3707 _elm_genlist_clear(obj);
3711 elm_genlist_multi_select_set(Evas_Object *obj,
3714 ELM_CHECK_WIDTYPE(obj, widtype);
3715 Widget_Data *wd = elm_widget_data_get(obj);
3721 elm_genlist_multi_select_get(const Evas_Object *obj)
3723 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3724 Widget_Data *wd = elm_widget_data_get(obj);
3725 if (!wd) return EINA_FALSE;
3730 elm_genlist_selected_item_get(const Evas_Object *obj)
3732 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3733 Widget_Data *wd = elm_widget_data_get(obj);
3734 if (!wd) return NULL;
3735 if (wd->selected) return wd->selected->data;
3739 EAPI const Eina_List *
3740 elm_genlist_selected_items_get(const Evas_Object *obj)
3742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3743 Widget_Data *wd = elm_widget_data_get(obj);
3744 if (!wd) return NULL;
3745 return wd->selected;
3749 elm_genlist_realized_items_get(const Evas_Object *obj)
3751 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3752 Widget_Data *wd = elm_widget_data_get(obj);
3753 Eina_List *list = NULL;
3755 Eina_Bool done = EINA_FALSE;
3756 if (!wd) return NULL;
3757 EINA_INLIST_FOREACH(wd->blocks, itb)
3765 EINA_LIST_FOREACH(itb->items, l, it)
3767 if (it->realized) list = eina_list_append(list, it);
3779 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3784 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3785 Widget_Data *wd = elm_widget_data_get(obj);
3786 Evas_Coord ox, oy, ow, oh;
3789 if (!wd) return NULL;
3790 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3792 EINA_INLIST_FOREACH(wd->blocks, itb)
3797 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3798 oy + itb->y - itb->wd->pan_y,
3799 itb->w, itb->h, x, y, 1, 1))
3801 EINA_LIST_FOREACH(itb->items, l, it)
3803 Evas_Coord itx, ity;
3805 itx = ox + itb->x + it->x - itb->wd->pan_x;
3806 ity = oy + itb->y + it->y - itb->wd->pan_y;
3807 if (ELM_RECTS_INTERSECT(itx, ity, it->item->w, it->item->h, x, y, 1, 1))
3811 if (y <= (ity + (it->item->h / 4))) *posret = -1;
3812 else if (y >= (ity + it->item->h - (it->item->h / 4)))
3818 lasty = ity + it->item->h;
3823 if (y > lasty) *posret = 1;
3830 elm_genlist_first_item_get(const Evas_Object *obj)
3832 return elm_genlist_first_item_get(obj);
3836 elm_genlist_last_item_get(const Evas_Object *obj)
3838 return elm_genlist_last_item_get(obj);
3842 elm_genlist_item_next_get(const Elm_Gen_Item *it)
3844 return elm_genlist_item_next_get(it);
3848 elm_genlist_item_prev_get(const Elm_Gen_Item *it)
3850 return elm_genlist_item_prev_get(it);
3854 elm_genlist_item_genlist_get(const Elm_Gen_Item *it)
3856 return elm_genlist_item_genlist_get(it);
3860 elm_genlist_item_parent_get(const Elm_Gen_Item *it)
3862 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3867 elm_genlist_item_subitems_clear(Elm_Gen_Item *it)
3869 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3870 Eina_List *tl = NULL, *l;
3873 EINA_LIST_FOREACH(it->item->items, l, it2)
3874 tl = eina_list_append(tl, it2);
3875 EINA_LIST_FREE(tl, it2)
3876 elm_genlist_item_del(it2);
3880 elm_genlist_item_selected_set(Elm_Gen_Item *it,
3883 _elm_genlist_item_selected_set(it, selected);
3887 elm_genlist_item_selected_get(const Elm_Gen_Item *it)
3889 return elm_genlist_item_selected_get(it);
3893 elm_genlist_item_expanded_set(Elm_Gen_Item *it,
3896 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3897 if (it->item->expanded == expanded) return;
3898 it->item->expanded = expanded;
3899 it->wd->expanded_item = it;
3900 if (it->item->expanded)
3903 edje_object_signal_emit(VIEW(it), "elm,state,expanded", "elm");
3904 evas_object_smart_callback_call(WIDGET(it), SIG_EXPANDED, it);
3905 it->wd->auto_scroll_enabled = EINA_TRUE;
3910 edje_object_signal_emit(VIEW(it), "elm,state,contracted", "elm");
3911 evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACTED, it);
3912 it->wd->auto_scroll_enabled = EINA_FALSE;
3917 elm_genlist_item_expanded_get(const Elm_Gen_Item *it)
3919 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3920 return it->item->expanded;
3924 elm_genlist_item_expanded_depth_get(const Elm_Gen_Item *it)
3926 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3927 return it->item->expanded_depth;
3931 elm_genlist_item_disabled_set(Elm_Gen_Item *it,
3934 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3937 if (it->disabled == disabled) return;
3938 if (it->delete_me) return;
3939 it->disabled = !!disabled;
3941 elm_genlist_item_selected_set(it, EINA_FALSE);
3945 edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
3947 edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
3948 EINA_LIST_FOREACH(it->content_objs, l, obj)
3949 elm_widget_disabled_set(obj, disabled);
3954 elm_genlist_item_disabled_get(const Elm_Gen_Item *it)
3956 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3957 if (it->delete_me) return EINA_FALSE;
3958 return it->disabled;
3962 elm_genlist_item_display_only_set(Elm_Gen_Item *it,
3963 Eina_Bool display_only)
3965 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3966 if (it->display_only == display_only) return;
3967 if (it->delete_me) return;
3968 it->display_only = display_only;
3969 it->item->mincalcd = EINA_FALSE;
3970 it->item->updateme = EINA_TRUE;
3971 if (it->item->block) it->item->block->updateme = EINA_TRUE;
3972 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3973 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3977 elm_genlist_item_display_only_get(const Elm_Gen_Item *it)
3979 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3980 if (it->delete_me) return EINA_FALSE;
3981 return it->display_only;
3985 elm_genlist_item_show(Elm_Gen_Item *it)
3987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3988 Evas_Coord gith = 0;
3989 if (it->delete_me) return;
3990 if ((it->item->queued) || (!it->item->mincalcd))
3992 it->wd->show_item = it;
3993 it->wd->bring_in = EINA_TRUE;
3994 it->item->showme = EINA_TRUE;
3997 if (it->wd->show_item)
3999 it->wd->show_item->item->showme = EINA_FALSE;
4000 it->wd->show_item = NULL;
4002 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4003 gith = it->item->group_item->item->h;
4004 elm_smart_scroller_child_region_show(it->wd->scr,
4005 it->x + it->item->block->x,
4006 it->y + it->item->block->y - gith,
4007 it->item->block->w, it->item->h);
4011 elm_genlist_item_promote(Elm_Gen_Item *it)
4013 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4014 if (it->delete_me) return;
4015 _item_move_before(it, elm_genlist_first_item_get(WIDGET(it)));
4019 elm_genlist_item_demote(Elm_Gen_Item *it)
4021 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4022 if (it->delete_me) return;
4023 _item_move_after(it, elm_genlist_last_item_get(WIDGET(it)));
4027 elm_genlist_item_bring_in(Elm_Gen_Item *it)
4029 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4030 Evas_Coord gith = 0;
4031 if (it->delete_me) return;
4032 if ((it->item->queued) || (!it->item->mincalcd))
4034 it->wd->show_item = it;
4035 it->wd->bring_in = EINA_TRUE;
4036 it->item->showme = EINA_TRUE;
4039 if (it->wd->show_item)
4041 it->wd->show_item->item->showme = EINA_FALSE;
4042 it->wd->show_item = NULL;
4044 if ((it->item->group_item) && (it->wd->pan_y > (it->y + it->item->block->y)))
4045 gith = it->item->group_item->item->h;
4046 elm_smart_scroller_region_bring_in(it->wd->scr,
4047 it->x + it->item->block->x,
4048 it->y + it->item->block->y - gith,
4049 it->item->block->w, it->item->h);
4053 elm_genlist_item_top_show(Elm_Gen_Item *it)
4055 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4057 Evas_Coord gith = 0;
4059 if (it->delete_me) return;
4060 if ((it->item->queued) || (!it->item->mincalcd))
4062 it->wd->show_item = it;
4063 it->wd->bring_in = EINA_TRUE;
4064 it->item->showme = EINA_TRUE;
4067 if (it->wd->show_item)
4069 it->wd->show_item->item->showme = EINA_FALSE;
4070 it->wd->show_item = NULL;
4072 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4073 if (it->item->group_item) gith = it->item->group_item->item->h;
4074 elm_smart_scroller_child_region_show(it->wd->scr,
4075 it->x + it->item->block->x,
4076 it->y + it->item->block->y - gith,
4077 it->item->block->w, oh);
4081 elm_genlist_item_top_bring_in(Elm_Gen_Item *it)
4083 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4085 Evas_Coord gith = 0;
4087 if (it->delete_me) return;
4088 if ((it->item->queued) || (!it->item->mincalcd))
4090 it->wd->show_item = it;
4091 it->wd->bring_in = EINA_TRUE;
4092 it->item->showme = EINA_TRUE;
4095 if (it->wd->show_item)
4097 it->wd->show_item->item->showme = EINA_FALSE;
4098 it->wd->show_item = NULL;
4100 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4101 if (it->item->group_item) gith = it->item->group_item->item->h;
4102 elm_smart_scroller_region_bring_in(it->wd->scr,
4103 it->x + it->item->block->x,
4104 it->y + it->item->block->y - gith,
4105 it->item->block->w, oh);
4109 elm_genlist_item_middle_show(Elm_Gen_Item *it)
4111 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4114 if (it->delete_me) return;
4115 if ((it->item->queued) || (!it->item->mincalcd))
4117 it->wd->show_item = it;
4118 it->wd->bring_in = EINA_TRUE;
4119 it->item->showme = EINA_TRUE;
4122 if (it->wd->show_item)
4124 it->wd->show_item->item->showme = EINA_FALSE;
4125 it->wd->show_item = NULL;
4127 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4128 elm_smart_scroller_child_region_show(it->wd->scr,
4129 it->x + it->item->block->x,
4130 it->y + it->item->block->y - oh / 2 +
4131 it->item->h / 2, it->item->block->w, oh);
4135 elm_genlist_item_middle_bring_in(Elm_Gen_Item *it)
4137 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4140 if (it->delete_me) return;
4141 if ((it->item->queued) || (!it->item->mincalcd))
4143 it->wd->show_item = it;
4144 it->wd->bring_in = EINA_TRUE;
4145 it->item->showme = EINA_TRUE;
4148 if (it->wd->show_item)
4150 it->wd->show_item->item->showme = EINA_FALSE;
4151 it->wd->show_item = NULL;
4153 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4154 elm_smart_scroller_region_bring_in(it->wd->scr,
4155 it->x + it->item->block->x,
4156 it->y + it->item->block->y - oh / 2 + it->item->h / 2,
4157 it->item->block->w, oh);
4161 elm_genlist_item_del(Elm_Gen_Item *it)
4163 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4164 if ((it->relcount > 0) || (it->walking > 0))
4166 elm_genlist_item_subitems_clear(it);
4167 if (it->wd->show_item == it) it->wd->show_item = NULL;
4168 elm_gen_item_del_notserious(it);
4169 if (it->item->block)
4171 if (it->realized) elm_gen_item_unrealize(it, EINA_FALSE);
4172 it->item->block->changed = EINA_TRUE;
4173 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4174 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4182 elm_genlist_item_data_set(Elm_Gen_Item *it,
4185 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4186 elm_widget_item_data_set(it, data);
4190 elm_genlist_item_data_get(const Elm_Gen_Item *it)
4192 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4193 return elm_widget_item_data_get(it);
4197 elm_genlist_item_icons_orphan(Elm_Gen_Item *it)
4199 elm_genlist_item_contents_orphan(it);
4203 elm_genlist_item_contents_orphan(Elm_Gen_Item *it)
4205 Evas_Object *content;
4206 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4207 EINA_LIST_FREE(it->content_objs, content)
4209 elm_widget_sub_object_del(WIDGET(it), content);
4210 evas_object_smart_member_del(content);
4211 evas_object_hide(content);
4215 EAPI const Evas_Object *
4216 elm_genlist_item_object_get(const Elm_Gen_Item *it)
4218 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4223 elm_genlist_item_update(Elm_Gen_Item *it)
4225 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4226 if (!it->item->block) return;
4227 if (it->delete_me) return;
4228 it->item->mincalcd = EINA_FALSE;
4229 it->item->updateme = EINA_TRUE;
4230 it->item->block->updateme = EINA_TRUE;
4231 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4232 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4236 elm_genlist_item_fields_update(Elm_Genlist_Item *it,
4238 Elm_Genlist_Item_Field_Flags itf)
4240 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4241 if (!it->item->block) return;
4242 if (it->delete_me) return;
4244 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
4245 _item_label_realize(it, it->base.view, &it->labels, parts);
4246 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
4248 it->content_objs = _item_content_unrealize(it, it->base.view,
4249 &it->contents, parts);
4250 it->content_objs = _item_content_realize(it, it->base.view,
4251 &it->contents, parts);
4253 if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
4254 _item_state_realize(it, it->base.view, &it->states, parts);
4258 elm_genlist_item_item_class_update(Elm_Gen_Item *it,
4259 const Elm_Genlist_Item_Class *itc)
4261 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4262 if (!it->item->block) return;
4263 EINA_SAFETY_ON_NULL_RETURN(itc);
4264 if (it->delete_me) return;
4266 it->item->nocache = EINA_TRUE;
4267 elm_genlist_item_update(it);
4270 EAPI const Elm_Genlist_Item_Class *
4271 elm_genlist_item_item_class_get(const Elm_Gen_Item *it)
4273 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4274 if (it->delete_me) return NULL;
4278 static Evas_Object *
4279 _elm_genlist_item_label_create(void *data,
4280 Evas_Object *obj __UNUSED__,
4281 Evas_Object *tooltip,
4282 void *it __UNUSED__)
4284 Evas_Object *label = elm_label_add(tooltip);
4287 elm_object_style_set(label, "tooltip");
4288 elm_object_text_set(label, data);
4293 _elm_genlist_item_label_del_cb(void *data,
4294 Evas_Object *obj __UNUSED__,
4295 void *event_info __UNUSED__)
4297 eina_stringshare_del(data);
4301 elm_genlist_item_tooltip_text_set(Elm_Gen_Item *it,
4304 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4305 text = eina_stringshare_add(text);
4306 elm_genlist_item_tooltip_content_cb_set(it, _elm_genlist_item_label_create,
4308 _elm_genlist_item_label_del_cb);
4312 elm_genlist_item_tooltip_content_cb_set(Elm_Gen_Item *it,
4313 Elm_Tooltip_Item_Content_Cb func,
4315 Evas_Smart_Cb del_cb)
4317 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, error);
4319 if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
4322 if (it->tooltip.del_cb)
4323 it->tooltip.del_cb((void *)it->tooltip.data,
4326 it->tooltip.content_cb = func;
4327 it->tooltip.data = data;
4328 it->tooltip.del_cb = del_cb;
4332 elm_widget_item_tooltip_content_cb_set(it,
4333 it->tooltip.content_cb,
4334 it->tooltip.data, NULL);
4335 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
4336 elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
4342 if (del_cb) del_cb((void *)data, NULL, NULL);
4346 elm_genlist_item_tooltip_unset(Elm_Gen_Item *it)
4348 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4349 if ((VIEW(it)) && (it->tooltip.content_cb))
4350 elm_widget_item_tooltip_unset(it);
4352 if (it->tooltip.del_cb)
4353 it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
4354 it->tooltip.del_cb = NULL;
4355 it->tooltip.content_cb = NULL;
4356 it->tooltip.data = NULL;
4357 it->tooltip.free_size = EINA_FALSE;
4358 if (it->tooltip.style)
4359 elm_genlist_item_tooltip_style_set(it, NULL);
4363 elm_genlist_item_tooltip_style_set(Elm_Gen_Item *it,
4366 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4367 eina_stringshare_replace(&it->tooltip.style, style);
4368 if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
4372 elm_genlist_item_tooltip_style_get(const Elm_Gen_Item *it)
4374 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4375 return it->tooltip.style;
4379 elm_genlist_item_tooltip_size_restrict_disable(Elm_Gen_Item *it, Eina_Bool disable)
4381 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4382 it->tooltip.free_size = disable;
4383 if (VIEW(it)) return elm_widget_item_tooltip_size_restrict_disable(it, disable);
4388 elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Gen_Item *it)
4390 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4391 return it->tooltip.free_size;
4395 elm_genlist_item_cursor_set(Elm_Gen_Item *it,
4398 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4399 eina_stringshare_replace(&it->mouse_cursor, cursor);
4400 if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
4404 elm_genlist_item_cursor_get(const Elm_Gen_Item *it)
4406 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4407 return elm_widget_item_cursor_get(it);
4411 elm_genlist_item_cursor_unset(Elm_Gen_Item *it)
4413 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4414 if (!it->mouse_cursor)
4418 elm_widget_item_cursor_unset(it);
4420 eina_stringshare_del(it->mouse_cursor);
4421 it->mouse_cursor = NULL;
4425 elm_genlist_item_cursor_style_set(Elm_Gen_Item *it,
4428 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4429 elm_widget_item_cursor_style_set(it, style);
4433 elm_genlist_item_cursor_style_get(const Elm_Gen_Item *it)
4435 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4436 return elm_widget_item_cursor_style_get(it);
4440 elm_genlist_item_cursor_engine_only_set(Elm_Gen_Item *it,
4441 Eina_Bool engine_only)
4443 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4444 elm_widget_item_cursor_engine_only_set(it, engine_only);
4448 elm_genlist_item_cursor_engine_only_get(const Elm_Gen_Item *it)
4450 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4451 return elm_widget_item_cursor_engine_only_get(it);
4455 elm_genlist_horizontal_set(Evas_Object *obj,
4458 ELM_CHECK_WIDTYPE(obj, widtype);
4459 Widget_Data *wd = elm_widget_data_get(obj);
4461 if (wd->mode == mode) return;
4467 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4470 elm_genlist_horizontal_set(obj, mode);
4474 elm_genlist_horizontal_get(const Evas_Object *obj)
4476 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4477 Widget_Data *wd = elm_widget_data_get(obj);
4478 if (!wd) return ELM_LIST_LAST;
4483 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4485 return elm_genlist_horizontal_get(obj);
4489 elm_genlist_always_select_mode_set(Evas_Object *obj,
4490 Eina_Bool always_select)
4492 _elm_genlist_always_select_mode_set(obj, always_select);
4496 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4498 return elm_genlist_always_select_mode_get(obj);
4502 elm_genlist_no_select_mode_set(Evas_Object *obj,
4503 Eina_Bool no_select)
4505 elm_genlist_no_select_mode_set(obj, no_select);
4509 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4511 return elm_genlist_no_select_mode_get(obj);
4515 elm_genlist_compress_mode_set(Evas_Object *obj,
4518 ELM_CHECK_WIDTYPE(obj, widtype);
4519 Widget_Data *wd = elm_widget_data_get(obj);
4521 wd->compress = compress;
4522 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4526 elm_genlist_compress_mode_get(const Evas_Object *obj)
4528 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4529 Widget_Data *wd = elm_widget_data_get(obj);
4530 if (!wd) return EINA_FALSE;
4531 return wd->compress;
4535 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4536 Eina_Bool height_for_width)
4538 ELM_CHECK_WIDTYPE(obj, widtype);
4539 Widget_Data *wd = elm_widget_data_get(obj);
4541 wd->height_for_width = !!height_for_width;
4542 if (wd->height_for_width)
4544 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4545 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4550 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4552 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4553 Widget_Data *wd = elm_widget_data_get(obj);
4554 if (!wd) return EINA_FALSE;
4555 return wd->height_for_width;
4559 elm_genlist_bounce_set(Evas_Object *obj,
4563 _elm_genlist_bounce_set(obj, h_bounce, v_bounce);
4567 elm_genlist_bounce_get(const Evas_Object *obj,
4568 Eina_Bool *h_bounce,
4569 Eina_Bool *v_bounce)
4571 _elm_genlist_bounce_get(obj, h_bounce, v_bounce);
4575 elm_genlist_homogeneous_set(Evas_Object *obj,
4576 Eina_Bool homogeneous)
4578 ELM_CHECK_WIDTYPE(obj, widtype);
4579 Widget_Data *wd = elm_widget_data_get(obj);
4581 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4582 wd->homogeneous = homogeneous;
4586 elm_genlist_homogeneous_get(const Evas_Object *obj)
4588 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4589 Widget_Data *wd = elm_widget_data_get(obj);
4590 if (!wd) return EINA_FALSE;
4591 return wd->homogeneous;
4595 elm_genlist_block_count_set(Evas_Object *obj,
4598 ELM_CHECK_WIDTYPE(obj, widtype);
4599 Widget_Data *wd = elm_widget_data_get(obj);
4601 wd->max_items_per_block = n;
4602 wd->item_cache_max = wd->max_items_per_block * 2;
4603 _item_cache_clean(wd);
4607 elm_genlist_block_count_get(const Evas_Object *obj)
4609 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4610 Widget_Data *wd = elm_widget_data_get(obj);
4612 return wd->max_items_per_block;
4616 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4619 ELM_CHECK_WIDTYPE(obj, widtype);
4620 Widget_Data *wd = elm_widget_data_get(obj);
4622 wd->longpress_timeout = timeout;
4626 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4628 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4629 Widget_Data *wd = elm_widget_data_get(obj);
4631 return wd->longpress_timeout;
4635 elm_genlist_scroller_policy_set(Evas_Object *obj,
4636 Elm_Scroller_Policy policy_h,
4637 Elm_Scroller_Policy policy_v)
4639 ELM_CHECK_WIDTYPE(obj, widtype);
4640 Widget_Data *wd = elm_widget_data_get(obj);
4641 if ((!wd) || (!wd->scr)) return;
4642 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4643 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4645 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4649 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4650 Elm_Scroller_Policy *policy_h,
4651 Elm_Scroller_Policy *policy_v)
4653 ELM_CHECK_WIDTYPE(obj, widtype);
4654 Widget_Data *wd = elm_widget_data_get(obj);
4655 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4656 if ((!wd) || (!wd->scr)) return;
4657 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4658 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4659 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4663 elm_genlist_realized_items_update(Evas_Object *obj)
4665 ELM_CHECK_WIDTYPE(obj, widtype);
4667 Eina_List *list, *l;
4670 list = elm_genlist_realized_items_get(obj);
4671 EINA_LIST_FOREACH(list, l, it)
4672 elm_genlist_item_update(it);
4676 elm_genlist_item_mode_set(Elm_Gen_Item *it,
4677 const char *mode_type,
4680 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4681 Widget_Data *wd = it->wd;
4686 if (!mode_type) return;
4687 if ((it->delete_me) || (it->disabled)) return;
4689 if ((wd->mode_item == it) &&
4690 (!strcmp(mode_type, wd->mode_type)) &&
4693 if (!wd->mode_item_style) return;
4694 it->mode_set = mode_set;
4698 EINA_LIST_FOREACH(wd->selected, l, it2)
4700 elm_genlist_item_selected_set(it2, EINA_FALSE);
4704 it2 = elm_genlist_selected_item_get(wd->obj);
4705 if ((it2) && (it2->realized))
4706 elm_genlist_item_selected_set(it2, EINA_FALSE);
4709 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
4711 ((it == wd->mode_item) && (!mode_set)))
4712 _item_mode_unset(wd);
4714 eina_stringshare_replace(&wd->mode_type, mode_type);
4715 if (mode_set) _item_mode_set(it);
4720 elm_genlist_mode_item_style_get(const Evas_Object *obj)
4722 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4723 Widget_Data *wd = elm_widget_data_get(obj);
4724 if (!wd) return NULL;
4725 return wd->mode_item_style;
4729 elm_genlist_mode_item_style_set(Evas_Object *obj, const char *style)
4731 ELM_CHECK_WIDTYPE(obj, widtype);
4732 Widget_Data *wd = elm_widget_data_get(obj);
4734 if ((style == wd->mode_item_style) || (style && wd->mode_item_style &&
4735 (!strcmp(style, wd->mode_item_style))))
4737 eina_stringshare_replace(&wd->mode_item_style, style);
4738 elm_genlist_realized_items_update(obj);
4742 elm_genlist_mode_get(const Evas_Object *obj)
4744 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4745 Widget_Data *wd = elm_widget_data_get(obj);
4746 if (!wd) return NULL;
4747 return wd->mode_type;
4750 EAPI const Elm_Gen_Item *
4751 elm_genlist_mode_item_get(const Evas_Object *obj)
4753 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4754 Widget_Data *wd = elm_widget_data_get(obj);
4755 if (!wd) return NULL;
4756 return wd->mode_item;
4760 elm_genlist_reorder_mode_set(Evas_Object *obj,
4761 Eina_Bool reorder_mode)
4763 ELM_CHECK_WIDTYPE(obj, widtype);
4764 Widget_Data *wd = elm_widget_data_get(obj);
4766 wd->reorder_mode = reorder_mode;
4770 elm_genlist_reorder_mode_get(const Evas_Object *obj)
4772 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4773 Widget_Data *wd = elm_widget_data_get(obj);
4774 if (!wd) return EINA_FALSE;
4775 return wd->reorder_mode;
4779 _elm_genlist_clear(Evas_Object *obj)
4781 ELM_CHECK_WIDTYPE(obj, widtype);
4782 Widget_Data *wd = elm_widget_data_get(obj);
4787 eina_inlist_sorted_state_free(wd->state);
4791 if (wd->walking > 0)
4795 EINA_INLIST_FOREACH(wd->items, it)
4799 evas_event_freeze(evas_object_evas_get(wd->obj));
4802 Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
4808 ecore_job_del(wd->calc_job);
4809 wd->calc_job = NULL;
4811 if (wd->selected) wd->selected = eina_list_free(wd->selected);
4812 if (wd->clear_cb) wd->clear_cb(wd);
4820 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4821 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4823 if (wd->sizing_cb) wd->sizing_cb(wd->obj);
4824 elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
4825 evas_event_thaw(evas_object_evas_get(wd->obj));
4826 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4830 _elm_genlist_always_select_mode_set(Evas_Object *obj,
4831 Eina_Bool always_select)
4833 ELM_CHECK_WIDTYPE(obj, widtype);
4834 Widget_Data *wd = elm_widget_data_get(obj);
4836 wd->always_select = always_select;
4840 _item_select(Elm_Gen_Item *it)
4842 if ((it->wd->no_select) || (it->delete_me) || (it->mode_set)) return;
4845 it->selected = EINA_TRUE;
4846 it->wd->selected = eina_list_append(it->wd->selected, it);
4848 else if (!it->wd->always_select) return;
4850 evas_object_ref(WIDGET(it));
4853 if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), it);
4855 evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
4858 evas_object_unref(WIDGET(it));
4859 if ((it->wd->clear_me) && (!it->wd->walking))
4860 _elm_genlist_clear(WIDGET(it));
4863 if ((!it->walking) && (it->delete_me))
4865 if (!it->relcount) it->del_cb(it);
4868 it->wd->last_selected_item = it;
4873 _elm_genlist_item_selected_set(Elm_Gen_Item *it,
4876 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4877 Widget_Data *wd = it->wd;
4879 if ((it->delete_me) || (it->disabled)) return;
4880 selected = !!selected;
4881 if (it->selected == selected) return;
4887 while (wd->selected)
4889 if (it->unhighlight_cb) it->unhighlight_cb(wd->selected->data);
4890 it->unsel_cb(wd->selected->data);
4893 it->highlight_cb(it);
4897 if (it->unhighlight_cb) it->unhighlight_cb(it);
4902 _elm_genlist_bounce_set(Evas_Object *obj,
4906 ELM_CHECK_WIDTYPE(obj, widtype);
4907 Widget_Data *wd = elm_widget_data_get(obj);
4909 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4910 wd->h_bounce = h_bounce;
4911 wd->v_bounce = v_bounce;
4915 _elm_genlist_bounce_get(const Evas_Object *obj,
4916 Eina_Bool *h_bounce,
4917 Eina_Bool *v_bounce)
4919 ELM_CHECK_WIDTYPE(obj, widtype);
4920 Widget_Data *wd = elm_widget_data_get(obj);
4922 if (h_bounce) *h_bounce = wd->h_bounce;
4923 if (v_bounce) *v_bounce = wd->v_bounce;