3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
11 * @defgroup Genlist Genlist
13 * The aim was to have more expansive list than the simple list in
14 * Elementary that could have more flexible items and allow many more entries
15 * while still being fast and low on memory usage. At the same time it was
16 * also made to be able to do tree structures. But the price to pay is more
17 * complex when it comes to usage. If all you want is a simple list with
18 * icons and a single label, use the normal List object.
20 * Genlist has a fairly large API, mostly because it's relatively complex,
21 * trying to be both expansive, powerful and efficient. First we will begin
22 * an overview on the theory behind genlist.
24 * Evas tracks every object you create. Every time it processes an event
25 * (mouse move, down, up etc.) it needs to walk through objects and find out
26 * what event that affects. Even worse every time it renders display updates,
27 * in order to just calculate what to re-draw, it needs to walk through many
28 * many many objects. Thus, the more objects you keep active, the more
29 * overhead Evas has in just doing its work. It is advisable to keep your
30 * active objects to the minimum working set you need. Also remember that
31 * object creation and deletion carries an overhead, so there is a
32 * middle-ground, which is not easily determined. But don't keep massive lists
33 * of objects you can't see or use. Genlist does this with list objects. It
34 * creates and destroys them dynamically as you scroll around. It groups them
35 * into blocks so it can determine the visibility etc. of a whole block at
36 * once as opposed to having to walk the whole list. This 2-level list allows
37 * for very large numbers of items to be in the list (tests have used up to
38 * 2,000,000 items). Also genlist employs a queue for adding items. As items
39 * may be different sizes, every item added needs to be calculated as to its
40 * size and thus this presents a lot of overhead on populating the list, this
41 * genlist employs a queue. Any item added is queued and spooled off over
42 * time, actually appearing some time later, so if your list has many members
43 * you may find it takes a while for them to all appear, with your process
44 * consuming a lot of CPU while it is busy spooling.
46 * Genlist also implements a tree structure, but it does so with callbacks to
47 * the application, with the application filling in tree structures when
48 * requested (allowing for efficient building of a very deep tree that could
49 * even be used for file-management). See the above smart signal callbacks for
52 * An item in the genlist world can have 0 or more text labels (they can be
53 * regular text or textblock - that's up to the style to determine), 0 or
54 * more icons (which are simply objects swallowed into the genlist item) and
55 * 0 or more boolean states that can be used for check, radio or other
56 * indicators by the edje theme style. An item may be one of several styles
57 * (Elementary provides 4 by default - "default", "double_label", "group_index"
58 * and "icon_top_text_bottom", but this can be extended by system or
59 * application custom themes/overlays/extensions).
61 * In order to implement the ability to add and delete items on the fly,
62 * Genlist implements a class/callback system where the application provides
63 * a structure with information about that type of item (genlist may contain
64 * multiple different items with different classes, states and styles).
65 * Genlist will call the functions in this struct (methods) when an item is
66 * "realized" (that is created dynamically while scrolling). All objects will
67 * simply be deleted when no longer needed with evas_object_del(). The
68 * Elm_Genlist_Item_Class structure contains the following members:
70 * item_style - This is a constant string and simply defines the name of the
71 * item style. It must be specified and the default should be "default".
73 * func.label_get - This function is called when an actual item object is
74 * created. The data parameter is the data parameter passed to
75 * elm_genlist_item_append() and related item creation functions. The obj
76 * parameter is the genlist object and the part parameter is the string name
77 * of the text part in the edje design that is listed as one of the possible
78 * labels that can be set. This function must return a strudup()'ed string as
79 * the caller will free() it when done.
81 * func.icon_get - This function is called when an actual item object is
82 * created. The data parameter is the data parameter passed to
83 * elm_genlist_item_append() and related item creation functions. The obj
84 * parameter is the genlist object and the part parameter is the string name
85 * of the icon part in the edje design that is listed as one of the possible
86 * icons that can be set. This must return NULL for no object or a valid
87 * object. The object will be deleted by genlist on shutdown or when the item
90 * func.state_get - This function is called when an actual item object is
91 * created. The data parameter is the data parameter passed to
92 * elm_genlist_item_append() and related item creation functions. The obj
93 * parameter is the genlist object and the part parameter is the string name
94 * of the state part in the edje design that is listed as one of the possible
95 * states that can be set. Return 0 for false or 1 for true. Genlist will
96 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
97 * true (the default is false), where XXX is the name of the part.
99 * func.del - This is called when elm_genlist_item_del() is called on an
100 * item, elm_genlist_clear() is called on the genlist, or
101 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
102 * intended for use when actual genlist items are deleted, so any backing
103 * data attached to the item (e.g. its data parameter on creation) can be
106 * Items can be added by several calls. All of them return a Elm_Genlist_Item
107 * handle that is an internal member inside the genlist. They all take a data
108 * parameter that is meant to be used for a handle to the applications
109 * internal data (eg the struct with the original item data). The parent
110 * parameter is the parent genlist item this belongs to if it is a tree or
111 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
112 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
113 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
114 * is displayed as an item that is able to expand and have child items.
115 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
116 * displayed at the top until the next group comes. The func parameter is a
117 * convenience callback that is called when the item is selected and the data
118 * parameter will be the func_data parameter, obj be the genlist object and
119 * event_info will be the genlist item.
121 * elm_genlist_item_append() appends an item to the end of the list, or if
122 * there is a parent, to the end of all the child items of the parent.
123 * elm_genlist_item_prepend() is the same but prepends to the beginning of
124 * the list or children list. elm_genlist_item_insert_before() inserts at
125 * item before another item and elm_genlist_item_insert_after() inserts after
126 * the indicated item.
128 * The application can clear the list with elm_genlist_clear() which deletes
129 * all the items in the list and elm_genlist_item_del() will delete a specific
130 * item. elm_genlist_item_subitems_clear() will clear all items that are
131 * children of the indicated parent item.
133 * If the application wants multiple items to be able to be selected,
134 * elm_genlist_multi_select_set() can enable this. If the list is
135 * single-selection only (the default), then elm_genlist_selected_item_get()
136 * will return the selected item, if any, or NULL I none is selected. If the
137 * list is multi-select then elm_genlist_selected_items_get() will return a
138 * list (that is only valid as long as no items are modified (added, deleted,
139 * selected or unselected)).
141 * To help inspect list items you can jump to the item at the top of the list
142 * with elm_genlist_first_item_get() which will return the item pointer, and
143 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
144 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
145 * and previous items respectively relative to the indicated item. Using
146 * these calls you can walk the entire item list/tree. Note that as a tree
147 * the items are flattened in the list, so elm_genlist_item_parent_get() will
148 * let you know which item is the parent (and thus know how to skip them if
151 * There are also convenience functions. elm_genlist_item_genlist_get() will
152 * return the genlist object the item belongs to. elm_genlist_item_show()
153 * will make the scroller scroll to show that specific item so its visible.
154 * elm_genlist_item_data_get() returns the data pointer set by the item
155 * creation functions.
157 * If an item changes (state of boolean changes, label or icons change),
158 * then use elm_genlist_item_update() to have genlist update the item with
159 * the new state. Genlist will re-realize the item thus call the functions
160 * in the _Elm_Genlist_Item_Class for that item.
162 * To programmatically (un)select an item use elm_genlist_item_selected_set().
163 * To get its selected state use elm_genlist_item_selected_get(). Similarly
164 * to expand/contract an item and get its expanded state, use
165 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
166 * again to make an item disabled (unable to be selected and appear
167 * differently) use elm_genlist_item_disabled_set() to set this and
168 * elm_genlist_item_disabled_get() to get the disabled state.
170 * In general to indicate how the genlist should expand items horizontally to
171 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
172 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
173 * mode means that if items are too wide to fit, the scroller will scroll
174 * horizontally. Otherwise items are expanded to fill the width of the
175 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
176 * to the viewport width and limited to that size. This can be combined with
177 * a different style that uses edjes' ellipsis feature (cutting text off like
180 * Items will only call their selection func and callback when first becoming
181 * selected. Any further clicks will do nothing, unless you enable always
182 * select with elm_genlist_always_select_mode_set(). This means even if
183 * selected, every click will make the selected callbacks be called.
184 * elm_genlist_no_select_mode_set() will turn off the ability to select
185 * items entirely and they will neither appear selected nor call selected
186 * callback functions.
188 * Remember that you can create new styles and add your own theme augmentation
189 * per application with elm_theme_extension_add(). If you absolutely must
190 * have a specific style that overrides any theme the user or system sets up
191 * you can use elm_theme_overlay_add() to add such a file.
195 typedef struct _Widget_Data Widget_Data;
196 typedef struct _Item_Block Item_Block;
197 typedef struct _Pan Pan;
198 typedef struct _Item_Cache Item_Cache;
202 Evas_Object *obj, *scr, *pan_smart;
203 Eina_Inlist *items, *blocks;
204 Eina_List *group_items;
206 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
207 Ecore_Job *calc_job, *update_job;
208 Ecore_Idle_Enterer *queue_idle_enterer;
209 Ecore_Idler *must_recalc_idler;
210 Eina_List *queue, *selected;
211 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
212 Eina_Inlist *item_cache;
215 Ecore_Timer *multi_timer, *scr_hold_timer;
216 const char *mode_type;
217 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
218 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
219 Eina_Bool mouse_down : 1;
220 Eina_Bool multi_down : 1;
221 Eina_Bool multi_timeout : 1;
222 Eina_Bool multitouched : 1;
223 Eina_Bool on_hold : 1;
225 Eina_Bool always_select : 1;
226 Eina_Bool longpressed : 1;
227 Eina_Bool wasselected : 1;
228 Eina_Bool no_select : 1;
229 Eina_Bool bring_in : 1;
230 Eina_Bool compress : 1;
231 Eina_Bool height_for_width : 1;
232 Eina_Bool homogeneous : 1;
233 Eina_Bool clear_me : 1;
238 } history[SWIPE_MOVES];
240 int item_cache_count;
246 int group_item_width;
247 int group_item_height;
248 int max_items_per_block;
249 double longpress_timeout;
259 Evas_Coord x, y, w, h, minw, minh;
260 Eina_Bool want_unrealize : 1;
261 Eina_Bool realized : 1;
262 Eina_Bool changed : 1;
263 Eina_Bool updateme : 1;
264 Eina_Bool showme : 1;
265 Eina_Bool must_recalc : 1;
268 struct _Elm_Genlist_Item
270 Elm_Widget_Item base;
275 Evas_Coord x, y, w, h, minw, minh;
276 const Elm_Genlist_Item_Class *itc;
277 Elm_Genlist_Item *parent;
278 Elm_Genlist_Item *group_item;
279 Elm_Genlist_Item_Flags flags;
287 Eina_List *labels, *icons, *states, *icon_objs;
288 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
289 Ecore_Timer *long_timer;
290 Ecore_Timer *swipe_timer;
292 Evas_Coord scrl_x, scrl_y;
294 Elm_Genlist_Item *rel;
295 Evas_Object *mode_view;
300 Elm_Tooltip_Item_Content_Cb content_cb;
301 Evas_Smart_Cb del_cb;
305 const char *mouse_cursor;
312 Eina_Bool before : 1;
314 Eina_Bool want_unrealize : 1;
315 Eina_Bool want_realize : 1;
316 Eina_Bool realized : 1;
317 Eina_Bool selected : 1;
318 Eina_Bool highlighted : 1;
319 Eina_Bool expanded : 1;
320 Eina_Bool disabled : 1;
321 Eina_Bool display_only : 1;
322 Eina_Bool mincalcd : 1;
323 Eina_Bool queued : 1;
324 Eina_Bool showme : 1;
325 Eina_Bool delete_me : 1;
327 Eina_Bool dragging : 1;
328 Eina_Bool updateme : 1;
329 Eina_Bool nocache : 1;
330 Eina_Bool stacking_even : 1;
331 Eina_Bool nostacking : 1;
338 Evas_Object *base_view, *spacer;
340 const char *item_style; // it->itc->item_style
341 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
342 Eina_Bool compress : 1; // it->wd->compress
344 Eina_Bool selected : 1; // it->selected
345 Eina_Bool disabled : 1; // it->disabled
346 Eina_Bool expanded : 1; // it->expanded
349 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
350 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
354 Evas_Object_Smart_Clipped_Data __clipped_data;
356 Ecore_Job *resize_job;
359 static const char *widtype = NULL;
360 static void _item_cache_zero(Widget_Data *wd);
361 static void _del_hook(Evas_Object *obj);
362 static void _mirrored_set(Evas_Object *obj,
364 static void _theme_hook(Evas_Object *obj);
365 static void _show_region_hook(void *data,
367 static void _sizing_eval(Evas_Object *obj);
368 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
369 static void _item_block_unrealize(Item_Block *itb);
370 static void _calc_job(void *data);
371 static void _on_focus_hook(void *data,
373 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
374 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
375 static Eina_Bool _item_single_select_up(Widget_Data *wd);
376 static Eina_Bool _item_single_select_down(Widget_Data *wd);
377 static Eina_Bool _event_hook(Evas_Object *obj,
379 Evas_Callback_Type type,
381 static void _signal_emit_hook(Evas_Object *obj,
382 const char *emission,
384 static Eina_Bool _deselect_all_items(Widget_Data *wd);
385 static void _pan_calculate(Evas_Object *obj);
386 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
387 static void _mode_item_realize(Elm_Genlist_Item *it);
388 static void _mode_item_unrealize(Elm_Genlist_Item *it);
389 static void _item_mode_set(Elm_Genlist_Item *it);
390 static void _item_mode_unset(Widget_Data *wd);
392 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
394 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
395 static const char SIG_SELECTED[] = "selected";
396 static const char SIG_UNSELECTED[] = "unselected";
397 static const char SIG_EXPANDED[] = "expanded";
398 static const char SIG_CONTRACTED[] = "contracted";
399 static const char SIG_EXPAND_REQUEST[] = "expand,request";
400 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
401 static const char SIG_REALIZED[] = "realized";
402 static const char SIG_UNREALIZED[] = "unrealized";
403 static const char SIG_DRAG_START_UP[] = "drag,start,up";
404 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
405 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
406 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
407 static const char SIG_DRAG_STOP[] = "drag,stop";
408 static const char SIG_DRAG[] = "drag";
409 static const char SIG_LONGPRESSED[] = "longpressed";
410 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
411 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
412 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
413 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
414 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
415 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
416 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
417 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
418 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
419 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
420 static const char SIG_SWIPE[] = "swipe";
422 static const Evas_Smart_Cb_Description _signals[] = {
423 {SIG_CLICKED_DOUBLE, ""},
425 {SIG_UNSELECTED, ""},
427 {SIG_CONTRACTED, ""},
428 {SIG_EXPAND_REQUEST, ""},
429 {SIG_CONTRACT_REQUEST, ""},
431 {SIG_UNREALIZED, ""},
432 {SIG_DRAG_START_UP, ""},
433 {SIG_DRAG_START_DOWN, ""},
434 {SIG_DRAG_START_LEFT, ""},
435 {SIG_DRAG_START_RIGHT, ""},
438 {SIG_LONGPRESSED, ""},
439 {SIG_SCROLL_EDGE_TOP, ""},
440 {SIG_SCROLL_EDGE_BOTTOM, ""},
441 {SIG_SCROLL_EDGE_LEFT, ""},
442 {SIG_SCROLL_EDGE_RIGHT, ""},
443 {SIG_MULTI_SWIPE_LEFT, ""},
444 {SIG_MULTI_SWIPE_RIGHT, ""},
445 {SIG_MULTI_SWIPE_UP, ""},
446 {SIG_MULTI_SWIPE_DOWN, ""},
447 {SIG_MULTI_PINCH_OUT, ""},
448 {SIG_MULTI_PINCH_IN, ""},
453 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
456 _event_hook(Evas_Object *obj,
457 Evas_Object *src __UNUSED__,
458 Evas_Callback_Type type,
461 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
462 Evas_Event_Key_Down *ev = event_info;
463 Widget_Data *wd = elm_widget_data_get(obj);
464 if (!wd) return EINA_FALSE;
465 if (!wd->items) return EINA_FALSE;
466 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
467 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
469 Elm_Genlist_Item *it = NULL;
472 Evas_Coord step_x = 0;
473 Evas_Coord step_y = 0;
476 Evas_Coord page_x = 0;
477 Evas_Coord page_y = 0;
479 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
480 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
481 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
482 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
484 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
488 else if ((!strcmp(ev->keyname, "Right")) ||
489 (!strcmp(ev->keyname, "KP_Right")))
493 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
495 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
496 (_item_multi_select_up(wd)))
497 || (_item_single_select_up(wd)))
499 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
505 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
507 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
508 (_item_multi_select_down(wd)))
509 || (_item_single_select_down(wd)))
511 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
517 else if ((!strcmp(ev->keyname, "Home")) ||
518 (!strcmp(ev->keyname, "KP_Home")))
520 it = elm_genlist_first_item_get(obj);
521 elm_genlist_item_bring_in(it);
522 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
525 else if ((!strcmp(ev->keyname, "End")) ||
526 (!strcmp(ev->keyname, "KP_End")))
528 it = elm_genlist_last_item_get(obj);
529 elm_genlist_item_bring_in(it);
530 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
533 else if ((!strcmp(ev->keyname, "Prior")) ||
534 (!strcmp(ev->keyname, "KP_Prior")))
537 y -= -(page_y * v_h) / 100;
541 else if ((!strcmp(ev->keyname, "Next")) ||
542 (!strcmp(ev->keyname, "KP_Next")))
545 y += -(page_y * v_h) / 100;
549 else if(((!strcmp(ev->keyname, "Return")) ||
550 (!strcmp(ev->keyname, "KP_Enter")) ||
551 (!strcmp(ev->keyname, "space")))
552 && (!wd->multi) && (wd->selected))
554 it = elm_genlist_selected_item_get(obj);
555 elm_genlist_item_expanded_set(it,
556 !elm_genlist_item_expanded_get(it));
558 else if (!strcmp(ev->keyname, "Escape"))
560 if (!_deselect_all_items(wd)) return EINA_FALSE;
561 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
564 else return EINA_FALSE;
566 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
567 elm_smart_scroller_child_pos_set(wd->scr, x, y);
572 _deselect_all_items(Widget_Data *wd)
574 if (!wd->selected) return EINA_FALSE;
576 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
582 _item_multi_select_up(Widget_Data *wd)
584 if (!wd->selected) return EINA_FALSE;
585 if (!wd->multi) return EINA_FALSE;
587 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
588 if (!prev) return EINA_TRUE;
590 if (elm_genlist_item_selected_get(prev))
592 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
593 wd->last_selected_item = prev;
594 elm_genlist_item_show(wd->last_selected_item);
598 elm_genlist_item_selected_set(prev, EINA_TRUE);
599 elm_genlist_item_show(prev);
605 _item_multi_select_down(Widget_Data *wd)
607 if (!wd->selected) return EINA_FALSE;
608 if (!wd->multi) return EINA_FALSE;
610 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
611 if (!next) return EINA_TRUE;
613 if (elm_genlist_item_selected_get(next))
615 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
616 wd->last_selected_item = next;
617 elm_genlist_item_show(wd->last_selected_item);
621 elm_genlist_item_selected_set(next, EINA_TRUE);
622 elm_genlist_item_show(next);
628 _item_single_select_up(Widget_Data *wd)
630 Elm_Genlist_Item *prev;
633 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
634 while ((prev) && (prev->delete_me))
635 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
637 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
639 if (!prev) return EINA_FALSE;
641 _deselect_all_items(wd);
643 elm_genlist_item_selected_set(prev, EINA_TRUE);
644 elm_genlist_item_show(prev);
649 _item_single_select_down(Widget_Data *wd)
651 Elm_Genlist_Item *next;
654 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
655 while ((next) && (next->delete_me))
656 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
658 else next = elm_genlist_item_next_get(wd->last_selected_item);
660 if (!next) return EINA_FALSE;
662 _deselect_all_items(wd);
664 elm_genlist_item_selected_set(next, EINA_TRUE);
665 elm_genlist_item_show(next);
670 _on_focus_hook(void *data __UNUSED__,
673 Widget_Data *wd = elm_widget_data_get(obj);
675 if (elm_widget_focus_get(obj))
677 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
678 evas_object_focus_set(wd->obj, EINA_TRUE);
679 if ((wd->selected) && (!wd->last_selected_item))
680 wd->last_selected_item = eina_list_data_get(wd->selected);
684 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
685 evas_object_focus_set(wd->obj, EINA_FALSE);
690 _del_hook(Evas_Object *obj)
692 Widget_Data *wd = elm_widget_data_get(obj);
694 _item_cache_zero(wd);
695 if (wd->calc_job) ecore_job_del(wd->calc_job);
696 if (wd->update_job) ecore_job_del(wd->update_job);
697 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
698 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
699 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
700 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
701 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
706 _del_pre_hook(Evas_Object *obj)
708 Widget_Data *wd = elm_widget_data_get(obj);
710 evas_object_del(wd->pan_smart);
711 wd->pan_smart = NULL;
712 elm_genlist_clear(obj);
716 _mirrored_set(Evas_Object *obj,
719 Widget_Data *wd = elm_widget_data_get(obj);
721 _item_cache_zero(wd);
722 elm_smart_scroller_mirrored_set(wd->scr, rtl);
726 _theme_hook(Evas_Object *obj)
728 Widget_Data *wd = elm_widget_data_get(obj);
731 evas_event_freeze(evas_object_evas_get(wd->obj));
732 _item_cache_zero(wd);
733 _elm_widget_mirrored_reload(obj);
734 _mirrored_set(obj, elm_widget_mirrored_get(obj));
735 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
736 elm_widget_style_get(obj));
737 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
738 wd->item_width = wd->item_height = 0;
739 wd->group_item_width = wd->group_item_height = 0;
740 wd->minw = wd->minh = wd->realminw = 0;
741 EINA_INLIST_FOREACH(wd->blocks, itb)
744 Elm_Genlist_Item *it;
746 if (itb->realized) _item_block_unrealize(itb);
747 EINA_LIST_FOREACH(itb->items, l, it)
748 it->mincalcd = EINA_FALSE;
750 itb->changed = EINA_TRUE;
752 if (wd->calc_job) ecore_job_del(wd->calc_job);
753 wd->calc_job = ecore_job_add(_calc_job, wd);
755 evas_event_thaw(evas_object_evas_get(wd->obj));
756 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
760 _show_region_hook(void *data,
763 Widget_Data *wd = elm_widget_data_get(data);
764 Evas_Coord x, y, w, h;
766 elm_widget_show_region_get(obj, &x, &y, &w, &h);
767 //x & y are screen coordinates, Add with pan coordinates
770 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
774 _sizing_eval(Evas_Object *obj)
776 Widget_Data *wd = elm_widget_data_get(obj);
777 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
779 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
780 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
782 if (wd->height_for_width)
786 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
787 if ((vw != 0) && (vw != wd->prev_viewport_w))
791 wd->prev_viewport_w = vw;
792 EINA_INLIST_FOREACH(wd->blocks, itb)
794 itb->must_recalc = EINA_TRUE;
796 if (wd->calc_job) ecore_job_del(wd->calc_job);
797 wd->calc_job = ecore_job_add(_calc_job, wd);
800 if (wd->mode == ELM_LIST_LIMIT)
802 Evas_Coord vmw, vmh, vw, vh;
806 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
807 if ((minw > 0) && (vw < minw)) vw = minw;
808 else if ((maxw > 0) && (vw > maxw))
810 edje_object_size_min_calc
811 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
818 edje_object_size_min_calc
819 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
823 evas_object_size_hint_min_set(obj, minw, minh);
824 evas_object_size_hint_max_set(obj, maxw, maxh);
828 _signal_emit_hook(Evas_Object *obj,
829 const char *emission,
832 Widget_Data *wd = elm_widget_data_get(obj);
833 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
838 _item_highlight(Elm_Genlist_Item *it)
840 const char *selectraise;
841 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
842 (it->disabled) || (it->display_only) || (it->mode_view))
844 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
845 selectraise = edje_object_data_get(it->base.view, "selectraise");
846 if ((selectraise) && (!strcmp(selectraise, "on")))
848 evas_object_raise(it->base.view);
849 if ((it->group_item) && (it->group_item->realized))
850 evas_object_raise(it->group_item->base.view);
852 it->highlighted = EINA_TRUE;
856 _item_unhighlight(Elm_Genlist_Item *it)
858 const char *stacking, *selectraise;
859 if ((it->delete_me) || (!it->highlighted)) return;
860 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
861 stacking = edje_object_data_get(it->base.view, "stacking");
862 selectraise = edje_object_data_get(it->base.view, "selectraise");
865 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
866 else evas_object_raise(it->base.view);
868 it->highlighted = EINA_FALSE;
872 _item_block_del(Elm_Genlist_Item *it)
875 Item_Block *itb = it->block;
877 itb->items = eina_list_remove(itb->items, it);
879 itb->changed = EINA_TRUE;
880 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
881 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
884 il = EINA_INLIST_GET(itb);
885 Item_Block *itbn = (Item_Block *)(il->next);
887 it->parent->items = eina_list_remove(it->parent->items, it);
889 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
891 if (itbn) itbn->changed = EINA_TRUE;
897 il = EINA_INLIST_GET(itb);
898 Item_Block *itbp = (Item_Block *)(il->prev);
899 Item_Block *itbn = (Item_Block *)(il->next);
900 if ((itbp) && ((itbp->count + itb->count) < 48))
902 Elm_Genlist_Item *it2;
904 EINA_LIST_FREE(itb->items, it2)
907 itbp->items = eina_list_append(itbp->items, it2);
909 itbp->changed = EINA_TRUE;
911 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
912 EINA_INLIST_GET(itb));
915 else if ((itbn) && ((itbn->count + itb->count) < 48))
919 Eina_List *last = eina_list_last(itb->items);
920 Elm_Genlist_Item *it2 = last->data;
923 itb->items = eina_list_remove_list(itb->items, last);
924 itbn->items = eina_list_prepend(itbn->items, it2);
926 itbn->changed = EINA_TRUE;
929 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
937 _item_del(Elm_Genlist_Item *it)
939 Evas_Object *tob = it->wd->obj;
941 evas_event_freeze(evas_object_evas_get(tob));
942 elm_widget_item_pre_notify_del(it);
943 elm_genlist_item_subitems_clear(it);
944 it->wd->walking -= it->walking;
945 if (it->wd->show_item == it) it->wd->show_item = NULL;
946 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
947 if (it->realized) _item_unrealize(it, EINA_FALSE);
948 if (it->block) _item_block_del(it);
949 if ((!it->delete_me) && (it->itc->func.del))
950 it->itc->func.del((void *)it->base.data, it->base.widget);
951 it->delete_me = EINA_TRUE;
953 it->wd->queue = eina_list_remove(it->wd->queue, it);
954 if (it->wd->anchor_item == it)
956 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
957 if (!it->wd->anchor_item)
958 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
960 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
962 it->parent->items = eina_list_remove(it->parent->items, it);
963 if (it->flags & ELM_GENLIST_ITEM_GROUP)
964 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
965 if (it->long_timer) ecore_timer_del(it->long_timer);
966 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
968 if (it->tooltip.del_cb)
969 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
971 evas_event_thaw(evas_object_evas_get(tob));
972 evas_event_thaw_eval(evas_object_evas_get(tob));
974 elm_widget_item_del(it);
978 _item_select(Elm_Genlist_Item *it)
980 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
983 if (it->wd->always_select) goto call;
986 it->selected = EINA_TRUE;
987 it->wd->selected = eina_list_append(it->wd->selected, it);
991 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
993 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
996 if ((it->wd->clear_me) && (!it->wd->walking))
997 elm_genlist_clear(it->base.widget);
1000 if ((!it->walking) && (it->delete_me))
1002 if (!it->relcount) _item_del(it);
1005 it->wd->last_selected_item = it;
1009 _item_unselect(Elm_Genlist_Item *it)
1011 if ((it->delete_me) || (!it->selected)) return;
1012 it->selected = EINA_FALSE;
1013 it->wd->selected = eina_list_remove(it->wd->selected, it);
1014 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1018 _mouse_move(void *data,
1019 Evas *evas __UNUSED__,
1023 Elm_Genlist_Item *it = data;
1024 Evas_Event_Mouse_Move *ev = event_info;
1025 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1027 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1029 if (!it->wd->on_hold)
1031 it->wd->on_hold = EINA_TRUE;
1032 if (!it->wd->wasselected)
1034 _item_unhighlight(it);
1039 if (it->wd->multitouched)
1041 it->wd->cur_x = ev->cur.canvas.x;
1042 it->wd->cur_y = ev->cur.canvas.y;
1045 if ((it->dragging) && (it->down))
1047 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1050 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1051 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1052 if (abs((it->wd->history[it->wd->movements].x -
1053 it->wd->history[0].x)) > 40)
1054 it->wd->swipe = EINA_TRUE;
1056 it->wd->movements++;
1060 ecore_timer_del(it->long_timer);
1061 it->long_timer = NULL;
1063 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1066 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1070 ecore_timer_del(it->long_timer);
1071 it->long_timer = NULL;
1075 if (!it->display_only)
1076 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1077 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1078 x = ev->cur.canvas.x - x;
1079 y = ev->cur.canvas.y - y;
1082 if (adx < 0) adx = -dx;
1085 if (ady < 0) ady = -dy;
1088 if ((adx > minw) || (ady > minh))
1090 it->dragging = EINA_TRUE;
1093 ecore_timer_del(it->long_timer);
1094 it->long_timer = NULL;
1096 if (!it->wd->wasselected)
1098 _item_unhighlight(it);
1104 evas_object_smart_callback_call(it->base.widget,
1105 SIG_DRAG_START_UP, it);
1109 evas_object_smart_callback_call(it->base.widget,
1110 SIG_DRAG_START_LEFT, it);
1112 evas_object_smart_callback_call(it->base.widget,
1113 SIG_DRAG_START_RIGHT, it);
1119 evas_object_smart_callback_call(it->base.widget,
1120 SIG_DRAG_START_DOWN, it);
1124 evas_object_smart_callback_call(it->base.widget,
1125 SIG_DRAG_START_LEFT, it);
1127 evas_object_smart_callback_call(it->base.widget,
1128 SIG_DRAG_START_RIGHT, it);
1135 _long_press(void *data)
1137 Elm_Genlist_Item *it = data;
1139 it->long_timer = NULL;
1140 if ((it->disabled) || (it->dragging) || (it->display_only))
1141 return ECORE_CALLBACK_CANCEL;
1142 it->wd->longpressed = EINA_TRUE;
1143 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1144 return ECORE_CALLBACK_CANCEL;
1148 _swipe(Elm_Genlist_Item *it)
1153 if ((it->display_only) || (it->disabled)) return;
1154 it->wd->swipe = EINA_FALSE;
1155 for (i = 0; i < it->wd->movements; i++)
1157 sum += it->wd->history[i].x;
1158 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1161 sum /= it->wd->movements;
1162 if (abs(sum - it->wd->history[0].x) <= 10) return;
1163 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1167 _swipe_cancel(void *data)
1169 Elm_Genlist_Item *it = data;
1171 if (!it) return ECORE_CALLBACK_CANCEL;
1172 it->wd->swipe = EINA_FALSE;
1173 it->wd->movements = 0;
1174 return ECORE_CALLBACK_RENEW;
1178 _multi_cancel(void *data)
1180 Widget_Data *wd = data;
1182 if (!wd) return ECORE_CALLBACK_CANCEL;
1183 wd->multi_timeout = EINA_TRUE;
1184 return ECORE_CALLBACK_RENEW;
1188 _multi_touch_gesture_eval(void *data)
1190 Elm_Genlist_Item *it = data;
1192 it->wd->multitouched = EINA_FALSE;
1193 if (it->wd->multi_timer)
1195 ecore_timer_del(it->wd->multi_timer);
1196 it->wd->multi_timer = NULL;
1198 if (it->wd->multi_timeout)
1200 it->wd->multi_timeout = EINA_FALSE;
1204 Evas_Coord minw = 0, minh = 0;
1205 Evas_Coord off_x, off_y, off_mx, off_my;
1207 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1208 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1209 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1210 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1211 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1213 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1215 if ((off_x + off_mx) > (off_y + off_my))
1217 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1218 evas_object_smart_callback_call(it->base.widget,
1219 SIG_MULTI_SWIPE_RIGHT, it);
1220 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1221 evas_object_smart_callback_call(it->base.widget,
1222 SIG_MULTI_SWIPE_LEFT, it);
1223 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1224 evas_object_smart_callback_call(it->base.widget,
1225 SIG_MULTI_PINCH_OUT, it);
1227 evas_object_smart_callback_call(it->base.widget,
1228 SIG_MULTI_PINCH_IN, it);
1232 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1233 evas_object_smart_callback_call(it->base.widget,
1234 SIG_MULTI_SWIPE_DOWN, it);
1235 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1236 evas_object_smart_callback_call(it->base.widget,
1237 SIG_MULTI_SWIPE_UP, it);
1238 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1239 evas_object_smart_callback_call(it->base.widget,
1240 SIG_MULTI_PINCH_OUT, it);
1242 evas_object_smart_callback_call(it->base.widget,
1243 SIG_MULTI_PINCH_IN, it);
1246 it->wd->multi_timeout = EINA_FALSE;
1250 _multi_down(void *data,
1251 Evas *evas __UNUSED__,
1252 Evas_Object *obj __UNUSED__,
1255 Elm_Genlist_Item *it = data;
1256 Evas_Event_Multi_Down *ev = event_info;
1258 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1259 it->wd->multi_device = ev->device;
1260 it->wd->multi_down = EINA_TRUE;
1261 it->wd->multitouched = EINA_TRUE;
1262 it->wd->prev_mx = ev->canvas.x;
1263 it->wd->prev_my = ev->canvas.y;
1264 if (!it->wd->wasselected)
1266 _item_unhighlight(it);
1269 it->wd->wasselected = EINA_FALSE;
1270 it->wd->longpressed = EINA_FALSE;
1273 ecore_timer_del(it->long_timer);
1274 it->long_timer = NULL;
1278 it->dragging = EINA_FALSE;
1279 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1281 if (it->swipe_timer)
1283 ecore_timer_del(it->swipe_timer);
1284 it->swipe_timer = NULL;
1286 if (it->wd->on_hold)
1288 it->wd->swipe = EINA_FALSE;
1289 it->wd->movements = 0;
1290 it->wd->on_hold = EINA_FALSE;
1295 _multi_up(void *data,
1296 Evas *evas __UNUSED__,
1297 Evas_Object *obj __UNUSED__,
1300 Elm_Genlist_Item *it = data;
1301 Evas_Event_Multi_Up *ev = event_info;
1303 if (it->wd->multi_device != ev->device) return;
1304 it->wd->multi_device = 0;
1305 it->wd->multi_down = EINA_FALSE;
1306 if (it->wd->mouse_down) return;
1307 _multi_touch_gesture_eval(data);
1311 _multi_move(void *data,
1312 Evas *evas __UNUSED__,
1313 Evas_Object *obj __UNUSED__,
1316 Elm_Genlist_Item *it = data;
1317 Evas_Event_Multi_Move *ev = event_info;
1319 if (it->wd->multi_device != ev->device) return;
1320 it->wd->cur_mx = ev->cur.canvas.x;
1321 it->wd->cur_my = ev->cur.canvas.y;
1325 _mouse_down(void *data,
1326 Evas *evas __UNUSED__,
1330 Elm_Genlist_Item *it = data;
1331 Evas_Event_Mouse_Down *ev = event_info;
1334 if (ev->button != 1) return;
1335 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1337 it->wd->on_hold = EINA_TRUE;
1340 it->down = EINA_TRUE;
1341 it->dragging = EINA_FALSE;
1342 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1343 it->dx = ev->canvas.x - x;
1344 it->dy = ev->canvas.y - y;
1345 it->wd->mouse_down = EINA_TRUE;
1346 if (!it->wd->multitouched)
1348 it->wd->prev_x = ev->canvas.x;
1349 it->wd->prev_y = ev->canvas.y;
1350 it->wd->multi_timeout = EINA_FALSE;
1351 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1352 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1354 it->wd->longpressed = EINA_FALSE;
1355 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1356 else it->wd->on_hold = EINA_FALSE;
1357 if (it->wd->on_hold) return;
1358 it->wd->wasselected = it->selected;
1359 _item_highlight(it);
1360 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1361 if ((!it->disabled) && (!it->display_only))
1363 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1364 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1366 if (it->long_timer) ecore_timer_del(it->long_timer);
1367 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1368 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1370 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1373 it->long_timer = NULL;
1374 it->wd->swipe = EINA_FALSE;
1375 it->wd->movements = 0;
1379 _mouse_up(void *data,
1380 Evas *evas __UNUSED__,
1381 Evas_Object *obj __UNUSED__,
1384 Elm_Genlist_Item *it = data;
1385 Evas_Event_Mouse_Up *ev = event_info;
1386 Eina_Bool dragged = EINA_FALSE;
1388 if (ev->button != 1) return;
1389 it->down = EINA_FALSE;
1390 it->wd->mouse_down = EINA_FALSE;
1391 if (it->wd->multitouched)
1393 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1394 if (it->wd->multi_down) return;
1395 _multi_touch_gesture_eval(data);
1398 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1399 else it->wd->on_hold = EINA_FALSE;
1402 ecore_timer_del(it->long_timer);
1403 it->long_timer = NULL;
1407 it->dragging = EINA_FALSE;
1408 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1411 if (it->swipe_timer)
1413 ecore_timer_del(it->swipe_timer);
1414 it->swipe_timer = NULL;
1416 if (it->wd->multi_timer)
1418 ecore_timer_del(it->wd->multi_timer);
1419 it->wd->multi_timer = NULL;
1420 it->wd->multi_timeout = EINA_FALSE;
1422 if (it->wd->on_hold)
1424 if (it->wd->swipe) _swipe(data);
1425 it->wd->longpressed = EINA_FALSE;
1426 it->wd->on_hold = EINA_FALSE;
1429 if (it->wd->longpressed)
1431 it->wd->longpressed = EINA_FALSE;
1432 if (!it->wd->wasselected)
1434 _item_unhighlight(it);
1437 it->wd->wasselected = EINA_FALSE;
1442 if (it->want_unrealize)
1444 _item_unrealize(it, EINA_FALSE);
1445 if (it->block->want_unrealize)
1446 _item_block_unrealize(it->block);
1449 if ((it->disabled) || (dragged) || (it->display_only)) return;
1450 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1455 _item_highlight(it);
1460 _item_unhighlight(it);
1468 Widget_Data *wd = it->wd;
1471 while (wd->selected)
1473 _item_unhighlight(wd->selected->data);
1474 _item_unselect(wd->selected->data);
1480 const Eina_List *l, *l_next;
1481 Elm_Genlist_Item *it2;
1483 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1486 _item_unhighlight(it2);
1487 _item_unselect(it2);
1489 //_item_highlight(it);
1492 _item_highlight(it);
1498 _signal_expand_toggle(void *data,
1499 Evas_Object *obj __UNUSED__,
1500 const char *emission __UNUSED__,
1501 const char *source __UNUSED__)
1503 Elm_Genlist_Item *it = data;
1506 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1508 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1512 _signal_expand(void *data,
1513 Evas_Object *obj __UNUSED__,
1514 const char *emission __UNUSED__,
1515 const char *source __UNUSED__)
1517 Elm_Genlist_Item *it = data;
1520 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1524 _signal_contract(void *data,
1525 Evas_Object *obj __UNUSED__,
1526 const char *emission __UNUSED__,
1527 const char *source __UNUSED__)
1529 Elm_Genlist_Item *it = data;
1532 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1536 _scr_hold_timer_cb(void *data)
1538 if (!data) return ECORE_CALLBACK_CANCEL;
1539 Widget_Data *wd = data;
1540 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1541 wd->scr_hold_timer = NULL;
1542 return ECORE_CALLBACK_CANCEL;
1546 _mode_finished_signal_cb(void *data,
1548 const char *emission __UNUSED__,
1549 const char *source __UNUSED__)
1553 Elm_Genlist_Item *it = data;
1554 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1557 evas_event_freeze(evas_object_evas_get(obj));
1558 it->nocache = EINA_FALSE;
1559 _mode_item_unrealize(it);
1560 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1561 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1562 evas_event_thaw(evas_object_evas_get(obj));
1563 evas_event_thaw_eval(evas_object_evas_get(obj));
1567 _item_cache_clean(Widget_Data *wd)
1569 evas_event_freeze(evas_object_evas_get(wd->obj));
1570 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1574 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1575 wd->item_cache = eina_inlist_remove(wd->item_cache,
1576 wd->item_cache->last);
1577 wd->item_cache_count--;
1578 if (itc->spacer) evas_object_del(itc->spacer);
1579 if (itc->base_view) evas_object_del(itc->base_view);
1580 if (itc->item_style) eina_stringshare_del(itc->item_style);
1583 evas_event_thaw(evas_object_evas_get(wd->obj));
1584 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1588 _item_cache_zero(Widget_Data *wd)
1590 int pmax = wd->item_cache_max;
1591 wd->item_cache_max = 0;
1592 _item_cache_clean(wd);
1593 wd->item_cache_max = pmax;
1597 _item_cache_add(Elm_Genlist_Item *it)
1601 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1602 if (it->wd->item_cache_max <= 0)
1604 evas_object_del(it->base.view);
1605 it->base.view = NULL;
1606 evas_object_del(it->spacer);
1608 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1609 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1613 it->wd->item_cache_count++;
1614 itc = calloc(1, sizeof(Item_Cache));
1615 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1616 EINA_INLIST_GET(itc));
1617 itc->spacer = it->spacer;
1619 itc->base_view = it->base.view;
1620 it->base.view = NULL;
1621 evas_object_hide(itc->base_view);
1622 evas_object_move(itc->base_view, -9999, -9999);
1623 itc->item_style = eina_stringshare_add(it->itc->item_style);
1624 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1625 itc->compress = (it->wd->compress);
1626 itc->selected = it->selected;
1627 itc->disabled = it->disabled;
1628 itc->expanded = it->expanded;
1631 ecore_timer_del(it->long_timer);
1632 it->long_timer = NULL;
1634 if (it->swipe_timer)
1636 ecore_timer_del(it->swipe_timer);
1637 it->swipe_timer = NULL;
1639 // FIXME: other callbacks?
1640 edje_object_signal_callback_del_full(itc->base_view,
1641 "elm,action,expand,toggle",
1642 "elm", _signal_expand_toggle, it);
1643 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1645 _signal_expand, it);
1646 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1647 "elm", _signal_contract, it);
1648 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1650 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1652 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1654 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1656 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1658 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1660 _item_cache_clean(it->wd);
1661 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1662 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1666 _item_cache_find(Elm_Genlist_Item *it)
1671 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1672 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1674 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1676 if ((itc->tree == tree) &&
1677 (itc->compress == it->wd->compress) &&
1678 (!strcmp(it->itc->item_style, itc->item_style)))
1680 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1681 EINA_INLIST_GET(itc));
1682 it->wd->item_cache_count--;
1690 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1692 if (!it->nostacking)
1694 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1695 evas_object_lower(it->base.view);
1697 evas_object_raise(it->base.view);
1700 if (it->order_num_in & 0x1)
1701 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1703 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1707 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1711 if (it->selected != itc->selected)
1714 edje_object_signal_emit(it->base.view,
1715 "elm,state,selected", "elm");
1717 if (it->disabled != itc->disabled)
1720 edje_object_signal_emit(it->base.view,
1721 "elm,state,disabled", "elm");
1723 if (it->expanded != itc->expanded)
1726 edje_object_signal_emit(it->base.view,
1727 "elm,state,expanded", "elm");
1733 edje_object_signal_emit(it->base.view,
1734 "elm,state,selected", "elm");
1736 edje_object_signal_emit(it->base.view,
1737 "elm,state,disabled", "elm");
1739 edje_object_signal_emit(it->base.view,
1740 "elm,state,expanded", "elm");
1745 _item_cache_free(Item_Cache *itc)
1747 if (itc->spacer) evas_object_del(itc->spacer);
1748 if (itc->base_view) evas_object_del(itc->base_view);
1749 if (itc->item_style) eina_stringshare_del(itc->item_style);
1754 _item_label_realize(Elm_Genlist_Item *it,
1755 Evas_Object *target,
1758 if (it->itc->func.label_get)
1763 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1764 EINA_LIST_FOREACH(*source, l, key)
1766 char *s = it->itc->func.label_get
1767 ((void *)it->base.data, it->base.widget, key);
1771 edje_object_part_text_set(target, key, s);
1776 edje_object_part_text_set(target, key, "");
1783 _item_icon_realize(Elm_Genlist_Item *it,
1784 Evas_Object *target,
1787 Eina_List *res = NULL;
1789 if (it->itc->func.icon_get)
1794 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1795 EINA_LIST_FOREACH(*source, l, key)
1797 Evas_Object *ic = it->itc->func.icon_get
1798 ((void *)it->base.data, it->base.widget, key);
1802 res = eina_list_append(res, ic);
1803 edje_object_part_swallow(target, key, ic);
1804 evas_object_show(ic);
1805 elm_widget_sub_object_add(it->base.widget, ic);
1807 elm_widget_disabled_set(ic, EINA_TRUE);
1816 _item_state_realize(Elm_Genlist_Item *it,
1817 Evas_Object *target,
1820 if (it->itc->func.state_get)
1826 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1827 EINA_LIST_FOREACH(*source, l, key)
1829 Eina_Bool on = it->itc->func.state_get
1830 ((void *)it->base.data, it->base.widget, key);
1834 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1835 edje_object_signal_emit(target, buf, "elm");
1839 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1840 edje_object_signal_emit(target, buf, "elm");
1847 _item_realize(Elm_Genlist_Item *it,
1851 Elm_Genlist_Item *it2;
1852 const char *treesize;
1854 int depth, tsize = 20;
1855 Item_Cache *itc = NULL;
1857 if (it->delete_me) return;
1858 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1861 if (it->order_num_in != in)
1863 it->order_num_in = in;
1864 _elm_genlist_item_odd_even_update(it);
1865 _elm_genlist_item_state_update(it, NULL);
1867 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1868 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1871 it->order_num_in = in;
1874 it->nocache = EINA_FALSE;
1876 itc = _item_cache_find(it);
1879 it->base.view = itc->base_view;
1880 itc->base_view = NULL;
1881 it->spacer = itc->spacer;
1886 const char *stacking_even;
1887 const char *stacking;
1889 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1890 edje_object_scale_set(it->base.view,
1891 elm_widget_scale_get(it->base.widget) *
1892 _elm_config->scale);
1893 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1894 elm_widget_sub_object_add(it->base.widget, it->base.view);
1896 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1897 strncpy(buf, "tree", sizeof(buf));
1898 else strncpy(buf, "item", sizeof(buf));
1899 if (it->wd->compress)
1900 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1902 strncat(buf, "/", sizeof(buf) - strlen(buf));
1903 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1905 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1906 elm_widget_style_get(it->base.widget));
1908 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1909 if (!stacking_even) stacking_even = "above";
1910 it->stacking_even = !!strcmp("above", stacking_even);
1912 stacking = edje_object_data_get(it->base.view, "stacking");
1913 if (!stacking) stacking = "yes";
1914 it->nostacking = !!strcmp("yes", stacking);
1916 edje_object_mirrored_set(it->base.view,
1917 elm_widget_mirrored_get(it->base.widget));
1919 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1920 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1921 elm_widget_sub_object_add(it->base.widget, it->spacer);
1924 _elm_genlist_item_odd_even_update(it);
1926 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1928 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1930 it->expanded_depth = depth;
1931 treesize = edje_object_data_get(it->base.view, "treesize");
1932 if (treesize) tsize = atoi(treesize);
1933 evas_object_size_hint_min_set(it->spacer,
1934 (depth * tsize) * _elm_config->scale, 1);
1935 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1938 edje_object_signal_callback_add(it->base.view,
1939 "elm,action,expand,toggle",
1940 "elm", _signal_expand_toggle, it);
1941 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1942 "elm", _signal_expand, it);
1943 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1944 "elm", _signal_contract, it);
1945 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1947 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1949 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1951 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1953 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1955 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1958 _elm_genlist_item_state_update(it, itc);
1961 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1963 /* homogenous genlist shortcut */
1966 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1968 it->w = it->minw = it->wd->group_item_width;
1969 it->h = it->minh = it->wd->group_item_height;
1973 it->w = it->minw = it->wd->item_width;
1974 it->h = it->minh = it->wd->item_height;
1976 it->mincalcd = EINA_TRUE;
1981 /* FIXME: If you see that assert, please notify us and we
1982 will clean our mess */
1983 assert(eina_list_count(it->icon_objs) == 0);
1985 _item_label_realize(it, it->base.view, &it->labels);
1986 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1987 _item_state_realize(it, it->base.view, &it->states);
1991 Evas_Coord mw = -1, mh = -1;
1993 if (!it->display_only)
1994 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1995 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1996 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1998 if (!it->display_only)
1999 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2000 it->w = it->minw = mw;
2001 it->h = it->minh = mh;
2002 it->mincalcd = EINA_TRUE;
2004 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2006 it->wd->group_item_width = mw;
2007 it->wd->group_item_height = mh;
2009 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2011 it->wd->item_width = mw;
2012 it->wd->item_height = mh;
2015 if (!calc) evas_object_show(it->base.view);
2018 if (it->tooltip.content_cb)
2020 elm_widget_item_tooltip_content_cb_set(it,
2021 it->tooltip.content_cb,
2022 it->tooltip.data, NULL);
2023 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2026 if (it->mouse_cursor)
2027 elm_widget_item_cursor_set(it, it->mouse_cursor);
2029 it->realized = EINA_TRUE;
2030 it->want_unrealize = EINA_FALSE;
2032 if (itc) _item_cache_free(itc);
2033 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2034 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2035 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2039 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2043 if (!it->realized) return;
2044 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2045 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2048 ecore_timer_del(it->long_timer);
2049 it->long_timer = NULL;
2053 evas_object_del(it->base.view);
2054 it->base.view = NULL;
2055 evas_object_del(it->spacer);
2060 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2061 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2062 _item_cache_add(it);
2064 elm_widget_stringlist_free(it->labels);
2066 elm_widget_stringlist_free(it->icons);
2068 elm_widget_stringlist_free(it->states);
2070 EINA_LIST_FREE(it->icon_objs, icon)
2071 evas_object_del(icon);
2073 _mode_item_unrealize(it);
2075 it->realized = EINA_FALSE;
2076 it->want_unrealize = EINA_FALSE;
2077 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2078 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2082 _item_block_recalc(Item_Block *itb,
2087 Elm_Genlist_Item *it;
2088 Evas_Coord minw = 0, minh = 0;
2089 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2092 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2094 EINA_LIST_FOREACH(itb->items, l, it)
2096 if (it->delete_me) continue;
2097 showme |= it->showme;
2102 if (!it->mincalcd) changed = EINA_TRUE;
2105 _item_realize(it, in, EINA_TRUE);
2106 _item_unrealize(it, EINA_TRUE);
2111 _item_realize(it, in, EINA_TRUE);
2112 _item_unrealize(it, EINA_TRUE);
2116 _item_realize(it, in, EINA_FALSE);
2118 if (minw < it->minw) minw = it->minw;
2126 itb->changed = EINA_FALSE;
2127 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2128 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2133 _item_block_realize(Item_Block *itb,
2138 Elm_Genlist_Item *it;
2140 if (itb->realized) return;
2141 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2142 EINA_LIST_FOREACH(itb->items, l, it)
2144 if (it->delete_me) continue;
2145 if (full) _item_realize(it, in, EINA_FALSE);
2148 itb->realized = EINA_TRUE;
2149 itb->want_unrealize = EINA_FALSE;
2150 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2151 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2155 _item_block_unrealize(Item_Block *itb)
2158 Elm_Genlist_Item *it;
2159 Eina_Bool dragging = EINA_FALSE;
2161 if (!itb->realized) return;
2162 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2163 EINA_LIST_FOREACH(itb->items, l, it)
2165 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2169 dragging = EINA_TRUE;
2170 it->want_unrealize = EINA_TRUE;
2173 _item_unrealize(it, EINA_FALSE);
2178 itb->realized = EINA_FALSE;
2179 itb->want_unrealize = EINA_TRUE;
2182 itb->want_unrealize = EINA_FALSE;
2183 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2184 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2188 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2193 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2194 evas_object_resize(view, it->w, it->h);
2195 evas_object_move(view, it->scrl_x, it->scrl_y);
2196 evas_object_show(view);
2197 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2198 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2202 _item_block_position(Item_Block *itb,
2206 Elm_Genlist_Item *it;
2207 Elm_Genlist_Item *git;
2208 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2211 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2212 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2213 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2215 EINA_LIST_FOREACH(itb->items, l, it)
2217 if (it->delete_me) continue;
2221 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2222 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2224 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2225 cvx, cvy, cvw, cvh));
2226 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2228 if ((itb->realized) && (!it->realized))
2230 if (vis) _item_realize(it, in, EINA_FALSE);
2236 git = it->group_item;
2239 if (git->scrl_y < oy)
2241 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2242 git->scrl_y = (it->scrl_y + it->h) - git->h;
2243 git->want_realize = EINA_TRUE;
2246 _item_position(it, it->mode_view);
2248 _item_position(it, it->base.view);
2252 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2259 if (vis) it->want_realize = EINA_TRUE;
2263 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2264 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2268 _group_items_recalc(void *data)
2270 Widget_Data *wd = data;
2272 Elm_Genlist_Item *git;
2274 evas_event_freeze(evas_object_evas_get(wd->obj));
2275 EINA_LIST_FOREACH(wd->group_items, l, git)
2277 if (git->want_realize)
2280 _item_realize(git, 0, EINA_FALSE);
2281 evas_object_resize(git->base.view, wd->minw, git->h);
2282 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2283 evas_object_show(git->base.view);
2284 evas_object_raise(git->base.view);
2286 else if (!git->want_realize && git->realized)
2289 _item_unrealize(git, EINA_FALSE);
2292 evas_event_thaw(evas_object_evas_get(wd->obj));
2293 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2297 _must_recalc_idler(void *data)
2299 Widget_Data *wd = data;
2300 if (wd->calc_job) ecore_job_del(wd->calc_job);
2301 wd->calc_job = ecore_job_add(_calc_job, wd);
2302 wd->must_recalc_idler = NULL;
2303 return ECORE_CALLBACK_CANCEL;
2307 _calc_job(void *data)
2309 Widget_Data *wd = data;
2311 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2312 Item_Block *chb = NULL;
2313 int in = 0, minw_change = 0;
2314 Eina_Bool changed = EINA_FALSE;
2316 Eina_Bool did_must_recalc = EINA_FALSE;
2319 t0 = ecore_time_get();
2320 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2324 evas_event_freeze(evas_object_evas_get(wd->obj));
2325 EINA_INLIST_FOREACH(wd->blocks, itb)
2327 Eina_Bool showme = EINA_FALSE;
2330 showme = itb->showme;
2331 itb->showme = EINA_FALSE;
2334 if (itb->realized) _item_block_unrealize(itb);
2336 if ((itb->changed) || (changed) ||
2337 ((itb->must_recalc) && (!did_must_recalc)))
2339 if ((changed) || (itb->must_recalc))
2342 Elm_Genlist_Item *it;
2343 EINA_LIST_FOREACH(itb->items, l, it)
2344 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2345 itb->changed = EINA_TRUE;
2346 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2347 itb->must_recalc = EINA_FALSE;
2349 if (itb->realized) _item_block_unrealize(itb);
2350 showme = _item_block_recalc(itb, in, 0);
2356 if (minw == -1) minw = itb->minw;
2357 else if ((!itb->must_recalc) && (minw < itb->minw))
2366 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2368 wd->show_item->showme = EINA_FALSE;
2370 elm_smart_scroller_region_bring_in(wd->scr,
2372 wd->show_item->block->x,
2374 wd->show_item->block->y,
2375 wd->show_item->block->w,
2378 elm_smart_scroller_child_region_show(wd->scr,
2380 wd->show_item->block->x,
2382 wd->show_item->block->y,
2383 wd->show_item->block->w,
2385 wd->show_item = NULL;
2390 EINA_INLIST_FOREACH(wd->blocks, itb)
2396 if ((chb) && (EINA_INLIST_GET(chb)->next))
2398 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2400 if (itb->realized) _item_block_unrealize(itb);
2403 wd->realminw = minw;
2404 if (minw < wd->w) minw = wd->w;
2405 if ((minw != wd->minw) || (minh != wd->minh))
2409 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2410 _sizing_eval(wd->obj);
2411 if ((wd->anchor_item) && (wd->anchor_item->block))
2413 Elm_Genlist_Item *it;
2416 it = wd->anchor_item;
2417 it_y = wd->anchor_y;
2418 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2419 it->block->y + it->y + it_y);
2420 wd->anchor_item = it;
2421 wd->anchor_y = it_y;
2424 t = ecore_time_get();
2425 if (did_must_recalc)
2427 if (!wd->must_recalc_idler)
2428 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2430 wd->calc_job = NULL;
2431 evas_object_smart_changed(wd->pan_smart);
2432 evas_event_thaw(evas_object_evas_get(wd->obj));
2433 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2437 _update_job(void *data)
2439 Widget_Data *wd = data;
2442 int num, num0, position = 0, recalc = 0;
2444 wd->update_job = NULL;
2447 evas_event_freeze(evas_object_evas_get(wd->obj));
2448 EINA_INLIST_FOREACH(wd->blocks, itb)
2450 Evas_Coord itminw, itminh;
2451 Elm_Genlist_Item *it;
2457 _item_block_position(itb, num);
2462 EINA_LIST_FOREACH(itb->items, l2, it)
2469 it->updateme = EINA_FALSE;
2472 _item_unrealize(it, EINA_FALSE);
2473 _item_realize(it, num, EINA_FALSE);
2478 _item_realize(it, num, EINA_TRUE);
2479 _item_unrealize(it, EINA_TRUE);
2481 if ((it->minw != itminw) || (it->minh != itminh))
2486 itb->updateme = EINA_FALSE;
2490 itb->changed = EINA_TRUE;
2491 _item_block_recalc(itb, num0, 0);
2492 _item_block_position(itb, num0);
2497 if (wd->calc_job) ecore_job_del(wd->calc_job);
2498 wd->calc_job = ecore_job_add(_calc_job, wd);
2500 evas_event_thaw(evas_object_evas_get(wd->obj));
2501 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2505 _pan_set(Evas_Object *obj,
2509 Pan *sd = evas_object_smart_data_get(obj);
2512 // Evas_Coord ow, oh;
2513 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2514 // ow = sd->wd->minw - ow;
2515 // if (ow < 0) ow = 0;
2516 // oh = sd->wd->minh - oh;
2517 // if (oh < 0) oh = 0;
2518 // if (x < 0) x = 0;
2519 // if (y < 0) y = 0;
2520 // if (x > ow) x = ow;
2521 // if (y > oh) y = oh;
2522 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2526 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2528 if ((itb->y + itb->h) > y)
2530 Elm_Genlist_Item *it;
2533 EINA_LIST_FOREACH(itb->items, l2, it)
2535 if ((itb->y + it->y) >= y)
2537 sd->wd->anchor_item = it;
2538 sd->wd->anchor_y = -(itb->y + it->y - y);
2545 evas_object_smart_changed(obj);
2549 _pan_get(Evas_Object *obj,
2553 Pan *sd = evas_object_smart_data_get(obj);
2555 if (x) *x = sd->wd->pan_x;
2556 if (y) *y = sd->wd->pan_y;
2560 _pan_max_get(Evas_Object *obj,
2564 Pan *sd = evas_object_smart_data_get(obj);
2567 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2568 ow = sd->wd->minw - ow;
2570 oh = sd->wd->minh - oh;
2577 _pan_min_get(Evas_Object *obj __UNUSED__,
2586 _pan_child_size_get(Evas_Object *obj,
2590 Pan *sd = evas_object_smart_data_get(obj);
2592 if (w) *w = sd->wd->minw;
2593 if (h) *h = sd->wd->minh;
2597 _pan_add(Evas_Object *obj)
2600 Evas_Object_Smart_Clipped_Data *cd;
2603 cd = evas_object_smart_data_get(obj);
2606 sd->__clipped_data = *cd;
2608 evas_object_smart_data_set(obj, sd);
2612 _pan_del(Evas_Object *obj)
2614 Pan *sd = evas_object_smart_data_get(obj);
2619 ecore_job_del(sd->resize_job);
2620 sd->resize_job = NULL;
2626 _pan_resize_job(void *data)
2629 _sizing_eval(sd->wd->obj);
2630 sd->resize_job = NULL;
2634 _pan_resize(Evas_Object *obj,
2638 Pan *sd = evas_object_smart_data_get(obj);
2641 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2642 if ((ow == w) && (oh == h)) return;
2643 if ((sd->wd->height_for_width) && (ow != w))
2645 if (sd->resize_job) ecore_job_del(sd->resize_job);
2646 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2648 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2649 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2653 _pan_calculate(Evas_Object *obj)
2655 Pan *sd = evas_object_smart_data_get(obj);
2657 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2659 Elm_Genlist_Item *git;
2662 evas_event_freeze(evas_object_evas_get(obj));
2663 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2664 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2665 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2667 git->want_realize = EINA_FALSE;
2669 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2671 itb->w = sd->wd->minw;
2672 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2673 itb->y - sd->wd->pan_y + oy,
2675 cvx, cvy, cvw, cvh))
2677 if ((!itb->realized) || (itb->changed))
2678 _item_block_realize(itb, in, 0);
2679 _item_block_position(itb, in);
2683 if (itb->realized) _item_block_unrealize(itb);
2687 _group_items_recalc(sd->wd);
2688 evas_event_thaw(evas_object_evas_get(obj));
2689 evas_event_thaw_eval(evas_object_evas_get(obj));
2693 _pan_move(Evas_Object *obj,
2694 Evas_Coord x __UNUSED__,
2695 Evas_Coord y __UNUSED__)
2697 Pan *sd = evas_object_smart_data_get(obj);
2699 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2700 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2704 _hold_on(void *data __UNUSED__,
2706 void *event_info __UNUSED__)
2708 Widget_Data *wd = elm_widget_data_get(obj);
2710 elm_smart_scroller_hold_set(wd->scr, 1);
2714 _hold_off(void *data __UNUSED__,
2716 void *event_info __UNUSED__)
2718 Widget_Data *wd = elm_widget_data_get(obj);
2720 elm_smart_scroller_hold_set(wd->scr, 0);
2724 _freeze_on(void *data __UNUSED__,
2726 void *event_info __UNUSED__)
2728 Widget_Data *wd = elm_widget_data_get(obj);
2730 elm_smart_scroller_freeze_set(wd->scr, 1);
2734 _freeze_off(void *data __UNUSED__,
2736 void *event_info __UNUSED__)
2738 Widget_Data *wd = elm_widget_data_get(obj);
2740 elm_smart_scroller_freeze_set(wd->scr, 0);
2744 _scroll_edge_left(void *data,
2745 Evas_Object *scr __UNUSED__,
2746 void *event_info __UNUSED__)
2748 Evas_Object *obj = data;
2749 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2753 _scroll_edge_right(void *data,
2754 Evas_Object *scr __UNUSED__,
2755 void *event_info __UNUSED__)
2757 Evas_Object *obj = data;
2758 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2762 _scroll_edge_top(void *data,
2763 Evas_Object *scr __UNUSED__,
2764 void *event_info __UNUSED__)
2766 Evas_Object *obj = data;
2767 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2771 _scroll_edge_bottom(void *data,
2772 Evas_Object *scr __UNUSED__,
2773 void *event_info __UNUSED__)
2775 Evas_Object *obj = data;
2776 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2780 _mode_item_realize(Elm_Genlist_Item *it)
2784 if ((it->mode_view) || (it->delete_me)) return;
2786 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2787 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2788 edje_object_scale_set(it->mode_view,
2789 elm_widget_scale_get(it->base.widget) *
2790 _elm_config->scale);
2791 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2792 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2794 strncpy(buf, "item", sizeof(buf));
2795 if (it->wd->compress)
2796 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2798 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2799 strncat(buf, "/", sizeof(buf) - strlen(buf));
2800 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2802 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2803 elm_widget_style_get(it->base.widget));
2804 edje_object_mirrored_set(it->mode_view,
2805 elm_widget_mirrored_get(it->base.widget));
2807 /* signal callback add */
2808 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2810 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2812 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2815 /* label_get, icon_get, state_get */
2816 /* FIXME: If you see that assert, please notify us and we
2817 will clean our mess */
2818 assert(eina_list_count(it->mode_icon_objs) == 0);
2820 _item_label_realize(it, it->mode_view, &it->mode_labels);
2821 it->mode_icon_objs = _item_icon_realize(it,
2824 _item_state_realize(it, it->mode_view, &it->mode_states);
2826 edje_object_part_swallow(it->mode_view,
2827 edje_object_data_get(it->mode_view, "mode_part"),
2830 it->want_unrealize = EINA_FALSE;
2831 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2832 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2836 _mode_item_unrealize(Elm_Genlist_Item *it)
2838 Widget_Data *wd = it->wd;
2840 if (!it->mode_view) return;
2842 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2843 elm_widget_stringlist_free(it->mode_labels);
2844 it->mode_labels = NULL;
2845 elm_widget_stringlist_free(it->mode_icons);
2846 it->mode_icons = NULL;
2847 elm_widget_stringlist_free(it->mode_states);
2849 EINA_LIST_FREE(it->mode_icon_objs, icon)
2850 evas_object_del(icon);
2852 edje_object_part_unswallow(it->mode_view, it->base.view);
2853 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2854 evas_object_del(it->mode_view);
2855 it->mode_view = NULL;
2857 if (wd->mode_item == it)
2858 wd->mode_item = NULL;
2859 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2860 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2864 _item_mode_set(Elm_Genlist_Item *it)
2867 Widget_Data *wd = it->wd;
2872 it->nocache = EINA_TRUE;
2874 if (wd->scr_hold_timer)
2876 ecore_timer_del(wd->scr_hold_timer);
2877 wd->scr_hold_timer = NULL;
2879 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2880 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2882 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2883 _mode_item_realize(it);
2884 _item_position(it, it->mode_view);
2885 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2886 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2888 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2889 edje_object_signal_emit(it->mode_view, buf, "elm");
2893 _item_mode_unset(Widget_Data *wd)
2896 if (!wd->mode_item) return;
2897 char buf[1024], buf2[1024];
2898 Elm_Genlist_Item *it;
2901 it->nocache = EINA_TRUE;
2903 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2904 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2906 edje_object_signal_emit(it->mode_view, buf, "elm");
2907 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2909 wd->mode_item = NULL;
2913 * Add a new Genlist object
2915 * @param parent The parent object
2916 * @return The new object or NULL if it cannot be created
2921 elm_genlist_add(Evas_Object *parent)
2926 Evas_Coord minw, minh;
2927 static Evas_Smart *smart = NULL;
2931 static Evas_Smart_Class sc;
2933 evas_object_smart_clipped_smart_set(&_pan_sc);
2935 sc.name = "elm_genlist_pan";
2936 sc.version = EVAS_SMART_CLASS_VERSION;
2939 sc.resize = _pan_resize;
2940 sc.move = _pan_move;
2941 sc.calculate = _pan_calculate;
2942 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2945 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2947 ELM_SET_WIDTYPE(widtype, "genlist");
2948 elm_widget_type_set(obj, "genlist");
2949 elm_widget_sub_object_add(parent, obj);
2950 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2951 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2952 elm_widget_data_set(obj, wd);
2953 elm_widget_del_hook_set(obj, _del_hook);
2954 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2955 elm_widget_theme_hook_set(obj, _theme_hook);
2956 elm_widget_can_focus_set(obj, EINA_TRUE);
2957 elm_widget_event_hook_set(obj, _event_hook);
2958 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2960 wd->scr = elm_smart_scroller_add(e);
2961 elm_smart_scroller_widget_set(wd->scr, obj);
2962 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2963 elm_widget_style_get(obj));
2964 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2965 _elm_config->thumbscroll_bounce_enable);
2966 elm_widget_resize_object_set(obj, wd->scr);
2968 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2969 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2971 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2972 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2976 wd->mode = ELM_LIST_SCROLL;
2977 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2978 wd->item_cache_max = wd->max_items_per_block * 2;
2979 wd->longpress_timeout = _elm_config->longpress_timeout;
2981 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2982 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2983 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2984 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2986 wd->pan_smart = evas_object_smart_add(e, smart);
2987 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2990 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2991 _pan_set, _pan_get, _pan_max_get,
2992 _pan_min_get, _pan_child_size_get);
2994 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2996 evas_object_size_hint_min_set(obj, minw, minh);
2998 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3000 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3005 static Elm_Genlist_Item *
3006 _item_new(Widget_Data *wd,
3007 const Elm_Genlist_Item_Class *itc,
3009 Elm_Genlist_Item *parent,
3010 Elm_Genlist_Item_Flags flags,
3012 const void *func_data)
3014 Elm_Genlist_Item *it;
3016 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3017 if (!it) return NULL;
3020 it->base.data = data;
3021 it->parent = parent;
3023 it->func.func = func;
3024 it->func.data = func_data;
3025 it->mouse_cursor = NULL;
3026 it->expanded_depth = 0;
3031 _item_block_add(Widget_Data *wd,
3032 Elm_Genlist_Item *it)
3034 Item_Block *itb = NULL;
3041 itb = calloc(1, sizeof(Item_Block));
3044 if (!it->rel->block)
3047 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3048 itb->items = eina_list_append(itb->items, it);
3054 wd->blocks = eina_inlist_prepend_relative
3055 (wd->blocks, EINA_INLIST_GET(itb),
3056 EINA_INLIST_GET(it->rel->block));
3058 eina_list_prepend_relative(itb->items, it, it->rel);
3062 wd->blocks = eina_inlist_append_relative
3063 (wd->blocks, EINA_INLIST_GET(itb),
3064 EINA_INLIST_GET(it->rel->block));
3066 eina_list_append_relative(itb->items, it, it->rel);
3076 itb = (Item_Block *)(wd->blocks);
3077 if (itb->count >= wd->max_items_per_block)
3079 itb = calloc(1, sizeof(Item_Block));
3083 eina_inlist_prepend(wd->blocks,
3084 EINA_INLIST_GET(itb));
3089 itb = calloc(1, sizeof(Item_Block));
3093 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3095 itb->items = eina_list_prepend(itb->items, it);
3101 itb = (Item_Block *)(wd->blocks->last);
3102 if (itb->count >= wd->max_items_per_block)
3104 itb = calloc(1, sizeof(Item_Block));
3108 eina_inlist_append(wd->blocks,
3109 EINA_INLIST_GET(itb));
3114 itb = calloc(1, sizeof(Item_Block));
3118 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3120 itb->items = eina_list_append(itb->items, it);
3126 itb = it->rel->block;
3127 if (!itb) goto newblock;
3129 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3131 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3134 itb->changed = EINA_TRUE;
3136 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3137 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3140 it->rel->relcount--;
3141 if ((it->rel->delete_me) && (!it->rel->relcount))
3145 if (itb->count > itb->wd->max_items_per_block)
3149 Elm_Genlist_Item *it2;
3151 newc = itb->count / 2;
3152 itb2 = calloc(1, sizeof(Item_Block));
3156 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3157 EINA_INLIST_GET(itb));
3158 itb2->changed = EINA_TRUE;
3159 while ((itb->count > newc) && (itb->items))
3163 l = eina_list_last(itb->items);
3165 itb->items = eina_list_remove_list(itb->items, l);
3168 itb2->items = eina_list_prepend(itb2->items, it2);
3176 _queue_process(Widget_Data *wd)
3179 Eina_Bool showme = EINA_FALSE;
3182 t0 = ecore_time_get();
3183 evas_event_freeze(evas_object_evas_get(wd->obj));
3184 for (n = 0; (wd->queue) && (n < 128); n++)
3186 Elm_Genlist_Item *it;
3188 it = wd->queue->data;
3189 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3190 it->queued = EINA_FALSE;
3191 _item_block_add(wd, it);
3192 t = ecore_time_get();
3193 if (it->block->changed)
3195 showme = _item_block_recalc(it->block, it->block->num, 1);
3196 it->block->changed = 0;
3198 if (showme) it->block->showme = EINA_TRUE;
3199 if (eina_inlist_count(wd->blocks) > 1)
3201 if ((t - t0) > (ecore_animator_frametime_get())) break;
3204 evas_event_thaw(evas_object_evas_get(wd->obj));
3205 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3210 _idle_process(void *data, Eina_Bool *wakeup)
3212 Widget_Data *wd = data;
3215 //static double q_start = 0.0;
3216 //if (q_start == 0.0) q_start = ecore_time_get();
3218 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3222 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3224 return ECORE_CALLBACK_CANCEL;
3226 return ECORE_CALLBACK_RENEW;
3230 _item_idle_enterer(void *data)
3232 Widget_Data *wd = data;
3233 Eina_Bool wakeup = EINA_FALSE;
3234 Eina_Bool ok = _idle_process(data, &wakeup);
3239 if (wd->calc_job) ecore_job_del(wd->calc_job);
3240 wd->calc_job = ecore_job_add(_calc_job, wd);
3242 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3247 _item_queue(Widget_Data *wd,
3248 Elm_Genlist_Item *it)
3250 if (it->queued) return;
3251 it->queued = EINA_TRUE;
3252 wd->queue = eina_list_append(wd->queue, it);
3253 evas_event_freeze(evas_object_evas_get(wd->obj));
3254 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3256 if (wd->queue_idle_enterer)
3258 ecore_idle_enterer_del(wd->queue_idle_enterer);
3259 wd->queue_idle_enterer = NULL;
3263 evas_event_thaw(evas_object_evas_get(wd->obj));
3264 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3265 if (!wd->queue_idle_enterer)
3266 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3270 _elm_genlist_item_compare(const void *data, const void *data1)
3272 Elm_Genlist_Item *item, *item1;
3273 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3274 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3275 return _elm_genlist_item_compare_cb(item->base.data, item1->base.data);
3279 * Append item to the end of the genlist
3281 * This appends the given item to the end of the list or the end of
3282 * the children if the parent is given.
3284 * @param obj The genlist object
3285 * @param itc The item class for the item
3286 * @param data The item data
3287 * @param parent The parent item, or NULL if none
3288 * @param flags Item flags
3289 * @param func Convenience function called when item selected
3290 * @param func_data Data passed to @p func above.
3291 * @return A handle to the item added or NULL if not possible
3295 EAPI Elm_Genlist_Item *
3296 elm_genlist_item_append(Evas_Object *obj,
3297 const Elm_Genlist_Item_Class *itc,
3299 Elm_Genlist_Item *parent,
3300 Elm_Genlist_Item_Flags flags,
3302 const void *func_data)
3304 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3305 Widget_Data *wd = elm_widget_data_get(obj);
3306 if (!wd) return NULL;
3307 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3309 if (!it) return NULL;
3312 if (flags & ELM_GENLIST_ITEM_GROUP)
3313 wd->group_items = eina_list_append(wd->group_items, it);
3314 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3319 Elm_Genlist_Item *it2 = NULL;
3320 Eina_List *ll = eina_list_last(it->parent->items);
3321 if (ll) it2 = ll->data;
3322 it->parent->items = eina_list_append(it->parent->items, it);
3323 if (!it2) it2 = it->parent;
3325 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3326 EINA_INLIST_GET(it2));
3328 it->rel->relcount++;
3330 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3331 it->group_item = parent;
3332 else if (it->parent->group_item)
3333 it->group_item = it->parent->group_item;
3335 it->before = EINA_FALSE;
3336 _item_queue(wd, it);
3341 * Prepend item at start of the genlist
3343 * This adds an item to the beginning of the list or beginning of the
3344 * children of the parent if given.
3346 * @param obj The genlist object
3347 * @param itc The item class for the item
3348 * @param data The item data
3349 * @param parent The parent item, or NULL if none
3350 * @param flags Item flags
3351 * @param func Convenience function called when item selected
3352 * @param func_data Data passed to @p func above.
3353 * @return A handle to the item added or NULL if not possible
3357 EAPI Elm_Genlist_Item *
3358 elm_genlist_item_prepend(Evas_Object *obj,
3359 const Elm_Genlist_Item_Class *itc,
3361 Elm_Genlist_Item *parent,
3362 Elm_Genlist_Item_Flags flags,
3364 const void *func_data)
3366 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3367 Widget_Data *wd = elm_widget_data_get(obj);
3368 if (!wd) return NULL;
3369 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3371 if (!it) return NULL;
3374 if (flags & ELM_GENLIST_ITEM_GROUP)
3375 wd->group_items = eina_list_prepend(wd->group_items, it);
3376 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3381 Elm_Genlist_Item *it2 = NULL;
3382 Eina_List *ll = it->parent->items;
3383 if (ll) it2 = ll->data;
3384 it->parent->items = eina_list_prepend(it->parent->items, it);
3385 if (!it2) it2 = it->parent;
3387 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3388 EINA_INLIST_GET(it2));
3390 it->rel->relcount++;
3392 it->before = EINA_TRUE;
3393 _item_queue(wd, it);
3398 * Insert item before another in the genlist
3400 * This inserts an item before another in the list. It will be in the
3401 * same tree level or group as the item it is inseted before.
3403 * @param obj The genlist object
3404 * @param itc The item class for the item
3405 * @param data The item data
3406 * @param before The item to insert before
3407 * @param flags Item flags
3408 * @param func Convenience function called when item selected
3409 * @param func_data Data passed to @p func above.
3410 * @return A handle to the item added or NULL if not possible
3414 EAPI Elm_Genlist_Item *
3415 elm_genlist_item_insert_before(Evas_Object *obj,
3416 const Elm_Genlist_Item_Class *itc,
3418 Elm_Genlist_Item *parent,
3419 Elm_Genlist_Item *before,
3420 Elm_Genlist_Item_Flags flags,
3422 const void *func_data)
3424 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3425 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3426 Widget_Data *wd = elm_widget_data_get(obj);
3427 if (!wd) return NULL;
3428 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3430 if (!it) return NULL;
3433 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3436 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3437 EINA_INLIST_GET(before));
3439 it->rel->relcount++;
3440 it->before = EINA_TRUE;
3441 _item_queue(wd, it);
3446 * Insert a new item into the sorted genlist object
3448 * @param obj The genlist object
3449 * @param itc The item class for the item
3450 * @param data The item data
3451 * @param parent The parent item, or NULL if none
3452 * @param flags Item flags
3453 * @param comp The function called for the sort
3454 * @param func Convenience function called when item selected
3455 * @param func_data Data passed to @p func above.
3456 * @return A handle to the item added or NULL if not possible
3460 EAPI Elm_Genlist_Item *
3461 elm_genlist_item_sorted_insert(Evas_Object *obj,
3462 const Elm_Genlist_Item_Class *itc,
3464 Elm_Genlist_Item *parent,
3465 Elm_Genlist_Item_Flags flags,
3466 Eina_Compare_Cb comp,
3468 const void *func_data)
3470 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3471 Widget_Data *wd = elm_widget_data_get(obj);
3472 if (!wd) return NULL;
3473 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3475 if (!it) return NULL;
3477 _elm_genlist_item_compare_cb = comp;
3481 eina_list_sorted_insert(it->parent->items, comp, it);
3483 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3484 _elm_genlist_item_compare);
3485 if (EINA_INLIST_GET(it)->next)
3487 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3488 it->rel->relcount++;
3489 it->before = EINA_TRUE;
3491 else if (EINA_INLIST_GET(it)->prev)
3493 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3494 it->rel->relcount++;
3495 it->before = EINA_FALSE;
3497 _item_queue(wd, it);
3503 * Insert an item after another in the genlst
3505 * This inserts an item after another in the list. It will be in the
3506 * same tree level or group as the item it is inseted after.
3508 * @param obj The genlist object
3509 * @param itc The item class for the item
3510 * @param data The item data
3511 * @param after The item to insert after
3512 * @param flags Item flags
3513 * @param func Convenience function called when item selected
3514 * @param func_data Data passed to @p func above.
3515 * @return A handle to the item added or NULL if not possible
3519 EAPI Elm_Genlist_Item *
3520 elm_genlist_item_insert_after(Evas_Object *obj,
3521 const Elm_Genlist_Item_Class *itc,
3523 Elm_Genlist_Item *parent,
3524 Elm_Genlist_Item *after,
3525 Elm_Genlist_Item_Flags flags,
3527 const void *func_data)
3529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3530 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3531 Widget_Data *wd = elm_widget_data_get(obj);
3532 if (!wd) return NULL;
3533 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3535 if (!it) return NULL;
3536 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3537 EINA_INLIST_GET(after));
3540 it->parent->items = eina_list_append_relative(it->parent->items, it,
3544 it->rel->relcount++;
3545 it->before = EINA_FALSE;
3546 _item_queue(wd, it);
3553 * This clears all items in the list, leaving it empty.
3555 * @param obj The genlist object
3560 elm_genlist_clear(Evas_Object *obj)
3562 ELM_CHECK_WIDTYPE(obj, widtype);
3563 Widget_Data *wd = elm_widget_data_get(obj);
3565 if (wd->walking > 0)
3567 Elm_Genlist_Item *it;
3569 wd->clear_me = EINA_TRUE;
3570 EINA_INLIST_FOREACH(wd->items, it)
3572 it->delete_me = EINA_TRUE;
3576 evas_event_freeze(evas_object_evas_get(wd->obj));
3579 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3581 if (wd->anchor_item == it)
3583 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3584 if (!wd->anchor_item)
3586 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3588 wd->items = eina_inlist_remove(wd->items, wd->items);
3589 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3590 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3591 elm_widget_item_pre_notify_del(it);
3592 if (it->realized) _item_unrealize(it, EINA_FALSE);
3593 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3594 it->itc->func.del((void *)it->base.data, it->base.widget);
3595 if (it->long_timer) ecore_timer_del(it->long_timer);
3596 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3597 elm_widget_item_del(it);
3599 wd->clear_me = EINA_FALSE;
3600 wd->anchor_item = NULL;
3603 Item_Block *itb = (Item_Block *)(wd->blocks);
3605 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3606 if (itb->items) eina_list_free(itb->items);
3611 ecore_job_del(wd->calc_job);
3612 wd->calc_job = NULL;
3614 if (wd->queue_idle_enterer)
3616 ecore_idle_enterer_del(wd->queue_idle_enterer);
3617 wd->queue_idle_enterer = NULL;
3619 if (wd->must_recalc_idler)
3621 ecore_idler_del(wd->must_recalc_idler);
3622 wd->must_recalc_idler = NULL;
3626 eina_list_free(wd->queue);
3631 eina_list_free(wd->selected);
3632 wd->selected = NULL;
3634 wd->show_item = NULL;
3641 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3642 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3645 evas_event_thaw(evas_object_evas_get(wd->obj));
3646 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3650 * Enable or disable multi-select in the genlist
3652 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3653 * the list. This allows more than 1 item to be selected.
3655 * @param obj The genlist object
3656 * @param multi Multi-select enable/disable
3661 elm_genlist_multi_select_set(Evas_Object *obj,
3664 ELM_CHECK_WIDTYPE(obj, widtype);
3665 Widget_Data *wd = elm_widget_data_get(obj);
3671 * Gets if multi-select in genlist is enable or disable
3673 * @param obj The genlist object
3674 * @return Multi-select enable/disable
3675 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3680 elm_genlist_multi_select_get(const Evas_Object *obj)
3682 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3683 Widget_Data *wd = elm_widget_data_get(obj);
3684 if (!wd) return EINA_FALSE;
3689 * Get the selectd item in the genlist
3691 * This gets the selected item in the list (if multi-select is enabled
3692 * only the first item in the list is selected - which is not very
3693 * useful, so see elm_genlist_selected_items_get() for when
3694 * multi-select is used).
3696 * If no item is selected, NULL is returned.
3698 * @param obj The genlist object
3699 * @return The selected item, or NULL if none.
3703 EAPI Elm_Genlist_Item *
3704 elm_genlist_selected_item_get(const Evas_Object *obj)
3706 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3707 Widget_Data *wd = elm_widget_data_get(obj);
3708 if (!wd) return NULL;
3709 if (wd->selected) return wd->selected->data;
3714 * Get a list of selected items in the genlist
3716 * This returns a list of the selected items. This list pointer is
3717 * only valid so long as no items are selected or unselected (or
3718 * unselected implicitly by deletion). The list contains
3719 * Elm_Genlist_Item pointers.
3721 * @param obj The genlist object
3722 * @return The list of selected items, nor NULL if none are selected.
3726 EAPI const Eina_List *
3727 elm_genlist_selected_items_get(const Evas_Object *obj)
3729 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3730 Widget_Data *wd = elm_widget_data_get(obj);
3731 if (!wd) return NULL;
3732 return wd->selected;
3736 * Get a list of realized items in genlist
3738 * This returns a list of the realized items in the genlist. The list
3739 * contains Elm_Genlist_Item pointers. The list must be freed by the
3740 * caller when done with eina_list_free(). The item pointers in the
3741 * list are only valid so long as those items are not deleted or the
3742 * genlist is not deleted.
3744 * @param obj The genlist object
3745 * @return The list of realized items, nor NULL if none are realized.
3750 elm_genlist_realized_items_get(const Evas_Object *obj)
3752 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3753 Widget_Data *wd = elm_widget_data_get(obj);
3754 Eina_List *list = NULL;
3756 Eina_Bool done = EINA_FALSE;
3757 if (!wd) return NULL;
3758 EINA_INLIST_FOREACH(wd->blocks, itb)
3763 Elm_Genlist_Item *it;
3766 EINA_LIST_FOREACH(itb->items, l, it)
3768 if (it->realized) list = eina_list_append(list, it);
3780 * Get the item that is at the x, y canvas coords
3782 * This returns the item at the given coordinates (which are canvas
3783 * relative not object-relative). If an item is at that coordinate,
3784 * that item handle is returned, and if @p posret is not NULL, the
3785 * integer pointed to is set to a value of -1, 0 or 1, depending if
3786 * the coordinate is on the upper portion of that item (-1), on the
3787 * middle section (0) or on the lower part (1). If NULL is returned as
3788 * an item (no item found there), then posret may indicate -1 or 1
3789 * based if the coordinate is above or below all items respectively in
3792 * @param it The item
3793 * @param x The input x coordinate
3794 * @param y The input y coordinate
3795 * @param posret The position relative to the item returned here
3796 * @return The item at the coordinates or NULL if none
3800 EAPI Elm_Genlist_Item *
3801 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3806 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3807 Widget_Data *wd = elm_widget_data_get(obj);
3808 Evas_Coord ox, oy, ow, oh;
3811 if (!wd) return NULL;
3812 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3814 EINA_INLIST_FOREACH(wd->blocks, itb)
3817 Elm_Genlist_Item *it;
3819 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3820 oy + itb->y - itb->wd->pan_y,
3821 itb->w, itb->h, x, y, 1, 1))
3823 EINA_LIST_FOREACH(itb->items, l, it)
3825 Evas_Coord itx, ity;
3827 itx = ox + itb->x + it->x - itb->wd->pan_x;
3828 ity = oy + itb->y + it->y - itb->wd->pan_y;
3829 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3833 if (y <= (ity + (it->h / 4))) *posret = -1;
3834 else if (y >= (ity + it->h - (it->h / 4)))
3840 lasty = ity + it->h;
3845 if (y > lasty) *posret = 1;
3852 * Get the first item in the genlist
3854 * This returns the first item in the list.
3856 * @param obj The genlist object
3857 * @return The first item, or NULL if none
3861 EAPI Elm_Genlist_Item *
3862 elm_genlist_first_item_get(const Evas_Object *obj)
3864 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3865 Widget_Data *wd = elm_widget_data_get(obj);
3866 if (!wd) return NULL;
3867 if (!wd->items) return NULL;
3868 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3869 while ((it) && (it->delete_me))
3870 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3875 * Get the last item in the genlist
3877 * This returns the last item in the list.
3879 * @return The last item, or NULL if none
3883 EAPI Elm_Genlist_Item *
3884 elm_genlist_last_item_get(const Evas_Object *obj)
3886 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3887 Widget_Data *wd = elm_widget_data_get(obj);
3888 if (!wd) return NULL;
3889 if (!wd->items) return NULL;
3890 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3891 while ((it) && (it->delete_me))
3892 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3897 * Get the next item in the genlist
3899 * This returns the item after the item @p it.
3901 * @param it The item
3902 * @return The item after @p it, or NULL if none
3906 EAPI Elm_Genlist_Item *
3907 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3909 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3912 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3913 if ((it) && (!it->delete_me)) break;
3915 return (Elm_Genlist_Item *)it;
3919 * Get the previous item in the genlist
3921 * This returns the item before the item @p it.
3923 * @param it The item
3924 * @return The item before @p it, or NULL if none
3928 EAPI Elm_Genlist_Item *
3929 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3931 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3934 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3935 if ((it) && (!it->delete_me)) break;
3937 return (Elm_Genlist_Item *)it;
3941 * Get the genlist object from an item
3943 * This returns the genlist object itself that an item belongs to.
3945 * @param it The item
3946 * @return The genlist object
3951 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3953 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3954 return it->base.widget;
3958 * Get the parent item of the given item
3960 * This returns the parent item of the item @p it given.
3962 * @param it The item
3963 * @return The parent of the item or NULL if none
3967 EAPI Elm_Genlist_Item *
3968 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3970 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3975 * Clear all sub-items (children) of the given item
3977 * This clears all items that are children (or their descendants) of the
3980 * @param it The item
3985 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3988 Eina_List *tl = NULL, *l;
3989 Elm_Genlist_Item *it2;
3991 EINA_LIST_FOREACH(it->items, l, it2)
3992 tl = eina_list_append(tl, it2);
3993 EINA_LIST_FREE(tl, it2)
3994 elm_genlist_item_del(it2);
3998 * Set the selected state of an item
4000 * This sets the selected state (1 selected, 0 not selected) of the given
4003 * @param it The item
4004 * @param selected The selected state
4009 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4012 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4013 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4015 if ((it->delete_me) || (it->disabled)) return;
4016 selected = !!selected;
4017 if (it->selected == selected) return;
4023 while (wd->selected)
4025 _item_unhighlight(wd->selected->data);
4026 _item_unselect(wd->selected->data);
4029 _item_highlight(it);
4034 _item_unhighlight(it);
4040 * Get the selected state of an item
4042 * This gets the selected state of an item (1 selected, 0 not selected).
4044 * @param it The item
4045 * @return The selected state
4050 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4052 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4053 return it->selected;
4057 * Sets the expanded state of an item (if it's a parent)
4059 * This expands or contracts a parent item (thus showing or hiding the
4062 * @param it The item
4063 * @param expanded The expanded state (1 expanded, 0 not expanded).
4068 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4071 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4072 if (it->expanded == expanded) return;
4073 it->expanded = expanded;
4077 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4078 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4083 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4084 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4089 * Get the expanded state of an item
4091 * This gets the expanded state of an item
4093 * @param it The item
4094 * @return Thre expanded state
4099 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4101 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4102 return it->expanded;
4106 * Get the depth of expanded item
4108 * @param it The genlist item object
4109 * @return The depth of expanded item
4114 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4116 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4117 return it->expanded_depth;
4121 * Sets the disabled state of an item.
4123 * A disabled item cannot be selected or unselected. It will also
4124 * change appearance to appear disabled. This sets the disabled state
4125 * (1 disabled, 0 not disabled).
4127 * @param it The item
4128 * @param disabled The disabled state
4133 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4136 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4139 if (it->disabled == disabled) return;
4140 if (it->delete_me) return;
4141 it->disabled = !!disabled;
4143 elm_genlist_item_selected_set(it, EINA_FALSE);
4147 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4149 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4150 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4151 elm_widget_disabled_set(obj, disabled);
4156 * Get the disabled state of an item
4158 * This gets the disabled state of the given item.
4160 * @param it The item
4161 * @return The disabled state
4166 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4168 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4169 if (it->delete_me) return EINA_FALSE;
4170 return it->disabled;
4174 * Sets the display only state of an item.
4176 * A display only item cannot be selected or unselected. It is for
4177 * display only and not selecting or otherwise clicking, dragging
4178 * etc. by the user, thus finger size rules will not be applied to
4181 * @param it The item
4182 * @param display_only The display only state
4187 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4188 Eina_Bool display_only)
4190 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4191 if (it->display_only == display_only) return;
4192 if (it->delete_me) return;
4193 it->display_only = display_only;
4194 it->mincalcd = EINA_FALSE;
4195 it->updateme = EINA_TRUE;
4196 if (it->block) it->block->updateme = EINA_TRUE;
4197 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4198 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4202 * Get the display only state of an item
4204 * This gets the display only state of the given item.
4206 * @param it The item
4207 * @return The display only state
4212 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4214 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4215 if (it->delete_me) return EINA_FALSE;
4216 return it->display_only;
4220 * Show the given item
4222 * This causes genlist to jump to the given item @p it and show it (by
4223 * scrolling), if it is not fully visible.
4225 * @param it The item
4230 elm_genlist_item_show(Elm_Genlist_Item *it)
4232 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4233 Evas_Coord gith = 0;
4234 if (it->delete_me) return;
4235 if ((it->queued) || (!it->mincalcd))
4237 it->wd->show_item = it;
4238 it->wd->bring_in = EINA_TRUE;
4239 it->showme = EINA_TRUE;
4242 if (it->wd->show_item)
4244 it->wd->show_item->showme = EINA_FALSE;
4245 it->wd->show_item = NULL;
4247 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4248 gith = it->group_item->h;
4249 elm_smart_scroller_child_region_show(it->wd->scr,
4250 it->x + it->block->x,
4251 it->y + it->block->y - gith,
4252 it->block->w, it->h);
4256 * Bring in the given item
4258 * This causes genlist to jump to the given item @p it and show it (by
4259 * scrolling), if it is not fully visible. This may use animation to
4260 * do so and take a period of time
4262 * @param it The item
4267 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4269 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4270 Evas_Coord gith = 0;
4271 if (it->delete_me) return;
4272 if ((it->queued) || (!it->mincalcd))
4274 it->wd->show_item = it;
4275 it->wd->bring_in = EINA_TRUE;
4276 it->showme = EINA_TRUE;
4279 if (it->wd->show_item)
4281 it->wd->show_item->showme = EINA_FALSE;
4282 it->wd->show_item = NULL;
4284 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4285 gith = it->group_item->h;
4286 elm_smart_scroller_region_bring_in(it->wd->scr,
4287 it->x + it->block->x,
4288 it->y + it->block->y - gith,
4289 it->block->w, it->h);
4293 * Show the given item at the top
4295 * This causes genlist to jump to the given item @p it and show it (by
4296 * scrolling), if it is not fully visible.
4298 * @param it The item
4303 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4305 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4307 Evas_Coord gith = 0;
4309 if (it->delete_me) return;
4310 if ((it->queued) || (!it->mincalcd))
4312 it->wd->show_item = it;
4313 it->wd->bring_in = EINA_TRUE;
4314 it->showme = EINA_TRUE;
4317 if (it->wd->show_item)
4319 it->wd->show_item->showme = EINA_FALSE;
4320 it->wd->show_item = NULL;
4322 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4323 if (it->group_item) gith = it->group_item->h;
4324 elm_smart_scroller_child_region_show(it->wd->scr,
4325 it->x + it->block->x,
4326 it->y + it->block->y - gith,
4331 * Bring in the given item at the top
4333 * This causes genlist to jump to the given item @p it and show it (by
4334 * scrolling), if it is not fully visible. This may use animation to
4335 * do so and take a period of time
4337 * @param it The item
4342 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4344 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4346 Evas_Coord gith = 0;
4348 if (it->delete_me) return;
4349 if ((it->queued) || (!it->mincalcd))
4351 it->wd->show_item = it;
4352 it->wd->bring_in = EINA_TRUE;
4353 it->showme = EINA_TRUE;
4356 if (it->wd->show_item)
4358 it->wd->show_item->showme = EINA_FALSE;
4359 it->wd->show_item = NULL;
4361 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4362 if (it->group_item) gith = it->group_item->h;
4363 elm_smart_scroller_region_bring_in(it->wd->scr,
4364 it->x + it->block->x,
4365 it->y + it->block->y - gith,
4370 * Show the given item at the middle
4372 * This causes genlist to jump to the given item @p it and show it (by
4373 * scrolling), if it is not fully visible.
4375 * @param it The item
4380 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4382 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4385 if (it->delete_me) return;
4386 if ((it->queued) || (!it->mincalcd))
4388 it->wd->show_item = it;
4389 it->wd->bring_in = EINA_TRUE;
4390 it->showme = EINA_TRUE;
4393 if (it->wd->show_item)
4395 it->wd->show_item->showme = EINA_FALSE;
4396 it->wd->show_item = NULL;
4398 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4399 elm_smart_scroller_child_region_show(it->wd->scr,
4400 it->x + it->block->x,
4401 it->y + it->block->y - oh / 2 +
4402 it->h / 2, it->block->w, oh);
4406 * Bring in the given item at the middle
4408 * This causes genlist to jump to the given item @p it and show it (by
4409 * scrolling), if it is not fully visible. This may use animation to
4410 * do so and take a period of time
4412 * @param it The item
4417 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4419 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4422 if (it->delete_me) return;
4423 if ((it->queued) || (!it->mincalcd))
4425 it->wd->show_item = it;
4426 it->wd->bring_in = EINA_TRUE;
4427 it->showme = EINA_TRUE;
4430 if (it->wd->show_item)
4432 it->wd->show_item->showme = EINA_FALSE;
4433 it->wd->show_item = NULL;
4435 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4436 elm_smart_scroller_region_bring_in(it->wd->scr,
4437 it->x + it->block->x,
4438 it->y + it->block->y - oh / 2 + it->h / 2,
4443 * Delete a given item
4445 * This deletes the item from genlist and calls the genlist item del
4446 * class callback defined in the item class, if it is set. This clears all
4447 * subitems if it is a tree.
4449 * @param it The item
4454 elm_genlist_item_del(Elm_Genlist_Item *it)
4456 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4457 if ((it->relcount > 0) || (it->walking > 0))
4459 elm_widget_item_pre_notify_del(it);
4460 elm_genlist_item_subitems_clear(it);
4461 it->delete_me = EINA_TRUE;
4462 if (it->wd->show_item == it) it->wd->show_item = NULL;
4464 it->wd->selected = eina_list_remove(it->wd->selected,
4468 if (it->realized) _item_unrealize(it, EINA_FALSE);
4469 it->block->changed = EINA_TRUE;
4470 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4471 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4473 if (it->itc->func.del)
4474 it->itc->func.del((void *)it->base.data, it->base.widget);
4481 * Set the data item from the genlist item
4483 * This set the data value passed on the elm_genlist_item_append() and
4484 * related item addition calls. This function will also call
4485 * elm_genlist_item_update() so the item will be updated to reflect the
4488 * @param it The item
4489 * @param data The new data pointer to set
4494 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4497 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4498 elm_widget_item_data_set(it, data);
4499 elm_genlist_item_update(it);
4503 * Get the data item from the genlist item
4505 * This returns the data value passed on the elm_genlist_item_append()
4506 * and related item addition calls and elm_genlist_item_data_set().
4508 * @param it The item
4509 * @return The data pointer provided when created
4514 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4516 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4517 return elm_widget_item_data_get(it);
4521 * Tells genlist to "orphan" icons fetchs by the item class
4523 * This instructs genlist to release references to icons in the item,
4524 * meaning that they will no longer be managed by genlist and are
4525 * floating "orphans" that can be re-used elsewhere if the user wants
4528 * @param it The item
4533 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4536 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4537 EINA_LIST_FREE(it->icon_objs, icon)
4539 elm_widget_sub_object_del(it->base.widget, icon);
4540 evas_object_smart_member_del(icon);
4541 evas_object_hide(icon);
4546 * Get the real evas object of the genlist item
4548 * This returns the actual evas object used for the specified genlist
4549 * item. This may be NULL as it may not be created, and may be deleted
4550 * at any time by genlist. Do not modify this object (move, resize,
4551 * show, hide etc.) as genlist is controlling it. This function is for
4552 * querying, emitting custom signals or hooking lower level callbacks
4553 * for events. Do not delete this object under any circumstances.
4555 * @param it The item
4556 * @return The object pointer
4560 EAPI const Evas_Object *
4561 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4563 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4564 return it->base.view;
4568 * Update the contents of an item
4570 * This updates an item by calling all the item class functions again
4571 * to get the icons, labels and states. Use this when the original
4572 * item data has changed and the changes are desired to be reflected.
4574 * @param it The item
4579 elm_genlist_item_update(Elm_Genlist_Item *it)
4581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4582 if (!it->block) return;
4583 if (it->delete_me) return;
4584 it->mincalcd = EINA_FALSE;
4585 it->updateme = EINA_TRUE;
4586 it->block->updateme = EINA_TRUE;
4587 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4588 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4592 * Update the item class of an item
4594 * @param it The item
4595 * @parem itc The item class for the item
4600 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4601 const Elm_Genlist_Item_Class *itc)
4603 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4604 if (!it->block) return;
4605 EINA_SAFETY_ON_NULL_RETURN(itc);
4606 if (it->delete_me) return;
4608 it->nocache = EINA_TRUE;
4609 elm_genlist_item_update(it);
4612 static Evas_Object *
4613 _elm_genlist_item_label_create(void *data,
4615 void *item __UNUSED__)
4617 Evas_Object *label = elm_label_add(obj);
4620 elm_object_style_set(label, "tooltip");
4621 elm_label_label_set(label, data);
4626 _elm_genlist_item_label_del_cb(void *data,
4627 Evas_Object *obj __UNUSED__,
4628 void *event_info __UNUSED__)
4630 eina_stringshare_del(data);
4634 * Set the text to be shown in the genlist item.
4636 * @param item Target item
4637 * @param text The text to set in the content
4639 * Setup the text as tooltip to object. The item can have only one
4640 * tooltip, so any previous tooltip data is removed.
4645 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4648 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4649 text = eina_stringshare_add(text);
4650 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4652 _elm_genlist_item_label_del_cb);
4656 * Set the content to be shown in the tooltip item
4658 * Setup the tooltip to item. The item can have only one tooltip, so
4659 * any previous tooltip data is removed. @p func(with @p data) will be
4660 * called every time that need to show the tooltip and it should return a
4661 * valid Evas_Object. This object is then managed fully by tooltip
4662 * system and is deleted when the tooltip is gone.
4664 * @param item the genlist item being attached by a tooltip.
4665 * @param func the function used to create the tooltip contents.
4666 * @param data what to provide to @a func as callback data/context.
4667 * @param del_cb called when data is not needed anymore, either when
4668 * another callback replaces @func, the tooltip is unset with
4669 * elm_genlist_item_tooltip_unset() or the owner @a item
4670 * dies. This callback receives as the first parameter the
4671 * given @a data, and @c event_info is the item.
4676 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4677 Elm_Tooltip_Item_Content_Cb func,
4679 Evas_Smart_Cb del_cb)
4681 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4683 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4686 if (item->tooltip.del_cb)
4687 item->tooltip.del_cb((void *)item->tooltip.data,
4688 item->base.widget, item);
4690 item->tooltip.content_cb = func;
4691 item->tooltip.data = data;
4692 item->tooltip.del_cb = del_cb;
4694 if (item->base.view)
4696 elm_widget_item_tooltip_content_cb_set(item,
4697 item->tooltip.content_cb,
4698 item->tooltip.data, NULL);
4699 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4705 if (del_cb) del_cb((void *)data, NULL, NULL);
4709 * Unset tooltip from item
4711 * @param item genlist item to remove previously set tooltip.
4713 * Remove tooltip from item. The callback provided as del_cb to
4714 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4715 * it is not used anymore.
4717 * @see elm_genlist_item_tooltip_content_cb_set()
4722 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4724 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4725 if ((item->base.view) && (item->tooltip.content_cb))
4726 elm_widget_item_tooltip_unset(item);
4728 if (item->tooltip.del_cb)
4729 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4730 item->tooltip.del_cb = NULL;
4731 item->tooltip.content_cb = NULL;
4732 item->tooltip.data = NULL;
4733 if (item->tooltip.style)
4734 elm_genlist_item_tooltip_style_set(item, NULL);
4738 * Sets a different style for this item tooltip.
4740 * @note before you set a style you should define a tooltip with
4741 * elm_genlist_item_tooltip_content_cb_set() or
4742 * elm_genlist_item_tooltip_text_set()
4744 * @param item genlist item with tooltip already set.
4745 * @param style the theme style to use (default, transparent, ...)
4750 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4753 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4754 eina_stringshare_replace(&item->tooltip.style, style);
4755 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4759 * Get the style for this item tooltip.
4761 * @param item genlist item with tooltip already set.
4762 * @return style the theme style in use, defaults to "default". If the
4763 * object does not have a tooltip set, then NULL is returned.
4768 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4770 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4771 return item->tooltip.style;
4775 * Set the cursor to be shown when mouse is over the genlist item
4777 * @param item Target item
4778 * @param cursor the cursor name to be used.
4780 * @see elm_object_cursor_set()
4784 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4787 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4788 eina_stringshare_replace(&item->mouse_cursor, cursor);
4789 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4793 * Get the cursor to be shown when mouse is over the genlist item
4795 * @param item genlist item with cursor already set.
4796 * @return the cursor name.
4801 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4803 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4804 return elm_widget_item_cursor_get(item);
4808 * Unset the cursor to be shown when mouse is over the genlist item
4810 * @param item Target item
4812 * @see elm_object_cursor_unset()
4816 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4818 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4819 if (!item->mouse_cursor)
4822 if (item->base.view)
4823 elm_widget_item_cursor_unset(item);
4825 eina_stringshare_del(item->mouse_cursor);
4826 item->mouse_cursor = NULL;
4830 * Sets a different style for this item cursor.
4832 * @note before you set a style you should define a cursor with
4833 * elm_genlist_item_cursor_set()
4835 * @param item genlist item with cursor already set.
4836 * @param style the theme style to use (default, transparent, ...)
4841 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4844 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4845 elm_widget_item_cursor_style_set(item, style);
4849 * Get the style for this item cursor.
4851 * @param item genlist item with cursor already set.
4852 * @return style the theme style in use, defaults to "default". If the
4853 * object does not have a cursor set, then NULL is returned.
4858 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4860 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4861 return elm_widget_item_cursor_style_get(item);
4865 * Set if the cursor set should be searched on the theme or should use
4866 * the provided by the engine, only.
4868 * @note before you set if should look on theme you should define a
4869 * cursor with elm_object_cursor_set(). By default it will only look
4870 * for cursors provided by the engine.
4872 * @param item widget item with cursor already set.
4873 * @param engine_only boolean to define it cursors should be looked
4874 * only between the provided by the engine or searched on widget's
4880 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4881 Eina_Bool engine_only)
4883 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4884 elm_widget_item_cursor_engine_only_set(item, engine_only);
4888 * Get the cursor engine only usage for this item cursor.
4890 * @param item widget item with cursor already set.
4891 * @return engine_only boolean to define it cursors should be looked
4892 * only between the provided by the engine or searched on widget's
4893 * theme as well. If the object does not have a cursor set, then
4894 * EINA_FALSE is returned.
4899 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4901 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4902 return elm_widget_item_cursor_engine_only_get(item);
4906 * This sets the horizontal stretching mode
4908 * This sets the mode used for sizing items horizontally. Valid modes
4909 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4910 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4911 * the scroller will scroll horizontally. Otherwise items are expanded
4912 * to fill the width of the viewport of the scroller. If it is
4913 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4914 * limited to that size.
4916 * @param obj The genlist object
4917 * @param mode The mode to use
4922 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4925 ELM_CHECK_WIDTYPE(obj, widtype);
4926 Widget_Data *wd = elm_widget_data_get(obj);
4928 if (wd->mode == mode) return;
4934 * Gets the horizontal stretching mode
4936 * @param obj The genlist object
4937 * @return The mode to use
4938 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4943 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4945 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4946 Widget_Data *wd = elm_widget_data_get(obj);
4947 if (!wd) return ELM_LIST_LAST;
4952 * Set the always select mode.
4954 * Items will only call their selection func and callback when first
4955 * becoming selected. Any further clicks will do nothing, unless you
4956 * enable always select with elm_genlist_always_select_mode_set().
4957 * This means even if selected, every click will make the selected
4958 * callbacks be called.
4960 * @param obj The genlist object
4961 * @param always_select The always select mode
4962 * (EINA_TRUE = on, EINA_FALSE = off)
4967 elm_genlist_always_select_mode_set(Evas_Object *obj,
4968 Eina_Bool always_select)
4970 ELM_CHECK_WIDTYPE(obj, widtype);
4971 Widget_Data *wd = elm_widget_data_get(obj);
4973 wd->always_select = always_select;
4977 * Get the always select mode.
4979 * @param obj The genlist object
4980 * @return The always select mode
4981 * (EINA_TRUE = on, EINA_FALSE = off)
4986 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4988 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4989 Widget_Data *wd = elm_widget_data_get(obj);
4990 if (!wd) return EINA_FALSE;
4991 return wd->always_select;
4995 * Set no select mode
4997 * This will turn off the ability to select items entirely and they
4998 * will neither appear selected nor call selected callback functions.
5000 * @param obj The genlist object
5001 * @param no_select The no select mode
5002 * (EINA_TRUE = on, EINA_FALSE = off)
5007 elm_genlist_no_select_mode_set(Evas_Object *obj,
5008 Eina_Bool no_select)
5010 ELM_CHECK_WIDTYPE(obj, widtype);
5011 Widget_Data *wd = elm_widget_data_get(obj);
5013 wd->no_select = no_select;
5017 * Gets no select mode
5019 * @param obj The genlist object
5020 * @return The no select mode
5021 * (EINA_TRUE = on, EINA_FALSE = off)
5026 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5028 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5029 Widget_Data *wd = elm_widget_data_get(obj);
5030 if (!wd) return EINA_FALSE;
5031 return wd->no_select;
5037 * This will enable the compress mode where items are "compressed"
5038 * horizontally to fit the genlist scrollable viewport width. This is
5039 * special for genlist. Do not rely on
5040 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5041 * work as genlist needs to handle it specially.
5043 * @param obj The genlist object
5044 * @param compress The compress mode
5045 * (EINA_TRUE = on, EINA_FALSE = off)
5050 elm_genlist_compress_mode_set(Evas_Object *obj,
5053 ELM_CHECK_WIDTYPE(obj, widtype);
5054 Widget_Data *wd = elm_widget_data_get(obj);
5056 wd->compress = compress;
5057 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5061 * Get the compress mode
5063 * @param obj The genlist object
5064 * @return The compress mode
5065 * (EINA_TRUE = on, EINA_FALSE = off)
5070 elm_genlist_compress_mode_get(const Evas_Object *obj)
5072 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5073 Widget_Data *wd = elm_widget_data_get(obj);
5074 if (!wd) return EINA_FALSE;
5075 return wd->compress;
5079 * Set height-for-width mode
5081 * With height-for-width mode the item width will be fixed (restricted
5082 * to a minimum of) to the list width when calculating its size in
5083 * order to allow the height to be calculated based on it. This allows,
5084 * for instance, text block to wrap lines if the Edje part is
5085 * configured with "text.min: 0 1".
5087 * @note This mode will make list resize slower as it will have to
5088 * recalculate every item height again whenever the list width
5091 * @note When height-for-width mode is enabled, it also enables
5092 * compress mode (see elm_genlist_compress_mode_set()) and
5093 * disables homogeneous (see elm_genlist_homogeneous_set()).
5095 * @param obj The genlist object
5096 * @param setting The height-for-width mode (EINA_TRUE = on,
5102 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5103 Eina_Bool height_for_width)
5105 ELM_CHECK_WIDTYPE(obj, widtype);
5106 Widget_Data *wd = elm_widget_data_get(obj);
5108 wd->height_for_width = !!height_for_width;
5109 if (wd->height_for_width)
5111 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5112 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5117 * Get the height-for-width mode
5119 * @param obj The genlist object
5120 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5126 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5128 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5129 Widget_Data *wd = elm_widget_data_get(obj);
5130 if (!wd) return EINA_FALSE;
5131 return wd->height_for_width;
5137 * This will enable or disable the scroller bounce mode for the
5138 * genlist. See elm_scroller_bounce_set() for details
5140 * @param obj The genlist object
5141 * @param h_bounce Allow bounce horizontally
5142 * @param v_bounce Allow bounce vertically
5147 elm_genlist_bounce_set(Evas_Object *obj,
5151 ELM_CHECK_WIDTYPE(obj, widtype);
5152 Widget_Data *wd = elm_widget_data_get(obj);
5154 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5158 * Get the bounce mode
5160 * @param obj The genlist object
5161 * @param h_bounce Allow bounce horizontally
5162 * @param v_bounce Allow bounce vertically
5167 elm_genlist_bounce_get(const Evas_Object *obj,
5168 Eina_Bool *h_bounce,
5169 Eina_Bool *v_bounce)
5171 ELM_CHECK_WIDTYPE(obj, widtype);
5172 Widget_Data *wd = elm_widget_data_get(obj);
5174 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5178 * Set homogenous mode
5180 * This will enable the homogeneous mode where items are of the same
5181 * height and width so that genlist may do the lazy-loading at its
5182 * maximum. This implies 'compressed' mode.
5184 * @param obj The genlist object
5185 * @param homogeneous Assume the items within the genlist are of the
5186 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5191 elm_genlist_homogeneous_set(Evas_Object *obj,
5192 Eina_Bool homogeneous)
5194 ELM_CHECK_WIDTYPE(obj, widtype);
5195 Widget_Data *wd = elm_widget_data_get(obj);
5197 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5198 wd->homogeneous = homogeneous;
5202 * Get the homogenous mode
5204 * @param obj The genlist object
5205 * @return Assume the items within the genlist are of the same height
5206 * and width (EINA_TRUE = on, EINA_FALSE = off)
5211 elm_genlist_homogeneous_get(const Evas_Object *obj)
5213 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5214 Widget_Data *wd = elm_widget_data_get(obj);
5215 if (!wd) return EINA_FALSE;
5216 return wd->homogeneous;
5220 * Set the maximum number of items within an item block
5222 * This will configure the block count to tune to the target with
5223 * particular performance matrix.
5225 * @param obj The genlist object
5226 * @param n Maximum number of items within an item block
5231 elm_genlist_block_count_set(Evas_Object *obj,
5234 ELM_CHECK_WIDTYPE(obj, widtype);
5235 Widget_Data *wd = elm_widget_data_get(obj);
5237 wd->max_items_per_block = n;
5238 wd->item_cache_max = wd->max_items_per_block * 2;
5239 _item_cache_clean(wd);
5243 * Get the maximum number of items within an item block
5245 * @param obj The genlist object
5246 * @return Maximum number of items within an item block
5251 elm_genlist_block_count_get(const Evas_Object *obj)
5253 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5254 Widget_Data *wd = elm_widget_data_get(obj);
5256 return wd->max_items_per_block;
5260 * Set the timeout in seconds for the longpress event
5262 * @param obj The genlist object
5263 * @param timeout timeout in seconds
5268 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5271 ELM_CHECK_WIDTYPE(obj, widtype);
5272 Widget_Data *wd = elm_widget_data_get(obj);
5274 wd->longpress_timeout = timeout;
5278 * Get the timeout in seconds for the longpress event
5280 * @param obj The genlist object
5281 * @return timeout in seconds
5286 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5288 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5289 Widget_Data *wd = elm_widget_data_get(obj);
5291 return wd->longpress_timeout;
5295 * Set the scrollbar policy
5297 * This sets the scrollbar visibility policy for the given genlist
5298 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5299 * made visible if it is needed, and otherwise kept hidden.
5300 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5301 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5302 * respectively for the horizontal and vertical scrollbars.
5304 * @param obj The genlist object
5305 * @param policy_h Horizontal scrollbar policy
5306 * @param policy_v Vertical scrollbar policy
5311 elm_genlist_scroller_policy_set(Evas_Object *obj,
5312 Elm_Scroller_Policy policy_h,
5313 Elm_Scroller_Policy policy_v)
5315 ELM_CHECK_WIDTYPE(obj, widtype);
5316 Widget_Data *wd = elm_widget_data_get(obj);
5318 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5319 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5322 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5326 * Get the scrollbar policy
5328 * @param obj The genlist object
5329 * @param policy_h Horizontal scrollbar policy
5330 * @param policy_v Vertical scrollbar policy
5335 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5336 Elm_Scroller_Policy *policy_h,
5337 Elm_Scroller_Policy *policy_v)
5339 ELM_CHECK_WIDTYPE(obj, widtype);
5340 Widget_Data *wd = elm_widget_data_get(obj);
5341 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5342 if ((!wd) || (!wd->scr)) return;
5343 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5344 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5345 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5349 * Update the contents of all realized items
5351 * This updates all realized items by calling all the item class functions again
5352 * to get the icons, labels and states. Use this when the original
5353 * item data has changed and the changes are desired to be reflected.
5355 * @param it The item
5360 elm_genlist_realized_items_update(Evas_Object *obj)
5362 ELM_CHECK_WIDTYPE(obj, widtype);
5364 Eina_List *list, *l;
5365 Elm_Genlist_Item *it;
5367 list = elm_genlist_realized_items_get(obj);
5368 EINA_LIST_FOREACH(list, l, it)
5369 elm_genlist_item_update(it);
5373 * Set genlist item mode
5375 * @param item The genlist item
5376 * @param mode Mode name
5377 * @param mode_set Boolean to define set or unset mode.
5382 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5383 const char *mode_type,
5386 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5387 Widget_Data *wd = it->wd;
5389 Elm_Genlist_Item *it2;
5392 if (!mode_type) return;
5393 if ((it->delete_me) || (it->disabled)) return;
5395 if ((wd->mode_item == it) &&
5396 (!strcmp(mode_type, wd->mode_type)) &&
5399 if (!it->itc->mode_item_style) return;
5403 EINA_LIST_FOREACH(wd->selected, l, it2)
5405 elm_genlist_item_selected_set(it2, EINA_FALSE);
5409 it2 = elm_genlist_selected_item_get(wd->obj);
5410 if ((it2) && (it2->realized))
5411 elm_genlist_item_selected_set(it2, EINA_FALSE);
5414 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5416 ((it == wd->mode_item) && (!mode_set)))
5417 _item_mode_unset(wd);
5419 eina_stringshare_replace(&wd->mode_type, mode_type);
5420 if (mode_set) _item_mode_set(it);
5424 * Get active genlist mode type
5426 * @param obj The genlist object
5431 elm_genlist_mode_get(const Evas_Object *obj)
5433 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5434 Widget_Data *wd = elm_widget_data_get(obj);
5435 if (!wd) return NULL;
5436 return wd->mode_type;
5440 * Get active genlist mode item
5442 * @param obj The genlist object
5446 EAPI const Elm_Genlist_Item *
5447 elm_genlist_mode_item_get(const Evas_Object *obj)
5449 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5450 Widget_Data *wd = elm_widget_data_get(obj);
5451 if (!wd) return NULL;
5452 return wd->mode_item;