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;
1556 Evas *te = evas_object_evas_get(obj);
1558 evas_event_freeze(te);
1559 it->nocache = EINA_FALSE;
1560 _mode_item_unrealize(it);
1561 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1562 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1563 evas_event_thaw(te);
1564 evas_event_thaw_eval(te);
1568 _item_cache_clean(Widget_Data *wd)
1570 evas_event_freeze(evas_object_evas_get(wd->obj));
1571 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1575 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1576 wd->item_cache = eina_inlist_remove(wd->item_cache,
1577 wd->item_cache->last);
1578 wd->item_cache_count--;
1579 if (itc->spacer) evas_object_del(itc->spacer);
1580 if (itc->base_view) evas_object_del(itc->base_view);
1581 if (itc->item_style) eina_stringshare_del(itc->item_style);
1584 evas_event_thaw(evas_object_evas_get(wd->obj));
1585 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1589 _item_cache_zero(Widget_Data *wd)
1591 int pmax = wd->item_cache_max;
1592 wd->item_cache_max = 0;
1593 _item_cache_clean(wd);
1594 wd->item_cache_max = pmax;
1598 _item_cache_add(Elm_Genlist_Item *it)
1602 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1603 if (it->wd->item_cache_max <= 0)
1605 evas_object_del(it->base.view);
1606 it->base.view = NULL;
1607 evas_object_del(it->spacer);
1609 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1610 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1614 it->wd->item_cache_count++;
1615 itc = calloc(1, sizeof(Item_Cache));
1616 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1617 EINA_INLIST_GET(itc));
1618 itc->spacer = it->spacer;
1620 itc->base_view = it->base.view;
1621 it->base.view = NULL;
1622 evas_object_hide(itc->base_view);
1623 evas_object_move(itc->base_view, -9999, -9999);
1624 itc->item_style = eina_stringshare_add(it->itc->item_style);
1625 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1626 itc->compress = (it->wd->compress);
1627 itc->selected = it->selected;
1628 itc->disabled = it->disabled;
1629 itc->expanded = it->expanded;
1632 ecore_timer_del(it->long_timer);
1633 it->long_timer = NULL;
1635 if (it->swipe_timer)
1637 ecore_timer_del(it->swipe_timer);
1638 it->swipe_timer = NULL;
1640 // FIXME: other callbacks?
1641 edje_object_signal_callback_del_full(itc->base_view,
1642 "elm,action,expand,toggle",
1643 "elm", _signal_expand_toggle, it);
1644 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1646 _signal_expand, it);
1647 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1648 "elm", _signal_contract, it);
1649 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1651 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1653 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1655 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1657 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1659 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1661 _item_cache_clean(it->wd);
1662 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1663 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1667 _item_cache_find(Elm_Genlist_Item *it)
1672 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1673 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1675 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1677 if ((itc->tree == tree) &&
1678 (itc->compress == it->wd->compress) &&
1679 (!strcmp(it->itc->item_style, itc->item_style)))
1681 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1682 EINA_INLIST_GET(itc));
1683 it->wd->item_cache_count--;
1691 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1693 if (!it->nostacking)
1695 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1696 evas_object_lower(it->base.view);
1698 evas_object_raise(it->base.view);
1701 if (it->order_num_in & 0x1)
1702 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1704 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1708 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1712 if (it->selected != itc->selected)
1715 edje_object_signal_emit(it->base.view,
1716 "elm,state,selected", "elm");
1718 if (it->disabled != itc->disabled)
1721 edje_object_signal_emit(it->base.view,
1722 "elm,state,disabled", "elm");
1724 if (it->expanded != itc->expanded)
1727 edje_object_signal_emit(it->base.view,
1728 "elm,state,expanded", "elm");
1734 edje_object_signal_emit(it->base.view,
1735 "elm,state,selected", "elm");
1737 edje_object_signal_emit(it->base.view,
1738 "elm,state,disabled", "elm");
1740 edje_object_signal_emit(it->base.view,
1741 "elm,state,expanded", "elm");
1746 _item_cache_free(Item_Cache *itc)
1748 if (itc->spacer) evas_object_del(itc->spacer);
1749 if (itc->base_view) evas_object_del(itc->base_view);
1750 if (itc->item_style) eina_stringshare_del(itc->item_style);
1755 _item_label_realize(Elm_Genlist_Item *it,
1756 Evas_Object *target,
1759 if (it->itc->func.label_get)
1764 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1765 EINA_LIST_FOREACH(*source, l, key)
1767 char *s = it->itc->func.label_get
1768 ((void *)it->base.data, it->base.widget, key);
1772 edje_object_part_text_set(target, key, s);
1777 edje_object_part_text_set(target, key, "");
1784 _item_icon_realize(Elm_Genlist_Item *it,
1785 Evas_Object *target,
1788 Eina_List *res = NULL;
1790 if (it->itc->func.icon_get)
1795 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1796 EINA_LIST_FOREACH(*source, l, key)
1798 Evas_Object *ic = it->itc->func.icon_get
1799 ((void *)it->base.data, it->base.widget, key);
1803 res = eina_list_append(res, ic);
1804 edje_object_part_swallow(target, key, ic);
1805 evas_object_show(ic);
1806 elm_widget_sub_object_add(it->base.widget, ic);
1808 elm_widget_disabled_set(ic, EINA_TRUE);
1817 _item_state_realize(Elm_Genlist_Item *it,
1818 Evas_Object *target,
1821 if (it->itc->func.state_get)
1827 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1828 EINA_LIST_FOREACH(*source, l, key)
1830 Eina_Bool on = it->itc->func.state_get
1831 ((void *)it->base.data, it->base.widget, key);
1835 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1836 edje_object_signal_emit(target, buf, "elm");
1840 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1841 edje_object_signal_emit(target, buf, "elm");
1848 _item_realize(Elm_Genlist_Item *it,
1852 Elm_Genlist_Item *it2;
1853 const char *treesize;
1855 int depth, tsize = 20;
1856 Item_Cache *itc = NULL;
1858 if (it->delete_me) return;
1859 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1862 if (it->order_num_in != in)
1864 it->order_num_in = in;
1865 _elm_genlist_item_odd_even_update(it);
1866 _elm_genlist_item_state_update(it, NULL);
1868 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1869 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1872 it->order_num_in = in;
1875 it->nocache = EINA_FALSE;
1877 itc = _item_cache_find(it);
1880 it->base.view = itc->base_view;
1881 itc->base_view = NULL;
1882 it->spacer = itc->spacer;
1887 const char *stacking_even;
1888 const char *stacking;
1890 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1891 edje_object_scale_set(it->base.view,
1892 elm_widget_scale_get(it->base.widget) *
1893 _elm_config->scale);
1894 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1895 elm_widget_sub_object_add(it->base.widget, it->base.view);
1897 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1898 strncpy(buf, "tree", sizeof(buf));
1899 else strncpy(buf, "item", sizeof(buf));
1900 if (it->wd->compress)
1901 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1903 strncat(buf, "/", sizeof(buf) - strlen(buf));
1904 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1906 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1907 elm_widget_style_get(it->base.widget));
1909 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1910 if (!stacking_even) stacking_even = "above";
1911 it->stacking_even = !!strcmp("above", stacking_even);
1913 stacking = edje_object_data_get(it->base.view, "stacking");
1914 if (!stacking) stacking = "yes";
1915 it->nostacking = !!strcmp("yes", stacking);
1917 edje_object_mirrored_set(it->base.view,
1918 elm_widget_mirrored_get(it->base.widget));
1920 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1921 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1922 elm_widget_sub_object_add(it->base.widget, it->spacer);
1925 _elm_genlist_item_odd_even_update(it);
1927 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1929 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1931 it->expanded_depth = depth;
1932 treesize = edje_object_data_get(it->base.view, "treesize");
1933 if (treesize) tsize = atoi(treesize);
1934 evas_object_size_hint_min_set(it->spacer,
1935 (depth * tsize) * _elm_config->scale, 1);
1936 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1939 edje_object_signal_callback_add(it->base.view,
1940 "elm,action,expand,toggle",
1941 "elm", _signal_expand_toggle, it);
1942 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1943 "elm", _signal_expand, it);
1944 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1945 "elm", _signal_contract, it);
1946 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1948 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1950 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1952 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1954 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1956 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1959 _elm_genlist_item_state_update(it, itc);
1962 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1964 /* homogenous genlist shortcut */
1967 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1969 it->w = it->minw = it->wd->group_item_width;
1970 it->h = it->minh = it->wd->group_item_height;
1974 it->w = it->minw = it->wd->item_width;
1975 it->h = it->minh = it->wd->item_height;
1977 it->mincalcd = EINA_TRUE;
1982 /* FIXME: If you see that assert, please notify us and we
1983 will clean our mess */
1984 assert(eina_list_count(it->icon_objs) == 0);
1986 _item_label_realize(it, it->base.view, &it->labels);
1987 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1988 _item_state_realize(it, it->base.view, &it->states);
1992 Evas_Coord mw = -1, mh = -1;
1994 if (!it->display_only)
1995 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1996 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1997 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1999 if (!it->display_only)
2000 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2001 it->w = it->minw = mw;
2002 it->h = it->minh = mh;
2003 it->mincalcd = EINA_TRUE;
2005 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2007 it->wd->group_item_width = mw;
2008 it->wd->group_item_height = mh;
2010 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2012 it->wd->item_width = mw;
2013 it->wd->item_height = mh;
2016 if (!calc) evas_object_show(it->base.view);
2019 if (it->tooltip.content_cb)
2021 elm_widget_item_tooltip_content_cb_set(it,
2022 it->tooltip.content_cb,
2023 it->tooltip.data, NULL);
2024 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2027 if (it->mouse_cursor)
2028 elm_widget_item_cursor_set(it, it->mouse_cursor);
2030 it->realized = EINA_TRUE;
2031 it->want_unrealize = EINA_FALSE;
2033 if (itc) _item_cache_free(itc);
2034 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2035 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2036 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2040 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2044 if (!it->realized) return;
2045 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2046 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2049 ecore_timer_del(it->long_timer);
2050 it->long_timer = NULL;
2054 evas_object_del(it->base.view);
2055 it->base.view = NULL;
2056 evas_object_del(it->spacer);
2061 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2062 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2063 _item_cache_add(it);
2065 elm_widget_stringlist_free(it->labels);
2067 elm_widget_stringlist_free(it->icons);
2069 elm_widget_stringlist_free(it->states);
2071 EINA_LIST_FREE(it->icon_objs, icon)
2072 evas_object_del(icon);
2074 _mode_item_unrealize(it);
2076 it->realized = EINA_FALSE;
2077 it->want_unrealize = EINA_FALSE;
2078 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2079 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2083 _item_block_recalc(Item_Block *itb,
2088 Elm_Genlist_Item *it;
2089 Evas_Coord minw = 0, minh = 0;
2090 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2093 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2095 EINA_LIST_FOREACH(itb->items, l, it)
2097 if (it->delete_me) continue;
2098 showme |= it->showme;
2103 if (!it->mincalcd) changed = EINA_TRUE;
2106 _item_realize(it, in, EINA_TRUE);
2107 _item_unrealize(it, EINA_TRUE);
2112 _item_realize(it, in, EINA_TRUE);
2113 _item_unrealize(it, EINA_TRUE);
2117 _item_realize(it, in, EINA_FALSE);
2119 if (minw < it->minw) minw = it->minw;
2127 itb->changed = EINA_FALSE;
2128 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2129 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2134 _item_block_realize(Item_Block *itb,
2139 Elm_Genlist_Item *it;
2141 if (itb->realized) return;
2142 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2143 EINA_LIST_FOREACH(itb->items, l, it)
2145 if (it->delete_me) continue;
2146 if (full) _item_realize(it, in, EINA_FALSE);
2149 itb->realized = EINA_TRUE;
2150 itb->want_unrealize = EINA_FALSE;
2151 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2152 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2156 _item_block_unrealize(Item_Block *itb)
2159 Elm_Genlist_Item *it;
2160 Eina_Bool dragging = EINA_FALSE;
2162 if (!itb->realized) return;
2163 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2164 EINA_LIST_FOREACH(itb->items, l, it)
2166 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2170 dragging = EINA_TRUE;
2171 it->want_unrealize = EINA_TRUE;
2174 _item_unrealize(it, EINA_FALSE);
2179 itb->realized = EINA_FALSE;
2180 itb->want_unrealize = EINA_TRUE;
2183 itb->want_unrealize = EINA_FALSE;
2184 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2185 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2189 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2194 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2195 evas_object_resize(view, it->w, it->h);
2196 evas_object_move(view, it->scrl_x, it->scrl_y);
2197 evas_object_show(view);
2198 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2199 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2203 _item_block_position(Item_Block *itb,
2207 Elm_Genlist_Item *it;
2208 Elm_Genlist_Item *git;
2209 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2212 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2213 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2214 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2216 EINA_LIST_FOREACH(itb->items, l, it)
2218 if (it->delete_me) continue;
2222 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2223 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2225 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2226 cvx, cvy, cvw, cvh));
2227 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2229 if ((itb->realized) && (!it->realized))
2231 if (vis) _item_realize(it, in, EINA_FALSE);
2237 git = it->group_item;
2240 if (git->scrl_y < oy)
2242 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2243 git->scrl_y = (it->scrl_y + it->h) - git->h;
2244 git->want_realize = EINA_TRUE;
2247 _item_position(it, it->mode_view);
2249 _item_position(it, it->base.view);
2253 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2260 if (vis) it->want_realize = EINA_TRUE;
2264 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2265 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2269 _group_items_recalc(void *data)
2271 Widget_Data *wd = data;
2273 Elm_Genlist_Item *git;
2275 evas_event_freeze(evas_object_evas_get(wd->obj));
2276 EINA_LIST_FOREACH(wd->group_items, l, git)
2278 if (git->want_realize)
2281 _item_realize(git, 0, EINA_FALSE);
2282 evas_object_resize(git->base.view, wd->minw, git->h);
2283 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2284 evas_object_show(git->base.view);
2285 evas_object_raise(git->base.view);
2287 else if (!git->want_realize && git->realized)
2290 _item_unrealize(git, EINA_FALSE);
2293 evas_event_thaw(evas_object_evas_get(wd->obj));
2294 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2298 _must_recalc_idler(void *data)
2300 Widget_Data *wd = data;
2301 if (wd->calc_job) ecore_job_del(wd->calc_job);
2302 wd->calc_job = ecore_job_add(_calc_job, wd);
2303 wd->must_recalc_idler = NULL;
2304 return ECORE_CALLBACK_CANCEL;
2308 _calc_job(void *data)
2310 Widget_Data *wd = data;
2312 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2313 Item_Block *chb = NULL;
2314 int in = 0, minw_change = 0;
2315 Eina_Bool changed = EINA_FALSE;
2317 Eina_Bool did_must_recalc = EINA_FALSE;
2320 t0 = ecore_time_get();
2321 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2325 evas_event_freeze(evas_object_evas_get(wd->obj));
2326 EINA_INLIST_FOREACH(wd->blocks, itb)
2328 Eina_Bool showme = EINA_FALSE;
2331 showme = itb->showme;
2332 itb->showme = EINA_FALSE;
2335 if (itb->realized) _item_block_unrealize(itb);
2337 if ((itb->changed) || (changed) ||
2338 ((itb->must_recalc) && (!did_must_recalc)))
2340 if ((changed) || (itb->must_recalc))
2343 Elm_Genlist_Item *it;
2344 EINA_LIST_FOREACH(itb->items, l, it)
2345 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2346 itb->changed = EINA_TRUE;
2347 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2348 itb->must_recalc = EINA_FALSE;
2350 if (itb->realized) _item_block_unrealize(itb);
2351 showme = _item_block_recalc(itb, in, 0);
2357 if (minw == -1) minw = itb->minw;
2358 else if ((!itb->must_recalc) && (minw < itb->minw))
2367 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2369 wd->show_item->showme = EINA_FALSE;
2371 elm_smart_scroller_region_bring_in(wd->scr,
2373 wd->show_item->block->x,
2375 wd->show_item->block->y,
2376 wd->show_item->block->w,
2379 elm_smart_scroller_child_region_show(wd->scr,
2381 wd->show_item->block->x,
2383 wd->show_item->block->y,
2384 wd->show_item->block->w,
2386 wd->show_item = NULL;
2391 EINA_INLIST_FOREACH(wd->blocks, itb)
2397 if ((chb) && (EINA_INLIST_GET(chb)->next))
2399 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2401 if (itb->realized) _item_block_unrealize(itb);
2404 wd->realminw = minw;
2405 if (minw < wd->w) minw = wd->w;
2406 if ((minw != wd->minw) || (minh != wd->minh))
2410 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2411 _sizing_eval(wd->obj);
2412 if ((wd->anchor_item) && (wd->anchor_item->block))
2414 Elm_Genlist_Item *it;
2417 it = wd->anchor_item;
2418 it_y = wd->anchor_y;
2419 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2420 it->block->y + it->y + it_y);
2421 wd->anchor_item = it;
2422 wd->anchor_y = it_y;
2425 t = ecore_time_get();
2426 if (did_must_recalc)
2428 if (!wd->must_recalc_idler)
2429 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2431 wd->calc_job = NULL;
2432 evas_object_smart_changed(wd->pan_smart);
2433 evas_event_thaw(evas_object_evas_get(wd->obj));
2434 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2438 _update_job(void *data)
2440 Widget_Data *wd = data;
2443 int num, num0, position = 0, recalc = 0;
2445 wd->update_job = NULL;
2448 evas_event_freeze(evas_object_evas_get(wd->obj));
2449 EINA_INLIST_FOREACH(wd->blocks, itb)
2451 Evas_Coord itminw, itminh;
2452 Elm_Genlist_Item *it;
2458 _item_block_position(itb, num);
2463 EINA_LIST_FOREACH(itb->items, l2, it)
2470 it->updateme = EINA_FALSE;
2473 _item_unrealize(it, EINA_FALSE);
2474 _item_realize(it, num, EINA_FALSE);
2479 _item_realize(it, num, EINA_TRUE);
2480 _item_unrealize(it, EINA_TRUE);
2482 if ((it->minw != itminw) || (it->minh != itminh))
2487 itb->updateme = EINA_FALSE;
2491 itb->changed = EINA_TRUE;
2492 _item_block_recalc(itb, num0, 0);
2493 _item_block_position(itb, num0);
2498 if (wd->calc_job) ecore_job_del(wd->calc_job);
2499 wd->calc_job = ecore_job_add(_calc_job, wd);
2501 evas_event_thaw(evas_object_evas_get(wd->obj));
2502 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2506 _pan_set(Evas_Object *obj,
2510 Pan *sd = evas_object_smart_data_get(obj);
2513 // Evas_Coord ow, oh;
2514 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2515 // ow = sd->wd->minw - ow;
2516 // if (ow < 0) ow = 0;
2517 // oh = sd->wd->minh - oh;
2518 // if (oh < 0) oh = 0;
2519 // if (x < 0) x = 0;
2520 // if (y < 0) y = 0;
2521 // if (x > ow) x = ow;
2522 // if (y > oh) y = oh;
2523 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2527 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2529 if ((itb->y + itb->h) > y)
2531 Elm_Genlist_Item *it;
2534 EINA_LIST_FOREACH(itb->items, l2, it)
2536 if ((itb->y + it->y) >= y)
2538 sd->wd->anchor_item = it;
2539 sd->wd->anchor_y = -(itb->y + it->y - y);
2546 evas_object_smart_changed(obj);
2550 _pan_get(Evas_Object *obj,
2554 Pan *sd = evas_object_smart_data_get(obj);
2556 if (x) *x = sd->wd->pan_x;
2557 if (y) *y = sd->wd->pan_y;
2561 _pan_max_get(Evas_Object *obj,
2565 Pan *sd = evas_object_smart_data_get(obj);
2568 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2569 ow = sd->wd->minw - ow;
2571 oh = sd->wd->minh - oh;
2578 _pan_min_get(Evas_Object *obj __UNUSED__,
2587 _pan_child_size_get(Evas_Object *obj,
2591 Pan *sd = evas_object_smart_data_get(obj);
2593 if (w) *w = sd->wd->minw;
2594 if (h) *h = sd->wd->minh;
2598 _pan_add(Evas_Object *obj)
2601 Evas_Object_Smart_Clipped_Data *cd;
2604 cd = evas_object_smart_data_get(obj);
2607 sd->__clipped_data = *cd;
2609 evas_object_smart_data_set(obj, sd);
2613 _pan_del(Evas_Object *obj)
2615 Pan *sd = evas_object_smart_data_get(obj);
2620 ecore_job_del(sd->resize_job);
2621 sd->resize_job = NULL;
2627 _pan_resize_job(void *data)
2630 _sizing_eval(sd->wd->obj);
2631 sd->resize_job = NULL;
2635 _pan_resize(Evas_Object *obj,
2639 Pan *sd = evas_object_smart_data_get(obj);
2642 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2643 if ((ow == w) && (oh == h)) return;
2644 if ((sd->wd->height_for_width) && (ow != w))
2646 if (sd->resize_job) ecore_job_del(sd->resize_job);
2647 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2649 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2650 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2654 _pan_calculate(Evas_Object *obj)
2656 Pan *sd = evas_object_smart_data_get(obj);
2658 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2660 Elm_Genlist_Item *git;
2663 evas_event_freeze(evas_object_evas_get(obj));
2664 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2665 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2666 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2668 git->want_realize = EINA_FALSE;
2670 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2672 itb->w = sd->wd->minw;
2673 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2674 itb->y - sd->wd->pan_y + oy,
2676 cvx, cvy, cvw, cvh))
2678 if ((!itb->realized) || (itb->changed))
2679 _item_block_realize(itb, in, 0);
2680 _item_block_position(itb, in);
2684 if (itb->realized) _item_block_unrealize(itb);
2688 _group_items_recalc(sd->wd);
2689 evas_event_thaw(evas_object_evas_get(obj));
2690 evas_event_thaw_eval(evas_object_evas_get(obj));
2694 _pan_move(Evas_Object *obj,
2695 Evas_Coord x __UNUSED__,
2696 Evas_Coord y __UNUSED__)
2698 Pan *sd = evas_object_smart_data_get(obj);
2700 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2701 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2705 _hold_on(void *data __UNUSED__,
2707 void *event_info __UNUSED__)
2709 Widget_Data *wd = elm_widget_data_get(obj);
2711 elm_smart_scroller_hold_set(wd->scr, 1);
2715 _hold_off(void *data __UNUSED__,
2717 void *event_info __UNUSED__)
2719 Widget_Data *wd = elm_widget_data_get(obj);
2721 elm_smart_scroller_hold_set(wd->scr, 0);
2725 _freeze_on(void *data __UNUSED__,
2727 void *event_info __UNUSED__)
2729 Widget_Data *wd = elm_widget_data_get(obj);
2731 elm_smart_scroller_freeze_set(wd->scr, 1);
2735 _freeze_off(void *data __UNUSED__,
2737 void *event_info __UNUSED__)
2739 Widget_Data *wd = elm_widget_data_get(obj);
2741 elm_smart_scroller_freeze_set(wd->scr, 0);
2745 _scroll_edge_left(void *data,
2746 Evas_Object *scr __UNUSED__,
2747 void *event_info __UNUSED__)
2749 Evas_Object *obj = data;
2750 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2754 _scroll_edge_right(void *data,
2755 Evas_Object *scr __UNUSED__,
2756 void *event_info __UNUSED__)
2758 Evas_Object *obj = data;
2759 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2763 _scroll_edge_top(void *data,
2764 Evas_Object *scr __UNUSED__,
2765 void *event_info __UNUSED__)
2767 Evas_Object *obj = data;
2768 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2772 _scroll_edge_bottom(void *data,
2773 Evas_Object *scr __UNUSED__,
2774 void *event_info __UNUSED__)
2776 Evas_Object *obj = data;
2777 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2781 _mode_item_realize(Elm_Genlist_Item *it)
2785 if ((it->mode_view) || (it->delete_me)) return;
2787 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2788 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2789 edje_object_scale_set(it->mode_view,
2790 elm_widget_scale_get(it->base.widget) *
2791 _elm_config->scale);
2792 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2793 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2795 strncpy(buf, "item", sizeof(buf));
2796 if (it->wd->compress)
2797 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2799 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2800 strncat(buf, "/", sizeof(buf) - strlen(buf));
2801 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2803 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2804 elm_widget_style_get(it->base.widget));
2805 edje_object_mirrored_set(it->mode_view,
2806 elm_widget_mirrored_get(it->base.widget));
2808 /* signal callback add */
2809 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2811 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2813 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2816 /* label_get, icon_get, state_get */
2817 /* FIXME: If you see that assert, please notify us and we
2818 will clean our mess */
2819 assert(eina_list_count(it->mode_icon_objs) == 0);
2821 _item_label_realize(it, it->mode_view, &it->mode_labels);
2822 it->mode_icon_objs = _item_icon_realize(it,
2825 _item_state_realize(it, it->mode_view, &it->mode_states);
2827 edje_object_part_swallow(it->mode_view,
2828 edje_object_data_get(it->mode_view, "mode_part"),
2831 it->want_unrealize = EINA_FALSE;
2832 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2833 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2837 _mode_item_unrealize(Elm_Genlist_Item *it)
2839 Widget_Data *wd = it->wd;
2841 if (!it->mode_view) return;
2843 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2844 elm_widget_stringlist_free(it->mode_labels);
2845 it->mode_labels = NULL;
2846 elm_widget_stringlist_free(it->mode_icons);
2847 it->mode_icons = NULL;
2848 elm_widget_stringlist_free(it->mode_states);
2850 EINA_LIST_FREE(it->mode_icon_objs, icon)
2851 evas_object_del(icon);
2853 edje_object_part_unswallow(it->mode_view, it->base.view);
2854 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2855 evas_object_del(it->mode_view);
2856 it->mode_view = NULL;
2858 if (wd->mode_item == it)
2859 wd->mode_item = NULL;
2860 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2861 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2865 _item_mode_set(Elm_Genlist_Item *it)
2868 Widget_Data *wd = it->wd;
2873 it->nocache = EINA_TRUE;
2875 if (wd->scr_hold_timer)
2877 ecore_timer_del(wd->scr_hold_timer);
2878 wd->scr_hold_timer = NULL;
2880 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2881 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2883 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2884 _mode_item_realize(it);
2885 _item_position(it, it->mode_view);
2886 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2887 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2889 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2890 edje_object_signal_emit(it->mode_view, buf, "elm");
2894 _item_mode_unset(Widget_Data *wd)
2897 if (!wd->mode_item) return;
2898 char buf[1024], buf2[1024];
2899 Elm_Genlist_Item *it;
2902 it->nocache = EINA_TRUE;
2904 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2905 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2907 edje_object_signal_emit(it->mode_view, buf, "elm");
2908 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2910 wd->mode_item = NULL;
2914 * Add a new Genlist object
2916 * @param parent The parent object
2917 * @return The new object or NULL if it cannot be created
2922 elm_genlist_add(Evas_Object *parent)
2927 Evas_Coord minw, minh;
2928 static Evas_Smart *smart = NULL;
2932 static Evas_Smart_Class sc;
2934 evas_object_smart_clipped_smart_set(&_pan_sc);
2936 sc.name = "elm_genlist_pan";
2937 sc.version = EVAS_SMART_CLASS_VERSION;
2940 sc.resize = _pan_resize;
2941 sc.move = _pan_move;
2942 sc.calculate = _pan_calculate;
2943 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2946 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2948 ELM_SET_WIDTYPE(widtype, "genlist");
2949 elm_widget_type_set(obj, "genlist");
2950 elm_widget_sub_object_add(parent, obj);
2951 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2952 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2953 elm_widget_data_set(obj, wd);
2954 elm_widget_del_hook_set(obj, _del_hook);
2955 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2956 elm_widget_theme_hook_set(obj, _theme_hook);
2957 elm_widget_can_focus_set(obj, EINA_TRUE);
2958 elm_widget_event_hook_set(obj, _event_hook);
2959 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2961 wd->scr = elm_smart_scroller_add(e);
2962 elm_smart_scroller_widget_set(wd->scr, obj);
2963 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2964 elm_widget_style_get(obj));
2965 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2966 _elm_config->thumbscroll_bounce_enable);
2967 elm_widget_resize_object_set(obj, wd->scr);
2969 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2970 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2972 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2973 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2977 wd->mode = ELM_LIST_SCROLL;
2978 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2979 wd->item_cache_max = wd->max_items_per_block * 2;
2980 wd->longpress_timeout = _elm_config->longpress_timeout;
2982 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2983 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2984 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2985 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2987 wd->pan_smart = evas_object_smart_add(e, smart);
2988 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2991 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2992 _pan_set, _pan_get, _pan_max_get,
2993 _pan_min_get, _pan_child_size_get);
2995 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2997 evas_object_size_hint_min_set(obj, minw, minh);
2999 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3001 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3006 static Elm_Genlist_Item *
3007 _item_new(Widget_Data *wd,
3008 const Elm_Genlist_Item_Class *itc,
3010 Elm_Genlist_Item *parent,
3011 Elm_Genlist_Item_Flags flags,
3013 const void *func_data)
3015 Elm_Genlist_Item *it;
3017 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3018 if (!it) return NULL;
3021 it->base.data = data;
3022 it->parent = parent;
3024 it->func.func = func;
3025 it->func.data = func_data;
3026 it->mouse_cursor = NULL;
3027 it->expanded_depth = 0;
3032 _item_block_add(Widget_Data *wd,
3033 Elm_Genlist_Item *it)
3035 Item_Block *itb = NULL;
3042 itb = calloc(1, sizeof(Item_Block));
3045 if (!it->rel->block)
3048 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3049 itb->items = eina_list_append(itb->items, it);
3055 wd->blocks = eina_inlist_prepend_relative
3056 (wd->blocks, EINA_INLIST_GET(itb),
3057 EINA_INLIST_GET(it->rel->block));
3059 eina_list_prepend_relative(itb->items, it, it->rel);
3063 wd->blocks = eina_inlist_append_relative
3064 (wd->blocks, EINA_INLIST_GET(itb),
3065 EINA_INLIST_GET(it->rel->block));
3067 eina_list_append_relative(itb->items, it, it->rel);
3077 itb = (Item_Block *)(wd->blocks);
3078 if (itb->count >= wd->max_items_per_block)
3080 itb = calloc(1, sizeof(Item_Block));
3084 eina_inlist_prepend(wd->blocks,
3085 EINA_INLIST_GET(itb));
3090 itb = calloc(1, sizeof(Item_Block));
3094 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3096 itb->items = eina_list_prepend(itb->items, it);
3102 itb = (Item_Block *)(wd->blocks->last);
3103 if (itb->count >= wd->max_items_per_block)
3105 itb = calloc(1, sizeof(Item_Block));
3109 eina_inlist_append(wd->blocks,
3110 EINA_INLIST_GET(itb));
3115 itb = calloc(1, sizeof(Item_Block));
3119 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3121 itb->items = eina_list_append(itb->items, it);
3127 itb = it->rel->block;
3128 if (!itb) goto newblock;
3130 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3132 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3135 itb->changed = EINA_TRUE;
3137 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3138 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3141 it->rel->relcount--;
3142 if ((it->rel->delete_me) && (!it->rel->relcount))
3146 if (itb->count > itb->wd->max_items_per_block)
3150 Elm_Genlist_Item *it2;
3152 newc = itb->count / 2;
3153 itb2 = calloc(1, sizeof(Item_Block));
3157 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3158 EINA_INLIST_GET(itb));
3159 itb2->changed = EINA_TRUE;
3160 while ((itb->count > newc) && (itb->items))
3164 l = eina_list_last(itb->items);
3166 itb->items = eina_list_remove_list(itb->items, l);
3169 itb2->items = eina_list_prepend(itb2->items, it2);
3177 _queue_process(Widget_Data *wd)
3180 Eina_Bool showme = EINA_FALSE;
3183 t0 = ecore_time_get();
3184 evas_event_freeze(evas_object_evas_get(wd->obj));
3185 for (n = 0; (wd->queue) && (n < 128); n++)
3187 Elm_Genlist_Item *it;
3189 it = wd->queue->data;
3190 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3191 it->queued = EINA_FALSE;
3192 _item_block_add(wd, it);
3193 t = ecore_time_get();
3194 if (it->block->changed)
3196 showme = _item_block_recalc(it->block, it->block->num, 1);
3197 it->block->changed = 0;
3199 if (showme) it->block->showme = EINA_TRUE;
3200 if (eina_inlist_count(wd->blocks) > 1)
3202 if ((t - t0) > (ecore_animator_frametime_get())) break;
3205 evas_event_thaw(evas_object_evas_get(wd->obj));
3206 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3211 _idle_process(void *data, Eina_Bool *wakeup)
3213 Widget_Data *wd = data;
3216 //static double q_start = 0.0;
3217 //if (q_start == 0.0) q_start = ecore_time_get();
3219 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3223 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3225 return ECORE_CALLBACK_CANCEL;
3227 return ECORE_CALLBACK_RENEW;
3231 _item_idle_enterer(void *data)
3233 Widget_Data *wd = data;
3234 Eina_Bool wakeup = EINA_FALSE;
3235 Eina_Bool ok = _idle_process(data, &wakeup);
3240 if (wd->calc_job) ecore_job_del(wd->calc_job);
3241 wd->calc_job = ecore_job_add(_calc_job, wd);
3243 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3248 _item_queue(Widget_Data *wd,
3249 Elm_Genlist_Item *it)
3251 if (it->queued) return;
3252 it->queued = EINA_TRUE;
3253 wd->queue = eina_list_append(wd->queue, it);
3254 // FIXME: why does a freeze then thaw here cause some genlist
3255 // elm_genlist_item_append() to be much much slower?
3256 // evas_event_freeze(evas_object_evas_get(wd->obj));
3257 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3259 if (wd->queue_idle_enterer)
3261 ecore_idle_enterer_del(wd->queue_idle_enterer);
3262 wd->queue_idle_enterer = NULL;
3266 // evas_event_thaw(evas_object_evas_get(wd->obj));
3267 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3268 if (!wd->queue_idle_enterer)
3269 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3273 _elm_genlist_item_compare(const void *data, const void *data1)
3275 Elm_Genlist_Item *item, *item1;
3276 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3277 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3278 return _elm_genlist_item_compare_cb(item->base.data, item1->base.data);
3282 * Append item to the end of the genlist
3284 * This appends the given item to the end of the list or the end of
3285 * the children if the parent is given.
3287 * @param obj The genlist object
3288 * @param itc The item class for the item
3289 * @param data The item data
3290 * @param parent The parent item, or NULL if none
3291 * @param flags Item flags
3292 * @param func Convenience function called when item selected
3293 * @param func_data Data passed to @p func above.
3294 * @return A handle to the item added or NULL if not possible
3298 EAPI Elm_Genlist_Item *
3299 elm_genlist_item_append(Evas_Object *obj,
3300 const Elm_Genlist_Item_Class *itc,
3302 Elm_Genlist_Item *parent,
3303 Elm_Genlist_Item_Flags flags,
3305 const void *func_data)
3307 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3308 Widget_Data *wd = elm_widget_data_get(obj);
3309 if (!wd) return NULL;
3310 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3312 if (!it) return NULL;
3315 if (flags & ELM_GENLIST_ITEM_GROUP)
3316 wd->group_items = eina_list_append(wd->group_items, it);
3317 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3322 Elm_Genlist_Item *it2 = NULL;
3323 Eina_List *ll = eina_list_last(it->parent->items);
3324 if (ll) it2 = ll->data;
3325 it->parent->items = eina_list_append(it->parent->items, it);
3326 if (!it2) it2 = it->parent;
3328 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3329 EINA_INLIST_GET(it2));
3331 it->rel->relcount++;
3333 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3334 it->group_item = parent;
3335 else if (it->parent->group_item)
3336 it->group_item = it->parent->group_item;
3338 it->before = EINA_FALSE;
3339 _item_queue(wd, it);
3344 * Prepend item at start of the genlist
3346 * This adds an item to the beginning of the list or beginning of the
3347 * children of the parent if given.
3349 * @param obj The genlist object
3350 * @param itc The item class for the item
3351 * @param data The item data
3352 * @param parent The parent item, or NULL if none
3353 * @param flags Item flags
3354 * @param func Convenience function called when item selected
3355 * @param func_data Data passed to @p func above.
3356 * @return A handle to the item added or NULL if not possible
3360 EAPI Elm_Genlist_Item *
3361 elm_genlist_item_prepend(Evas_Object *obj,
3362 const Elm_Genlist_Item_Class *itc,
3364 Elm_Genlist_Item *parent,
3365 Elm_Genlist_Item_Flags flags,
3367 const void *func_data)
3369 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3370 Widget_Data *wd = elm_widget_data_get(obj);
3371 if (!wd) return NULL;
3372 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3374 if (!it) return NULL;
3377 if (flags & ELM_GENLIST_ITEM_GROUP)
3378 wd->group_items = eina_list_prepend(wd->group_items, it);
3379 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3384 Elm_Genlist_Item *it2 = NULL;
3385 Eina_List *ll = it->parent->items;
3386 if (ll) it2 = ll->data;
3387 it->parent->items = eina_list_prepend(it->parent->items, it);
3388 if (!it2) it2 = it->parent;
3390 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3391 EINA_INLIST_GET(it2));
3393 it->rel->relcount++;
3395 it->before = EINA_TRUE;
3396 _item_queue(wd, it);
3401 * Insert item before another in the genlist
3403 * This inserts an item before another in the list. It will be in the
3404 * same tree level or group as the item it is inseted before.
3406 * @param obj The genlist object
3407 * @param itc The item class for the item
3408 * @param data The item data
3409 * @param before The item to insert before
3410 * @param flags Item flags
3411 * @param func Convenience function called when item selected
3412 * @param func_data Data passed to @p func above.
3413 * @return A handle to the item added or NULL if not possible
3417 EAPI Elm_Genlist_Item *
3418 elm_genlist_item_insert_before(Evas_Object *obj,
3419 const Elm_Genlist_Item_Class *itc,
3421 Elm_Genlist_Item *parent,
3422 Elm_Genlist_Item *before,
3423 Elm_Genlist_Item_Flags flags,
3425 const void *func_data)
3427 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3428 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3429 Widget_Data *wd = elm_widget_data_get(obj);
3430 if (!wd) return NULL;
3431 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3433 if (!it) return NULL;
3436 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3439 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3440 EINA_INLIST_GET(before));
3442 it->rel->relcount++;
3443 it->before = EINA_TRUE;
3444 _item_queue(wd, it);
3449 * Insert a new item into the sorted genlist object
3451 * @param obj The genlist object
3452 * @param itc The item class for the item
3453 * @param data The item data
3454 * @param parent The parent item, or NULL if none
3455 * @param flags Item flags
3456 * @param comp The function called for the sort
3457 * @param func Convenience function called when item selected
3458 * @param func_data Data passed to @p func above.
3459 * @return A handle to the item added or NULL if not possible
3463 EAPI Elm_Genlist_Item *
3464 elm_genlist_item_sorted_insert(Evas_Object *obj,
3465 const Elm_Genlist_Item_Class *itc,
3467 Elm_Genlist_Item *parent,
3468 Elm_Genlist_Item_Flags flags,
3469 Eina_Compare_Cb comp,
3471 const void *func_data)
3473 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3474 Widget_Data *wd = elm_widget_data_get(obj);
3475 if (!wd) return NULL;
3476 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3478 if (!it) return NULL;
3480 _elm_genlist_item_compare_cb = comp;
3484 eina_list_sorted_insert(it->parent->items, comp, it);
3486 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3487 _elm_genlist_item_compare);
3488 if (EINA_INLIST_GET(it)->next)
3490 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3491 it->rel->relcount++;
3492 it->before = EINA_TRUE;
3494 else if (EINA_INLIST_GET(it)->prev)
3496 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3497 it->rel->relcount++;
3498 it->before = EINA_FALSE;
3500 _item_queue(wd, it);
3506 * Insert an item after another in the genlst
3508 * This inserts an item after another in the list. It will be in the
3509 * same tree level or group as the item it is inseted after.
3511 * @param obj The genlist object
3512 * @param itc The item class for the item
3513 * @param data The item data
3514 * @param after The item to insert after
3515 * @param flags Item flags
3516 * @param func Convenience function called when item selected
3517 * @param func_data Data passed to @p func above.
3518 * @return A handle to the item added or NULL if not possible
3522 EAPI Elm_Genlist_Item *
3523 elm_genlist_item_insert_after(Evas_Object *obj,
3524 const Elm_Genlist_Item_Class *itc,
3526 Elm_Genlist_Item *parent,
3527 Elm_Genlist_Item *after,
3528 Elm_Genlist_Item_Flags flags,
3530 const void *func_data)
3532 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3533 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3534 Widget_Data *wd = elm_widget_data_get(obj);
3535 if (!wd) return NULL;
3536 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3538 if (!it) return NULL;
3539 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3540 EINA_INLIST_GET(after));
3543 it->parent->items = eina_list_append_relative(it->parent->items, it,
3547 it->rel->relcount++;
3548 it->before = EINA_FALSE;
3549 _item_queue(wd, it);
3556 * This clears all items in the list, leaving it empty.
3558 * @param obj The genlist object
3563 elm_genlist_clear(Evas_Object *obj)
3565 ELM_CHECK_WIDTYPE(obj, widtype);
3566 Widget_Data *wd = elm_widget_data_get(obj);
3568 if (wd->walking > 0)
3570 Elm_Genlist_Item *it;
3572 wd->clear_me = EINA_TRUE;
3573 EINA_INLIST_FOREACH(wd->items, it)
3575 it->delete_me = EINA_TRUE;
3579 evas_event_freeze(evas_object_evas_get(wd->obj));
3582 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3584 if (wd->anchor_item == it)
3586 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3587 if (!wd->anchor_item)
3589 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3591 wd->items = eina_inlist_remove(wd->items, wd->items);
3592 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3593 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3594 elm_widget_item_pre_notify_del(it);
3595 if (it->realized) _item_unrealize(it, EINA_FALSE);
3596 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3597 it->itc->func.del((void *)it->base.data, it->base.widget);
3598 if (it->long_timer) ecore_timer_del(it->long_timer);
3599 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3600 elm_widget_item_del(it);
3602 wd->clear_me = EINA_FALSE;
3603 wd->anchor_item = NULL;
3606 Item_Block *itb = (Item_Block *)(wd->blocks);
3608 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3609 if (itb->items) eina_list_free(itb->items);
3614 ecore_job_del(wd->calc_job);
3615 wd->calc_job = NULL;
3617 if (wd->queue_idle_enterer)
3619 ecore_idle_enterer_del(wd->queue_idle_enterer);
3620 wd->queue_idle_enterer = NULL;
3622 if (wd->must_recalc_idler)
3624 ecore_idler_del(wd->must_recalc_idler);
3625 wd->must_recalc_idler = NULL;
3629 eina_list_free(wd->queue);
3634 eina_list_free(wd->selected);
3635 wd->selected = NULL;
3637 wd->show_item = NULL;
3644 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3645 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3648 evas_event_thaw(evas_object_evas_get(wd->obj));
3649 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3653 * Enable or disable multi-select in the genlist
3655 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3656 * the list. This allows more than 1 item to be selected.
3658 * @param obj The genlist object
3659 * @param multi Multi-select enable/disable
3664 elm_genlist_multi_select_set(Evas_Object *obj,
3667 ELM_CHECK_WIDTYPE(obj, widtype);
3668 Widget_Data *wd = elm_widget_data_get(obj);
3674 * Gets if multi-select in genlist is enable or disable
3676 * @param obj The genlist object
3677 * @return Multi-select enable/disable
3678 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3683 elm_genlist_multi_select_get(const Evas_Object *obj)
3685 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3686 Widget_Data *wd = elm_widget_data_get(obj);
3687 if (!wd) return EINA_FALSE;
3692 * Get the selectd item in the genlist
3694 * This gets the selected item in the list (if multi-select is enabled
3695 * only the first item in the list is selected - which is not very
3696 * useful, so see elm_genlist_selected_items_get() for when
3697 * multi-select is used).
3699 * If no item is selected, NULL is returned.
3701 * @param obj The genlist object
3702 * @return The selected item, or NULL if none.
3706 EAPI Elm_Genlist_Item *
3707 elm_genlist_selected_item_get(const Evas_Object *obj)
3709 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3710 Widget_Data *wd = elm_widget_data_get(obj);
3711 if (!wd) return NULL;
3712 if (wd->selected) return wd->selected->data;
3717 * Get a list of selected items in the genlist
3719 * This returns a list of the selected items. This list pointer is
3720 * only valid so long as no items are selected or unselected (or
3721 * unselected implicitly by deletion). The list contains
3722 * Elm_Genlist_Item pointers.
3724 * @param obj The genlist object
3725 * @return The list of selected items, nor NULL if none are selected.
3729 EAPI const Eina_List *
3730 elm_genlist_selected_items_get(const Evas_Object *obj)
3732 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3733 Widget_Data *wd = elm_widget_data_get(obj);
3734 if (!wd) return NULL;
3735 return wd->selected;
3739 * Get a list of realized items in genlist
3741 * This returns a list of the realized items in the genlist. The list
3742 * contains Elm_Genlist_Item pointers. The list must be freed by the
3743 * caller when done with eina_list_free(). The item pointers in the
3744 * list are only valid so long as those items are not deleted or the
3745 * genlist is not deleted.
3747 * @param obj The genlist object
3748 * @return The list of realized items, nor NULL if none are realized.
3753 elm_genlist_realized_items_get(const Evas_Object *obj)
3755 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3756 Widget_Data *wd = elm_widget_data_get(obj);
3757 Eina_List *list = NULL;
3759 Eina_Bool done = EINA_FALSE;
3760 if (!wd) return NULL;
3761 EINA_INLIST_FOREACH(wd->blocks, itb)
3766 Elm_Genlist_Item *it;
3769 EINA_LIST_FOREACH(itb->items, l, it)
3771 if (it->realized) list = eina_list_append(list, it);
3783 * Get the item that is at the x, y canvas coords
3785 * This returns the item at the given coordinates (which are canvas
3786 * relative not object-relative). If an item is at that coordinate,
3787 * that item handle is returned, and if @p posret is not NULL, the
3788 * integer pointed to is set to a value of -1, 0 or 1, depending if
3789 * the coordinate is on the upper portion of that item (-1), on the
3790 * middle section (0) or on the lower part (1). If NULL is returned as
3791 * an item (no item found there), then posret may indicate -1 or 1
3792 * based if the coordinate is above or below all items respectively in
3795 * @param it The item
3796 * @param x The input x coordinate
3797 * @param y The input y coordinate
3798 * @param posret The position relative to the item returned here
3799 * @return The item at the coordinates or NULL if none
3803 EAPI Elm_Genlist_Item *
3804 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3809 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3810 Widget_Data *wd = elm_widget_data_get(obj);
3811 Evas_Coord ox, oy, ow, oh;
3814 if (!wd) return NULL;
3815 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3817 EINA_INLIST_FOREACH(wd->blocks, itb)
3820 Elm_Genlist_Item *it;
3822 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3823 oy + itb->y - itb->wd->pan_y,
3824 itb->w, itb->h, x, y, 1, 1))
3826 EINA_LIST_FOREACH(itb->items, l, it)
3828 Evas_Coord itx, ity;
3830 itx = ox + itb->x + it->x - itb->wd->pan_x;
3831 ity = oy + itb->y + it->y - itb->wd->pan_y;
3832 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3836 if (y <= (ity + (it->h / 4))) *posret = -1;
3837 else if (y >= (ity + it->h - (it->h / 4)))
3843 lasty = ity + it->h;
3848 if (y > lasty) *posret = 1;
3855 * Get the first item in the genlist
3857 * This returns the first item in the list.
3859 * @param obj The genlist object
3860 * @return The first item, or NULL if none
3864 EAPI Elm_Genlist_Item *
3865 elm_genlist_first_item_get(const Evas_Object *obj)
3867 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3868 Widget_Data *wd = elm_widget_data_get(obj);
3869 if (!wd) return NULL;
3870 if (!wd->items) return NULL;
3871 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3872 while ((it) && (it->delete_me))
3873 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3878 * Get the last item in the genlist
3880 * This returns the last item in the list.
3882 * @return The last item, or NULL if none
3886 EAPI Elm_Genlist_Item *
3887 elm_genlist_last_item_get(const Evas_Object *obj)
3889 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3890 Widget_Data *wd = elm_widget_data_get(obj);
3891 if (!wd) return NULL;
3892 if (!wd->items) return NULL;
3893 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3894 while ((it) && (it->delete_me))
3895 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3900 * Get the next item in the genlist
3902 * This returns the item after the item @p it.
3904 * @param it The item
3905 * @return The item after @p it, or NULL if none
3909 EAPI Elm_Genlist_Item *
3910 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3912 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3915 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3916 if ((it) && (!it->delete_me)) break;
3918 return (Elm_Genlist_Item *)it;
3922 * Get the previous item in the genlist
3924 * This returns the item before the item @p it.
3926 * @param it The item
3927 * @return The item before @p it, or NULL if none
3931 EAPI Elm_Genlist_Item *
3932 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3934 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3937 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3938 if ((it) && (!it->delete_me)) break;
3940 return (Elm_Genlist_Item *)it;
3944 * Get the genlist object from an item
3946 * This returns the genlist object itself that an item belongs to.
3948 * @param it The item
3949 * @return The genlist object
3954 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3956 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3957 return it->base.widget;
3961 * Get the parent item of the given item
3963 * This returns the parent item of the item @p it given.
3965 * @param it The item
3966 * @return The parent of the item or NULL if none
3970 EAPI Elm_Genlist_Item *
3971 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3973 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3978 * Clear all sub-items (children) of the given item
3980 * This clears all items that are children (or their descendants) of the
3983 * @param it The item
3988 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3990 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3991 Eina_List *tl = NULL, *l;
3992 Elm_Genlist_Item *it2;
3994 EINA_LIST_FOREACH(it->items, l, it2)
3995 tl = eina_list_append(tl, it2);
3996 EINA_LIST_FREE(tl, it2)
3997 elm_genlist_item_del(it2);
4001 * Set the selected state of an item
4003 * This sets the selected state (1 selected, 0 not selected) of the given
4006 * @param it The item
4007 * @param selected The selected state
4012 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4015 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4016 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4018 if ((it->delete_me) || (it->disabled)) return;
4019 selected = !!selected;
4020 if (it->selected == selected) return;
4026 while (wd->selected)
4028 _item_unhighlight(wd->selected->data);
4029 _item_unselect(wd->selected->data);
4032 _item_highlight(it);
4037 _item_unhighlight(it);
4043 * Get the selected state of an item
4045 * This gets the selected state of an item (1 selected, 0 not selected).
4047 * @param it The item
4048 * @return The selected state
4053 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4055 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4056 return it->selected;
4060 * Sets the expanded state of an item (if it's a parent)
4062 * This expands or contracts a parent item (thus showing or hiding the
4065 * @param it The item
4066 * @param expanded The expanded state (1 expanded, 0 not expanded).
4071 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4074 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4075 if (it->expanded == expanded) return;
4076 it->expanded = expanded;
4080 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4081 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4086 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4087 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4092 * Get the expanded state of an item
4094 * This gets the expanded state of an item
4096 * @param it The item
4097 * @return Thre expanded state
4102 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4104 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4105 return it->expanded;
4109 * Get the depth of expanded item
4111 * @param it The genlist item object
4112 * @return The depth of expanded item
4117 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4119 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4120 return it->expanded_depth;
4124 * Sets the disabled state of an item.
4126 * A disabled item cannot be selected or unselected. It will also
4127 * change appearance to appear disabled. This sets the disabled state
4128 * (1 disabled, 0 not disabled).
4130 * @param it The item
4131 * @param disabled The disabled state
4136 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4139 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4142 if (it->disabled == disabled) return;
4143 if (it->delete_me) return;
4144 it->disabled = !!disabled;
4146 elm_genlist_item_selected_set(it, EINA_FALSE);
4150 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4152 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4153 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4154 elm_widget_disabled_set(obj, disabled);
4159 * Get the disabled state of an item
4161 * This gets the disabled state of the given item.
4163 * @param it The item
4164 * @return The disabled state
4169 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4171 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4172 if (it->delete_me) return EINA_FALSE;
4173 return it->disabled;
4177 * Sets the display only state of an item.
4179 * A display only item cannot be selected or unselected. It is for
4180 * display only and not selecting or otherwise clicking, dragging
4181 * etc. by the user, thus finger size rules will not be applied to
4184 * @param it The item
4185 * @param display_only The display only state
4190 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4191 Eina_Bool display_only)
4193 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4194 if (it->display_only == display_only) return;
4195 if (it->delete_me) return;
4196 it->display_only = display_only;
4197 it->mincalcd = EINA_FALSE;
4198 it->updateme = EINA_TRUE;
4199 if (it->block) it->block->updateme = EINA_TRUE;
4200 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4201 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4205 * Get the display only state of an item
4207 * This gets the display only state of the given item.
4209 * @param it The item
4210 * @return The display only state
4215 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4217 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4218 if (it->delete_me) return EINA_FALSE;
4219 return it->display_only;
4223 * Show the given item
4225 * This causes genlist to jump to the given item @p it and show it (by
4226 * scrolling), if it is not fully visible.
4228 * @param it The item
4233 elm_genlist_item_show(Elm_Genlist_Item *it)
4235 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4236 Evas_Coord gith = 0;
4237 if (it->delete_me) return;
4238 if ((it->queued) || (!it->mincalcd))
4240 it->wd->show_item = it;
4241 it->wd->bring_in = EINA_TRUE;
4242 it->showme = EINA_TRUE;
4245 if (it->wd->show_item)
4247 it->wd->show_item->showme = EINA_FALSE;
4248 it->wd->show_item = NULL;
4250 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4251 gith = it->group_item->h;
4252 elm_smart_scroller_child_region_show(it->wd->scr,
4253 it->x + it->block->x,
4254 it->y + it->block->y - gith,
4255 it->block->w, it->h);
4259 * Bring in the given item
4261 * This causes genlist to jump to the given item @p it and show it (by
4262 * scrolling), if it is not fully visible. This may use animation to
4263 * do so and take a period of time
4265 * @param it The item
4270 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4272 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4273 Evas_Coord gith = 0;
4274 if (it->delete_me) return;
4275 if ((it->queued) || (!it->mincalcd))
4277 it->wd->show_item = it;
4278 it->wd->bring_in = EINA_TRUE;
4279 it->showme = EINA_TRUE;
4282 if (it->wd->show_item)
4284 it->wd->show_item->showme = EINA_FALSE;
4285 it->wd->show_item = NULL;
4287 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4288 gith = it->group_item->h;
4289 elm_smart_scroller_region_bring_in(it->wd->scr,
4290 it->x + it->block->x,
4291 it->y + it->block->y - gith,
4292 it->block->w, it->h);
4296 * Show the given item at the top
4298 * This causes genlist to jump to the given item @p it and show it (by
4299 * scrolling), if it is not fully visible.
4301 * @param it The item
4306 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4308 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4310 Evas_Coord gith = 0;
4312 if (it->delete_me) return;
4313 if ((it->queued) || (!it->mincalcd))
4315 it->wd->show_item = it;
4316 it->wd->bring_in = EINA_TRUE;
4317 it->showme = EINA_TRUE;
4320 if (it->wd->show_item)
4322 it->wd->show_item->showme = EINA_FALSE;
4323 it->wd->show_item = NULL;
4325 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4326 if (it->group_item) gith = it->group_item->h;
4327 elm_smart_scroller_child_region_show(it->wd->scr,
4328 it->x + it->block->x,
4329 it->y + it->block->y - gith,
4334 * Bring in the given item at the top
4336 * This causes genlist to jump to the given item @p it and show it (by
4337 * scrolling), if it is not fully visible. This may use animation to
4338 * do so and take a period of time
4340 * @param it The item
4345 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4347 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4349 Evas_Coord gith = 0;
4351 if (it->delete_me) return;
4352 if ((it->queued) || (!it->mincalcd))
4354 it->wd->show_item = it;
4355 it->wd->bring_in = EINA_TRUE;
4356 it->showme = EINA_TRUE;
4359 if (it->wd->show_item)
4361 it->wd->show_item->showme = EINA_FALSE;
4362 it->wd->show_item = NULL;
4364 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4365 if (it->group_item) gith = it->group_item->h;
4366 elm_smart_scroller_region_bring_in(it->wd->scr,
4367 it->x + it->block->x,
4368 it->y + it->block->y - gith,
4373 * Show the given item at the middle
4375 * This causes genlist to jump to the given item @p it and show it (by
4376 * scrolling), if it is not fully visible.
4378 * @param it The item
4383 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4385 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4388 if (it->delete_me) return;
4389 if ((it->queued) || (!it->mincalcd))
4391 it->wd->show_item = it;
4392 it->wd->bring_in = EINA_TRUE;
4393 it->showme = EINA_TRUE;
4396 if (it->wd->show_item)
4398 it->wd->show_item->showme = EINA_FALSE;
4399 it->wd->show_item = NULL;
4401 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4402 elm_smart_scroller_child_region_show(it->wd->scr,
4403 it->x + it->block->x,
4404 it->y + it->block->y - oh / 2 +
4405 it->h / 2, it->block->w, oh);
4409 * Bring in the given item at the middle
4411 * This causes genlist to jump to the given item @p it and show it (by
4412 * scrolling), if it is not fully visible. This may use animation to
4413 * do so and take a period of time
4415 * @param it The item
4420 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4422 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4425 if (it->delete_me) return;
4426 if ((it->queued) || (!it->mincalcd))
4428 it->wd->show_item = it;
4429 it->wd->bring_in = EINA_TRUE;
4430 it->showme = EINA_TRUE;
4433 if (it->wd->show_item)
4435 it->wd->show_item->showme = EINA_FALSE;
4436 it->wd->show_item = NULL;
4438 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4439 elm_smart_scroller_region_bring_in(it->wd->scr,
4440 it->x + it->block->x,
4441 it->y + it->block->y - oh / 2 + it->h / 2,
4446 * Delete a given item
4448 * This deletes the item from genlist and calls the genlist item del
4449 * class callback defined in the item class, if it is set. This clears all
4450 * subitems if it is a tree.
4452 * @param it The item
4457 elm_genlist_item_del(Elm_Genlist_Item *it)
4459 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4460 if ((it->relcount > 0) || (it->walking > 0))
4462 elm_widget_item_pre_notify_del(it);
4463 elm_genlist_item_subitems_clear(it);
4464 it->delete_me = EINA_TRUE;
4465 if (it->wd->show_item == it) it->wd->show_item = NULL;
4467 it->wd->selected = eina_list_remove(it->wd->selected,
4471 if (it->realized) _item_unrealize(it, EINA_FALSE);
4472 it->block->changed = EINA_TRUE;
4473 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4474 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4476 if (it->itc->func.del)
4477 it->itc->func.del((void *)it->base.data, it->base.widget);
4484 * Set the data item from the genlist item
4486 * This set the data value passed on the elm_genlist_item_append() and
4487 * related item addition calls. This function will also call
4488 * elm_genlist_item_update() so the item will be updated to reflect the
4491 * @param it The item
4492 * @param data The new data pointer to set
4497 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4500 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4501 elm_widget_item_data_set(it, data);
4502 elm_genlist_item_update(it);
4506 * Get the data item from the genlist item
4508 * This returns the data value passed on the elm_genlist_item_append()
4509 * and related item addition calls and elm_genlist_item_data_set().
4511 * @param it The item
4512 * @return The data pointer provided when created
4517 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4519 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4520 return elm_widget_item_data_get(it);
4524 * Tells genlist to "orphan" icons fetchs by the item class
4526 * This instructs genlist to release references to icons in the item,
4527 * meaning that they will no longer be managed by genlist and are
4528 * floating "orphans" that can be re-used elsewhere if the user wants
4531 * @param it The item
4536 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4539 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4540 EINA_LIST_FREE(it->icon_objs, icon)
4542 elm_widget_sub_object_del(it->base.widget, icon);
4543 evas_object_smart_member_del(icon);
4544 evas_object_hide(icon);
4549 * Get the real evas object of the genlist item
4551 * This returns the actual evas object used for the specified genlist
4552 * item. This may be NULL as it may not be created, and may be deleted
4553 * at any time by genlist. Do not modify this object (move, resize,
4554 * show, hide etc.) as genlist is controlling it. This function is for
4555 * querying, emitting custom signals or hooking lower level callbacks
4556 * for events. Do not delete this object under any circumstances.
4558 * @param it The item
4559 * @return The object pointer
4563 EAPI const Evas_Object *
4564 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4566 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4567 return it->base.view;
4571 * Update the contents of an item
4573 * This updates an item by calling all the item class functions again
4574 * to get the icons, labels and states. Use this when the original
4575 * item data has changed and the changes are desired to be reflected.
4577 * @param it The item
4582 elm_genlist_item_update(Elm_Genlist_Item *it)
4584 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4585 if (!it->block) return;
4586 if (it->delete_me) return;
4587 it->mincalcd = EINA_FALSE;
4588 it->updateme = EINA_TRUE;
4589 it->block->updateme = EINA_TRUE;
4590 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4591 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4595 * Update the item class of an item
4597 * @param it The item
4598 * @parem itc The item class for the item
4603 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4604 const Elm_Genlist_Item_Class *itc)
4606 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4607 if (!it->block) return;
4608 EINA_SAFETY_ON_NULL_RETURN(itc);
4609 if (it->delete_me) return;
4611 it->nocache = EINA_TRUE;
4612 elm_genlist_item_update(it);
4615 static Evas_Object *
4616 _elm_genlist_item_label_create(void *data,
4618 void *item __UNUSED__)
4620 Evas_Object *label = elm_label_add(obj);
4623 elm_object_style_set(label, "tooltip");
4624 elm_label_label_set(label, data);
4629 _elm_genlist_item_label_del_cb(void *data,
4630 Evas_Object *obj __UNUSED__,
4631 void *event_info __UNUSED__)
4633 eina_stringshare_del(data);
4637 * Set the text to be shown in the genlist item.
4639 * @param item Target item
4640 * @param text The text to set in the content
4642 * Setup the text as tooltip to object. The item can have only one
4643 * tooltip, so any previous tooltip data is removed.
4648 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4651 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4652 text = eina_stringshare_add(text);
4653 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4655 _elm_genlist_item_label_del_cb);
4659 * Set the content to be shown in the tooltip item
4661 * Setup the tooltip to item. The item can have only one tooltip, so
4662 * any previous tooltip data is removed. @p func(with @p data) will be
4663 * called every time that need to show the tooltip and it should return a
4664 * valid Evas_Object. This object is then managed fully by tooltip
4665 * system and is deleted when the tooltip is gone.
4667 * @param item the genlist item being attached by a tooltip.
4668 * @param func the function used to create the tooltip contents.
4669 * @param data what to provide to @a func as callback data/context.
4670 * @param del_cb called when data is not needed anymore, either when
4671 * another callback replaces @func, the tooltip is unset with
4672 * elm_genlist_item_tooltip_unset() or the owner @a item
4673 * dies. This callback receives as the first parameter the
4674 * given @a data, and @c event_info is the item.
4679 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4680 Elm_Tooltip_Item_Content_Cb func,
4682 Evas_Smart_Cb del_cb)
4684 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4686 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4689 if (item->tooltip.del_cb)
4690 item->tooltip.del_cb((void *)item->tooltip.data,
4691 item->base.widget, item);
4693 item->tooltip.content_cb = func;
4694 item->tooltip.data = data;
4695 item->tooltip.del_cb = del_cb;
4697 if (item->base.view)
4699 elm_widget_item_tooltip_content_cb_set(item,
4700 item->tooltip.content_cb,
4701 item->tooltip.data, NULL);
4702 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4708 if (del_cb) del_cb((void *)data, NULL, NULL);
4712 * Unset tooltip from item
4714 * @param item genlist item to remove previously set tooltip.
4716 * Remove tooltip from item. The callback provided as del_cb to
4717 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4718 * it is not used anymore.
4720 * @see elm_genlist_item_tooltip_content_cb_set()
4725 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4727 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4728 if ((item->base.view) && (item->tooltip.content_cb))
4729 elm_widget_item_tooltip_unset(item);
4731 if (item->tooltip.del_cb)
4732 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4733 item->tooltip.del_cb = NULL;
4734 item->tooltip.content_cb = NULL;
4735 item->tooltip.data = NULL;
4736 if (item->tooltip.style)
4737 elm_genlist_item_tooltip_style_set(item, NULL);
4741 * Sets a different style for this item tooltip.
4743 * @note before you set a style you should define a tooltip with
4744 * elm_genlist_item_tooltip_content_cb_set() or
4745 * elm_genlist_item_tooltip_text_set()
4747 * @param item genlist item with tooltip already set.
4748 * @param style the theme style to use (default, transparent, ...)
4753 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4756 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4757 eina_stringshare_replace(&item->tooltip.style, style);
4758 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4762 * Get the style for this item tooltip.
4764 * @param item genlist item with tooltip already set.
4765 * @return style the theme style in use, defaults to "default". If the
4766 * object does not have a tooltip set, then NULL is returned.
4771 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4774 return item->tooltip.style;
4778 * Set the cursor to be shown when mouse is over the genlist item
4780 * @param item Target item
4781 * @param cursor the cursor name to be used.
4783 * @see elm_object_cursor_set()
4787 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4790 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4791 eina_stringshare_replace(&item->mouse_cursor, cursor);
4792 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4796 * Get the cursor to be shown when mouse is over the genlist item
4798 * @param item genlist item with cursor already set.
4799 * @return the cursor name.
4804 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4806 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4807 return elm_widget_item_cursor_get(item);
4811 * Unset the cursor to be shown when mouse is over the genlist item
4813 * @param item Target item
4815 * @see elm_object_cursor_unset()
4819 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4821 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4822 if (!item->mouse_cursor)
4825 if (item->base.view)
4826 elm_widget_item_cursor_unset(item);
4828 eina_stringshare_del(item->mouse_cursor);
4829 item->mouse_cursor = NULL;
4833 * Sets a different style for this item cursor.
4835 * @note before you set a style you should define a cursor with
4836 * elm_genlist_item_cursor_set()
4838 * @param item genlist item with cursor already set.
4839 * @param style the theme style to use (default, transparent, ...)
4844 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4847 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4848 elm_widget_item_cursor_style_set(item, style);
4852 * Get the style for this item cursor.
4854 * @param item genlist item with cursor already set.
4855 * @return style the theme style in use, defaults to "default". If the
4856 * object does not have a cursor set, then NULL is returned.
4861 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4863 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4864 return elm_widget_item_cursor_style_get(item);
4868 * Set if the cursor set should be searched on the theme or should use
4869 * the provided by the engine, only.
4871 * @note before you set if should look on theme you should define a
4872 * cursor with elm_object_cursor_set(). By default it will only look
4873 * for cursors provided by the engine.
4875 * @param item widget item with cursor already set.
4876 * @param engine_only boolean to define it cursors should be looked
4877 * only between the provided by the engine or searched on widget's
4883 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4884 Eina_Bool engine_only)
4886 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4887 elm_widget_item_cursor_engine_only_set(item, engine_only);
4891 * Get the cursor engine only usage for this item cursor.
4893 * @param item widget item with cursor already set.
4894 * @return engine_only boolean to define it cursors should be looked
4895 * only between the provided by the engine or searched on widget's
4896 * theme as well. If the object does not have a cursor set, then
4897 * EINA_FALSE is returned.
4902 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4904 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4905 return elm_widget_item_cursor_engine_only_get(item);
4909 * This sets the horizontal stretching mode
4911 * This sets the mode used for sizing items horizontally. Valid modes
4912 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4913 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4914 * the scroller will scroll horizontally. Otherwise items are expanded
4915 * to fill the width of the viewport of the scroller. If it is
4916 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4917 * limited to that size.
4919 * @param obj The genlist object
4920 * @param mode The mode to use
4925 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4928 ELM_CHECK_WIDTYPE(obj, widtype);
4929 Widget_Data *wd = elm_widget_data_get(obj);
4931 if (wd->mode == mode) return;
4937 * Gets the horizontal stretching mode
4939 * @param obj The genlist object
4940 * @return The mode to use
4941 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4946 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4948 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4949 Widget_Data *wd = elm_widget_data_get(obj);
4950 if (!wd) return ELM_LIST_LAST;
4955 * Set the always select mode.
4957 * Items will only call their selection func and callback when first
4958 * becoming selected. Any further clicks will do nothing, unless you
4959 * enable always select with elm_genlist_always_select_mode_set().
4960 * This means even if selected, every click will make the selected
4961 * callbacks be called.
4963 * @param obj The genlist object
4964 * @param always_select The always select mode
4965 * (EINA_TRUE = on, EINA_FALSE = off)
4970 elm_genlist_always_select_mode_set(Evas_Object *obj,
4971 Eina_Bool always_select)
4973 ELM_CHECK_WIDTYPE(obj, widtype);
4974 Widget_Data *wd = elm_widget_data_get(obj);
4976 wd->always_select = always_select;
4980 * Get the always select mode.
4982 * @param obj The genlist object
4983 * @return The always select mode
4984 * (EINA_TRUE = on, EINA_FALSE = off)
4989 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4991 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4992 Widget_Data *wd = elm_widget_data_get(obj);
4993 if (!wd) return EINA_FALSE;
4994 return wd->always_select;
4998 * Set no select mode
5000 * This will turn off the ability to select items entirely and they
5001 * will neither appear selected nor call selected callback functions.
5003 * @param obj The genlist object
5004 * @param no_select The no select mode
5005 * (EINA_TRUE = on, EINA_FALSE = off)
5010 elm_genlist_no_select_mode_set(Evas_Object *obj,
5011 Eina_Bool no_select)
5013 ELM_CHECK_WIDTYPE(obj, widtype);
5014 Widget_Data *wd = elm_widget_data_get(obj);
5016 wd->no_select = no_select;
5020 * Gets no select mode
5022 * @param obj The genlist object
5023 * @return The no select mode
5024 * (EINA_TRUE = on, EINA_FALSE = off)
5029 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5031 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5032 Widget_Data *wd = elm_widget_data_get(obj);
5033 if (!wd) return EINA_FALSE;
5034 return wd->no_select;
5040 * This will enable the compress mode where items are "compressed"
5041 * horizontally to fit the genlist scrollable viewport width. This is
5042 * special for genlist. Do not rely on
5043 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5044 * work as genlist needs to handle it specially.
5046 * @param obj The genlist object
5047 * @param compress The compress mode
5048 * (EINA_TRUE = on, EINA_FALSE = off)
5053 elm_genlist_compress_mode_set(Evas_Object *obj,
5056 ELM_CHECK_WIDTYPE(obj, widtype);
5057 Widget_Data *wd = elm_widget_data_get(obj);
5059 wd->compress = compress;
5060 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5064 * Get the compress mode
5066 * @param obj The genlist object
5067 * @return The compress mode
5068 * (EINA_TRUE = on, EINA_FALSE = off)
5073 elm_genlist_compress_mode_get(const Evas_Object *obj)
5075 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5076 Widget_Data *wd = elm_widget_data_get(obj);
5077 if (!wd) return EINA_FALSE;
5078 return wd->compress;
5082 * Set height-for-width mode
5084 * With height-for-width mode the item width will be fixed (restricted
5085 * to a minimum of) to the list width when calculating its size in
5086 * order to allow the height to be calculated based on it. This allows,
5087 * for instance, text block to wrap lines if the Edje part is
5088 * configured with "text.min: 0 1".
5090 * @note This mode will make list resize slower as it will have to
5091 * recalculate every item height again whenever the list width
5094 * @note When height-for-width mode is enabled, it also enables
5095 * compress mode (see elm_genlist_compress_mode_set()) and
5096 * disables homogeneous (see elm_genlist_homogeneous_set()).
5098 * @param obj The genlist object
5099 * @param setting The height-for-width mode (EINA_TRUE = on,
5105 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5106 Eina_Bool height_for_width)
5108 ELM_CHECK_WIDTYPE(obj, widtype);
5109 Widget_Data *wd = elm_widget_data_get(obj);
5111 wd->height_for_width = !!height_for_width;
5112 if (wd->height_for_width)
5114 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5115 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5120 * Get the height-for-width mode
5122 * @param obj The genlist object
5123 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5129 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5131 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5132 Widget_Data *wd = elm_widget_data_get(obj);
5133 if (!wd) return EINA_FALSE;
5134 return wd->height_for_width;
5140 * This will enable or disable the scroller bounce mode for the
5141 * genlist. See elm_scroller_bounce_set() for details
5143 * @param obj The genlist object
5144 * @param h_bounce Allow bounce horizontally
5145 * @param v_bounce Allow bounce vertically
5150 elm_genlist_bounce_set(Evas_Object *obj,
5154 ELM_CHECK_WIDTYPE(obj, widtype);
5155 Widget_Data *wd = elm_widget_data_get(obj);
5157 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5161 * Get the bounce mode
5163 * @param obj The genlist object
5164 * @param h_bounce Allow bounce horizontally
5165 * @param v_bounce Allow bounce vertically
5170 elm_genlist_bounce_get(const Evas_Object *obj,
5171 Eina_Bool *h_bounce,
5172 Eina_Bool *v_bounce)
5174 ELM_CHECK_WIDTYPE(obj, widtype);
5175 Widget_Data *wd = elm_widget_data_get(obj);
5177 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5181 * Set homogenous mode
5183 * This will enable the homogeneous mode where items are of the same
5184 * height and width so that genlist may do the lazy-loading at its
5185 * maximum. This implies 'compressed' mode.
5187 * @param obj The genlist object
5188 * @param homogeneous Assume the items within the genlist are of the
5189 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5194 elm_genlist_homogeneous_set(Evas_Object *obj,
5195 Eina_Bool homogeneous)
5197 ELM_CHECK_WIDTYPE(obj, widtype);
5198 Widget_Data *wd = elm_widget_data_get(obj);
5200 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5201 wd->homogeneous = homogeneous;
5205 * Get the homogenous mode
5207 * @param obj The genlist object
5208 * @return Assume the items within the genlist are of the same height
5209 * and width (EINA_TRUE = on, EINA_FALSE = off)
5214 elm_genlist_homogeneous_get(const Evas_Object *obj)
5216 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5217 Widget_Data *wd = elm_widget_data_get(obj);
5218 if (!wd) return EINA_FALSE;
5219 return wd->homogeneous;
5223 * Set the maximum number of items within an item block
5225 * This will configure the block count to tune to the target with
5226 * particular performance matrix.
5228 * @param obj The genlist object
5229 * @param n Maximum number of items within an item block
5234 elm_genlist_block_count_set(Evas_Object *obj,
5237 ELM_CHECK_WIDTYPE(obj, widtype);
5238 Widget_Data *wd = elm_widget_data_get(obj);
5240 wd->max_items_per_block = n;
5241 wd->item_cache_max = wd->max_items_per_block * 2;
5242 _item_cache_clean(wd);
5246 * Get the maximum number of items within an item block
5248 * @param obj The genlist object
5249 * @return Maximum number of items within an item block
5254 elm_genlist_block_count_get(const Evas_Object *obj)
5256 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5257 Widget_Data *wd = elm_widget_data_get(obj);
5259 return wd->max_items_per_block;
5263 * Set the timeout in seconds for the longpress event
5265 * @param obj The genlist object
5266 * @param timeout timeout in seconds
5271 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5274 ELM_CHECK_WIDTYPE(obj, widtype);
5275 Widget_Data *wd = elm_widget_data_get(obj);
5277 wd->longpress_timeout = timeout;
5281 * Get the timeout in seconds for the longpress event
5283 * @param obj The genlist object
5284 * @return timeout in seconds
5289 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5291 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5292 Widget_Data *wd = elm_widget_data_get(obj);
5294 return wd->longpress_timeout;
5298 * Set the scrollbar policy
5300 * This sets the scrollbar visibility policy for the given genlist
5301 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5302 * made visible if it is needed, and otherwise kept hidden.
5303 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5304 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5305 * respectively for the horizontal and vertical scrollbars.
5307 * @param obj The genlist object
5308 * @param policy_h Horizontal scrollbar policy
5309 * @param policy_v Vertical scrollbar policy
5314 elm_genlist_scroller_policy_set(Evas_Object *obj,
5315 Elm_Scroller_Policy policy_h,
5316 Elm_Scroller_Policy policy_v)
5318 ELM_CHECK_WIDTYPE(obj, widtype);
5319 Widget_Data *wd = elm_widget_data_get(obj);
5321 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5322 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5325 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5329 * Get the scrollbar policy
5331 * @param obj The genlist object
5332 * @param policy_h Horizontal scrollbar policy
5333 * @param policy_v Vertical scrollbar policy
5338 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5339 Elm_Scroller_Policy *policy_h,
5340 Elm_Scroller_Policy *policy_v)
5342 ELM_CHECK_WIDTYPE(obj, widtype);
5343 Widget_Data *wd = elm_widget_data_get(obj);
5344 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5345 if ((!wd) || (!wd->scr)) return;
5346 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5347 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5348 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5352 * Update the contents of all realized items
5354 * This updates all realized items by calling all the item class functions again
5355 * to get the icons, labels and states. Use this when the original
5356 * item data has changed and the changes are desired to be reflected.
5358 * @param it The item
5363 elm_genlist_realized_items_update(Evas_Object *obj)
5365 ELM_CHECK_WIDTYPE(obj, widtype);
5367 Eina_List *list, *l;
5368 Elm_Genlist_Item *it;
5370 list = elm_genlist_realized_items_get(obj);
5371 EINA_LIST_FOREACH(list, l, it)
5372 elm_genlist_item_update(it);
5376 * Set genlist item mode
5378 * @param item The genlist item
5379 * @param mode Mode name
5380 * @param mode_set Boolean to define set or unset mode.
5385 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5386 const char *mode_type,
5389 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5390 Widget_Data *wd = it->wd;
5392 Elm_Genlist_Item *it2;
5395 if (!mode_type) return;
5396 if ((it->delete_me) || (it->disabled)) return;
5398 if ((wd->mode_item == it) &&
5399 (!strcmp(mode_type, wd->mode_type)) &&
5402 if (!it->itc->mode_item_style) return;
5406 EINA_LIST_FOREACH(wd->selected, l, it2)
5408 elm_genlist_item_selected_set(it2, EINA_FALSE);
5412 it2 = elm_genlist_selected_item_get(wd->obj);
5413 if ((it2) && (it2->realized))
5414 elm_genlist_item_selected_set(it2, EINA_FALSE);
5417 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5419 ((it == wd->mode_item) && (!mode_set)))
5420 _item_mode_unset(wd);
5422 eina_stringshare_replace(&wd->mode_type, mode_type);
5423 if (mode_set) _item_mode_set(it);
5427 * Get active genlist mode type
5429 * @param obj The genlist object
5434 elm_genlist_mode_get(const Evas_Object *obj)
5436 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5437 Widget_Data *wd = elm_widget_data_get(obj);
5438 if (!wd) return NULL;
5439 return wd->mode_type;
5443 * Get active genlist mode item
5445 * @param obj The genlist object
5449 EAPI const Elm_Genlist_Item *
5450 elm_genlist_mode_item_get(const Evas_Object *obj)
5452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5453 Widget_Data *wd = elm_widget_data_get(obj);
5454 if (!wd) return NULL;
5455 return wd->mode_item;