1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Genlist has a fairly large API, mostly because it's relatively complex,
19 * trying to be both expansive, powerful and efficient. First we will begin
20 * an overview on the theory behind genlist.
22 * Evas tracks every object you create. Every time it processes an event
23 * (mouse move, down, up etc.) it needs to walk through objects and find out
24 * what event that affects. Even worse every time it renders display updates,
25 * in order to just calculate what to re-draw, it needs to walk through many
26 * many many objects. Thus, the more objects you keep active, the more
27 * overhead Evas has in just doing its work. It is advisable to keep your
28 * active objects to the minimum working set you need. Also remember that
29 * object creation and deletion carries an overhead, so there is a
30 * middle-ground, which is not easily determined. But don't keep massive lists
31 * of objects you can't see or use. Genlist does this with list objects. It
32 * creates and destroys them dynamically as you scroll around. It groups them
33 * into blocks so it can determine the visibility etc. of a whole block at
34 * once as opposed to having to walk the whole list. This 2-level list allows
35 * for very large numbers of items to be in the list (tests have used up to
36 * 2,000,000 items). Also genlist employs a queue for adding items. As items
37 * may be different sizes, every item added needs to be calculated as to its
38 * size and thus this presents a lot of overhead on populating the list, this
39 * genlist employs a queue. Any item added is queued and spooled off over
40 * time, actually appearing some time later, so if your list has many members
41 * you may find it takes a while for them to all appear, with your process
42 * consuming a lot of CPU while it is busy spooling.
44 * Genlist also implements a tree structure, but it does so with callbacks to
45 * the application, with the application filling in tree structures when
46 * requested (allowing for efficient building of a very deep tree that could
47 * even be used for file-management). See the above smart signal callbacks for
50 * An item in the genlist world can have 0 or more text labels (they can be
51 * regular text or textblock - that's up to the style to determine), 0 or
52 * more icons (which are simply objects swallowed into the genlist item) and
53 * 0 or more boolean states that can be used for check, radio or other
54 * indicators by the edje theme style. An item may be one of several styles
55 * (Elementary provides 4 by default - "default", "double_label", "group_index"
56 * and "icon_top_text_bottom", but this can be extended by system or
57 * application custom themes/overlays/extensions).
59 * In order to implement the ability to add and delete items on the fly,
60 * Genlist implements a class/callback system where the application provides
61 * a structure with information about that type of item (genlist may contain
62 * multiple different items with different classes, states and styles).
63 * Genlist will call the functions in this struct (methods) when an item is
64 * "realized" (that is created dynamically while scrolling). All objects will
65 * simply be deleted when no longer needed with evas_object_del(). The
66 * Elm_Genlist_Item_Class structure contains the following members:
68 * item_style - This is a constant string and simply defines the name of the
69 * item style. It must be specified and the default should be "default".
71 * func.label_get - This function is called when an actual item object is
72 * created. The data parameter is the data parameter passed to
73 * elm_genlist_item_append() and related item creation functions. The obj
74 * parameter is the genlist object and the part parameter is the string name
75 * of the text part in the edje design that is listed as one of the possible
76 * labels that can be set. This function must return a strudup()'ed string as
77 * the caller will free() it when done.
79 * func.icon_get - This function is called when an actual item object is
80 * created. The data parameter is the data parameter passed to
81 * elm_genlist_item_append() and related item creation functions. The obj
82 * parameter is the genlist object and the part parameter is the string name
83 * of the icon part in the edje design that is listed as one of the possible
84 * icons that can be set. This must return NULL for no object or a valid
85 * object. The object will be deleted by genlist on shutdown or when the item
88 * func.state_get - This function is called when an actual item object is
89 * created. The data parameter is the data parameter passed to
90 * elm_genlist_item_append() and related item creation functions. The obj
91 * parameter is the genlist object and the part parameter is the string name
92 * of the state part in the edje design that is listed as one of the possible
93 * states that can be set. Return 0 for false or 1 for true. Genlist will
94 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95 * true (the default is false), where XXX is the name of the part.
97 * func.del - This is called when elm_genlist_item_del() is called on an
98 * item, elm_genlist_clear() is called on the genlist, or
99 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100 * intended for use when actual genlist items are deleted, so any backing
101 * data attached to the item (e.g. its data parameter on creation) can be
104 * Items can be added by several calls. All of them return a Elm_Genlist_Item
105 * handle that is an internal member inside the genlist. They all take a data
106 * parameter that is meant to be used for a handle to the applications
107 * internal data (eg the struct with the original item data). The parent
108 * parameter is the parent genlist item this belongs to if it is a tree or
109 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112 * is displayed as an item that is able to expand and have child items.
113 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114 * displayed at the top until the next group comes. The func parameter is a
115 * convenience callback that is called when the item is selected and the data
116 * parameter will be the func_data parameter, obj be the genlist object and
117 * event_info will be the genlist item.
119 * elm_genlist_item_append() appends an item to the end of the list, or if
120 * there is a parent, to the end of all the child items of the parent.
121 * elm_genlist_item_prepend() is the same but prepends to the beginning of
122 * the list or children list. elm_genlist_item_insert_before() inserts at
123 * item before another item and elm_genlist_item_insert_after() inserts after
124 * the indicated item.
126 * The application can clear the list with elm_genlist_clear() which deletes
127 * all the items in the list and elm_genlist_item_del() will delete a specific
128 * item. elm_genlist_item_subitems_clear() will clear all items that are
129 * children of the indicated parent item.
131 * If the application wants multiple items to be able to be selected,
132 * elm_genlist_multi_select_set() can enable this. If the list is
133 * single-selection only (the default), then elm_genlist_selected_item_get()
134 * will return the selected item, if any, or NULL I none is selected. If the
135 * list is multi-select then elm_genlist_selected_items_get() will return a
136 * list (that is only valid as long as no items are modified (added, deleted,
137 * selected or unselected)).
139 * To help inspect list items you can jump to the item at the top of the list
140 * with elm_genlist_first_item_get() which will return the item pointer, and
141 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143 * and previous items respectively relative to the indicated item. Using
144 * these calls you can walk the entire item list/tree. Note that as a tree
145 * the items are flattened in the list, so elm_genlist_item_parent_get() will
146 * let you know which item is the parent (and thus know how to skip them if
149 * There are also convenience functions. elm_genlist_item_genlist_get() will
150 * return the genlist object the item belongs to. elm_genlist_item_show()
151 * will make the scroller scroll to show that specific item so its visible.
152 * elm_genlist_item_data_get() returns the data pointer set by the item
153 * creation functions.
155 * If an item changes (state of boolean changes, label or icons change),
156 * then use elm_genlist_item_update() to have genlist update the item with
157 * the new state. Genlist will re-realize the item thus call the functions
158 * in the _Elm_Genlist_Item_Class for that item.
160 * To programmatically (un)select an item use elm_genlist_item_selected_set().
161 * To get its selected state use elm_genlist_item_selected_get(). Similarly
162 * to expand/contract an item and get its expanded state, use
163 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164 * again to make an item disabled (unable to be selected and appear
165 * differently) use elm_genlist_item_disabled_set() to set this and
166 * elm_genlist_item_disabled_get() to get the disabled state.
168 * In general to indicate how the genlist should expand items horizontally to
169 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171 * mode means that if items are too wide to fit, the scroller will scroll
172 * horizontally. Otherwise items are expanded to fill the width of the
173 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174 * to the viewport width and limited to that size. This can be combined with
175 * a different style that uses edjes' ellipsis feature (cutting text off like
178 * Items will only call their selection func and callback when first becoming
179 * selected. Any further clicks will do nothing, unless you enable always
180 * select with elm_genlist_always_select_mode_set(). This means even if
181 * selected, every click will make the selected callbacks be called.
182 * elm_genlist_no_select_mode_set() will turn off the ability to select
183 * items entirely and they will neither appear selected nor call selected
184 * callback functions.
186 * Remember that you can create new styles and add your own theme augmentation
187 * per application with elm_theme_extension_add(). If you absolutely must
188 * have a specific style that overrides any theme the user or system sets up
189 * you can use elm_theme_overlay_add() to add such a file.
191 * Signals that you can add callbacks for are:
193 * "clicked,double" - This is called when a user has double-clicked an item. The
194 * event_info parameter is the genlist item that was double-clicked.
196 * "selected" - This is called when a user has made an item selected. The
197 * event_info parameter is the genlist item that was selected.
199 * "unselected" - This is called when a user has made an item unselected. The
200 * event_info parameter is the genlist item that was unselected.
202 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
203 * and the item is now meant to be expanded. The event_info parameter is the
204 * genlist item that was indicated to expand. It is the job of this callback
205 * to then fill in the child items.
207 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
208 * and the item is now meant to be contracted. The event_info parameter is
209 * the genlist item that was indicated to contract. It is the job of this
210 * callback to then delete the child items.
212 * "expand,request" - This is called when a user has indicated they want to
213 * expand a tree branch item. The callback should decide if the item can
214 * expand (has any children) and then call elm_genlist_item_expanded_set()
215 * appropriately to set the state. The event_info parameter is the genlist
216 * item that was indicated to expand.
218 * "contract,request" - This is called when a user has indicated they want to
219 * contract a tree branch item. The callback should decide if the item can
220 * contract (has any children) and then call elm_genlist_item_expanded_set()
221 * appropriately to set the state. The event_info parameter is the genlist
222 * item that was indicated to contract.
224 * "realized" - This is called when the item in the list is created as a real
225 * evas object. event_info parameter is the genlist item that was created.
226 * The object may be deleted at any time, so it is up to the caller to
227 * not use the object pointer from elm_genlist_item_object_get() in a way
228 * where it may point to freed objects.
230 * "unrealized" - This is called just before an item is unrealized. After
231 * this call icon objects provided will be deleted and the item object
232 * itself delete or be put into a floating cache.
234 * "drag,start,up" - This is called when the item in the list has been dragged
237 * "drag,start,down" - This is called when the item in the list has been dragged
238 * (not scrolled) down.
240 * "drag,start,left" - This is called when the item in the list has been dragged
241 * (not scrolled) left.
243 * "drag,start,right" - This is called when the item in the list has been dragged
244 * (not scrolled) right.
246 * "drag,stop" - This is called when the item in the list has stopped being
249 * "drag" - This is called when the item in the list is being dragged.
251 * "longpressed" - This is called when the item is pressed for a certain amount
252 * of time. By default it's 1 second.
254 * "scroll,edge,top" - This is called when the genlist is scrolled until the
257 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
260 * "scroll,edge,left" - This is called when the genlist is scrolled until the
263 * "scroll,edge,right" - This is called when the genlist is scrolled until the
266 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
269 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
272 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
274 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
277 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
280 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
283 typedef struct _Widget_Data Widget_Data;
284 typedef struct _Item_Block Item_Block;
285 typedef struct _Pan Pan;
286 typedef struct _Item_Cache Item_Cache;
290 Evas_Object *obj, *scr, *pan_smart;
291 Eina_Inlist *items, *blocks;
292 Eina_List *group_items;
294 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
295 Ecore_Job *calc_job, *update_job;
296 Ecore_Idler *queue_idler;
297 Ecore_Idler *must_recalc_idler;
298 Eina_List *queue, *selected;
299 Elm_Genlist_Item *show_item;
300 Elm_Genlist_Item *last_selected_item;
301 Eina_Inlist *item_cache;
302 Elm_Genlist_Item *anchor_item;
305 Ecore_Timer *multi_timer;
306 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
307 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
308 Eina_Bool mouse_down : 1;
309 Eina_Bool multi_down : 1;
310 Eina_Bool multi_timeout : 1;
311 Eina_Bool multitouched : 1;
312 Eina_Bool on_hold : 1;
314 Eina_Bool always_select : 1;
315 Eina_Bool longpressed : 1;
316 Eina_Bool wasselected : 1;
317 Eina_Bool no_select : 1;
318 Eina_Bool bring_in : 1;
319 Eina_Bool compress : 1;
320 Eina_Bool height_for_width : 1;
321 Eina_Bool homogeneous : 1;
322 Eina_Bool clear_me : 1;
327 } history[SWIPE_MOVES];
329 int item_cache_count;
335 int group_item_width;
336 int group_item_height;
337 int max_items_per_block;
338 double longpress_timeout;
348 Evas_Coord x, y, w, h, minw, minh;
349 Eina_Bool want_unrealize : 1;
350 Eina_Bool realized : 1;
351 Eina_Bool changed : 1;
352 Eina_Bool updateme : 1;
353 Eina_Bool showme : 1;
354 Eina_Bool must_recalc : 1;
357 struct _Elm_Genlist_Item
359 Elm_Widget_Item base;
364 Evas_Coord x, y, w, h, minw, minh;
365 const Elm_Genlist_Item_Class *itc;
366 Elm_Genlist_Item *parent;
367 Elm_Genlist_Item *group_item;
368 Elm_Genlist_Item_Flags flags;
376 Eina_List *labels, *icons, *states, *icon_objs;
377 Ecore_Timer *long_timer;
378 Ecore_Timer *swipe_timer;
380 Evas_Coord scrl_x, scrl_y;
382 Elm_Genlist_Item *rel;
387 Elm_Tooltip_Item_Content_Cb content_cb;
388 Evas_Smart_Cb del_cb;
392 const char *mouse_cursor;
399 Eina_Bool before : 1;
401 Eina_Bool want_unrealize : 1;
402 Eina_Bool want_realize : 1;
403 Eina_Bool realized : 1;
404 Eina_Bool selected : 1;
405 Eina_Bool highlighted : 1;
406 Eina_Bool expanded : 1;
407 Eina_Bool disabled : 1;
408 Eina_Bool display_only : 1;
409 Eina_Bool mincalcd : 1;
410 Eina_Bool queued : 1;
411 Eina_Bool showme : 1;
412 Eina_Bool delete_me : 1;
414 Eina_Bool dragging : 1;
415 Eina_Bool updateme : 1;
416 Eina_Bool nocache : 1;
423 Evas_Object *base_view, *spacer;
425 const char *item_style; // it->itc->item_style
426 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
427 Eina_Bool compress : 1; // it->wd->compress
428 Eina_Bool odd : 1; // in & 0x1
430 Eina_Bool selected : 1; // it->selected
431 Eina_Bool disabled : 1; // it->disabled
432 Eina_Bool expanded : 1; // it->expanded
435 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
436 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
440 Evas_Object_Smart_Clipped_Data __clipped_data;
442 Ecore_Job *resize_job;
445 static const char *widtype = NULL;
446 static void _item_cache_zero(Widget_Data *wd);
447 static void _del_hook(Evas_Object *obj);
448 static void _mirrored_set(Evas_Object *obj,
450 static void _theme_hook(Evas_Object *obj);
451 static void _show_region_hook(void *data,
453 static void _sizing_eval(Evas_Object *obj);
454 static void _item_unrealize(Elm_Genlist_Item *it);
455 static void _item_block_unrealize(Item_Block *itb);
456 static void _calc_job(void *data);
457 static void _on_focus_hook(void *data,
459 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
460 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
461 static Eina_Bool _item_single_select_up(Widget_Data *wd);
462 static Eina_Bool _item_single_select_down(Widget_Data *wd);
463 static Eina_Bool _event_hook(Evas_Object *obj,
465 Evas_Callback_Type type,
467 static Eina_Bool _deselect_all_items(Widget_Data *wd);
468 static void _pan_calculate(Evas_Object *obj);
470 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
473 _event_hook(Evas_Object *obj,
474 Evas_Object *src __UNUSED__,
475 Evas_Callback_Type type,
478 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
479 Evas_Event_Key_Down *ev = event_info;
480 Widget_Data *wd = elm_widget_data_get(obj);
481 if (!wd) return EINA_FALSE;
482 if (!wd->items) return EINA_FALSE;
483 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
484 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
486 Elm_Genlist_Item *it = NULL;
489 Evas_Coord step_x = 0;
490 Evas_Coord step_y = 0;
493 Evas_Coord page_x = 0;
494 Evas_Coord page_y = 0;
496 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
497 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
498 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
499 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
501 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
505 else if ((!strcmp(ev->keyname, "Right")) ||
506 (!strcmp(ev->keyname, "KP_Right")))
510 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
512 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
513 (_item_multi_select_up(wd)))
514 || (_item_single_select_up(wd)))
516 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
522 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
524 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
525 (_item_multi_select_down(wd)))
526 || (_item_single_select_down(wd)))
528 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
534 else if ((!strcmp(ev->keyname, "Home")) ||
535 (!strcmp(ev->keyname, "KP_Home")))
537 it = elm_genlist_first_item_get(obj);
538 elm_genlist_item_bring_in(it);
539 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
542 else if ((!strcmp(ev->keyname, "End")) ||
543 (!strcmp(ev->keyname, "KP_End")))
545 it = elm_genlist_last_item_get(obj);
546 elm_genlist_item_bring_in(it);
547 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
550 else if ((!strcmp(ev->keyname, "Prior")) ||
551 (!strcmp(ev->keyname, "KP_Prior")))
554 y -= -(page_y * v_h) / 100;
558 else if ((!strcmp(ev->keyname, "Next")) ||
559 (!strcmp(ev->keyname, "KP_Next")))
562 y += -(page_y * v_h) / 100;
566 else if(((!strcmp(ev->keyname, "Return")) ||
567 (!strcmp(ev->keyname, "KP_Enter")) ||
568 (!strcmp(ev->keyname, "space")))
569 && (!wd->multi) && (wd->selected))
571 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
572 elm_genlist_item_expanded_set(it,
573 !elm_genlist_item_expanded_get(it));
575 else if (!strcmp(ev->keyname, "Escape"))
577 if (!_deselect_all_items(wd)) return EINA_FALSE;
578 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
581 else return EINA_FALSE;
583 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
584 elm_smart_scroller_child_pos_set(wd->scr, x, y);
589 _deselect_all_items(Widget_Data *wd)
591 if (!wd->selected) return EINA_FALSE;
593 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
599 _item_multi_select_up(Widget_Data *wd)
601 if (!wd->selected) return EINA_FALSE;
602 if (!wd->multi) return EINA_FALSE;
604 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
605 if (!prev) return EINA_TRUE;
607 if (elm_genlist_item_selected_get(prev))
609 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
610 wd->last_selected_item = prev;
611 elm_genlist_item_show(wd->last_selected_item);
615 elm_genlist_item_selected_set(prev, EINA_TRUE);
616 elm_genlist_item_show(prev);
622 _item_multi_select_down(Widget_Data *wd)
624 if (!wd->selected) return EINA_FALSE;
625 if (!wd->multi) return EINA_FALSE;
627 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
628 if (!next) return EINA_TRUE;
630 if (elm_genlist_item_selected_get(next))
632 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
633 wd->last_selected_item = next;
634 elm_genlist_item_show(wd->last_selected_item);
638 elm_genlist_item_selected_set(next, EINA_TRUE);
639 elm_genlist_item_show(next);
645 _item_single_select_up(Widget_Data *wd)
647 Elm_Genlist_Item *prev;
650 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
651 while ((prev) && (prev->delete_me))
652 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
654 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
656 if (!prev) return EINA_FALSE;
658 _deselect_all_items(wd);
660 elm_genlist_item_selected_set(prev, EINA_TRUE);
661 elm_genlist_item_show(prev);
666 _item_single_select_down(Widget_Data *wd)
668 Elm_Genlist_Item *next;
671 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
672 while ((next) && (next->delete_me))
673 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
675 else next = elm_genlist_item_next_get(wd->last_selected_item);
677 if (!next) return EINA_FALSE;
679 _deselect_all_items(wd);
681 elm_genlist_item_selected_set(next, EINA_TRUE);
682 elm_genlist_item_show(next);
687 _on_focus_hook(void *data __UNUSED__,
690 Widget_Data *wd = elm_widget_data_get(obj);
692 if (elm_widget_focus_get(obj))
694 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
695 evas_object_focus_set(wd->obj, EINA_TRUE);
696 if ((wd->selected) && (!wd->last_selected_item))
697 wd->last_selected_item = eina_list_data_get(wd->selected);
701 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
702 evas_object_focus_set(wd->obj, EINA_FALSE);
707 _del_hook(Evas_Object *obj)
709 Widget_Data *wd = elm_widget_data_get(obj);
711 _item_cache_zero(wd);
712 if (wd->calc_job) ecore_job_del(wd->calc_job);
713 if (wd->update_job) ecore_job_del(wd->update_job);
714 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
715 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
720 _del_pre_hook(Evas_Object *obj)
722 Widget_Data *wd = elm_widget_data_get(obj);
724 evas_object_del(wd->pan_smart);
725 wd->pan_smart = NULL;
726 elm_genlist_clear(obj);
730 _mirrored_set(Evas_Object *obj,
733 Widget_Data *wd = elm_widget_data_get(obj);
735 _item_cache_zero(wd);
736 elm_smart_scroller_mirrored_set(wd->scr, rtl);
740 _theme_hook(Evas_Object *obj)
742 Widget_Data *wd = elm_widget_data_get(obj);
745 _item_cache_zero(wd);
746 _elm_widget_mirrored_reload(obj);
747 _mirrored_set(obj, elm_widget_mirrored_get(obj));
748 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
749 elm_widget_style_get(obj));
750 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
751 wd->item_width = wd->item_height = 0;
752 wd->group_item_width = wd->group_item_height = 0;
753 wd->minw = wd->minh = wd->realminw = 0;
754 EINA_INLIST_FOREACH(wd->blocks, itb)
757 Elm_Genlist_Item *it;
759 if (itb->realized) _item_block_unrealize(itb);
760 EINA_LIST_FOREACH(itb->items, l, it)
761 it->mincalcd = EINA_FALSE;
763 itb->changed = EINA_TRUE;
765 if (wd->calc_job) ecore_job_del(wd->calc_job);
766 wd->calc_job = ecore_job_add(_calc_job, wd);
771 _show_region_hook(void *data,
774 Widget_Data *wd = elm_widget_data_get(data);
775 Evas_Coord x, y, w, h;
777 elm_widget_show_region_get(obj, &x, &y, &w, &h);
778 //x & y are screen coordinates, Add with pan coordinates
781 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
785 _sizing_eval(Evas_Object *obj)
787 Widget_Data *wd = elm_widget_data_get(obj);
788 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
790 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
791 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
793 if (wd->height_for_width)
797 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
798 if ((vw != 0) && (vw != wd->prev_viewport_w))
802 wd->prev_viewport_w = vw;
803 EINA_INLIST_FOREACH(wd->blocks, itb)
805 itb->must_recalc = EINA_TRUE;
807 if (wd->calc_job) ecore_job_del(wd->calc_job);
808 wd->calc_job = ecore_job_add(_calc_job, wd);
811 if (wd->mode == ELM_LIST_LIMIT)
813 Evas_Coord vmw, vmh, vw, vh;
817 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
818 if ((minw > 0) && (vw < minw)) vw = minw;
819 else if ((maxw > 0) && (vw > maxw))
821 edje_object_size_min_calc
822 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
829 edje_object_size_min_calc
830 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
834 evas_object_size_hint_min_set(obj, minw, minh);
835 evas_object_size_hint_max_set(obj, maxw, maxh);
839 _item_highlight(Elm_Genlist_Item *it)
841 const char *selectraise;
842 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
843 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
844 selectraise = edje_object_data_get(it->base.view, "selectraise");
845 if ((selectraise) && (!strcmp(selectraise, "on")))
847 evas_object_raise(it->base.view);
848 if ((it->group_item) && (it->group_item->realized))
849 evas_object_raise(it->group_item->base.view);
851 it->highlighted = EINA_TRUE;
855 _item_block_del(Elm_Genlist_Item *it)
858 Item_Block *itb = it->block;
860 itb->items = eina_list_remove(itb->items, it);
862 itb->changed = EINA_TRUE;
863 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
864 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
867 il = EINA_INLIST_GET(itb);
868 Item_Block *itbn = (Item_Block *)(il->next);
870 it->parent->items = eina_list_remove(it->parent->items, it);
872 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
874 if (itbn) itbn->changed = EINA_TRUE;
880 il = EINA_INLIST_GET(itb);
881 Item_Block *itbp = (Item_Block *)(il->prev);
882 Item_Block *itbn = (Item_Block *)(il->next);
883 if ((itbp) && ((itbp->count + itb->count) < 48))
885 Elm_Genlist_Item *it2;
887 EINA_LIST_FREE(itb->items, it2)
890 itbp->items = eina_list_append(itbp->items, it2);
892 itbp->changed = EINA_TRUE;
894 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
895 EINA_INLIST_GET(itb));
898 else if ((itbn) && ((itbn->count + itb->count) < 48))
902 Eina_List *last = eina_list_last(itb->items);
903 Elm_Genlist_Item *it2 = last->data;
906 itb->items = eina_list_remove_list(itb->items, last);
907 itbn->items = eina_list_prepend(itbn->items, it2);
909 itbn->changed = EINA_TRUE;
912 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
920 _item_del(Elm_Genlist_Item *it)
922 elm_widget_item_pre_notify_del(it);
923 elm_genlist_item_subitems_clear(it);
924 it->wd->walking -= it->walking;
925 if (it->wd->show_item == it) it->wd->show_item = NULL;
926 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
927 if (it->realized) _item_unrealize(it);
928 if (it->block) _item_block_del(it);
929 if ((!it->delete_me) && (it->itc->func.del))
930 it->itc->func.del((void *)it->base.data, it->base.widget);
931 it->delete_me = EINA_TRUE;
933 it->wd->queue = eina_list_remove(it->wd->queue, it);
934 if (it->wd->anchor_item == it)
936 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
937 if (!it->wd->anchor_item)
938 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
940 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
942 it->parent->items = eina_list_remove(it->parent->items, it);
943 if (it->flags & ELM_GENLIST_ITEM_GROUP)
944 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
945 if (it->long_timer) ecore_timer_del(it->long_timer);
946 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
948 if (it->tooltip.del_cb)
949 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
951 elm_widget_item_del(it);
955 _item_select(Elm_Genlist_Item *it)
957 if ((it->wd->no_select) || (it->delete_me)) return;
960 if (it->wd->always_select) goto call;
963 it->selected = EINA_TRUE;
964 it->wd->selected = eina_list_append(it->wd->selected, it);
968 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
970 evas_object_smart_callback_call(it->base.widget, "selected", it);
973 if ((it->wd->clear_me) && (!it->wd->walking))
974 elm_genlist_clear(it->base.widget);
977 if ((!it->walking) && (it->delete_me))
979 if (!it->relcount) _item_del(it);
982 it->wd->last_selected_item = it;
986 _item_unselect(Elm_Genlist_Item *it)
988 const char *stacking, *selectraise;
990 if ((it->delete_me) || (!it->highlighted)) return;
991 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
992 stacking = edje_object_data_get(it->base.view, "stacking");
993 selectraise = edje_object_data_get(it->base.view, "selectraise");
994 if ((selectraise) && (!strcmp(selectraise, "on")))
996 if ((stacking) && (!strcmp(stacking, "below")))
997 evas_object_lower(it->base.view);
999 it->highlighted = EINA_FALSE;
1002 it->selected = EINA_FALSE;
1003 it->wd->selected = eina_list_remove(it->wd->selected, it);
1004 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1009 _mouse_move(void *data,
1010 Evas *evas __UNUSED__,
1014 Elm_Genlist_Item *it = data;
1015 Evas_Event_Mouse_Move *ev = event_info;
1016 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1018 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1020 if (!it->wd->on_hold)
1022 it->wd->on_hold = EINA_TRUE;
1023 if (!it->wd->wasselected)
1027 if (it->wd->multitouched)
1029 it->wd->cur_x = ev->cur.canvas.x;
1030 it->wd->cur_y = ev->cur.canvas.y;
1033 if ((it->dragging) && (it->down))
1035 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1038 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1039 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1040 if (abs((it->wd->history[it->wd->movements].x -
1041 it->wd->history[0].x)) > 40)
1042 it->wd->swipe = EINA_TRUE;
1044 it->wd->movements++;
1048 ecore_timer_del(it->long_timer);
1049 it->long_timer = NULL;
1051 evas_object_smart_callback_call(it->base.widget, "drag", it);
1054 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1058 ecore_timer_del(it->long_timer);
1059 it->long_timer = NULL;
1063 if (!it->display_only)
1064 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1065 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1066 x = ev->cur.canvas.x - x;
1067 y = ev->cur.canvas.y - y;
1070 if (adx < 0) adx = -dx;
1073 if (ady < 0) ady = -dy;
1076 if ((adx > minw) || (ady > minh))
1078 it->dragging = EINA_TRUE;
1081 ecore_timer_del(it->long_timer);
1082 it->long_timer = NULL;
1084 if (!it->wd->wasselected)
1089 evas_object_smart_callback_call(it->base.widget,
1090 "drag,start,up", it);
1094 evas_object_smart_callback_call(it->base.widget,
1095 "drag,start,left", it);
1097 evas_object_smart_callback_call(it->base.widget,
1098 "drag,start,right", it);
1104 evas_object_smart_callback_call(it->base.widget,
1105 "drag,start,down", it);
1109 evas_object_smart_callback_call(it->base.widget,
1110 "drag,start,left", it);
1112 evas_object_smart_callback_call(it->base.widget,
1113 "drag,start,right", it);
1120 _long_press(void *data)
1122 Elm_Genlist_Item *it = data;
1124 it->long_timer = NULL;
1125 if ((it->disabled) || (it->dragging) || (it->display_only))
1126 return ECORE_CALLBACK_CANCEL;
1127 it->wd->longpressed = EINA_TRUE;
1128 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1129 return ECORE_CALLBACK_CANCEL;
1133 _swipe(Elm_Genlist_Item *it)
1138 if ((it->display_only) || (it->disabled)) return;
1139 it->wd->swipe = EINA_FALSE;
1140 for (i = 0; i < it->wd->movements; i++)
1142 sum += it->wd->history[i].x;
1143 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1146 sum /= it->wd->movements;
1147 if (abs(sum - it->wd->history[0].x) <= 10) return;
1148 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1152 _swipe_cancel(void *data)
1154 Elm_Genlist_Item *it = data;
1156 if (!it) return ECORE_CALLBACK_CANCEL;
1157 it->wd->swipe = EINA_FALSE;
1158 it->wd->movements = 0;
1159 return ECORE_CALLBACK_RENEW;
1163 _multi_cancel(void *data)
1165 Widget_Data *wd = data;
1167 if (!wd) return ECORE_CALLBACK_CANCEL;
1168 wd->multi_timeout = EINA_TRUE;
1169 return ECORE_CALLBACK_RENEW;
1173 _multi_touch_gesture_eval(void *data)
1175 Elm_Genlist_Item *it = data;
1177 it->wd->multitouched = EINA_FALSE;
1178 if (it->wd->multi_timer)
1180 ecore_timer_del(it->wd->multi_timer);
1181 it->wd->multi_timer = NULL;
1183 if (it->wd->multi_timeout)
1185 it->wd->multi_timeout = EINA_FALSE;
1189 Evas_Coord minw = 0, minh = 0;
1190 Evas_Coord off_x, off_y, off_mx, off_my;
1192 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1193 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1194 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1195 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1196 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1198 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1200 if ((off_x + off_mx) > (off_y + off_my))
1202 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1203 evas_object_smart_callback_call(it->base.widget,
1204 "multi,swipe,right", it);
1205 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1206 evas_object_smart_callback_call(it->base.widget,
1207 "multi,swipe,left", it);
1208 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1209 evas_object_smart_callback_call(it->base.widget,
1210 "multi,pinch,out", it);
1212 evas_object_smart_callback_call(it->base.widget,
1213 "multi,pinch,in", it);
1217 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1218 evas_object_smart_callback_call(it->base.widget,
1219 "multi,swipe,down", it);
1220 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1221 evas_object_smart_callback_call(it->base.widget,
1222 "multi,swipe,up", it);
1223 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1224 evas_object_smart_callback_call(it->base.widget,
1225 "multi,pinch,out", it);
1227 evas_object_smart_callback_call(it->base.widget,
1228 "multi,pinch,in", it);
1231 it->wd->multi_timeout = EINA_FALSE;
1235 _multi_down(void *data,
1236 Evas *evas __UNUSED__,
1237 Evas_Object *obj __UNUSED__,
1240 Elm_Genlist_Item *it = data;
1241 Evas_Event_Multi_Down *ev = event_info;
1243 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1244 it->wd->multi_device = ev->device;
1245 it->wd->multi_down = EINA_TRUE;
1246 it->wd->multitouched = EINA_TRUE;
1247 it->wd->prev_mx = ev->canvas.x;
1248 it->wd->prev_my = ev->canvas.y;
1249 if (!it->wd->wasselected) _item_unselect(it);
1250 it->wd->wasselected = EINA_FALSE;
1251 it->wd->longpressed = EINA_FALSE;
1254 ecore_timer_del(it->long_timer);
1255 it->long_timer = NULL;
1259 it->dragging = EINA_FALSE;
1260 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1262 if (it->swipe_timer)
1264 ecore_timer_del(it->swipe_timer);
1265 it->swipe_timer = NULL;
1267 if (it->wd->on_hold)
1269 it->wd->swipe = EINA_FALSE;
1270 it->wd->movements = 0;
1271 it->wd->on_hold = EINA_FALSE;
1276 _multi_up(void *data,
1277 Evas *evas __UNUSED__,
1278 Evas_Object *obj __UNUSED__,
1281 Elm_Genlist_Item *it = data;
1282 Evas_Event_Multi_Up *ev = event_info;
1284 if (it->wd->multi_device != ev->device) return;
1285 it->wd->multi_device = 0;
1286 it->wd->multi_down = EINA_FALSE;
1287 if (it->wd->mouse_down) return;
1288 _multi_touch_gesture_eval(data);
1292 _multi_move(void *data,
1293 Evas *evas __UNUSED__,
1294 Evas_Object *obj __UNUSED__,
1297 Elm_Genlist_Item *it = data;
1298 Evas_Event_Multi_Move *ev = event_info;
1300 if (it->wd->multi_device != ev->device) return;
1301 it->wd->cur_mx = ev->cur.canvas.x;
1302 it->wd->cur_my = ev->cur.canvas.y;
1306 _mouse_down(void *data,
1307 Evas *evas __UNUSED__,
1311 Elm_Genlist_Item *it = data;
1312 Evas_Event_Mouse_Down *ev = event_info;
1315 if (ev->button != 1) return;
1316 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1318 it->wd->on_hold = EINA_TRUE;
1321 it->down = EINA_TRUE;
1322 it->dragging = EINA_FALSE;
1323 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1324 it->dx = ev->canvas.x - x;
1325 it->dy = ev->canvas.y - y;
1326 it->wd->mouse_down = EINA_TRUE;
1327 if (!it->wd->multitouched)
1329 it->wd->prev_x = ev->canvas.x;
1330 it->wd->prev_y = ev->canvas.y;
1331 it->wd->multi_timeout = EINA_FALSE;
1332 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1333 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1335 it->wd->longpressed = EINA_FALSE;
1336 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1337 else it->wd->on_hold = EINA_FALSE;
1338 if (it->wd->on_hold) return;
1339 it->wd->wasselected = it->selected;
1340 _item_highlight(it);
1341 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1342 if ((!it->disabled) && (!it->display_only))
1344 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1345 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1347 if (it->long_timer) ecore_timer_del(it->long_timer);
1348 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1349 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1351 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1354 it->long_timer = NULL;
1355 it->wd->swipe = EINA_FALSE;
1356 it->wd->movements = 0;
1360 _mouse_up(void *data,
1361 Evas *evas __UNUSED__,
1362 Evas_Object *obj __UNUSED__,
1365 Elm_Genlist_Item *it = data;
1366 Evas_Event_Mouse_Up *ev = event_info;
1367 Eina_Bool dragged = EINA_FALSE;
1369 if (ev->button != 1) return;
1370 it->down = EINA_FALSE;
1371 it->wd->mouse_down = EINA_FALSE;
1372 if (it->wd->multitouched)
1374 if (it->wd->multi_down) return;
1375 _multi_touch_gesture_eval(data);
1378 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1379 else it->wd->on_hold = EINA_FALSE;
1382 ecore_timer_del(it->long_timer);
1383 it->long_timer = NULL;
1387 it->dragging = EINA_FALSE;
1388 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1391 if (it->swipe_timer)
1393 ecore_timer_del(it->swipe_timer);
1394 it->swipe_timer = NULL;
1396 if (it->wd->multi_timer)
1398 ecore_timer_del(it->wd->multi_timer);
1399 it->wd->multi_timer = NULL;
1400 it->wd->multi_timeout = EINA_FALSE;
1402 if (it->wd->on_hold)
1404 if (it->wd->swipe) _swipe(data);
1405 it->wd->longpressed = EINA_FALSE;
1406 it->wd->on_hold = EINA_FALSE;
1409 if (it->wd->longpressed)
1411 it->wd->longpressed = EINA_FALSE;
1412 if (!it->wd->wasselected)
1414 it->wd->wasselected = EINA_FALSE;
1419 if (it->want_unrealize)
1421 _item_unrealize(it);
1422 if (it->block->want_unrealize)
1423 _item_block_unrealize(it->block);
1426 if ((it->disabled) || (dragged) || (it->display_only)) return;
1427 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1432 _item_highlight(it);
1435 else _item_unselect(it);
1441 Widget_Data *wd = it->wd;
1444 while (wd->selected) _item_unselect(wd->selected->data);
1449 const Eina_List *l, *l_next;
1450 Elm_Genlist_Item *it2;
1452 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1453 if (it2 != it) _item_unselect(it2);
1454 //_item_highlight(it);
1457 _item_highlight(it);
1463 _signal_expand_toggle(void *data,
1464 Evas_Object *obj __UNUSED__,
1465 const char *emission __UNUSED__,
1466 const char *source __UNUSED__)
1468 Elm_Genlist_Item *it = data;
1471 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1473 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1477 _signal_expand(void *data,
1478 Evas_Object *obj __UNUSED__,
1479 const char *emission __UNUSED__,
1480 const char *source __UNUSED__)
1482 Elm_Genlist_Item *it = data;
1485 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1489 _signal_contract(void *data,
1490 Evas_Object *obj __UNUSED__,
1491 const char *emission __UNUSED__,
1492 const char *source __UNUSED__)
1494 Elm_Genlist_Item *it = data;
1497 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1501 _item_cache_clean(Widget_Data *wd)
1503 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1507 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1508 wd->item_cache = eina_inlist_remove(wd->item_cache,
1509 wd->item_cache->last);
1510 wd->item_cache_count--;
1511 if (itc->spacer) evas_object_del(itc->spacer);
1512 if (itc->base_view) evas_object_del(itc->base_view);
1513 if (itc->item_style) eina_stringshare_del(itc->item_style);
1519 _item_cache_zero(Widget_Data *wd)
1521 int pmax = wd->item_cache_max;
1522 wd->item_cache_max = 0;
1523 _item_cache_clean(wd);
1524 wd->item_cache_max = pmax;
1528 _item_cache_add(Elm_Genlist_Item *it)
1532 if (it->wd->item_cache_max <= 0)
1534 evas_object_del(it->base.view);
1535 it->base.view = NULL;
1536 evas_object_del(it->spacer);
1541 it->wd->item_cache_count++;
1542 itc = calloc(1, sizeof(Item_Cache));
1543 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1544 EINA_INLIST_GET(itc));
1545 itc->spacer = it->spacer;
1547 itc->base_view = it->base.view;
1548 it->base.view = NULL;
1549 evas_object_hide(itc->base_view);
1550 evas_object_move(itc->base_view, -9999, -9999);
1551 itc->item_style = eina_stringshare_add(it->itc->item_style);
1552 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1553 itc->compress = (it->wd->compress);
1554 itc->odd = (it->order_num_in & 0x1);
1555 itc->selected = it->selected;
1556 itc->disabled = it->disabled;
1557 itc->expanded = it->expanded;
1560 ecore_timer_del(it->long_timer);
1561 it->long_timer = NULL;
1563 if (it->swipe_timer)
1565 ecore_timer_del(it->swipe_timer);
1566 it->swipe_timer = NULL;
1568 // FIXME: other callbacks?
1569 edje_object_signal_callback_del_full(itc->base_view,
1570 "elm,action,expand,toggle",
1571 "elm", _signal_expand_toggle, it);
1572 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1574 _signal_expand, it);
1575 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1576 "elm", _signal_contract, it);
1577 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1579 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1581 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1583 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1585 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1587 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1589 _item_cache_clean(it->wd);
1593 _item_cache_find(Elm_Genlist_Item *it)
1596 Eina_Bool tree = 0, odd;
1598 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1599 odd = (it->order_num_in & 0x1);
1600 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1602 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1604 if ((itc->tree == tree) &&
1605 (itc->odd == odd) &&
1606 (itc->compress == it->wd->compress) &&
1607 (!strcmp(it->itc->item_style, itc->item_style)))
1609 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1610 EINA_INLIST_GET(itc));
1611 it->wd->item_cache_count--;
1619 _item_cache_free(Item_Cache *itc)
1621 if (itc->spacer) evas_object_del(itc->spacer);
1622 if (itc->base_view) evas_object_del(itc->base_view);
1623 if (itc->item_style) eina_stringshare_del(itc->item_style);
1628 _item_realize(Elm_Genlist_Item *it,
1632 Elm_Genlist_Item *it2;
1633 const char *stacking;
1634 const char *treesize;
1636 int depth, tsize = 20;
1637 Item_Cache *itc = NULL;
1639 if ((it->realized) || (it->delete_me)) return;
1640 it->order_num_in = in;
1643 it->nocache = EINA_FALSE;
1645 itc = _item_cache_find(it);
1648 it->base.view = itc->base_view;
1649 itc->base_view = NULL;
1650 it->spacer = itc->spacer;
1655 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1656 edje_object_scale_set(it->base.view,
1657 elm_widget_scale_get(it->base.widget) *
1658 _elm_config->scale);
1659 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1660 elm_widget_sub_object_add(it->base.widget, it->base.view);
1662 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1663 strncpy(buf, "tree", sizeof(buf));
1664 else strncpy(buf, "item", sizeof(buf));
1665 if (it->wd->compress)
1666 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1668 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1669 strncat(buf, "/", sizeof(buf) - strlen(buf));
1670 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1672 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1673 elm_widget_style_get(it->base.widget));
1674 edje_object_mirrored_set(it->base.view,
1675 elm_widget_mirrored_get(it->base.widget));
1677 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1678 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1679 elm_widget_sub_object_add(it->base.widget, it->spacer);
1681 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1683 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1685 it->expanded_depth = depth;
1686 treesize = edje_object_data_get(it->base.view, "treesize");
1687 if (treesize) tsize = atoi(treesize);
1688 evas_object_size_hint_min_set(it->spacer,
1689 (depth * tsize) * _elm_config->scale, 1);
1690 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1693 edje_object_signal_callback_add(it->base.view,
1694 "elm,action,expand,toggle",
1695 "elm", _signal_expand_toggle, it);
1696 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1697 "elm", _signal_expand, it);
1698 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1699 "elm", _signal_contract, it);
1700 stacking = edje_object_data_get(it->base.view, "stacking");
1703 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1704 else if (!strcmp(stacking, "above"))
1705 evas_object_raise(it->base.view);
1707 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1709 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1711 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1713 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1715 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1717 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1721 if (it->selected != itc->selected)
1724 edje_object_signal_emit(it->base.view,
1725 "elm,state,selected", "elm");
1727 if (it->disabled != itc->disabled)
1730 edje_object_signal_emit(it->base.view,
1731 "elm,state,disabled", "elm");
1733 if (it->expanded != itc->expanded)
1736 edje_object_signal_emit(it->base.view,
1737 "elm,state,expanded", "elm");
1743 edje_object_signal_emit(it->base.view,
1744 "elm,state,selected", "elm");
1746 edje_object_signal_emit(it->base.view,
1747 "elm,state,disabled", "elm");
1749 edje_object_signal_emit(it->base.view,
1750 "elm,state,expanded", "elm");
1754 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1756 /* homogenous genlist shortcut */
1759 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1761 it->w = it->minw = it->wd->group_item_width;
1762 it->h = it->minh = it->wd->group_item_height;
1766 it->w = it->minw = it->wd->item_width;
1767 it->h = it->minh = it->wd->item_height;
1769 it->mincalcd = EINA_TRUE;
1774 if (it->itc->func.label_get)
1780 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1782 EINA_LIST_FOREACH(it->labels, l, key)
1784 char *s = it->itc->func.label_get
1785 ((void *)it->base.data, it->base.widget, l->data);
1789 edje_object_part_text_set(it->base.view, l->data, s);
1793 edje_object_part_text_set(it->base.view, l->data, "");
1796 if (it->itc->func.icon_get)
1802 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1804 EINA_LIST_FOREACH(it->icons, l, key)
1806 Evas_Object *ic = it->itc->func.icon_get
1807 ((void *)it->base.data, it->base.widget, l->data);
1811 it->icon_objs = eina_list_append(it->icon_objs, ic);
1812 edje_object_part_swallow(it->base.view, key, ic);
1813 evas_object_show(ic);
1814 elm_widget_sub_object_add(it->base.widget, ic);
1818 if (it->itc->func.state_get)
1824 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1826 EINA_LIST_FOREACH(it->states, l, key)
1828 Eina_Bool on = it->itc->func.state_get
1829 ((void *)it->base.data, it->base.widget, l->data);
1833 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1834 edje_object_signal_emit(it->base.view, buf, "elm");
1838 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1839 edje_object_signal_emit(it->base.view, buf, "elm");
1845 Evas_Coord mw = -1, mh = -1;
1847 if (it->wd->height_for_width) mw = it->wd->w;
1849 if (!it->display_only)
1850 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1851 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1852 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1854 if (!it->display_only)
1855 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1856 it->w = it->minw = mw;
1857 it->h = it->minh = mh;
1858 it->mincalcd = EINA_TRUE;
1860 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1862 it->wd->group_item_width = mw;
1863 it->wd->group_item_height = mh;
1865 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1867 it->wd->item_width = mw;
1868 it->wd->item_height = mh;
1871 if (!calc) evas_object_show(it->base.view);
1874 if (it->tooltip.content_cb)
1876 elm_widget_item_tooltip_content_cb_set(it,
1877 it->tooltip.content_cb,
1878 it->tooltip.data, NULL);
1879 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1882 if (it->mouse_cursor)
1883 elm_widget_item_cursor_set(it, it->mouse_cursor);
1885 it->realized = EINA_TRUE;
1886 it->want_unrealize = EINA_FALSE;
1888 if (itc) _item_cache_free(itc);
1889 evas_object_smart_callback_call(it->base.widget, "realized", it);
1893 _item_unrealize(Elm_Genlist_Item *it)
1897 if (!it->realized) return;
1898 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1901 ecore_timer_del(it->long_timer);
1902 it->long_timer = NULL;
1906 evas_object_del(it->base.view);
1907 it->base.view = NULL;
1908 evas_object_del(it->spacer);
1913 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1914 _item_cache_add(it);
1916 elm_widget_stringlist_free(it->labels);
1918 elm_widget_stringlist_free(it->icons);
1920 elm_widget_stringlist_free(it->states);
1922 EINA_LIST_FREE(it->icon_objs, icon)
1923 evas_object_del(icon);
1926 it->realized = EINA_FALSE;
1927 it->want_unrealize = EINA_FALSE;
1931 _item_block_recalc(Item_Block *itb,
1937 Elm_Genlist_Item *it;
1938 Evas_Coord minw = 0, minh = 0;
1939 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1943 EINA_LIST_FOREACH(itb->items, l, it)
1945 if (it->delete_me) continue;
1946 showme |= it->showme;
1951 if (!it->mincalcd) changed = EINA_TRUE;
1954 _item_realize(it, in, EINA_TRUE);
1955 _item_unrealize(it);
1960 _item_realize(it, in, EINA_TRUE);
1961 _item_unrealize(it);
1965 _item_realize(it, in, EINA_FALSE);
1967 if (minw < it->minw) minw = it->minw;
1975 itb->changed = EINA_FALSE;
1976 /* force an evas norender to garbage collect deleted objects */
1977 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1982 _item_block_realize(Item_Block *itb,
1987 Elm_Genlist_Item *it;
1989 if (itb->realized) return;
1990 EINA_LIST_FOREACH(itb->items, l, it)
1992 if (it->delete_me) continue;
1993 if (full) _item_realize(it, in, EINA_FALSE);
1996 itb->realized = EINA_TRUE;
1997 itb->want_unrealize = EINA_FALSE;
2001 _item_block_unrealize(Item_Block *itb)
2004 Elm_Genlist_Item *it;
2005 Eina_Bool dragging = EINA_FALSE;
2007 if (!itb->realized) return;
2008 EINA_LIST_FOREACH(itb->items, l, it)
2010 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2014 dragging = EINA_TRUE;
2015 it->want_unrealize = EINA_TRUE;
2018 _item_unrealize(it);
2023 itb->realized = EINA_FALSE;
2024 itb->want_unrealize = EINA_TRUE;
2027 itb->want_unrealize = EINA_FALSE;
2031 _item_block_position(Item_Block *itb,
2035 Elm_Genlist_Item *it;
2036 Elm_Genlist_Item *git;
2037 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2040 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2041 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2043 EINA_LIST_FOREACH(itb->items, l, it)
2045 if (it->delete_me) continue;
2049 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2050 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2052 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2053 cvx, cvy, cvw, cvh));
2054 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2056 if ((itb->realized) && (!it->realized))
2058 if (vis) _item_realize(it, in, EINA_FALSE);
2064 git = it->group_item;
2067 if (git->scrl_y < oy)
2069 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2070 git->scrl_y = (it->scrl_y + it->h) - git->h;
2071 git->want_realize = EINA_TRUE;
2073 evas_object_resize(it->base.view, it->w, it->h);
2074 evas_object_move(it->base.view,
2075 it->scrl_x, it->scrl_y);
2076 evas_object_show(it->base.view);
2080 if (!it->dragging) _item_unrealize(it);
2087 if (vis) it->want_realize = EINA_TRUE;
2094 _group_items_recalc(void *data)
2096 Widget_Data *wd = data;
2098 Elm_Genlist_Item *git;
2100 EINA_LIST_FOREACH(wd->group_items, l, git)
2102 if (git->want_realize)
2105 _item_realize(git, 0, EINA_FALSE);
2106 evas_object_resize(git->base.view, wd->minw, git->h);
2107 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2108 evas_object_show(git->base.view);
2109 evas_object_raise(git->base.view);
2111 else if (!git->want_realize && git->realized)
2114 _item_unrealize(git);
2120 _must_recalc_idler(void *data)
2122 Widget_Data *wd = data;
2123 if (wd->calc_job) ecore_job_del(wd->calc_job);
2124 wd->calc_job = ecore_job_add(_calc_job, wd);
2125 wd->must_recalc_idler = NULL;
2126 return ECORE_CALLBACK_CANCEL;
2130 _calc_job(void *data)
2132 Widget_Data *wd = data;
2134 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2135 Item_Block *chb = NULL;
2136 int in = 0, minw_change = 0;
2137 Eina_Bool changed = EINA_FALSE;
2139 Eina_Bool did_must_recalc = EINA_FALSE;
2142 t0 = ecore_time_get();
2143 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2147 // if (wd->height_for_width) changed = EINA_TRUE;
2150 EINA_INLIST_FOREACH(wd->blocks, itb)
2152 Eina_Bool showme = EINA_FALSE;
2155 showme = itb->showme;
2156 itb->showme = EINA_FALSE;
2159 if (itb->realized) _item_block_unrealize(itb);
2161 if ((itb->changed) || (changed) ||
2162 ((itb->must_recalc) && (!did_must_recalc)))
2164 if ((changed) || (itb->must_recalc))
2167 Elm_Genlist_Item *it;
2168 EINA_LIST_FOREACH(itb->items, l, it)
2169 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2170 itb->changed = EINA_TRUE;
2171 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2172 itb->must_recalc = EINA_FALSE;
2174 if (itb->realized) _item_block_unrealize(itb);
2175 showme = _item_block_recalc(itb, in, 0, 1);
2181 if (minw == -1) minw = itb->minw;
2182 else if ((!itb->must_recalc) && (minw < itb->minw))
2191 if ((showme) && (wd->show_item))
2193 wd->show_item->showme = EINA_FALSE;
2195 elm_smart_scroller_region_bring_in(wd->scr,
2197 wd->show_item->block->x,
2199 wd->show_item->block->y,
2200 wd->show_item->block->w,
2203 elm_smart_scroller_child_region_show(wd->scr,
2205 wd->show_item->block->x,
2207 wd->show_item->block->y,
2208 wd->show_item->block->w,
2210 wd->show_item = NULL;
2215 EINA_INLIST_FOREACH(wd->blocks, itb)
2221 if ((chb) && (EINA_INLIST_GET(chb)->next))
2223 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2225 if (itb->realized) _item_block_unrealize(itb);
2228 wd->realminw = minw;
2229 if (minw < wd->w) minw = wd->w;
2230 if ((minw != wd->minw) || (minh != wd->minh))
2234 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2235 _sizing_eval(wd->obj);
2236 if ((wd->anchor_item) && (wd->anchor_item->block))
2238 Elm_Genlist_Item *it;
2241 it = wd->anchor_item;
2242 it_y = wd->anchor_y;
2243 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2244 it->block->y + it->y + it_y);
2245 wd->anchor_item = it;
2246 wd->anchor_y = it_y;
2249 t = ecore_time_get();
2250 if (did_must_recalc)
2252 if (!wd->must_recalc_idler)
2253 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2255 wd->calc_job = NULL;
2256 evas_object_smart_changed(wd->pan_smart);
2260 _update_job(void *data)
2262 Widget_Data *wd = data;
2265 int num, num0, position = 0, recalc = 0;
2267 wd->update_job = NULL;
2269 EINA_INLIST_FOREACH(wd->blocks, itb)
2271 Evas_Coord itminw, itminh;
2272 Elm_Genlist_Item *it;
2278 _item_block_position(itb, num);
2283 EINA_LIST_FOREACH(itb->items, l2, it)
2290 it->updateme = EINA_FALSE;
2293 _item_unrealize(it);
2294 _item_realize(it, num, EINA_FALSE);
2299 _item_realize(it, num, EINA_TRUE);
2300 _item_unrealize(it);
2302 if ((it->minw != itminw) || (it->minh != itminh))
2307 itb->updateme = EINA_FALSE;
2311 itb->changed = EINA_TRUE;
2312 _item_block_recalc(itb, num0, 0, 1);
2313 _item_block_position(itb, num0);
2318 if (wd->calc_job) ecore_job_del(wd->calc_job);
2319 wd->calc_job = ecore_job_add(_calc_job, wd);
2324 _pan_set(Evas_Object *obj,
2328 Pan *sd = evas_object_smart_data_get(obj);
2331 // Evas_Coord ow, oh;
2332 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2333 // ow = sd->wd->minw - ow;
2334 // if (ow < 0) ow = 0;
2335 // oh = sd->wd->minh - oh;
2336 // if (oh < 0) oh = 0;
2337 // if (x < 0) x = 0;
2338 // if (y < 0) y = 0;
2339 // if (x > ow) x = ow;
2340 // if (y > oh) y = oh;
2341 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2345 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2347 if ((itb->y + itb->h) > y)
2349 Elm_Genlist_Item *it;
2352 EINA_LIST_FOREACH(itb->items, l2, it)
2354 if ((itb->y + it->y) >= y)
2356 sd->wd->anchor_item = it;
2357 sd->wd->anchor_y = -(itb->y + it->y - y);
2364 evas_object_smart_changed(obj);
2368 _pan_get(Evas_Object *obj,
2372 Pan *sd = evas_object_smart_data_get(obj);
2374 if (x) *x = sd->wd->pan_x;
2375 if (y) *y = sd->wd->pan_y;
2379 _pan_max_get(Evas_Object *obj,
2383 Pan *sd = evas_object_smart_data_get(obj);
2386 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2387 ow = sd->wd->minw - ow;
2389 oh = sd->wd->minh - oh;
2396 _pan_min_get(Evas_Object *obj __UNUSED__,
2405 _pan_child_size_get(Evas_Object *obj,
2409 Pan *sd = evas_object_smart_data_get(obj);
2411 if (w) *w = sd->wd->minw;
2412 if (h) *h = sd->wd->minh;
2416 _pan_add(Evas_Object *obj)
2419 Evas_Object_Smart_Clipped_Data *cd;
2422 cd = evas_object_smart_data_get(obj);
2425 sd->__clipped_data = *cd;
2427 evas_object_smart_data_set(obj, sd);
2431 _pan_del(Evas_Object *obj)
2433 Pan *sd = evas_object_smart_data_get(obj);
2438 ecore_job_del(sd->resize_job);
2439 sd->resize_job = NULL;
2445 _pan_resize_job(void *data)
2448 _sizing_eval(sd->wd->obj);
2449 sd->resize_job = NULL;
2453 _pan_resize(Evas_Object *obj,
2457 Pan *sd = evas_object_smart_data_get(obj);
2460 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2461 if ((ow == w) && (oh == h)) return;
2462 if ((sd->wd->height_for_width) && (ow != w))
2464 if (sd->resize_job) ecore_job_del(sd->resize_job);
2465 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2467 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2468 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2472 _pan_calculate(Evas_Object *obj)
2474 Pan *sd = evas_object_smart_data_get(obj);
2476 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2478 Elm_Genlist_Item *git;
2481 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2482 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2483 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2485 git->want_realize = EINA_FALSE;
2487 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2489 itb->w = sd->wd->minw;
2490 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2491 itb->y - sd->wd->pan_y + oy,
2493 cvx, cvy, cvw, cvh))
2495 if ((!itb->realized) || (itb->changed))
2496 _item_block_realize(itb, in, 0);
2497 _item_block_position(itb, in);
2501 if (itb->realized) _item_block_unrealize(itb);
2505 _group_items_recalc(sd->wd);
2509 _pan_move(Evas_Object *obj,
2510 Evas_Coord x __UNUSED__,
2511 Evas_Coord y __UNUSED__)
2513 Pan *sd = evas_object_smart_data_get(obj);
2515 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2516 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2520 _hold_on(void *data __UNUSED__,
2522 void *event_info __UNUSED__)
2524 Widget_Data *wd = elm_widget_data_get(obj);
2526 elm_smart_scroller_hold_set(wd->scr, 1);
2530 _hold_off(void *data __UNUSED__,
2532 void *event_info __UNUSED__)
2534 Widget_Data *wd = elm_widget_data_get(obj);
2536 elm_smart_scroller_hold_set(wd->scr, 0);
2540 _freeze_on(void *data __UNUSED__,
2542 void *event_info __UNUSED__)
2544 Widget_Data *wd = elm_widget_data_get(obj);
2546 elm_smart_scroller_freeze_set(wd->scr, 1);
2550 _freeze_off(void *data __UNUSED__,
2552 void *event_info __UNUSED__)
2554 Widget_Data *wd = elm_widget_data_get(obj);
2556 elm_smart_scroller_freeze_set(wd->scr, 0);
2560 _scroll_edge_left(void *data,
2561 Evas_Object *scr __UNUSED__,
2562 void *event_info __UNUSED__)
2564 Evas_Object *obj = data;
2565 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2569 _scroll_edge_right(void *data,
2570 Evas_Object *scr __UNUSED__,
2571 void *event_info __UNUSED__)
2573 Evas_Object *obj = data;
2574 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2578 _scroll_edge_top(void *data,
2579 Evas_Object *scr __UNUSED__,
2580 void *event_info __UNUSED__)
2582 Evas_Object *obj = data;
2583 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2587 _scroll_edge_bottom(void *data,
2588 Evas_Object *scr __UNUSED__,
2589 void *event_info __UNUSED__)
2591 Evas_Object *obj = data;
2592 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2596 * Add a new Genlist object
2598 * @param parent The parent object
2599 * @return The new object or NULL if it cannot be created
2604 elm_genlist_add(Evas_Object *parent)
2609 Evas_Coord minw, minh;
2610 static Evas_Smart *smart = NULL;
2614 static Evas_Smart_Class sc;
2616 evas_object_smart_clipped_smart_set(&_pan_sc);
2618 sc.name = "elm_genlist_pan";
2619 sc.version = EVAS_SMART_CLASS_VERSION;
2622 sc.resize = _pan_resize;
2623 sc.move = _pan_move;
2624 sc.calculate = _pan_calculate;
2625 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2628 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2630 ELM_SET_WIDTYPE(widtype, "genlist");
2631 elm_widget_type_set(obj, "genlist");
2632 elm_widget_sub_object_add(parent, obj);
2633 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2634 elm_widget_data_set(obj, wd);
2635 elm_widget_del_hook_set(obj, _del_hook);
2636 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2637 elm_widget_theme_hook_set(obj, _theme_hook);
2638 elm_widget_can_focus_set(obj, EINA_TRUE);
2639 elm_widget_event_hook_set(obj, _event_hook);
2640 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2642 wd->scr = elm_smart_scroller_add(e);
2643 elm_smart_scroller_widget_set(wd->scr, obj);
2644 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2645 elm_widget_style_get(obj));
2646 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2647 _elm_config->thumbscroll_bounce_enable);
2648 elm_widget_resize_object_set(obj, wd->scr);
2650 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2651 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2653 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2654 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2658 wd->mode = ELM_LIST_SCROLL;
2659 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2660 wd->item_cache_max = wd->max_items_per_block * 2;
2661 wd->longpress_timeout = _elm_config->longpress_timeout;
2663 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2664 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2665 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2666 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2668 wd->pan_smart = evas_object_smart_add(e, smart);
2669 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2672 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2673 _pan_set, _pan_get, _pan_max_get,
2674 _pan_min_get, _pan_child_size_get);
2676 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2678 evas_object_size_hint_min_set(obj, minw, minh);
2680 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2685 static Elm_Genlist_Item *
2686 _item_new(Widget_Data *wd,
2687 const Elm_Genlist_Item_Class *itc,
2689 Elm_Genlist_Item *parent,
2690 Elm_Genlist_Item_Flags flags,
2692 const void *func_data)
2694 Elm_Genlist_Item *it;
2696 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2697 if (!it) return NULL;
2700 it->base.data = data;
2701 it->parent = parent;
2703 it->func.func = func;
2704 it->func.data = func_data;
2705 it->mouse_cursor = NULL;
2706 it->expanded_depth = 0;
2711 _item_block_add(Widget_Data *wd,
2712 Elm_Genlist_Item *it)
2714 Item_Block *itb = NULL;
2721 itb = calloc(1, sizeof(Item_Block));
2724 if (!it->rel->block)
2727 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2728 itb->items = eina_list_append(itb->items, it);
2734 wd->blocks = eina_inlist_prepend_relative
2735 (wd->blocks, EINA_INLIST_GET(itb),
2736 EINA_INLIST_GET(it->rel->block));
2738 eina_list_prepend_relative(itb->items, it, it->rel);
2742 wd->blocks = eina_inlist_append_relative
2743 (wd->blocks, EINA_INLIST_GET(itb),
2744 EINA_INLIST_GET(it->rel->block));
2746 eina_list_append_relative(itb->items, it, it->rel);
2756 itb = (Item_Block *)(wd->blocks);
2757 if (itb->count >= wd->max_items_per_block)
2759 itb = calloc(1, sizeof(Item_Block));
2763 eina_inlist_prepend(wd->blocks,
2764 EINA_INLIST_GET(itb));
2769 itb = calloc(1, sizeof(Item_Block));
2773 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2775 itb->items = eina_list_prepend(itb->items, it);
2781 itb = (Item_Block *)(wd->blocks->last);
2782 if (itb->count >= wd->max_items_per_block)
2784 itb = calloc(1, sizeof(Item_Block));
2788 eina_inlist_append(wd->blocks,
2789 EINA_INLIST_GET(itb));
2794 itb = calloc(1, sizeof(Item_Block));
2798 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2800 itb->items = eina_list_append(itb->items, it);
2806 itb = it->rel->block;
2807 if (!itb) goto newblock;
2809 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2811 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2814 itb->changed = EINA_TRUE;
2816 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2817 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2820 it->rel->relcount--;
2821 if ((it->rel->delete_me) && (!it->rel->relcount))
2825 if (itb->count > itb->wd->max_items_per_block)
2829 Elm_Genlist_Item *it2;
2831 newc = itb->count / 2;
2832 itb2 = calloc(1, sizeof(Item_Block));
2836 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2837 EINA_INLIST_GET(itb));
2838 itb2->changed = EINA_TRUE;
2839 while ((itb->count > newc) && (itb->items))
2843 l = eina_list_last(itb->items);
2845 itb->items = eina_list_remove_list(itb->items, l);
2848 itb2->items = eina_list_prepend(itb2->items, it2);
2856 _queue_process(Widget_Data *wd,
2860 Eina_Bool showme = EINA_FALSE;
2863 t0 = ecore_time_get();
2864 for (n = 0; (wd->queue) && (n < 128); n++)
2866 Elm_Genlist_Item *it;
2868 it = wd->queue->data;
2869 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2870 it->queued = EINA_FALSE;
2871 _item_block_add(wd, it);
2872 t = ecore_time_get();
2873 if (it->block->changed)
2875 showme = _item_block_recalc(it->block, it->block->num, 1,
2877 it->block->changed = 0;
2879 if (showme) it->block->showme = EINA_TRUE;
2880 if (eina_inlist_count(wd->blocks) > 1)
2882 if ((t - t0) > (ecore_animator_frametime_get())) break;
2889 _item_idler(void *data)
2891 Widget_Data *wd = data;
2894 //static double q_start = 0.0;
2895 //if (q_start == 0.0) q_start = ecore_time_get();
2898 if (_queue_process(wd, 1) > 0)
2900 if (wd->calc_job) ecore_job_del(wd->calc_job);
2901 wd->calc_job = ecore_job_add(_calc_job, wd);
2906 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2908 wd->queue_idler = NULL;
2909 return ECORE_CALLBACK_CANCEL;
2911 return ECORE_CALLBACK_RENEW;
2915 _item_queue(Widget_Data *wd,
2916 Elm_Genlist_Item *it)
2918 if (it->queued) return;
2919 it->queued = EINA_TRUE;
2920 wd->queue = eina_list_append(wd->queue, it);
2921 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2923 if (wd->queue_idler)
2925 ecore_idler_del(wd->queue_idler);
2926 wd->queue_idler = NULL;
2928 _queue_process(wd, 0);
2930 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2934 * Append item to the end of the genlist
2936 * This appends the given item to the end of the list or the end of
2937 * the children if the parent is given.
2939 * @param obj The genlist object
2940 * @param itc The item class for the item
2941 * @param data The item data
2942 * @param parent The parent item, or NULL if none
2943 * @param flags Item flags
2944 * @param func Convenience function called when item selected
2945 * @param func_data Data passed to @p func above.
2946 * @return A handle to the item added or NULL if not possible
2950 EAPI Elm_Genlist_Item *
2951 elm_genlist_item_append(Evas_Object *obj,
2952 const Elm_Genlist_Item_Class *itc,
2954 Elm_Genlist_Item *parent,
2955 Elm_Genlist_Item_Flags flags,
2957 const void *func_data)
2959 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2960 Widget_Data *wd = elm_widget_data_get(obj);
2961 if (!wd) return NULL;
2962 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2964 if (!it) return NULL;
2967 if (flags & ELM_GENLIST_ITEM_GROUP)
2968 wd->group_items = eina_list_append(wd->group_items, it);
2969 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2974 Elm_Genlist_Item *it2 = NULL;
2975 Eina_List *ll = eina_list_last(it->parent->items);
2976 if (ll) it2 = ll->data;
2977 it->parent->items = eina_list_append(it->parent->items, it);
2978 if (!it2) it2 = it->parent;
2980 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2981 EINA_INLIST_GET(it2));
2983 it->rel->relcount++;
2985 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2986 it->group_item = parent;
2987 else if (it->parent->group_item)
2988 it->group_item = it->parent->group_item;
2990 it->before = EINA_FALSE;
2991 _item_queue(wd, it);
2996 * Prepend item at start of the genlist
2998 * This adds an item to the beginning of the list or beginning of the
2999 * children of the parent if given.
3001 * @param obj The genlist object
3002 * @param itc The item class for the item
3003 * @param data The item data
3004 * @param parent The parent item, or NULL if none
3005 * @param flags Item flags
3006 * @param func Convenience function called when item selected
3007 * @param func_data Data passed to @p func above.
3008 * @return A handle to the item added or NULL if not possible
3012 EAPI Elm_Genlist_Item *
3013 elm_genlist_item_prepend(Evas_Object *obj,
3014 const Elm_Genlist_Item_Class *itc,
3016 Elm_Genlist_Item *parent,
3017 Elm_Genlist_Item_Flags flags,
3019 const void *func_data)
3021 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3022 Widget_Data *wd = elm_widget_data_get(obj);
3023 if (!wd) return NULL;
3024 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3026 if (!it) return NULL;
3029 if (flags & ELM_GENLIST_ITEM_GROUP)
3030 wd->group_items = eina_list_prepend(wd->group_items, it);
3031 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3036 Elm_Genlist_Item *it2 = NULL;
3037 Eina_List *ll = it->parent->items;
3038 if (ll) it2 = ll->data;
3039 it->parent->items = eina_list_prepend(it->parent->items, it);
3040 if (!it2) it2 = it->parent;
3042 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3043 EINA_INLIST_GET(it2));
3045 it->rel->relcount++;
3047 it->before = EINA_TRUE;
3048 _item_queue(wd, it);
3053 * Insert item before another in the genlist
3055 * This inserts an item before another in the list. It will be in the
3056 * same tree level or group as the item it is inseted before.
3058 * @param obj The genlist object
3059 * @param itc The item class for the item
3060 * @param data The item data
3061 * @param before The item to insert before
3062 * @param flags Item flags
3063 * @param func Convenience function called when item selected
3064 * @param func_data Data passed to @p func above.
3065 * @return A handle to the item added or NULL if not possible
3069 EAPI Elm_Genlist_Item *
3070 elm_genlist_item_insert_before(Evas_Object *obj,
3071 const Elm_Genlist_Item_Class *itc,
3073 Elm_Genlist_Item *parent,
3074 Elm_Genlist_Item *before,
3075 Elm_Genlist_Item_Flags flags,
3077 const void *func_data)
3079 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3080 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3081 Widget_Data *wd = elm_widget_data_get(obj);
3082 if (!wd) return NULL;
3083 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3085 if (!it) return NULL;
3088 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3091 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3092 EINA_INLIST_GET(before));
3094 it->rel->relcount++;
3095 it->before = EINA_TRUE;
3096 _item_queue(wd, it);
3101 * Insert an item after another in the genlst
3103 * This inserts an item after another in the list. It will be in the
3104 * same tree level or group as the item it is inseted after.
3106 * @param obj The genlist object
3107 * @param itc The item class for the item
3108 * @param data The item data
3109 * @param after The item to insert after
3110 * @param flags Item flags
3111 * @param func Convenience function called when item selected
3112 * @param func_data Data passed to @p func above.
3113 * @return A handle to the item added or NULL if not possible
3117 EAPI Elm_Genlist_Item *
3118 elm_genlist_item_insert_after(Evas_Object *obj,
3119 const Elm_Genlist_Item_Class *itc,
3121 Elm_Genlist_Item *parent,
3122 Elm_Genlist_Item *after,
3123 Elm_Genlist_Item_Flags flags,
3125 const void *func_data)
3127 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3128 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3129 Widget_Data *wd = elm_widget_data_get(obj);
3130 if (!wd) return NULL;
3131 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3133 if (!it) return NULL;
3134 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3135 EINA_INLIST_GET(after));
3138 it->parent->items = eina_list_append_relative(it->parent->items, it,
3142 it->rel->relcount++;
3143 it->before = EINA_FALSE;
3144 _item_queue(wd, it);
3151 * This clears all items in the list, leaving it empty.
3153 * @param obj The genlist object
3158 elm_genlist_clear(Evas_Object *obj)
3160 ELM_CHECK_WIDTYPE(obj, widtype);
3161 Widget_Data *wd = elm_widget_data_get(obj);
3163 if (wd->walking > 0)
3165 Elm_Genlist_Item *it;
3167 wd->clear_me = EINA_TRUE;
3168 EINA_INLIST_FOREACH(wd->items, it)
3170 it->delete_me = EINA_TRUE;
3176 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3178 if (wd->anchor_item == it)
3180 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3181 if (!wd->anchor_item)
3183 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3185 wd->items = eina_inlist_remove(wd->items, wd->items);
3186 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3187 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3188 elm_widget_item_pre_notify_del(it);
3189 if (it->realized) _item_unrealize(it);
3190 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3191 it->itc->func.del((void *)it->base.data, it->base.widget);
3192 if (it->long_timer) ecore_timer_del(it->long_timer);
3193 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3194 elm_widget_item_del(it);
3196 wd->clear_me = EINA_FALSE;
3197 wd->anchor_item = NULL;
3200 Item_Block *itb = (Item_Block *)(wd->blocks);
3202 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3203 if (itb->items) eina_list_free(itb->items);
3208 ecore_job_del(wd->calc_job);
3209 wd->calc_job = NULL;
3211 if (wd->queue_idler)
3213 ecore_idler_del(wd->queue_idler);
3214 wd->queue_idler = NULL;
3216 if (wd->must_recalc_idler)
3218 ecore_idler_del(wd->must_recalc_idler);
3219 wd->must_recalc_idler = NULL;
3223 eina_list_free(wd->queue);
3228 eina_list_free(wd->selected);
3229 wd->selected = NULL;
3231 wd->show_item = NULL;
3238 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3239 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3245 * Enable or disable multi-select in the genlist
3247 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3248 * the list. This allows more than 1 item to be selected.
3250 * @param obj The genlist object
3251 * @param multi Multi-select enable/disable
3256 elm_genlist_multi_select_set(Evas_Object *obj,
3259 ELM_CHECK_WIDTYPE(obj, widtype);
3260 Widget_Data *wd = elm_widget_data_get(obj);
3266 * Gets if multi-select in genlist is enable or disable
3268 * @param obj The genlist object
3269 * @return Multi-select enable/disable
3270 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3275 elm_genlist_multi_select_get(const Evas_Object *obj)
3277 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3278 Widget_Data *wd = elm_widget_data_get(obj);
3279 if (!wd) return EINA_FALSE;
3284 * Get the selectd item in the genlist
3286 * This gets the selected item in the list (if multi-select is enabled
3287 * only the first item in the list is selected - which is not very
3288 * useful, so see elm_genlist_selected_items_get() for when
3289 * multi-select is used).
3291 * If no item is selected, NULL is returned.
3293 * @param obj The genlist object
3294 * @return The selected item, or NULL if none.
3298 EAPI Elm_Genlist_Item *
3299 elm_genlist_selected_item_get(const Evas_Object *obj)
3301 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3302 Widget_Data *wd = elm_widget_data_get(obj);
3303 if (!wd) return NULL;
3304 if (wd->selected) return wd->selected->data;
3309 * Get a list of selected items in the genlist
3311 * This returns a list of the selected items. This list pointer is
3312 * only valid so long as no items are selected or unselected (or
3313 * unselected implicitly by deletion). The list contains
3314 * Elm_Genlist_Item pointers.
3316 * @param obj The genlist object
3317 * @return The list of selected items, nor NULL if none are selected.
3321 EAPI const Eina_List *
3322 elm_genlist_selected_items_get(const Evas_Object *obj)
3324 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3325 Widget_Data *wd = elm_widget_data_get(obj);
3326 if (!wd) return NULL;
3327 return wd->selected;
3331 * Get a list of realized items in genlist
3333 * This returns a list of the realized items in the genlist. The list
3334 * contains Elm_Genlist_Item pointers. The list must be freed by the
3335 * caller when done with eina_list_free(). The item pointers in the
3336 * list are only valid so long as those items are not deleted or the
3337 * genlist is not deleted.
3339 * @param obj The genlist object
3340 * @return The list of realized items, nor NULL if none are realized.
3345 elm_genlist_realized_items_get(const Evas_Object *obj)
3347 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3348 Widget_Data *wd = elm_widget_data_get(obj);
3349 Eina_List *list = NULL;
3351 Eina_Bool done = EINA_FALSE;
3352 if (!wd) return NULL;
3353 EINA_INLIST_FOREACH(wd->blocks, itb)
3358 Elm_Genlist_Item *it;
3361 EINA_LIST_FOREACH(itb->items, l, it)
3363 if (it->realized) list = eina_list_append(list, it);
3375 * Get the item that is at the x, y canvas coords
3377 * This returns the item at the given coordinates (which are canvas
3378 * relative not object-relative). If an item is at that coordinate,
3379 * that item handle is returned, and if @p posret is not NULL, the
3380 * integer pointed to is set to a value of -1, 0 or 1, depending if
3381 * the coordinate is on the upper portion of that item (-1), on the
3382 * middle section (0) or on the lower part (1). If NULL is returned as
3383 * an item (no item found there), then posret may indicate -1 or 1
3384 * based if the coordinate is above or below all items respectively in
3387 * @param it The item
3388 * @param x The input x coordinate
3389 * @param y The input y coordinate
3390 * @param posret The position relative to the item returned here
3391 * @return The item at the coordinates or NULL if none
3395 EAPI Elm_Genlist_Item *
3396 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3401 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3402 Widget_Data *wd = elm_widget_data_get(obj);
3403 Evas_Coord ox, oy, ow, oh;
3406 if (!wd) return NULL;
3407 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3409 EINA_INLIST_FOREACH(wd->blocks, itb)
3412 Elm_Genlist_Item *it;
3414 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3415 oy + itb->y - itb->wd->pan_y,
3416 itb->w, itb->h, x, y, 1, 1))
3418 EINA_LIST_FOREACH(itb->items, l, it)
3420 Evas_Coord itx, ity;
3422 itx = ox + itb->x + it->x - itb->wd->pan_x;
3423 ity = oy + itb->y + it->y - itb->wd->pan_y;
3424 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3428 if (y <= (ity + (it->h / 4))) *posret = -1;
3429 else if (y >= (ity + it->h - (it->h / 4)))
3435 lasty = ity + it->h;
3440 if (y > lasty) *posret = 1;
3447 * Get the first item in the genlist
3449 * This returns the first item in the list.
3451 * @param obj The genlist object
3452 * @return The first item, or NULL if none
3456 EAPI Elm_Genlist_Item *
3457 elm_genlist_first_item_get(const Evas_Object *obj)
3459 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3460 Widget_Data *wd = elm_widget_data_get(obj);
3461 if (!wd) return NULL;
3462 if (!wd->items) return NULL;
3463 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3464 while ((it) && (it->delete_me))
3465 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3470 * Get the last item in the genlist
3472 * This returns the last item in the list.
3474 * @return The last item, or NULL if none
3478 EAPI Elm_Genlist_Item *
3479 elm_genlist_last_item_get(const Evas_Object *obj)
3481 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3482 Widget_Data *wd = elm_widget_data_get(obj);
3483 if (!wd) return NULL;
3484 if (!wd->items) return NULL;
3485 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3486 while ((it) && (it->delete_me))
3487 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3492 * Get the next item in the genlist
3494 * This returns the item after the item @p it.
3496 * @param it The item
3497 * @return The item after @p it, or NULL if none
3501 EAPI Elm_Genlist_Item *
3502 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3504 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3507 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3508 if ((it) && (!it->delete_me)) break;
3510 return (Elm_Genlist_Item *)it;
3514 * Get the previous item in the genlist
3516 * This returns the item before the item @p it.
3518 * @param it The item
3519 * @return The item before @p it, or NULL if none
3523 EAPI Elm_Genlist_Item *
3524 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3526 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3529 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3530 if ((it) && (!it->delete_me)) break;
3532 return (Elm_Genlist_Item *)it;
3536 * Get the genlist object from an item
3538 * This returns the genlist object itself that an item belongs to.
3540 * @param it The item
3541 * @return The genlist object
3546 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3548 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3549 return it->base.widget;
3553 * Get the parent item of the given item
3555 * This returns the parent item of the item @p it given.
3557 * @param it The item
3558 * @return The parent of the item or NULL if none
3562 EAPI Elm_Genlist_Item *
3563 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3565 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3570 * Clear all sub-items (children) of the given item
3572 * This clears all items that are children (or their descendants) of the
3575 * @param it The item
3580 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3582 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3583 Eina_List *tl = NULL, *l;
3584 Elm_Genlist_Item *it2;
3586 EINA_LIST_FOREACH(it->items, l, it2)
3587 tl = eina_list_append(tl, it2);
3588 EINA_LIST_FREE(tl, it2)
3589 elm_genlist_item_del(it2);
3593 * Set the selected state of an item
3595 * This sets the selected state (1 selected, 0 not selected) of the given
3598 * @param it The item
3599 * @param selected The selected state
3604 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3607 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3608 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3610 if (it->delete_me) return;
3611 selected = !!selected;
3612 if (it->selected == selected) return;
3618 while (wd->selected)
3619 _item_unselect(wd->selected->data);
3621 _item_highlight(it);
3629 * Get the selected state of an item
3631 * This gets the selected state of an item (1 selected, 0 not selected).
3633 * @param it The item
3634 * @return The selected state
3639 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3641 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3642 return it->selected;
3646 * Sets the expanded state of an item (if it's a parent)
3648 * This expands or contracts a parent item (thus showing or hiding the
3651 * @param it The item
3652 * @param expanded The expanded state (1 expanded, 0 not expanded).
3657 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3660 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3661 if (it->expanded == expanded) return;
3662 it->expanded = expanded;
3666 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3667 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3672 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3673 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3678 * Get the expanded state of an item
3680 * This gets the expanded state of an item
3682 * @param it The item
3683 * @return Thre expanded state
3688 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3690 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3691 return it->expanded;
3695 * Get the depth of expanded item
3697 * @param it The genlist item object
3698 * @return The depth of expanded item
3703 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3705 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3706 return it->expanded_depth;
3710 * Sets the disabled state of an item.
3712 * A disabled item cannot be selected or unselected. It will also
3713 * change appearance to appear disabled. This sets the disabled state
3714 * (1 disabled, 0 not disabled).
3716 * @param it The item
3717 * @param disabled The disabled state
3722 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3725 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3726 if (it->disabled == disabled) return;
3727 if (it->delete_me) return;
3728 it->disabled = disabled;
3732 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3734 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3739 * Get the disabled state of an item
3741 * This gets the disabled state of the given item.
3743 * @param it The item
3744 * @return The disabled state
3749 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3751 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3752 if (it->delete_me) return EINA_FALSE;
3753 return it->disabled;
3757 * Sets the display only state of an item.
3759 * A display only item cannot be selected or unselected. It is for
3760 * display only and not selecting or otherwise clicking, dragging
3761 * etc. by the user, thus finger size rules will not be applied to
3764 * @param it The item
3765 * @param display_only The display only state
3770 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3771 Eina_Bool display_only)
3773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3774 if (it->display_only == display_only) return;
3775 if (it->delete_me) return;
3776 it->display_only = display_only;
3777 it->mincalcd = EINA_FALSE;
3778 it->updateme = EINA_TRUE;
3779 if (it->block) it->block->updateme = EINA_TRUE;
3780 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3781 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3785 * Get the display only state of an item
3787 * This gets the display only state of the given item.
3789 * @param it The item
3790 * @return The display only state
3795 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3797 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3798 if (it->delete_me) return EINA_FALSE;
3799 return it->display_only;
3803 * Show the given item
3805 * This causes genlist to jump to the given item @p it and show it (by
3806 * scrolling), if it is not fully visible.
3808 * @param it The item
3813 elm_genlist_item_show(Elm_Genlist_Item *it)
3815 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3816 Evas_Coord gith = 0;
3817 if (it->delete_me) return;
3818 if ((it->queued) || (!it->mincalcd))
3820 it->wd->show_item = it;
3821 it->wd->bring_in = EINA_TRUE;
3822 it->showme = EINA_TRUE;
3825 if (it->wd->show_item)
3827 it->wd->show_item->showme = EINA_FALSE;
3828 it->wd->show_item = NULL;
3830 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3831 gith = it->group_item->h;
3832 elm_smart_scroller_child_region_show(it->wd->scr,
3833 it->x + it->block->x,
3834 it->y + it->block->y - gith,
3835 it->block->w, it->h);
3839 * Bring in the given item
3841 * This causes genlist to jump to the given item @p it and show it (by
3842 * scrolling), if it is not fully visible. This may use animation to
3843 * do so and take a period of time
3845 * @param it The item
3850 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3852 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3853 Evas_Coord gith = 0;
3854 if (it->delete_me) return;
3855 if ((it->queued) || (!it->mincalcd))
3857 it->wd->show_item = it;
3858 it->wd->bring_in = EINA_TRUE;
3859 it->showme = EINA_TRUE;
3862 if (it->wd->show_item)
3864 it->wd->show_item->showme = EINA_FALSE;
3865 it->wd->show_item = NULL;
3867 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3868 gith = it->group_item->h;
3869 elm_smart_scroller_region_bring_in(it->wd->scr,
3870 it->x + it->block->x,
3871 it->y + it->block->y - gith,
3872 it->block->w, it->h);
3876 * Show the given item at the top
3878 * This causes genlist to jump to the given item @p it and show it (by
3879 * scrolling), if it is not fully visible.
3881 * @param it The item
3886 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3888 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3890 Evas_Coord gith = 0;
3892 if (it->delete_me) return;
3893 if ((it->queued) || (!it->mincalcd))
3895 it->wd->show_item = it;
3896 it->wd->bring_in = EINA_TRUE;
3897 it->showme = EINA_TRUE;
3900 if (it->wd->show_item)
3902 it->wd->show_item->showme = EINA_FALSE;
3903 it->wd->show_item = NULL;
3905 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3906 if (it->group_item) gith = it->group_item->h;
3907 elm_smart_scroller_child_region_show(it->wd->scr,
3908 it->x + it->block->x,
3909 it->y + it->block->y - gith,
3914 * Bring in the given item at the top
3916 * This causes genlist to jump to the given item @p it and show it (by
3917 * scrolling), if it is not fully visible. This may use animation to
3918 * do so and take a period of time
3920 * @param it The item
3925 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3927 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3929 Evas_Coord gith = 0;
3931 if (it->delete_me) return;
3932 if ((it->queued) || (!it->mincalcd))
3934 it->wd->show_item = it;
3935 it->wd->bring_in = EINA_TRUE;
3936 it->showme = EINA_TRUE;
3939 if (it->wd->show_item)
3941 it->wd->show_item->showme = EINA_FALSE;
3942 it->wd->show_item = NULL;
3944 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3945 if (it->group_item) gith = it->group_item->h;
3946 elm_smart_scroller_region_bring_in(it->wd->scr,
3947 it->x + it->block->x,
3948 it->y + it->block->y - gith,
3953 * Show the given item at the middle
3955 * This causes genlist to jump to the given item @p it and show it (by
3956 * scrolling), if it is not fully visible.
3958 * @param it The item
3963 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3965 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3968 if (it->delete_me) return;
3969 if ((it->queued) || (!it->mincalcd))
3971 it->wd->show_item = it;
3972 it->wd->bring_in = EINA_TRUE;
3973 it->showme = EINA_TRUE;
3976 if (it->wd->show_item)
3978 it->wd->show_item->showme = EINA_FALSE;
3979 it->wd->show_item = NULL;
3981 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3982 elm_smart_scroller_child_region_show(it->wd->scr,
3983 it->x + it->block->x,
3984 it->y + it->block->y - oh / 2 +
3985 it->h / 2, it->block->w, oh);
3989 * Bring in the given item at the middle
3991 * This causes genlist to jump to the given item @p it and show it (by
3992 * scrolling), if it is not fully visible. This may use animation to
3993 * do so and take a period of time
3995 * @param it The item
4000 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4002 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4005 if (it->delete_me) return;
4006 if ((it->queued) || (!it->mincalcd))
4008 it->wd->show_item = it;
4009 it->wd->bring_in = EINA_TRUE;
4010 it->showme = EINA_TRUE;
4013 if (it->wd->show_item)
4015 it->wd->show_item->showme = EINA_FALSE;
4016 it->wd->show_item = NULL;
4018 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4019 elm_smart_scroller_region_bring_in(it->wd->scr,
4020 it->x + it->block->x,
4021 it->y + it->block->y - oh / 2 + it->h / 2,
4026 * Delete a given item
4028 * This deletes the item from genlist and calls the genlist item del
4029 * class callback defined in the item class, if it is set. This clears all
4030 * subitems if it is a tree.
4032 * @param it The item
4037 elm_genlist_item_del(Elm_Genlist_Item *it)
4039 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4040 if ((it->relcount > 0) || (it->walking > 0))
4042 elm_widget_item_pre_notify_del(it);
4043 elm_genlist_item_subitems_clear(it);
4044 it->delete_me = EINA_TRUE;
4045 if (it->wd->show_item == it) it->wd->show_item = NULL;
4047 it->wd->selected = eina_list_remove(it->wd->selected,
4051 if (it->realized) _item_unrealize(it);
4052 it->block->changed = EINA_TRUE;
4053 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4054 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4056 if (it->itc->func.del)
4057 it->itc->func.del((void *)it->base.data, it->base.widget);
4064 * Set the data item from the genlist item
4066 * This set the data value passed on the elm_genlist_item_append() and
4067 * related item addition calls. This function will also call
4068 * elm_genlist_item_update() so the item will be updated to reflect the
4071 * @param it The item
4072 * @param data The new data pointer to set
4077 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4080 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4081 elm_widget_item_data_set(it, data);
4082 elm_genlist_item_update(it);
4086 * Get the data item from the genlist item
4088 * This returns the data value passed on the elm_genlist_item_append()
4089 * and related item addition calls and elm_genlist_item_data_set().
4091 * @param it The item
4092 * @return The data pointer provided when created
4097 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4099 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4100 return elm_widget_item_data_get(it);
4104 * Tells genlist to "orphan" icons fetchs by the item class
4106 * This instructs genlist to release references to icons in the item,
4107 * meaning that they will no longer be managed by genlist and are
4108 * floating "orphans" that can be re-used elsewhere if the user wants
4111 * @param it The item
4116 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4119 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4120 EINA_LIST_FREE(it->icon_objs, icon)
4122 elm_widget_sub_object_del(it->base.widget, icon);
4123 evas_object_smart_member_del(icon);
4124 evas_object_hide(icon);
4129 * Get the real evas object of the genlist item
4131 * This returns the actual evas object used for the specified genlist
4132 * item. This may be NULL as it may not be created, and may be deleted
4133 * at any time by genlist. Do not modify this object (move, resize,
4134 * show, hide etc.) as genlist is controlling it. This function is for
4135 * querying, emitting custom signals or hooking lower level callbacks
4136 * for events. Do not delete this object under any circumstances.
4138 * @param it The item
4139 * @return The object pointer
4143 EAPI const Evas_Object *
4144 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4146 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4147 return it->base.view;
4151 * Update the contents of an item
4153 * This updates an item by calling all the item class functions again
4154 * to get the icons, labels and states. Use this when the original
4155 * item data has changed and the changes are desired to be reflected.
4157 * @param it The item
4162 elm_genlist_item_update(Elm_Genlist_Item *it)
4164 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4165 if (!it->block) return;
4166 if (it->delete_me) return;
4167 it->mincalcd = EINA_FALSE;
4168 it->updateme = EINA_TRUE;
4169 it->block->updateme = EINA_TRUE;
4170 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4171 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4175 * Update the item class of an item
4177 * @param it The item
4178 * @parem itc The item class for the item
4183 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4184 const Elm_Genlist_Item_Class *itc)
4186 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4187 if (!it->block) return;
4188 EINA_SAFETY_ON_NULL_RETURN(itc);
4189 if (it->delete_me) return;
4191 it->nocache = EINA_TRUE;
4192 elm_genlist_item_update(it);
4195 static Evas_Object *
4196 _elm_genlist_item_label_create(void *data,
4198 void *item __UNUSED__)
4200 Evas_Object *label = elm_label_add(obj);
4203 elm_object_style_set(label, "tooltip");
4204 elm_label_label_set(label, data);
4209 _elm_genlist_item_label_del_cb(void *data,
4210 Evas_Object *obj __UNUSED__,
4211 void *event_info __UNUSED__)
4213 eina_stringshare_del(data);
4217 * Set the text to be shown in the genlist item.
4219 * @param item Target item
4220 * @param text The text to set in the content
4222 * Setup the text as tooltip to object. The item can have only one
4223 * tooltip, so any previous tooltip data is removed.
4228 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4232 text = eina_stringshare_add(text);
4233 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4235 _elm_genlist_item_label_del_cb);
4239 * Set the content to be shown in the tooltip item
4241 * Setup the tooltip to item. The item can have only one tooltip, so
4242 * any previous tooltip data is removed. @p func(with @p data) will be
4243 * called every time that need to show the tooltip and it should return a
4244 * valid Evas_Object. This object is then managed fully by tooltip
4245 * system and is deleted when the tooltip is gone.
4247 * @param item the genlist item being attached by a tooltip.
4248 * @param func the function used to create the tooltip contents.
4249 * @param data what to provide to @a func as callback data/context.
4250 * @param del_cb called when data is not needed anymore, either when
4251 * another callback replaces @func, the tooltip is unset with
4252 * elm_genlist_item_tooltip_unset() or the owner @a item
4253 * dies. This callback receives as the first parameter the
4254 * given @a data, and @c event_info is the item.
4259 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4260 Elm_Tooltip_Item_Content_Cb func,
4262 Evas_Smart_Cb del_cb)
4264 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4266 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4269 if (item->tooltip.del_cb)
4270 item->tooltip.del_cb((void *)item->tooltip.data,
4271 item->base.widget, item);
4273 item->tooltip.content_cb = func;
4274 item->tooltip.data = data;
4275 item->tooltip.del_cb = del_cb;
4277 if (item->base.view)
4279 elm_widget_item_tooltip_content_cb_set(item,
4280 item->tooltip.content_cb,
4281 item->tooltip.data, NULL);
4282 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4288 if (del_cb) del_cb((void *)data, NULL, NULL);
4292 * Unset tooltip from item
4294 * @param item genlist item to remove previously set tooltip.
4296 * Remove tooltip from item. The callback provided as del_cb to
4297 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4298 * it is not used anymore.
4300 * @see elm_genlist_item_tooltip_content_cb_set()
4305 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4307 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4308 if ((item->base.view) && (item->tooltip.content_cb))
4309 elm_widget_item_tooltip_unset(item);
4311 if (item->tooltip.del_cb)
4312 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4313 item->tooltip.del_cb = NULL;
4314 item->tooltip.content_cb = NULL;
4315 item->tooltip.data = NULL;
4316 if (item->tooltip.style)
4317 elm_genlist_item_tooltip_style_set(item, NULL);
4321 * Sets a different style for this item tooltip.
4323 * @note before you set a style you should define a tooltip with
4324 * elm_genlist_item_tooltip_content_cb_set() or
4325 * elm_genlist_item_tooltip_text_set()
4327 * @param item genlist item with tooltip already set.
4328 * @param style the theme style to use (default, transparent, ...)
4333 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4337 eina_stringshare_replace(&item->tooltip.style, style);
4338 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4342 * Get the style for this item tooltip.
4344 * @param item genlist item with tooltip already set.
4345 * @return style the theme style in use, defaults to "default". If the
4346 * object does not have a tooltip set, then NULL is returned.
4351 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4353 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4354 return item->tooltip.style;
4358 * Set the cursor to be shown when mouse is over the genlist item
4360 * @param item Target item
4361 * @param cursor the cursor name to be used.
4363 * @see elm_object_cursor_set()
4367 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4370 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4371 eina_stringshare_replace(&item->mouse_cursor, cursor);
4372 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4376 * Get the cursor to be shown when mouse is over the genlist item
4378 * @param item genlist item with cursor already set.
4379 * @return the cursor name.
4384 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4386 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4387 return elm_widget_item_cursor_get(item);
4391 * Unset the cursor to be shown when mouse is over the genlist item
4393 * @param item Target item
4395 * @see elm_object_cursor_unset()
4399 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4401 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4402 if (!item->mouse_cursor)
4405 if (item->base.view)
4406 elm_widget_item_cursor_unset(item);
4408 eina_stringshare_del(item->mouse_cursor);
4409 item->mouse_cursor = NULL;
4413 * Sets a different style for this item cursor.
4415 * @note before you set a style you should define a cursor with
4416 * elm_genlist_item_cursor_set()
4418 * @param item genlist item with cursor already set.
4419 * @param style the theme style to use (default, transparent, ...)
4424 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4427 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4428 elm_widget_item_cursor_style_set(item, style);
4432 * Get the style for this item cursor.
4434 * @param item genlist item with cursor already set.
4435 * @return style the theme style in use, defaults to "default". If the
4436 * object does not have a cursor set, then NULL is returned.
4441 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4443 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4444 return elm_widget_item_cursor_style_get(item);
4448 * Set if the cursor set should be searched on the theme or should use
4449 * the provided by the engine, only.
4451 * @note before you set if should look on theme you should define a
4452 * cursor with elm_object_cursor_set(). By default it will only look
4453 * for cursors provided by the engine.
4455 * @param item widget item with cursor already set.
4456 * @param engine_only boolean to define it cursors should be looked
4457 * only between the provided by the engine or searched on widget's
4463 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4464 Eina_Bool engine_only)
4466 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4467 elm_widget_item_cursor_engine_only_set(item, engine_only);
4471 * Get the cursor engine only usage for this item cursor.
4473 * @param item widget item with cursor already set.
4474 * @return engine_only boolean to define it cursors should be looked
4475 * only between the provided by the engine or searched on widget's
4476 * theme as well. If the object does not have a cursor set, then
4477 * EINA_FALSE is returned.
4482 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4484 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4485 return elm_widget_item_cursor_engine_only_get(item);
4489 * This sets the horizontal stretching mode
4491 * This sets the mode used for sizing items horizontally. Valid modes
4492 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4493 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4494 * the scroller will scroll horizontally. Otherwise items are expanded
4495 * to fill the width of the viewport of the scroller. If it is
4496 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4497 * limited to that size.
4499 * @param obj The genlist object
4500 * @param mode The mode to use
4505 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4508 ELM_CHECK_WIDTYPE(obj, widtype);
4509 Widget_Data *wd = elm_widget_data_get(obj);
4511 if (wd->mode == mode) return;
4517 * Gets the horizontal stretching mode
4519 * @param obj The genlist object
4520 * @return The mode to use
4521 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4526 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4528 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4529 Widget_Data *wd = elm_widget_data_get(obj);
4530 if (!wd) return ELM_LIST_LAST;
4535 * Set the always select mode.
4537 * Items will only call their selection func and callback when first
4538 * becoming selected. Any further clicks will do nothing, unless you
4539 * enable always select with elm_genlist_always_select_mode_set().
4540 * This means even if selected, every click will make the selected
4541 * callbacks be called.
4543 * @param obj The genlist object
4544 * @param always_select The always select mode
4545 * (EINA_TRUE = on, EINA_FALSE = off)
4550 elm_genlist_always_select_mode_set(Evas_Object *obj,
4551 Eina_Bool always_select)
4553 ELM_CHECK_WIDTYPE(obj, widtype);
4554 Widget_Data *wd = elm_widget_data_get(obj);
4556 wd->always_select = always_select;
4560 * Get the always select mode.
4562 * @param obj The genlist object
4563 * @return The always select mode
4564 * (EINA_TRUE = on, EINA_FALSE = off)
4569 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4571 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4572 Widget_Data *wd = elm_widget_data_get(obj);
4573 if (!wd) return EINA_FALSE;
4574 return wd->always_select;
4578 * Set no select mode
4580 * This will turn off the ability to select items entirely and they
4581 * will neither appear selected nor call selected callback functions.
4583 * @param obj The genlist object
4584 * @param no_select The no select mode
4585 * (EINA_TRUE = on, EINA_FALSE = off)
4590 elm_genlist_no_select_mode_set(Evas_Object *obj,
4591 Eina_Bool no_select)
4593 ELM_CHECK_WIDTYPE(obj, widtype);
4594 Widget_Data *wd = elm_widget_data_get(obj);
4596 wd->no_select = no_select;
4600 * Gets no select mode
4602 * @param obj The genlist object
4603 * @return The no select mode
4604 * (EINA_TRUE = on, EINA_FALSE = off)
4609 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4611 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4612 Widget_Data *wd = elm_widget_data_get(obj);
4613 if (!wd) return EINA_FALSE;
4614 return wd->no_select;
4620 * This will enable the compress mode where items are "compressed"
4621 * horizontally to fit the genlist scrollable viewport width. This is
4622 * special for genlist. Do not rely on
4623 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4624 * work as genlist needs to handle it specially.
4626 * @param obj The genlist object
4627 * @param compress The compress mode
4628 * (EINA_TRUE = on, EINA_FALSE = off)
4633 elm_genlist_compress_mode_set(Evas_Object *obj,
4636 ELM_CHECK_WIDTYPE(obj, widtype);
4637 Widget_Data *wd = elm_widget_data_get(obj);
4639 wd->compress = compress;
4643 * Get the compress mode
4645 * @param obj The genlist object
4646 * @return The compress mode
4647 * (EINA_TRUE = on, EINA_FALSE = off)
4652 elm_genlist_compress_mode_get(const Evas_Object *obj)
4654 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4655 Widget_Data *wd = elm_widget_data_get(obj);
4656 if (!wd) return EINA_FALSE;
4657 return wd->compress;
4661 * Set height-for-width mode
4663 * With height-for-width mode the item width will be fixed (restricted
4664 * to a minimum of) to the list width when calculating its size in
4665 * order to allow the height to be calculated based on it. This allows,
4666 * for instance, text block to wrap lines if the Edje part is
4667 * configured with "text.min: 0 1".
4669 * @note This mode will make list resize slower as it will have to
4670 * recalculate every item height again whenever the list width
4673 * @note When height-for-width mode is enabled, it also enables
4674 * compress mode (see elm_genlist_compress_mode_set()) and
4675 * disables homogeneous (see elm_genlist_homogeneous_set()).
4677 * @param obj The genlist object
4678 * @param setting The height-for-width mode (EINA_TRUE = on,
4684 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4685 Eina_Bool height_for_width)
4687 ELM_CHECK_WIDTYPE(obj, widtype);
4688 Widget_Data *wd = elm_widget_data_get(obj);
4690 wd->height_for_width = !!height_for_width;
4691 if (wd->height_for_width)
4693 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4694 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4699 * Get the height-for-width mode
4701 * @param obj The genlist object
4702 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4708 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4710 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4711 Widget_Data *wd = elm_widget_data_get(obj);
4712 if (!wd) return EINA_FALSE;
4713 return wd->height_for_width;
4719 * This will enable or disable the scroller bounce mode for the
4720 * genlist. See elm_scroller_bounce_set() for details
4722 * @param obj The genlist object
4723 * @param h_bounce Allow bounce horizontally
4724 * @param v_bounce Allow bounce vertically
4729 elm_genlist_bounce_set(Evas_Object *obj,
4733 ELM_CHECK_WIDTYPE(obj, widtype);
4734 Widget_Data *wd = elm_widget_data_get(obj);
4736 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4740 * Get the bounce mode
4742 * @param obj The genlist object
4743 * @param h_bounce Allow bounce horizontally
4744 * @param v_bounce Allow bounce vertically
4749 elm_genlist_bounce_get(const Evas_Object *obj,
4750 Eina_Bool *h_bounce,
4751 Eina_Bool *v_bounce)
4753 ELM_CHECK_WIDTYPE(obj, widtype);
4754 Widget_Data *wd = elm_widget_data_get(obj);
4756 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4760 * Set homogenous mode
4762 * This will enable the homogeneous mode where items are of the same
4763 * height and width so that genlist may do the lazy-loading at its
4764 * maximum. This implies 'compressed' mode.
4766 * @param obj The genlist object
4767 * @param homogeneous Assume the items within the genlist are of the
4768 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4773 elm_genlist_homogeneous_set(Evas_Object *obj,
4774 Eina_Bool homogeneous)
4776 ELM_CHECK_WIDTYPE(obj, widtype);
4777 Widget_Data *wd = elm_widget_data_get(obj);
4779 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4780 wd->homogeneous = homogeneous;
4784 * Get the homogenous mode
4786 * @param obj The genlist object
4787 * @return Assume the items within the genlist are of the same height
4788 * and width (EINA_TRUE = on, EINA_FALSE = off)
4793 elm_genlist_homogeneous_get(const Evas_Object *obj)
4795 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4796 Widget_Data *wd = elm_widget_data_get(obj);
4797 if (!wd) return EINA_FALSE;
4798 return wd->homogeneous;
4802 * Set the maximum number of items within an item block
4804 * This will configure the block count to tune to the target with
4805 * particular performance matrix.
4807 * @param obj The genlist object
4808 * @param n Maximum number of items within an item block
4813 elm_genlist_block_count_set(Evas_Object *obj,
4816 ELM_CHECK_WIDTYPE(obj, widtype);
4817 Widget_Data *wd = elm_widget_data_get(obj);
4819 wd->max_items_per_block = n;
4820 wd->item_cache_max = wd->max_items_per_block * 2;
4821 _item_cache_clean(wd);
4825 * Get the maximum number of items within an item block
4827 * @param obj The genlist object
4828 * @return Maximum number of items within an item block
4833 elm_genlist_block_count_get(const Evas_Object *obj)
4835 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4836 Widget_Data *wd = elm_widget_data_get(obj);
4838 return wd->max_items_per_block;
4842 * Set the timeout in seconds for the longpress event
4844 * @param obj The genlist object
4845 * @param timeout timeout in seconds
4850 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4853 ELM_CHECK_WIDTYPE(obj, widtype);
4854 Widget_Data *wd = elm_widget_data_get(obj);
4856 wd->longpress_timeout = timeout;
4860 * Get the timeout in seconds for the longpress event
4862 * @param obj The genlist object
4863 * @return timeout in seconds
4868 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4870 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4871 Widget_Data *wd = elm_widget_data_get(obj);
4873 return wd->longpress_timeout;
4877 * Set the scrollbar policy
4879 * This sets the scrollbar visibility policy for the given genlist
4880 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
4881 * made visible if it is needed, and otherwise kept hidden.
4882 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
4883 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
4884 * respectively for the horizontal and vertical scrollbars.
4886 * @param obj The genlist object
4887 * @param policy_h Horizontal scrollbar policy
4888 * @param policy_v Vertical scrollbar policy
4893 elm_genlist_scroller_policy_set(Evas_Object *obj,
4894 Elm_Scroller_Policy policy_h,
4895 Elm_Scroller_Policy policy_v)
4897 ELM_CHECK_WIDTYPE(obj, widtype);
4898 Widget_Data *wd = elm_widget_data_get(obj);
4900 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4901 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4904 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4908 * Get the scrollbar policy
4910 * @param obj The genlist object
4911 * @param policy_h Horizontal scrollbar policy
4912 * @param policy_v Vertical scrollbar policy
4917 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4918 Elm_Scroller_Policy *policy_h,
4919 Elm_Scroller_Policy *policy_v)
4921 ELM_CHECK_WIDTYPE(obj, widtype);
4922 Widget_Data *wd = elm_widget_data_get(obj);
4923 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4924 if ((!wd) || (!wd->scr)) return;
4925 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4926 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4927 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;