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 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items.
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * unrealized - This is called just before an item is unrealized. After
58 * this call icon objects provided will be deleted and the item object
59 * itself delete or be put into a floating cache.
61 * drag,start,up - This is called when the item in the list has been dragged
64 * drag,start,down - This is called when the item in the list has been dragged
65 * (not scrolled) down.
67 * drag,start,left - This is called when the item in the list has been dragged
68 * (not scrolled) left.
70 * drag,start,right - This is called when the item in the list has been dragged
71 * (not scrolled) right.
73 * drag,stop - This is called when the item in the list has stopped being
76 * drag - This is called when the item in the list is being dragged.
78 * longpressed - This is called when the item is pressed for a certain amount
79 * of time. By default it's 1 second.
81 * scroll,edge,top - This is called when the genlist is scrolled until the top
84 * scroll,edge,bottom - This is called when the genlist is scrolled until the
87 * scroll,edge,left - This is called when the genlist is scrolled until the
90 * scroll,edge,right - This is called when the genlist is scrolled until the
93 * multi,swipe,left - This is called when the genlist is multi-touch swiped
96 * multi,swipe,right - This is called when the genlist is multi-touch swiped
99 * multi,swipe,up - This is called when the genlist is multi-touch swiped
102 * multi,swipe,down - This is called when the genlist is multi-touch swiped
105 * multi,pinch,out - This is called when the genlist is multi-touch pinched
108 * multi,pinch,in - This is called when the genlist is multi-touch pinched
111 * Genlist has a fairly large API, mostly because it's relatively complex,
112 * trying to be both expansive, powerful and efficient. First we will begin
113 * an overview on the theory behind genlist.
115 * Evas tracks every object you create. Every time it processes an event
116 * (mouse move, down, up etc.) it needs to walk through objects and find out
117 * what event that affects. Even worse every time it renders display updates,
118 * in order to just calculate what to re-draw, it needs to walk through many
119 * many many objects. Thus, the more objects you keep active, the more
120 * overhead Evas has in just doing its work. It is advisable to keep your
121 * active objects to the minimum working set you need. Also remember that
122 * object creation and deletion carries an overhead, so there is a
123 * middle-ground, which is not easily determined. But don't keep massive lists
124 * of objects you can't see or use. Genlist does this with list objects. It
125 * creates and destroys them dynamically as you scroll around. It groups them
126 * into blocks so it can determine the visibility etc. of a whole block at
127 * once as opposed to having to walk the whole list. This 2-level list allows
128 * for very large numbers of items to be in the list (tests have used up to
129 * 2,000,000 items). Also genlist employs a queue for adding items. As items
130 * may be different sizes, every item added needs to be calculated as to its
131 * size and thus this presents a lot of overhead on populating the list, this
132 * genlist employs a queue. Any item added is queued and spooled off over
133 * time, actually appearing some time later, so if your list has many members
134 * you may find it takes a while for them to all appear, with your process
135 * consuming a lot of CPU while it is busy spooling.
137 * Genlist also implements a tree structure, but it does so with callbacks to
138 * the application, with the application filling in tree structures when
139 * requested (allowing for efficient building of a very deep tree that could
140 * even be used for file-management). See the above smart signal callbacks for
143 * An item in the genlist world can have 0 or more text labels (they can be
144 * regular text or textblock – that's up to the style to determine), 0 or
145 * more icons (which are simply objects swallowed into the genlist item) and
146 * 0 or more boolean states that can be used for check, radio or other
147 * indicators by the edje theme style. An item may be one of several styles
148 * (Elementary provides 4 by default - “default”, “double_label”, "group_index"
149 * and "icon_top_text_bottom", but this can be extended by system or
150 * application custom themes/overlays/extensions).
152 * In order to implement the ability to add and delete items on the fly,
153 * Genlist implements a class/callback system where the application provides
154 * a structure with information about that type of item (genlist may contain
155 * multiple different items with different classes, states and styles).
156 * Genlist will call the functions in this struct (methods) when an item is
157 * “realized” (that is created dynamically while scrolling). All objects will
158 * simply be deleted when no longer needed with evas_object_del(). The
159 * Elm_Genlist_Item_Class structure contains the following members:
161 * item_style - This is a constant string and simply defines the name of the
162 * item style. It must be specified and the default should be “default”.
164 * func.label_get - This function is called when an actual item object is
165 * created. The data parameter is the data parameter passed to
166 * elm_genlist_item_append() and related item creation functions. The obj
167 * parameter is the genlist object and the part parameter is the string name
168 * of the text part in the edje design that is listed as one of the possible
169 * labels that can be set. This function must return a strudup()'ed string as
170 * the caller will free() it when done.
172 * func.icon_get - This function is called when an actual item object is
173 * created. The data parameter is the data parameter passed to
174 * elm_genlist_item_append() and related item creation functions. The obj
175 * parameter is the genlist object and the part parameter is the string name
176 * of the icon part in the edje design that is listed as one of the possible
177 * icons that can be set. This must return NULL for no object or a valid
178 * object. The object will be deleted by genlist on shutdown or when the item
181 * func.state_get - This function is called when an actual item object is
182 * created. The data parameter is the data parameter passed to
183 * elm_genlist_item_append() and related item creation functions. The obj
184 * parameter is the genlist object and the part parameter is the string name
185 * of the state part in the edje design that is listed as one of the possible
186 * states that can be set. Return 0 for false or 1 for true. Genlist will
187 * emit a signal to the edje object with “elm,state,XXX,active” “elm” when
188 * true (the default is false), where XXX is the name of the part.
190 * func.del - This is called when elm_genlist_item_del() is called on an
191 * item, elm_genlist_clear() is called on the genlist, or
192 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
193 * intended for use when actual genlist items are deleted, so any backing
194 * data attached to the item (e.g. its data parameter on creation) can be
197 * Items can be added by several calls. All of them return a Elm_Genlist_Item
198 * handle that is an internal member inside the genlist. They all take a data
199 * parameter that is meant to be used for a handle to the applications
200 * internal data (eg the struct with the original item data). The parent
201 * parameter is the parent genlist item this belongs to if it is a tree or
202 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
203 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
204 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
205 * is displayed as an item that is able to expand and have child items.
206 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
207 * displayed at the top until the next group comes. The func parameter is a
208 * convenience callback that is called when the item is selected and the data
209 * parameter will be the func_data parameter, obj be the genlist object and
210 * event_info will be the genlist item.
212 * elm_genlist_item_append() appends an item to the end of the list, or if
213 * there is a parent, to the end of all the child items of the parent.
214 * elm_genlist_item_prepend() is the same but prepends to the beginning of
215 * the list or children list. elm_genlist_item_insert_before() inserts at
216 * item before another item and elm_genlist_item_insert_after() inserts after
217 * the indicated item.
219 * The application can clear the list with elm_genlist_clear() which deletes
220 * all the items in the list and elm_genlist_item_del() will delete a specific
221 * item. elm_genlist_item_subitems_clear() will clear all items that are
222 * children of the indicated parent item.
224 * If the application wants multiple items to be able to be selected,
225 * elm_genlist_multi_select_set() can enable this. If the list is
226 * single-selection only (the default), then elm_genlist_selected_item_get()
227 * will return the selected item, if any, or NULL I none is selected. If the
228 * list is multi-select then elm_genlist_selected_items_get() will return a
229 * list (that is only valid as long as no items are modified (added, deleted,
230 * selected or unselected)).
232 * To help inspect list items you can jump to the item at the top of the list
233 * with elm_genlist_first_item_get() which will return the item pointer, and
234 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
235 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
236 * and previous items respectively relative to the indicated item. Using
237 * these calls you can walk the entire item list/tree. Note that as a tree
238 * the items are flattened in the list, so elm_genlist_item_parent_get() will
239 * let you know which item is the parent (and thus know how to skip them if
242 * There are also convenience functions. elm_genlist_item_genlist_get() will
243 * return the genlist object the item belongs to. elm_genlist_item_show()
244 * will make the scroller scroll to show that specific item so its visible.
245 * elm_genlist_item_data_get() returns the data pointer set by the item
246 * creation functions.
248 * If an item changes (state of boolean changes, label or icons change),
249 * then use elm_genlist_item_update() to have genlist update the item with
250 * the new state. Genlist will re-realize the item thus call the functions
251 * in the _Elm_Genlist_Item_Class for that item.
253 * To programmatically (un)select an item use elm_genlist_item_selected_set().
254 * To get its selected state use elm_genlist_item_selected_get(). Similarly
255 * to expand/contract an item and get its expanded state, use
256 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
257 * again to make an item disabled (unable to be selected and appear
258 * differently) use elm_genlist_item_disabled_set() to set this and
259 * elm_genlist_item_disabled_get() to get the disabled state.
261 * In general to indicate how the genlist should expand items horizontally to
262 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
263 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
264 * mode means that if items are too wide to fit, the scroller will scroll
265 * horizontally. Otherwise items are expanded to fill the width of the
266 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
267 * to the viewport width and limited to that size. This can be combined with
268 * a different style that uses edjes' ellipsis feature (cutting text off like
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
292 Evas_Object *obj, *scr, *pan_smart;
293 Eina_Inlist *items, *blocks;
294 Eina_List *group_items;
296 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
297 Ecore_Job *calc_job, *update_job;
298 Ecore_Idler *queue_idler;
299 Ecore_Idler *must_recalc_idler;
300 Eina_List *queue, *selected;
301 Elm_Genlist_Item *show_item;
302 Elm_Genlist_Item *last_selected_item;
303 Eina_Inlist *item_cache;
304 Elm_Genlist_Item *anchor_item;
307 Ecore_Timer *multi_timer;
308 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
309 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
310 Eina_Bool mouse_down : 1;
311 Eina_Bool multi_down : 1;
312 Eina_Bool multi_timeout : 1;
313 Eina_Bool multitouched : 1;
314 Eina_Bool on_hold : 1;
316 Eina_Bool always_select : 1;
317 Eina_Bool longpressed : 1;
318 Eina_Bool wasselected : 1;
319 Eina_Bool no_select : 1;
320 Eina_Bool bring_in : 1;
321 Eina_Bool compress : 1;
322 Eina_Bool height_for_width : 1;
323 Eina_Bool homogeneous : 1;
324 Eina_Bool clear_me : 1;
329 } history[SWIPE_MOVES];
331 int item_cache_count;
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 hilighted : 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, Eina_Bool rtl);
449 static void _theme_hook(Evas_Object *obj);
450 //static void _show_region_hook(void *data, Evas_Object *obj);
451 static void _sizing_eval(Evas_Object *obj);
452 static void _item_unrealize(Elm_Genlist_Item *it);
453 static void _item_block_unrealize(Item_Block *itb);
454 static void _calc_job(void *data);
455 static void _on_focus_hook(void *data,
457 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
458 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
459 static Eina_Bool _item_single_select_up(Widget_Data *wd);
460 static Eina_Bool _item_single_select_down(Widget_Data *wd);
461 static Eina_Bool _event_hook(Evas_Object *obj,
463 Evas_Callback_Type type,
465 static Eina_Bool _deselect_all_items(Widget_Data *wd);
466 static void _pan_calculate(Evas_Object *obj);
468 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
471 _event_hook(Evas_Object *obj,
472 Evas_Object *src __UNUSED__,
473 Evas_Callback_Type type,
476 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
477 Evas_Event_Key_Down *ev = event_info;
478 Widget_Data *wd = elm_widget_data_get(obj);
479 if (!wd) return EINA_FALSE;
480 if (!wd->items) return EINA_FALSE;
481 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
482 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
484 Elm_Genlist_Item *it = NULL;
487 Evas_Coord step_x = 0;
488 Evas_Coord step_y = 0;
491 Evas_Coord page_x = 0;
492 Evas_Coord page_y = 0;
494 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
495 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
496 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
497 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
499 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
503 else if ((!strcmp(ev->keyname, "Right")) ||
504 (!strcmp(ev->keyname, "KP_Right")))
508 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
510 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
511 (_item_multi_select_up(wd)))
512 || (_item_single_select_up(wd)))
514 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
520 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
522 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
523 (_item_multi_select_down(wd)))
524 || (_item_single_select_down(wd)))
526 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
532 else if ((!strcmp(ev->keyname, "Home")) ||
533 (!strcmp(ev->keyname, "KP_Home")))
535 it = elm_genlist_first_item_get(obj);
536 elm_genlist_item_bring_in(it);
537 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
540 else if ((!strcmp(ev->keyname, "End")) ||
541 (!strcmp(ev->keyname, "KP_End")))
543 it = elm_genlist_last_item_get(obj);
544 elm_genlist_item_bring_in(it);
545 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
548 else if ((!strcmp(ev->keyname, "Prior")) ||
549 (!strcmp(ev->keyname, "KP_Prior")))
552 y -= -(page_y * v_h) / 100;
556 else if ((!strcmp(ev->keyname, "Next")) ||
557 (!strcmp(ev->keyname, "KP_Next")))
560 y += -(page_y * v_h) / 100;
564 else if(((!strcmp(ev->keyname, "Return")) ||
565 (!strcmp(ev->keyname, "KP_Enter")) ||
566 (!strcmp(ev->keyname, "space")))
567 && (!wd->multi) && (wd->selected))
569 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
570 elm_genlist_item_expanded_set(it,
571 !elm_genlist_item_expanded_get(it));
573 else if (!strcmp(ev->keyname, "Escape"))
575 if (!_deselect_all_items(wd)) return EINA_FALSE;
576 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
579 else return EINA_FALSE;
581 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
582 elm_smart_scroller_child_pos_set(wd->scr, x, y);
587 _deselect_all_items(Widget_Data *wd)
589 if (!wd->selected) return EINA_FALSE;
591 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
597 _item_multi_select_up(Widget_Data *wd)
599 if (!wd->selected) return EINA_FALSE;
600 if (!wd->multi) return EINA_FALSE;
602 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
603 if (!prev) return EINA_TRUE;
605 if (elm_genlist_item_selected_get(prev))
607 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
608 wd->last_selected_item = prev;
609 elm_genlist_item_show(wd->last_selected_item);
613 elm_genlist_item_selected_set(prev, EINA_TRUE);
614 elm_genlist_item_show(prev);
620 _item_multi_select_down(Widget_Data *wd)
622 if (!wd->selected) return EINA_FALSE;
623 if (!wd->multi) return EINA_FALSE;
625 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
626 if (!next) return EINA_TRUE;
628 if (elm_genlist_item_selected_get(next))
630 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
631 wd->last_selected_item = next;
632 elm_genlist_item_show(wd->last_selected_item);
636 elm_genlist_item_selected_set(next, EINA_TRUE);
637 elm_genlist_item_show(next);
643 _item_single_select_up(Widget_Data *wd)
645 Elm_Genlist_Item *prev;
648 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
649 while ((prev) && (prev->delete_me))
650 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
652 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
654 if (!prev) return EINA_FALSE;
656 _deselect_all_items(wd);
658 elm_genlist_item_selected_set(prev, EINA_TRUE);
659 elm_genlist_item_show(prev);
664 _item_single_select_down(Widget_Data *wd)
666 Elm_Genlist_Item *next;
669 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
670 while ((next) && (next->delete_me))
671 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
673 else next = elm_genlist_item_next_get(wd->last_selected_item);
675 if (!next) return EINA_FALSE;
677 _deselect_all_items(wd);
679 elm_genlist_item_selected_set(next, EINA_TRUE);
680 elm_genlist_item_show(next);
685 _on_focus_hook(void *data __UNUSED__,
688 Widget_Data *wd = elm_widget_data_get(obj);
690 if (elm_widget_focus_get(obj))
692 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
693 evas_object_focus_set(wd->obj, EINA_TRUE);
694 if ((wd->selected) && (!wd->last_selected_item))
695 wd->last_selected_item = eina_list_data_get(wd->selected);
699 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
700 evas_object_focus_set(wd->obj, EINA_FALSE);
705 _del_hook(Evas_Object *obj)
707 Widget_Data *wd = elm_widget_data_get(obj);
709 _item_cache_zero(wd);
710 if (wd->calc_job) ecore_job_del(wd->calc_job);
711 if (wd->update_job) ecore_job_del(wd->update_job);
712 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
713 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
718 _del_pre_hook(Evas_Object *obj)
720 Widget_Data *wd = elm_widget_data_get(obj);
722 evas_object_del(wd->pan_smart);
723 wd->pan_smart = NULL;
724 elm_genlist_clear(obj);
728 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
730 Widget_Data *wd = elm_widget_data_get(obj);
732 _item_cache_zero(wd);
733 elm_smart_scroller_mirrored_set(wd->scr, rtl);
737 _theme_hook(Evas_Object *obj)
739 Widget_Data *wd = elm_widget_data_get(obj);
742 _item_cache_zero(wd);
743 _mirrored_set(obj, elm_widget_mirrored_get(obj));
744 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
745 elm_widget_style_get(obj));
746 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
747 wd->item_width = wd->item_height = 0;
748 wd->minw = wd->minh = wd->realminw = 0;
749 EINA_INLIST_FOREACH(wd->blocks, itb)
752 Elm_Genlist_Item *it;
754 if (itb->realized) _item_block_unrealize(itb);
755 EINA_LIST_FOREACH(itb->items, l, it)
756 it->mincalcd = EINA_FALSE;
758 itb->changed = EINA_TRUE;
760 if (wd->calc_job) ecore_job_del(wd->calc_job);
761 wd->calc_job = ecore_job_add(_calc_job, wd);
767 _show_region_hook(void *data, Evas_Object *obj)
769 Widget_Data *wd = elm_widget_data_get(data);
770 Evas_Coord x, y, w, h;
772 elm_widget_show_region_get(obj, &x, &y, &w, &h);
773 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
778 _sizing_eval(Evas_Object *obj)
780 Widget_Data *wd = elm_widget_data_get(obj);
781 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
783 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
784 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
786 if (wd->height_for_width)
790 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
791 if ((vw != 0) && (vw != wd->prev_viewport_w))
795 wd->prev_viewport_w = vw;
796 EINA_INLIST_FOREACH(wd->blocks, itb)
798 itb->must_recalc = EINA_TRUE;
800 if (wd->calc_job) ecore_job_del(wd->calc_job);
801 wd->calc_job = ecore_job_add(_calc_job, wd);
804 if (wd->mode == ELM_LIST_LIMIT)
806 Evas_Coord vmw, vmh, vw, vh;
810 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
811 if ((minw > 0) && (vw < minw)) vw = minw;
812 else if ((maxw > 0) && (vw > maxw))
814 edje_object_size_min_calc
815 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
822 edje_object_size_min_calc
823 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
827 evas_object_size_hint_min_set(obj, minw, minh);
828 evas_object_size_hint_max_set(obj, maxw, maxh);
832 _item_hilight(Elm_Genlist_Item *it)
834 const char *selectraise;
835 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted)) return;
836 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
837 selectraise = edje_object_data_get(it->base.view, "selectraise");
838 if ((selectraise) && (!strcmp(selectraise, "on")))
840 evas_object_raise(it->base.view);
841 if ((it->group_item) && (it->group_item->realized))
842 evas_object_raise(it->group_item->base.view);
844 it->hilighted = EINA_TRUE;
848 _item_block_del(Elm_Genlist_Item *it)
851 Item_Block *itb = it->block;
853 itb->items = eina_list_remove(itb->items, it);
855 itb->changed = EINA_TRUE;
856 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
857 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
860 il = EINA_INLIST_GET(itb);
861 Item_Block *itbn = (Item_Block *)(il->next);
863 it->parent->items = eina_list_remove(it->parent->items, it);
865 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
867 if (itbn) itbn->changed = EINA_TRUE;
873 il = EINA_INLIST_GET(itb);
874 Item_Block *itbp = (Item_Block *)(il->prev);
875 Item_Block *itbn = (Item_Block *)(il->next);
876 if ((itbp) && ((itbp->count + itb->count) < 48))
878 Elm_Genlist_Item *it2;
880 EINA_LIST_FREE(itb->items, it2)
883 itbp->items = eina_list_append(itbp->items, it2);
885 itbp->changed = EINA_TRUE;
887 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
888 EINA_INLIST_GET(itb));
891 else if ((itbn) && ((itbn->count + itb->count) < 48))
895 Eina_List *last = eina_list_last(itb->items);
896 Elm_Genlist_Item *it2 = last->data;
899 itb->items = eina_list_remove_list(itb->items, last);
900 itbn->items = eina_list_prepend(itbn->items, it2);
902 itbn->changed = EINA_TRUE;
905 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
913 _item_del(Elm_Genlist_Item *it)
915 elm_widget_item_pre_notify_del(it);
916 elm_genlist_item_subitems_clear(it);
917 it->wd->walking -= it->walking;
918 if (it->wd->show_item == it) it->wd->show_item = NULL;
919 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
920 if (it->realized) _item_unrealize(it);
921 if (it->block) _item_block_del(it);
922 if ((!it->delete_me) && (it->itc->func.del))
923 it->itc->func.del((void *)it->base.data, it->base.widget);
924 it->delete_me = EINA_TRUE;
926 it->wd->queue = eina_list_remove(it->wd->queue, it);
927 if (it->wd->anchor_item == it)
929 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
930 if (!it->wd->anchor_item)
931 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
933 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
935 it->parent->items = eina_list_remove(it->parent->items, it);
936 if (it->flags & ELM_GENLIST_ITEM_GROUP)
937 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
938 if (it->long_timer) ecore_timer_del(it->long_timer);
939 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
941 if (it->tooltip.del_cb)
942 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
944 elm_widget_item_del(it);
948 _item_select(Elm_Genlist_Item *it)
950 if ((it->wd->no_select) || (it->delete_me)) return;
953 if (it->wd->always_select) goto call;
956 it->selected = EINA_TRUE;
957 it->wd->selected = eina_list_append(it->wd->selected, it);
961 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
963 evas_object_smart_callback_call(it->base.widget, "selected", it);
966 if ((it->wd->clear_me) && (!it->wd->walking))
967 elm_genlist_clear(it->base.widget);
970 if ((!it->walking) && (it->delete_me))
972 if (!it->relcount) _item_del(it);
975 it->wd->last_selected_item = it;
979 _item_unselect(Elm_Genlist_Item *it)
981 const char *stacking, *selectraise;
983 if ((it->delete_me) || (!it->hilighted)) return;
984 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
985 stacking = edje_object_data_get(it->base.view, "stacking");
986 selectraise = edje_object_data_get(it->base.view, "selectraise");
987 if ((selectraise) && (!strcmp(selectraise, "on")))
989 if ((stacking) && (!strcmp(stacking, "below")))
990 evas_object_lower(it->base.view);
992 it->hilighted = EINA_FALSE;
995 it->selected = EINA_FALSE;
996 it->wd->selected = eina_list_remove(it->wd->selected, it);
997 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1002 _mouse_move(void *data,
1003 Evas *evas __UNUSED__,
1007 Elm_Genlist_Item *it = data;
1008 Evas_Event_Mouse_Move *ev = event_info;
1009 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1011 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1013 if (!it->wd->on_hold)
1015 it->wd->on_hold = EINA_TRUE;
1016 if (!it->wd->wasselected)
1020 if (it->wd->multitouched)
1022 it->wd->cur_x = ev->cur.canvas.x;
1023 it->wd->cur_y = ev->cur.canvas.y;
1026 if ((it->dragging) && (it->down))
1028 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1031 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1032 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1033 if (abs((it->wd->history[it->wd->movements].x -
1034 it->wd->history[0].x)) > 40)
1035 it->wd->swipe = EINA_TRUE;
1037 it->wd->movements++;
1041 ecore_timer_del(it->long_timer);
1042 it->long_timer = NULL;
1044 evas_object_smart_callback_call(it->base.widget, "drag", it);
1047 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1051 ecore_timer_del(it->long_timer);
1052 it->long_timer = NULL;
1056 if (!it->display_only)
1057 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1058 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1059 x = ev->cur.canvas.x - x;
1060 y = ev->cur.canvas.y - y;
1063 if (adx < 0) adx = -dx;
1066 if (ady < 0) ady = -dy;
1069 if ((adx > minw) || (ady > minh))
1071 it->dragging = EINA_TRUE;
1074 ecore_timer_del(it->long_timer);
1075 it->long_timer = NULL;
1077 if (!it->wd->wasselected)
1082 evas_object_smart_callback_call(it->base.widget,
1083 "drag,start,up", it);
1087 evas_object_smart_callback_call(it->base.widget,
1088 "drag,start,left", it);
1090 evas_object_smart_callback_call(it->base.widget,
1091 "drag,start,right", it);
1097 evas_object_smart_callback_call(it->base.widget,
1098 "drag,start,down", it);
1102 evas_object_smart_callback_call(it->base.widget,
1103 "drag,start,left", it);
1105 evas_object_smart_callback_call(it->base.widget,
1106 "drag,start,right", it);
1113 _long_press(void *data)
1115 Elm_Genlist_Item *it = data;
1117 it->long_timer = NULL;
1118 if ((it->disabled) || (it->dragging) || (it->display_only))
1119 return ECORE_CALLBACK_CANCEL;
1120 it->wd->longpressed = EINA_TRUE;
1121 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1122 return ECORE_CALLBACK_CANCEL;
1126 _swipe(Elm_Genlist_Item *it)
1131 it->wd->swipe = EINA_FALSE;
1132 for (i = 0; i < it->wd->movements; i++)
1134 sum += it->wd->history[i].x;
1135 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1138 sum /= it->wd->movements;
1139 if (abs(sum - it->wd->history[0].x) <= 10) return;
1140 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1144 _swipe_cancel(void *data)
1146 Elm_Genlist_Item *it = data;
1148 if (!it) return ECORE_CALLBACK_CANCEL;
1149 it->wd->swipe = EINA_FALSE;
1150 it->wd->movements = 0;
1151 return ECORE_CALLBACK_RENEW;
1155 _multi_cancel(void *data)
1157 Widget_Data *wd = data;
1159 if (!wd) return ECORE_CALLBACK_CANCEL;
1160 wd->multi_timeout = EINA_TRUE;
1161 return ECORE_CALLBACK_RENEW;
1165 _multi_touch_gesture_eval(void *data)
1167 Elm_Genlist_Item *it = data;
1169 it->wd->multitouched = EINA_FALSE;
1170 if (it->wd->multi_timer)
1172 ecore_timer_del(it->wd->multi_timer);
1173 it->wd->multi_timer = NULL;
1175 if (it->wd->multi_timeout)
1177 it->wd->multi_timeout = EINA_FALSE;
1181 Evas_Coord minw = 0, minh = 0;
1182 Evas_Coord off_x, off_y, off_mx, off_my;
1184 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1185 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1186 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1187 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1188 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1190 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1192 if ((off_x + off_mx) > (off_y + off_my))
1194 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1195 evas_object_smart_callback_call(it->base.widget,
1196 "multi,swipe,right", it);
1197 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1198 evas_object_smart_callback_call(it->base.widget,
1199 "multi,swipe,left", it);
1200 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1201 evas_object_smart_callback_call(it->base.widget,
1202 "multi,pinch,out", it);
1204 evas_object_smart_callback_call(it->base.widget,
1205 "multi,pinch,in", it);
1209 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1210 evas_object_smart_callback_call(it->base.widget,
1211 "multi,swipe,down", it);
1212 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1213 evas_object_smart_callback_call(it->base.widget,
1214 "multi,swipe,up", it);
1215 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1216 evas_object_smart_callback_call(it->base.widget,
1217 "multi,pinch,out", it);
1219 evas_object_smart_callback_call(it->base.widget,
1220 "multi,pinch,in", it);
1223 it->wd->multi_timeout = EINA_FALSE;
1227 _multi_down(void *data,
1228 Evas *evas __UNUSED__,
1229 Evas_Object *obj __UNUSED__,
1232 Elm_Genlist_Item *it = data;
1233 Evas_Event_Multi_Down *ev = event_info;
1235 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1236 it->wd->multi_device = ev->device;
1237 it->wd->multi_down = EINA_TRUE;
1238 it->wd->multitouched = EINA_TRUE;
1239 it->wd->prev_mx = ev->canvas.x;
1240 it->wd->prev_my = ev->canvas.y;
1241 if (!it->wd->wasselected) _item_unselect(it);
1242 it->wd->wasselected = EINA_FALSE;
1243 it->wd->longpressed = EINA_FALSE;
1246 ecore_timer_del(it->long_timer);
1247 it->long_timer = NULL;
1251 it->dragging = EINA_FALSE;
1252 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1254 if (it->swipe_timer)
1256 ecore_timer_del(it->swipe_timer);
1257 it->swipe_timer = NULL;
1259 if (it->wd->on_hold)
1261 it->wd->swipe = EINA_FALSE;
1262 it->wd->movements = 0;
1263 it->wd->on_hold = EINA_FALSE;
1268 _multi_up(void *data,
1269 Evas *evas __UNUSED__,
1270 Evas_Object *obj __UNUSED__,
1273 Elm_Genlist_Item *it = data;
1274 Evas_Event_Multi_Up *ev = event_info;
1276 if (it->wd->multi_device != ev->device) return;
1277 it->wd->multi_device = 0;
1278 it->wd->multi_down = EINA_FALSE;
1279 if (it->wd->mouse_down) return;
1280 _multi_touch_gesture_eval(data);
1284 _multi_move(void *data,
1285 Evas *evas __UNUSED__,
1286 Evas_Object *obj __UNUSED__,
1289 Elm_Genlist_Item *it = data;
1290 Evas_Event_Multi_Move *ev = event_info;
1292 if (it->wd->multi_device != ev->device) return;
1293 it->wd->cur_mx = ev->cur.canvas.x;
1294 it->wd->cur_my = ev->cur.canvas.y;
1298 _mouse_down(void *data,
1299 Evas *evas __UNUSED__,
1303 Elm_Genlist_Item *it = data;
1304 Evas_Event_Mouse_Down *ev = event_info;
1307 if (ev->button != 1) return;
1308 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1310 it->wd->on_hold = EINA_TRUE;
1313 it->down = EINA_TRUE;
1314 it->dragging = EINA_FALSE;
1315 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1316 it->dx = ev->canvas.x - x;
1317 it->dy = ev->canvas.y - y;
1318 it->wd->mouse_down = EINA_TRUE;
1319 if (!it->wd->multitouched)
1321 it->wd->prev_x = ev->canvas.x;
1322 it->wd->prev_y = ev->canvas.y;
1323 it->wd->multi_timeout = EINA_FALSE;
1324 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1325 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1327 it->wd->longpressed = EINA_FALSE;
1328 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1329 else it->wd->on_hold = EINA_FALSE;
1330 if (it->wd->on_hold) return;
1331 it->wd->wasselected = it->selected;
1333 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1334 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1335 if (it->long_timer) ecore_timer_del(it->long_timer);
1336 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1337 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1339 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1342 it->long_timer = NULL;
1343 it->wd->swipe = EINA_FALSE;
1344 it->wd->movements = 0;
1348 _mouse_up(void *data,
1349 Evas *evas __UNUSED__,
1350 Evas_Object *obj __UNUSED__,
1353 Elm_Genlist_Item *it = data;
1354 Evas_Event_Mouse_Up *ev = event_info;
1355 Eina_Bool dragged = EINA_FALSE;
1357 if (ev->button != 1) return;
1358 it->down = EINA_FALSE;
1359 it->wd->mouse_down = EINA_FALSE;
1360 if (it->wd->multitouched)
1362 if (it->wd->multi_down) return;
1363 _multi_touch_gesture_eval(data);
1366 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1367 else it->wd->on_hold = EINA_FALSE;
1370 ecore_timer_del(it->long_timer);
1371 it->long_timer = NULL;
1375 it->dragging = EINA_FALSE;
1376 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1379 if (it->swipe_timer)
1381 ecore_timer_del(it->swipe_timer);
1382 it->swipe_timer = NULL;
1384 if (it->wd->multi_timer)
1386 ecore_timer_del(it->wd->multi_timer);
1387 it->wd->multi_timer = NULL;
1388 it->wd->multi_timeout = EINA_FALSE;
1390 if (it->wd->on_hold)
1392 if (it->wd->swipe) _swipe(data);
1393 it->wd->longpressed = EINA_FALSE;
1394 it->wd->on_hold = EINA_FALSE;
1397 if (it->wd->longpressed)
1399 it->wd->longpressed = EINA_FALSE;
1400 if (!it->wd->wasselected)
1402 it->wd->wasselected = EINA_FALSE;
1407 if (it->want_unrealize)
1409 _item_unrealize(it);
1410 if (it->block->want_unrealize)
1411 _item_block_unrealize(it->block);
1414 if ((it->disabled) || (dragged) || (it->display_only)) return;
1415 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1423 else _item_unselect(it);
1429 Widget_Data *wd = it->wd;
1432 while (wd->selected) _item_unselect(wd->selected->data);
1437 const Eina_List *l, *l_next;
1438 Elm_Genlist_Item *it2;
1440 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1441 if (it2 != it) _item_unselect(it2);
1442 //_item_hilight(it);
1451 _signal_expand_toggle(void *data,
1452 Evas_Object *obj __UNUSED__,
1453 const char *emission __UNUSED__,
1454 const char *source __UNUSED__)
1456 Elm_Genlist_Item *it = data;
1459 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1461 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1465 _signal_expand(void *data,
1466 Evas_Object *obj __UNUSED__,
1467 const char *emission __UNUSED__,
1468 const char *source __UNUSED__)
1470 Elm_Genlist_Item *it = data;
1473 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1477 _signal_contract(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, "contract,request", it);
1489 _item_cache_clean(Widget_Data *wd)
1491 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1495 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1496 wd->item_cache = eina_inlist_remove(wd->item_cache,
1497 wd->item_cache->last);
1498 wd->item_cache_count--;
1499 if (itc->spacer) evas_object_del(itc->spacer);
1500 if (itc->base_view) evas_object_del(itc->base_view);
1501 if (itc->item_style) eina_stringshare_del(itc->item_style);
1507 _item_cache_zero(Widget_Data *wd)
1509 int pmax = wd->item_cache_max;
1510 wd->item_cache_max = 0;
1511 _item_cache_clean(wd);
1512 wd->item_cache_max = pmax;
1516 _item_cache_add(Elm_Genlist_Item *it)
1520 if (it->wd->item_cache_max <= 0)
1522 evas_object_del(it->base.view);
1523 it->base.view = NULL;
1524 evas_object_del(it->spacer);
1529 it->wd->item_cache_count++;
1530 itc = calloc(1, sizeof(Item_Cache));
1531 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1532 EINA_INLIST_GET(itc));
1533 itc->spacer = it->spacer;
1535 itc->base_view = it->base.view;
1536 it->base.view = NULL;
1537 evas_object_hide(itc->base_view);
1538 evas_object_move(itc->base_view, -9999, -9999);
1539 itc->item_style = eina_stringshare_add(it->itc->item_style);
1540 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1541 itc->compress = (it->wd->compress);
1542 itc->odd = (it->order_num_in & 0x1);
1543 itc->selected = it->selected;
1544 itc->disabled = it->disabled;
1545 itc->expanded = it->expanded;
1548 ecore_timer_del(it->long_timer);
1549 it->long_timer = NULL;
1551 if (it->swipe_timer)
1553 ecore_timer_del(it->swipe_timer);
1554 it->swipe_timer = NULL;
1556 // FIXME: other callbacks?
1557 edje_object_signal_callback_del_full(itc->base_view,
1558 "elm,action,expand,toggle",
1559 "elm", _signal_expand_toggle, it);
1560 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1562 _signal_expand, it);
1563 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1564 "elm", _signal_contract, it);
1565 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1567 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1569 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1571 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1573 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1575 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1577 _item_cache_clean(it->wd);
1581 _item_cache_find(Elm_Genlist_Item *it)
1584 Eina_Bool tree = 0, odd;
1586 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1587 odd = (it->order_num_in & 0x1);
1588 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1590 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1592 if ((itc->tree == tree) &&
1593 (itc->odd == odd) &&
1594 (itc->compress == it->wd->compress) &&
1595 (!strcmp(it->itc->item_style, itc->item_style)))
1597 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1598 EINA_INLIST_GET(itc));
1599 it->wd->item_cache_count--;
1607 _item_cache_free(Item_Cache *itc)
1609 if (itc->spacer) evas_object_del(itc->spacer);
1610 if (itc->base_view) evas_object_del(itc->base_view);
1611 if (itc->item_style) eina_stringshare_del(itc->item_style);
1616 _item_realize(Elm_Genlist_Item *it,
1620 Elm_Genlist_Item *it2;
1621 const char *stacking;
1622 const char *treesize;
1624 int depth, tsize = 20;
1625 Item_Cache *itc = NULL;
1627 if ((it->realized) || (it->delete_me)) return;
1628 it->order_num_in = in;
1631 it->nocache = EINA_FALSE;
1633 itc = _item_cache_find(it);
1636 it->base.view = itc->base_view;
1637 itc->base_view = NULL;
1638 it->spacer = itc->spacer;
1643 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1644 edje_object_scale_set(it->base.view,
1645 elm_widget_scale_get(it->base.widget) *
1646 _elm_config->scale);
1647 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1648 elm_widget_sub_object_add(it->base.widget, it->base.view);
1650 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1651 strncpy(buf, "tree", sizeof(buf));
1652 else strncpy(buf, "item", sizeof(buf));
1653 if (it->wd->compress)
1654 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1656 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1657 strncat(buf, "/", sizeof(buf) - strlen(buf));
1658 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1660 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1661 elm_widget_style_get(it->base.widget));
1662 edje_object_mirrored_set(it->base.view,
1663 elm_widget_mirrored_get(it->base.widget));
1665 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1666 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1667 elm_widget_sub_object_add(it->base.widget, it->spacer);
1669 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1671 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1673 it->expanded_depth = depth;
1674 treesize = edje_object_data_get(it->base.view, "treesize");
1675 if (treesize) tsize = atoi(treesize);
1676 evas_object_size_hint_min_set(it->spacer,
1677 (depth * tsize) * _elm_config->scale, 1);
1678 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1681 edje_object_signal_callback_add(it->base.view,
1682 "elm,action,expand,toggle",
1683 "elm", _signal_expand_toggle, it);
1684 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1685 "elm", _signal_expand, it);
1686 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1687 "elm", _signal_contract, it);
1688 stacking = edje_object_data_get(it->base.view, "stacking");
1691 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1692 else if (!strcmp(stacking, "above"))
1693 evas_object_raise(it->base.view);
1695 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1697 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1699 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1701 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1703 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1705 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1709 if (it->selected != itc->selected)
1712 edje_object_signal_emit(it->base.view,
1713 "elm,state,selected", "elm");
1715 if (it->disabled != itc->disabled)
1718 edje_object_signal_emit(it->base.view,
1719 "elm,state,disabled", "elm");
1721 if (it->expanded != itc->expanded)
1724 edje_object_signal_emit(it->base.view,
1725 "elm,state,expanded", "elm");
1731 edje_object_signal_emit(it->base.view,
1732 "elm,state,selected", "elm");
1734 edje_object_signal_emit(it->base.view,
1735 "elm,state,disabled", "elm");
1737 edje_object_signal_emit(it->base.view,
1738 "elm,state,expanded", "elm");
1742 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1744 /* homogenous genlist shortcut */
1747 it->w = it->minw = it->wd->item_width;
1748 it->h = it->minh = it->wd->item_height;
1749 it->mincalcd = EINA_TRUE;
1754 if (it->itc->func.label_get)
1760 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1762 EINA_LIST_FOREACH(it->labels, l, key)
1764 char *s = it->itc->func.label_get
1765 ((void *)it->base.data, it->base.widget, l->data);
1769 edje_object_part_text_set(it->base.view, l->data, s);
1773 edje_object_part_text_set(it->base.view, l->data, "");
1776 if (it->itc->func.icon_get)
1782 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1784 EINA_LIST_FOREACH(it->icons, l, key)
1786 Evas_Object *ic = it->itc->func.icon_get
1787 ((void *)it->base.data, it->base.widget, l->data);
1791 it->icon_objs = eina_list_append(it->icon_objs, ic);
1792 edje_object_part_swallow(it->base.view, key, ic);
1793 evas_object_show(ic);
1794 elm_widget_sub_object_add(it->base.widget, ic);
1798 if (it->itc->func.state_get)
1804 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1806 EINA_LIST_FOREACH(it->states, l, key)
1808 Eina_Bool on = it->itc->func.state_get
1809 ((void *)it->base.data, it->base.widget, l->data);
1813 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1814 edje_object_signal_emit(it->base.view, buf, "elm");
1818 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1819 edje_object_signal_emit(it->base.view, buf, "elm");
1825 Evas_Coord mw = -1, mh = -1;
1827 if (it->wd->height_for_width) mw = it->wd->w;
1829 if (!it->display_only)
1830 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1831 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1832 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1834 if (!it->display_only)
1835 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1836 it->w = it->minw = mw;
1837 it->h = it->minh = mh;
1838 it->mincalcd = EINA_TRUE;
1840 if ((!in) && (it->wd->homogeneous))
1842 it->wd->item_width = mw;
1843 it->wd->item_height = mh;
1846 if (!calc) evas_object_show(it->base.view);
1849 if (it->tooltip.content_cb)
1851 elm_widget_item_tooltip_content_cb_set(it,
1852 it->tooltip.content_cb,
1853 it->tooltip.data, NULL);
1854 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1857 if (it->mouse_cursor)
1858 elm_widget_item_cursor_set(it, it->mouse_cursor);
1860 it->realized = EINA_TRUE;
1861 it->want_unrealize = EINA_FALSE;
1863 if (itc) _item_cache_free(itc);
1864 evas_object_smart_callback_call(it->base.widget, "realized", it);
1868 _item_unrealize(Elm_Genlist_Item *it)
1872 if (!it->realized) return;
1873 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1876 ecore_timer_del(it->long_timer);
1877 it->long_timer = NULL;
1881 evas_object_del(it->base.view);
1882 it->base.view = NULL;
1883 evas_object_del(it->spacer);
1888 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1889 _item_cache_add(it);
1891 elm_widget_stringlist_free(it->labels);
1893 elm_widget_stringlist_free(it->icons);
1895 elm_widget_stringlist_free(it->states);
1897 EINA_LIST_FREE(it->icon_objs, icon)
1898 evas_object_del(icon);
1901 it->realized = EINA_FALSE;
1902 it->want_unrealize = EINA_FALSE;
1906 _item_block_recalc(Item_Block *itb,
1912 Elm_Genlist_Item *it;
1913 Evas_Coord minw = 0, minh = 0;
1914 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1918 EINA_LIST_FOREACH(itb->items, l, it)
1920 if (it->delete_me) continue;
1921 showme |= it->showme;
1926 if (!it->mincalcd) changed = EINA_TRUE;
1929 _item_realize(it, in, 1);
1930 _item_unrealize(it);
1935 _item_realize(it, in, 1);
1936 _item_unrealize(it);
1940 _item_realize(it, in, 0);
1942 if (minw < it->minw) minw = it->minw;
1950 itb->changed = EINA_FALSE;
1951 /* force an evas norender to garbage collect deleted objects */
1952 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1957 _item_block_realize(Item_Block *itb,
1962 Elm_Genlist_Item *it;
1964 if (itb->realized) return;
1965 EINA_LIST_FOREACH(itb->items, l, it)
1967 if (it->delete_me) continue;
1968 if (full) _item_realize(it, in, 0);
1971 itb->realized = EINA_TRUE;
1972 itb->want_unrealize = EINA_FALSE;
1976 _item_block_unrealize(Item_Block *itb)
1979 Elm_Genlist_Item *it;
1980 Eina_Bool dragging = EINA_FALSE;
1982 if (!itb->realized) return;
1983 EINA_LIST_FOREACH(itb->items, l, it)
1985 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1989 dragging = EINA_TRUE;
1990 it->want_unrealize = EINA_TRUE;
1993 _item_unrealize(it);
1998 itb->realized = EINA_FALSE;
1999 itb->want_unrealize = EINA_TRUE;
2002 itb->want_unrealize = EINA_FALSE;
2006 _item_block_position(Item_Block *itb,
2010 Elm_Genlist_Item *it;
2011 Elm_Genlist_Item *git;
2012 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2015 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2016 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2018 EINA_LIST_FOREACH(itb->items, l, it)
2020 if (it->delete_me) continue;
2024 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2025 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2027 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2028 cvx, cvy, cvw, cvh));
2029 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2031 if ((itb->realized) && (!it->realized))
2033 if (vis) _item_realize(it, in, 0);
2039 git = it->group_item;
2042 if (git->scrl_y < oy)
2044 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2045 git->scrl_y = (it->scrl_y + it->h) - git->h;
2046 git->want_realize = EINA_TRUE;
2048 evas_object_resize(it->base.view, it->w, it->h);
2049 evas_object_move(it->base.view,
2050 it->scrl_x, it->scrl_y);
2051 evas_object_show(it->base.view);
2055 if (!it->dragging) _item_unrealize(it);
2062 if (vis) it->want_realize = EINA_TRUE;
2069 _group_items_recalc(void *data)
2071 Widget_Data *wd = data;
2073 Elm_Genlist_Item *git;
2075 EINA_LIST_FOREACH(wd->group_items, l, git)
2077 if (git->want_realize)
2080 _item_realize(git, 0, 0);
2081 evas_object_resize(git->base.view, wd->minw, git->h);
2082 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2083 evas_object_show(git->base.view);
2084 evas_object_raise(git->base.view);
2086 else if (!git->want_realize && git->realized)
2089 _item_unrealize(git);
2095 _must_recalc_idler(void *data)
2097 Widget_Data *wd = data;
2098 if (wd->calc_job) ecore_job_del(wd->calc_job);
2099 wd->calc_job = ecore_job_add(_calc_job, wd);
2100 wd->must_recalc_idler = NULL;
2101 return ECORE_CALLBACK_CANCEL;
2105 _calc_job(void *data)
2107 Widget_Data *wd = data;
2109 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2110 Item_Block *chb = NULL;
2111 int in = 0, minw_change = 0;
2112 Eina_Bool changed = EINA_FALSE;
2114 Eina_Bool did_must_recalc = EINA_FALSE;
2117 t0 = ecore_time_get();
2118 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2122 // if (wd->height_for_width) changed = EINA_TRUE;
2125 EINA_INLIST_FOREACH(wd->blocks, itb)
2127 Eina_Bool showme = EINA_FALSE;
2130 showme = itb->showme;
2131 itb->showme = EINA_FALSE;
2134 if (itb->realized) _item_block_unrealize(itb);
2136 if ((itb->changed) || (changed) ||
2137 ((itb->must_recalc) && (!did_must_recalc)))
2139 if ((changed) || (itb->must_recalc))
2142 Elm_Genlist_Item *it;
2143 EINA_LIST_FOREACH(itb->items, l, it)
2144 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2145 itb->changed = EINA_TRUE;
2146 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2147 itb->must_recalc = EINA_FALSE;
2149 if (itb->realized) _item_block_unrealize(itb);
2150 showme = _item_block_recalc(itb, in, 0, 1);
2156 if (minw == -1) minw = itb->minw;
2157 else if ((!itb->must_recalc) && (minw < itb->minw))
2166 if ((showme) && (wd->show_item))
2168 wd->show_item->showme = EINA_FALSE;
2170 elm_smart_scroller_region_bring_in(wd->scr,
2172 wd->show_item->block->x,
2174 wd->show_item->block->y,
2175 wd->show_item->block->w,
2178 elm_smart_scroller_child_region_show(wd->scr,
2180 wd->show_item->block->x,
2182 wd->show_item->block->y,
2183 wd->show_item->block->w,
2185 wd->show_item = NULL;
2190 EINA_INLIST_FOREACH(wd->blocks, itb)
2196 if ((chb) && (EINA_INLIST_GET(chb)->next))
2198 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2200 if (itb->realized) _item_block_unrealize(itb);
2203 wd->realminw = minw;
2204 if (minw < wd->w) minw = wd->w;
2205 if ((minw != wd->minw) || (minh != wd->minh))
2209 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2210 _sizing_eval(wd->obj);
2211 if ((wd->anchor_item) && (wd->anchor_item->block))
2213 Elm_Genlist_Item *it;
2216 it = wd->anchor_item;
2217 it_y = wd->anchor_y;
2218 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2219 it->block->y + it->y + it_y);
2220 wd->anchor_item = it;
2221 wd->anchor_y = it_y;
2224 t = ecore_time_get();
2225 if (did_must_recalc)
2227 if (!wd->must_recalc_idler)
2228 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2230 wd->calc_job = NULL;
2231 evas_object_smart_changed(wd->pan_smart);
2235 _update_job(void *data)
2237 Widget_Data *wd = data;
2240 int num, num0, position = 0, recalc = 0;
2242 wd->update_job = NULL;
2244 EINA_INLIST_FOREACH(wd->blocks, itb)
2246 Evas_Coord itminw, itminh;
2247 Elm_Genlist_Item *it;
2253 _item_block_position(itb, num);
2258 EINA_LIST_FOREACH(itb->items, l2, it)
2265 it->updateme = EINA_FALSE;
2268 _item_unrealize(it);
2269 _item_realize(it, num, 0);
2274 _item_realize(it, num, 1);
2275 _item_unrealize(it);
2277 if ((it->minw != itminw) || (it->minh != itminh))
2282 itb->updateme = EINA_FALSE;
2286 itb->changed = EINA_TRUE;
2287 _item_block_recalc(itb, num0, 0, 1);
2288 _item_block_position(itb, num0);
2293 if (wd->calc_job) ecore_job_del(wd->calc_job);
2294 wd->calc_job = ecore_job_add(_calc_job, wd);
2299 _pan_set(Evas_Object *obj,
2303 Pan *sd = evas_object_smart_data_get(obj);
2306 // Evas_Coord ow, oh;
2307 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2308 // ow = sd->wd->minw - ow;
2309 // if (ow < 0) ow = 0;
2310 // oh = sd->wd->minh - oh;
2311 // if (oh < 0) oh = 0;
2312 // if (x < 0) x = 0;
2313 // if (y < 0) y = 0;
2314 // if (x > ow) x = ow;
2315 // if (y > oh) y = oh;
2316 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2320 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2322 if ((itb->y + itb->h) > y)
2324 Elm_Genlist_Item *it;
2327 EINA_LIST_FOREACH(itb->items, l2, it)
2329 if ((itb->y + it->y) >= y)
2331 sd->wd->anchor_item = it;
2332 sd->wd->anchor_y = -(itb->y + it->y - y);
2339 evas_object_smart_changed(obj);
2343 _pan_get(Evas_Object *obj,
2347 Pan *sd = evas_object_smart_data_get(obj);
2349 if (x) *x = sd->wd->pan_x;
2350 if (y) *y = sd->wd->pan_y;
2354 _pan_max_get(Evas_Object *obj,
2358 Pan *sd = evas_object_smart_data_get(obj);
2361 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2362 ow = sd->wd->minw - ow;
2364 oh = sd->wd->minh - oh;
2371 _pan_min_get(Evas_Object *obj __UNUSED__,
2380 _pan_child_size_get(Evas_Object *obj,
2384 Pan *sd = evas_object_smart_data_get(obj);
2386 if (w) *w = sd->wd->minw;
2387 if (h) *h = sd->wd->minh;
2391 _pan_add(Evas_Object *obj)
2394 Evas_Object_Smart_Clipped_Data *cd;
2397 cd = evas_object_smart_data_get(obj);
2400 sd->__clipped_data = *cd;
2402 evas_object_smart_data_set(obj, sd);
2406 _pan_del(Evas_Object *obj)
2408 Pan *sd = evas_object_smart_data_get(obj);
2413 ecore_job_del(sd->resize_job);
2414 sd->resize_job = NULL;
2420 _pan_resize_job(void *data)
2423 _sizing_eval(sd->wd->obj);
2424 sd->resize_job = NULL;
2428 _pan_resize(Evas_Object *obj,
2432 Pan *sd = evas_object_smart_data_get(obj);
2435 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2436 if ((ow == w) && (oh == h)) return;
2437 if ((sd->wd->height_for_width) && (ow != w))
2439 if (sd->resize_job) ecore_job_del(sd->resize_job);
2440 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2442 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2443 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2447 _pan_calculate(Evas_Object *obj)
2449 Pan *sd = evas_object_smart_data_get(obj);
2451 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2453 Elm_Genlist_Item *git;
2456 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2457 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2458 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2460 git->want_realize = EINA_FALSE;
2462 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2464 itb->w = sd->wd->minw;
2465 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2466 itb->y - sd->wd->pan_y + oy,
2468 cvx, cvy, cvw, cvh))
2470 if ((!itb->realized) || (itb->changed))
2471 _item_block_realize(itb, in, 0);
2472 _item_block_position(itb, in);
2476 if (itb->realized) _item_block_unrealize(itb);
2480 _group_items_recalc(sd->wd);
2484 _pan_move(Evas_Object *obj,
2485 Evas_Coord x __UNUSED__,
2486 Evas_Coord y __UNUSED__)
2488 Pan *sd = evas_object_smart_data_get(obj);
2490 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2491 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2495 _hold_on(void *data __UNUSED__,
2497 void *event_info __UNUSED__)
2499 Widget_Data *wd = elm_widget_data_get(obj);
2501 elm_smart_scroller_hold_set(wd->scr, 1);
2505 _hold_off(void *data __UNUSED__,
2507 void *event_info __UNUSED__)
2509 Widget_Data *wd = elm_widget_data_get(obj);
2511 elm_smart_scroller_hold_set(wd->scr, 0);
2515 _freeze_on(void *data __UNUSED__,
2517 void *event_info __UNUSED__)
2519 Widget_Data *wd = elm_widget_data_get(obj);
2521 elm_smart_scroller_freeze_set(wd->scr, 1);
2525 _freeze_off(void *data __UNUSED__,
2527 void *event_info __UNUSED__)
2529 Widget_Data *wd = elm_widget_data_get(obj);
2531 elm_smart_scroller_freeze_set(wd->scr, 0);
2535 _scroll_edge_left(void *data,
2536 Evas_Object *scr __UNUSED__,
2537 void *event_info __UNUSED__)
2539 Evas_Object *obj = data;
2540 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2544 _scroll_edge_right(void *data,
2545 Evas_Object *scr __UNUSED__,
2546 void *event_info __UNUSED__)
2548 Evas_Object *obj = data;
2549 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2553 _scroll_edge_top(void *data,
2554 Evas_Object *scr __UNUSED__,
2555 void *event_info __UNUSED__)
2557 Evas_Object *obj = data;
2558 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2562 _scroll_edge_bottom(void *data,
2563 Evas_Object *scr __UNUSED__,
2564 void *event_info __UNUSED__)
2566 Evas_Object *obj = data;
2567 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2571 * Add a new Genlist object
2573 * @param parent The parent object
2574 * @return The new object or NULL if it cannot be created
2579 elm_genlist_add(Evas_Object *parent)
2584 Evas_Coord minw, minh;
2585 static Evas_Smart *smart = NULL;
2587 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2591 static Evas_Smart_Class sc;
2593 evas_object_smart_clipped_smart_set(&_pan_sc);
2595 sc.name = "elm_genlist_pan";
2596 sc.version = EVAS_SMART_CLASS_VERSION;
2599 sc.resize = _pan_resize;
2600 sc.move = _pan_move;
2601 sc.calculate = _pan_calculate;
2602 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2604 wd = ELM_NEW(Widget_Data);
2605 e = evas_object_evas_get(parent);
2606 if (!e) return NULL;
2607 obj = elm_widget_add(e);
2608 ELM_SET_WIDTYPE(widtype, "genlist");
2609 elm_widget_type_set(obj, "genlist");
2610 elm_widget_sub_object_add(parent, obj);
2611 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2612 elm_widget_data_set(obj, wd);
2613 elm_widget_del_hook_set(obj, _del_hook);
2614 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2615 elm_widget_theme_hook_set(obj, _theme_hook);
2616 elm_widget_can_focus_set(obj, EINA_TRUE);
2617 elm_widget_event_hook_set(obj, _event_hook);
2619 wd->scr = elm_smart_scroller_add(e);
2620 elm_smart_scroller_widget_set(wd->scr, obj);
2621 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2622 elm_widget_style_get(obj));
2623 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2624 _elm_config->thumbscroll_bounce_enable);
2625 elm_widget_resize_object_set(obj, wd->scr);
2627 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2628 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2630 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2631 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2635 wd->mode = ELM_LIST_SCROLL;
2636 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2637 wd->item_cache_max = wd->max_items_per_block * 2;
2638 wd->longpress_timeout = _elm_config->longpress_timeout;
2640 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2641 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2642 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2643 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2645 wd->pan_smart = evas_object_smart_add(e, smart);
2646 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2649 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2650 _pan_set, _pan_get, _pan_max_get,
2651 _pan_min_get, _pan_child_size_get);
2653 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2655 evas_object_size_hint_min_set(obj, minw, minh);
2657 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2662 static Elm_Genlist_Item *
2663 _item_new(Widget_Data *wd,
2664 const Elm_Genlist_Item_Class *itc,
2666 Elm_Genlist_Item *parent,
2667 Elm_Genlist_Item_Flags flags,
2669 const void *func_data)
2671 Elm_Genlist_Item *it;
2673 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2674 if (!it) return NULL;
2677 it->base.data = data;
2678 it->parent = parent;
2680 it->func.func = func;
2681 it->func.data = func_data;
2682 it->mouse_cursor = NULL;
2683 it->expanded_depth = 0;
2688 _item_block_add(Widget_Data *wd,
2689 Elm_Genlist_Item *it)
2691 Item_Block *itb = NULL;
2698 itb = calloc(1, sizeof(Item_Block));
2701 if (!it->rel->block)
2704 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2705 itb->items = eina_list_append(itb->items, it);
2711 wd->blocks = eina_inlist_prepend_relative
2712 (wd->blocks, EINA_INLIST_GET(itb),
2713 EINA_INLIST_GET(it->rel->block));
2715 eina_list_prepend_relative(itb->items, it, it->rel);
2719 wd->blocks = eina_inlist_append_relative
2720 (wd->blocks, EINA_INLIST_GET(itb),
2721 EINA_INLIST_GET(it->rel->block));
2723 eina_list_append_relative(itb->items, it, it->rel);
2733 itb = (Item_Block *)(wd->blocks);
2734 if (itb->count >= wd->max_items_per_block)
2736 itb = calloc(1, sizeof(Item_Block));
2740 eina_inlist_prepend(wd->blocks,
2741 EINA_INLIST_GET(itb));
2746 itb = calloc(1, sizeof(Item_Block));
2750 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2752 itb->items = eina_list_prepend(itb->items, it);
2758 itb = (Item_Block *)(wd->blocks->last);
2759 if (itb->count >= wd->max_items_per_block)
2761 itb = calloc(1, sizeof(Item_Block));
2765 eina_inlist_append(wd->blocks,
2766 EINA_INLIST_GET(itb));
2771 itb = calloc(1, sizeof(Item_Block));
2775 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2777 itb->items = eina_list_append(itb->items, it);
2783 itb = it->rel->block;
2784 if (!itb) goto newblock;
2786 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2788 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2791 itb->changed = EINA_TRUE;
2793 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2794 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2797 it->rel->relcount--;
2798 if ((it->rel->delete_me) && (!it->rel->relcount))
2802 if (itb->count > itb->wd->max_items_per_block)
2806 Elm_Genlist_Item *it2;
2808 newc = itb->count / 2;
2809 itb2 = calloc(1, sizeof(Item_Block));
2813 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2814 EINA_INLIST_GET(itb));
2815 itb2->changed = EINA_TRUE;
2816 while ((itb->count > newc) && (itb->items))
2820 l = eina_list_last(itb->items);
2822 itb->items = eina_list_remove_list(itb->items, l);
2825 itb2->items = eina_list_prepend(itb2->items, it2);
2833 _queue_process(Widget_Data *wd,
2837 Eina_Bool showme = EINA_FALSE;
2840 t0 = ecore_time_get();
2841 for (n = 0; (wd->queue) && (n < 128); n++)
2843 Elm_Genlist_Item *it;
2845 it = wd->queue->data;
2846 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2847 it->queued = EINA_FALSE;
2848 _item_block_add(wd, it);
2849 t = ecore_time_get();
2850 if (it->block->changed)
2852 showme = _item_block_recalc(it->block, it->block->num, 1,
2854 it->block->changed = 0;
2856 if (showme) it->block->showme = EINA_TRUE;
2857 if (eina_inlist_count(wd->blocks) > 1)
2859 if ((t - t0) > (ecore_animator_frametime_get())) break;
2866 _item_idler(void *data)
2868 Widget_Data *wd = data;
2871 //static double q_start = 0.0;
2872 //if (q_start == 0.0) q_start = ecore_time_get();
2875 if (_queue_process(wd, 1) > 0)
2877 if (wd->calc_job) ecore_job_del(wd->calc_job);
2878 wd->calc_job = ecore_job_add(_calc_job, wd);
2883 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2885 wd->queue_idler = NULL;
2886 return ECORE_CALLBACK_CANCEL;
2888 return ECORE_CALLBACK_RENEW;
2892 _item_queue(Widget_Data *wd,
2893 Elm_Genlist_Item *it)
2895 if (it->queued) return;
2896 it->queued = EINA_TRUE;
2897 wd->queue = eina_list_append(wd->queue, it);
2898 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2900 if (wd->queue_idler)
2902 ecore_idler_del(wd->queue_idler);
2903 wd->queue_idler = NULL;
2905 _queue_process(wd, 0);
2907 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2911 * Append item to the end of the genlist
2913 * This appends the given item to the end of the list or the end of
2914 * the children if the parent is given.
2916 * @param obj The genlist object
2917 * @param itc The item class for the item
2918 * @param data The item data
2919 * @param parent The parent item, or NULL if none
2920 * @param flags Item flags
2921 * @param func Convenience function called when item selected
2922 * @param func_data Data passed to @p func above.
2923 * @return A handle to the item added or NULL if not possible
2927 EAPI Elm_Genlist_Item *
2928 elm_genlist_item_append(Evas_Object *obj,
2929 const Elm_Genlist_Item_Class *itc,
2931 Elm_Genlist_Item *parent,
2932 Elm_Genlist_Item_Flags flags,
2934 const void *func_data)
2936 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2937 Widget_Data *wd = elm_widget_data_get(obj);
2938 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2940 if (!wd) return NULL;
2941 if (!it) return NULL;
2944 if (flags & ELM_GENLIST_ITEM_GROUP)
2945 wd->group_items = eina_list_append(wd->group_items, it);
2946 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2951 Elm_Genlist_Item *it2 = NULL;
2952 Eina_List *ll = eina_list_last(it->parent->items);
2953 if (ll) it2 = ll->data;
2954 it->parent->items = eina_list_append(it->parent->items, it);
2955 if (!it2) it2 = it->parent;
2957 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2958 EINA_INLIST_GET(it2));
2960 it->rel->relcount++;
2962 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2963 it->group_item = parent;
2964 else if (it->parent->group_item)
2965 it->group_item = it->parent->group_item;
2967 it->before = EINA_FALSE;
2968 _item_queue(wd, it);
2973 * Prepend item at start of the genlist
2975 * This adds an item to the beginning of the list or beginning of the
2976 * children of the parent if given.
2978 * @param obj The genlist object
2979 * @param itc The item class for the item
2980 * @param data The item data
2981 * @param parent The parent item, or NULL if none
2982 * @param flags Item flags
2983 * @param func Convenience function called when item selected
2984 * @param func_data Data passed to @p func above.
2985 * @return A handle to the item added or NULL if not possible
2989 EAPI Elm_Genlist_Item *
2990 elm_genlist_item_prepend(Evas_Object *obj,
2991 const Elm_Genlist_Item_Class *itc,
2993 Elm_Genlist_Item *parent,
2994 Elm_Genlist_Item_Flags flags,
2996 const void *func_data)
2998 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2999 Widget_Data *wd = elm_widget_data_get(obj);
3000 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3002 if (!wd) return NULL;
3003 if (!it) return NULL;
3006 if (flags & ELM_GENLIST_ITEM_GROUP)
3007 wd->group_items = eina_list_prepend(wd->group_items, it);
3008 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3013 Elm_Genlist_Item *it2 = NULL;
3014 Eina_List *ll = it->parent->items;
3015 if (ll) it2 = ll->data;
3016 it->parent->items = eina_list_prepend(it->parent->items, it);
3017 if (!it2) it2 = it->parent;
3019 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3020 EINA_INLIST_GET(it2));
3022 it->rel->relcount++;
3024 it->before = EINA_TRUE;
3025 _item_queue(wd, it);
3030 * Insert item before another in the genlist
3032 * This inserts an item before another in the list. It will be in the
3033 * same tree level or group as the item it is inseted before.
3035 * @param obj The genlist object
3036 * @param itc The item class for the item
3037 * @param data The item data
3038 * @param before The item to insert before
3039 * @param flags Item flags
3040 * @param func Convenience function called when item selected
3041 * @param func_data Data passed to @p func above.
3042 * @return A handle to the item added or NULL if not possible
3046 EAPI Elm_Genlist_Item *
3047 elm_genlist_item_insert_before(Evas_Object *obj,
3048 const Elm_Genlist_Item_Class *itc,
3050 Elm_Genlist_Item *parent,
3051 Elm_Genlist_Item *before,
3052 Elm_Genlist_Item_Flags flags,
3054 const void *func_data)
3056 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3057 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3058 Widget_Data *wd = elm_widget_data_get(obj);
3059 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3061 if (!wd) return NULL;
3062 if (!it) return NULL;
3065 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3068 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3069 EINA_INLIST_GET(before));
3071 it->rel->relcount++;
3072 it->before = EINA_TRUE;
3073 _item_queue(wd, it);
3078 * Insert an item after another in the genlst
3080 * This inserts an item after another in the list. It will be in the
3081 * same tree level or group as the item it is inseted after.
3083 * @param obj The genlist object
3084 * @param itc The item class for the item
3085 * @param data The item data
3086 * @param after The item to insert after
3087 * @param flags Item flags
3088 * @param func Convenience function called when item selected
3089 * @param func_data Data passed to @p func above.
3090 * @return A handle to the item added or NULL if not possible
3094 EAPI Elm_Genlist_Item *
3095 elm_genlist_item_insert_after(Evas_Object *obj,
3096 const Elm_Genlist_Item_Class *itc,
3098 Elm_Genlist_Item *parent,
3099 Elm_Genlist_Item *after,
3100 Elm_Genlist_Item_Flags flags,
3102 const void *func_data)
3104 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3105 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3106 Widget_Data *wd = elm_widget_data_get(obj);
3107 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3109 if (!wd) return NULL;
3110 if (!it) return NULL;
3111 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3112 EINA_INLIST_GET(after));
3115 it->parent->items = eina_list_append_relative(it->parent->items, it,
3119 it->rel->relcount++;
3120 it->before = EINA_FALSE;
3121 _item_queue(wd, it);
3128 * This clears all items in the list, leaving it empty.
3130 * @param obj The genlist object
3135 elm_genlist_clear(Evas_Object *obj)
3137 ELM_CHECK_WIDTYPE(obj, widtype);
3138 Widget_Data *wd = elm_widget_data_get(obj);
3140 if (wd->walking > 0)
3142 Elm_Genlist_Item *it;
3144 wd->clear_me = EINA_TRUE;
3145 EINA_INLIST_FOREACH(wd->items, it)
3147 it->delete_me = EINA_TRUE;
3151 wd->clear_me = EINA_FALSE;
3154 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3156 if (wd->anchor_item == it)
3158 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3159 if (!wd->anchor_item)
3161 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3163 wd->items = eina_inlist_remove(wd->items, wd->items);
3164 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3165 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3166 elm_widget_item_pre_notify_del(it);
3167 if (it->realized) _item_unrealize(it);
3168 if (it->itc->func.del)
3169 it->itc->func.del((void *)it->base.data, it->base.widget);
3170 if (it->long_timer) ecore_timer_del(it->long_timer);
3171 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3172 elm_widget_item_del(it);
3174 wd->anchor_item = NULL;
3177 Item_Block *itb = (Item_Block *)(wd->blocks);
3179 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3180 if (itb->items) eina_list_free(itb->items);
3185 ecore_job_del(wd->calc_job);
3186 wd->calc_job = NULL;
3188 if (wd->queue_idler)
3190 ecore_idler_del(wd->queue_idler);
3191 wd->queue_idler = NULL;
3193 if (wd->must_recalc_idler)
3195 ecore_idler_del(wd->must_recalc_idler);
3196 wd->must_recalc_idler = NULL;
3200 eina_list_free(wd->queue);
3205 eina_list_free(wd->selected);
3206 wd->selected = NULL;
3208 wd->show_item = NULL;
3215 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3216 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3222 * Enable or disable multi-select in the genlist
3224 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3225 * the list. This allows more than 1 item to be selected.
3227 * @param obj The genlist object
3228 * @param multi Multi-select enable/disable
3233 elm_genlist_multi_select_set(Evas_Object *obj,
3236 ELM_CHECK_WIDTYPE(obj, widtype);
3237 Widget_Data *wd = elm_widget_data_get(obj);
3243 * Gets if multi-select in genlist is enable or disable
3245 * @param obj The genlist object
3246 * @return Multi-select enable/disable
3247 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3252 elm_genlist_multi_select_get(const Evas_Object *obj)
3254 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3255 Widget_Data *wd = elm_widget_data_get(obj);
3256 if (!wd) return EINA_FALSE;
3261 * Get the selectd item in the genlist
3263 * This gets the selected item in the list (if multi-select is enabled
3264 * only the first item in the list is selected - which is not very
3265 * useful, so see elm_genlist_selected_items_get() for when
3266 * multi-select is used).
3268 * If no item is selected, NULL is returned.
3270 * @param obj The genlist object
3271 * @return The selected item, or NULL if none.
3275 EAPI Elm_Genlist_Item *
3276 elm_genlist_selected_item_get(const Evas_Object *obj)
3278 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3279 Widget_Data *wd = elm_widget_data_get(obj);
3280 if (!wd) return NULL;
3281 if (wd->selected) return wd->selected->data;
3286 * Get a list of selected items in the genlist
3288 * This returns a list of the selected items. This list pointer is
3289 * only valid so long as no items are selected or unselected (or
3290 * unselected implicitly by deletion). The list contains
3291 * Elm_Genlist_Item pointers.
3293 * @param obj The genlist object
3294 * @return The list of selected items, nor NULL if none are selected.
3298 EAPI const Eina_List *
3299 elm_genlist_selected_items_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 return wd->selected;
3308 * Get a list of realized items in genlist
3310 * This returns a list of the realized items in the genlist. The list
3311 * contains Elm_Genlist_Item pointers. The list must be freed by the
3312 * caller when done with eina_list_free(). The item pointers in the
3313 * list are only valid so long as those items are not deleted or the
3314 * genlist is not deleted.
3316 * @param obj The genlist object
3317 * @return The list of realized items, nor NULL if none are realized.
3322 elm_genlist_realized_items_get(const Evas_Object *obj)
3324 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3325 Widget_Data *wd = elm_widget_data_get(obj);
3326 Eina_List *list = NULL;
3328 Eina_Bool done = EINA_FALSE;
3329 if (!wd) return NULL;
3330 EINA_INLIST_FOREACH(wd->blocks, itb)
3335 Elm_Genlist_Item *it;
3338 EINA_LIST_FOREACH(itb->items, l, it)
3340 if (it->realized) list = eina_list_append(list, it);
3352 * Get the item that is at the x, y canvas coords
3354 * This returns the item at the given coordinates (which are canvas
3355 * relative not object-relative). If an item is at that coordinate,
3356 * that item handle is returned, and if @p posret is not NULL, the
3357 * integer pointed to is set to a value of -1, 0 or 1, depending if
3358 * the coordinate is on the upper portion of that item (-1), on the
3359 * middle section (0) or on the lower part (1). If NULL is returned as
3360 * an item (no item found there), then posret may indicate -1 or 1
3361 * based if the coordinate is above or below all items respectively in
3364 * @param it The item
3365 * @param x The input x coordinate
3366 * @param y The input y coordinate
3367 * @param posret The position relative to the item returned here
3368 * @return The item at the coordinates or NULL if none
3372 EAPI Elm_Genlist_Item *
3373 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3378 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3379 Widget_Data *wd = elm_widget_data_get(obj);
3380 Evas_Coord ox, oy, ow, oh;
3383 if (!wd) return NULL;
3384 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3386 EINA_INLIST_FOREACH(wd->blocks, itb)
3389 Elm_Genlist_Item *it;
3391 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3392 oy + itb->y - itb->wd->pan_y,
3393 itb->w, itb->h, x, y, 1, 1))
3395 EINA_LIST_FOREACH(itb->items, l, it)
3397 Evas_Coord itx, ity;
3399 itx = ox + itb->x + it->x - itb->wd->pan_x;
3400 ity = oy + itb->y + it->y - itb->wd->pan_y;
3401 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3405 if (y <= (ity + (it->h / 4))) *posret = -1;
3406 else if (y >= (ity + it->h - (it->h / 4)))
3412 lasty = ity + it->h;
3417 if (y > lasty) *posret = 1;
3424 * Get the first item in the genlist
3426 * This returns the first item in the list.
3428 * @param obj The genlist object
3429 * @return The first item, or NULL if none
3433 EAPI Elm_Genlist_Item *
3434 elm_genlist_first_item_get(const Evas_Object *obj)
3436 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3437 Widget_Data *wd = elm_widget_data_get(obj);
3438 if (!wd) return NULL;
3439 if (!wd->items) return NULL;
3440 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3441 while ((it) && (it->delete_me))
3442 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3447 * Get the last item in the genlist
3449 * This returns the last item in the list.
3451 * @return The last item, or NULL if none
3455 EAPI Elm_Genlist_Item *
3456 elm_genlist_last_item_get(const Evas_Object *obj)
3458 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3459 Widget_Data *wd = elm_widget_data_get(obj);
3460 if (!wd) return NULL;
3461 if (!wd->items) return NULL;
3462 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3463 while ((it) && (it->delete_me))
3464 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3469 * Get the next item in the genlist
3471 * This returns the item after the item @p it.
3473 * @param it The item
3474 * @return The item after @p it, or NULL if none
3478 EAPI Elm_Genlist_Item *
3479 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3481 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3484 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3485 if ((it) && (!it->delete_me)) break;
3487 return (Elm_Genlist_Item *)it;
3491 * Get the previous item in the genlist
3493 * This returns the item before the item @p it.
3495 * @param it The item
3496 * @return The item before @p it, or NULL if none
3500 EAPI Elm_Genlist_Item *
3501 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3503 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3506 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3507 if ((it) && (!it->delete_me)) break;
3509 return (Elm_Genlist_Item *)it;
3513 * Get the genlist object from an item
3515 * This returns the genlist object itself that an item belongs to.
3517 * @param it The item
3518 * @return The genlist object
3523 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3525 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3526 return it->base.widget;
3530 * Get the parent item of the given item
3532 * This returns the parent item of the item @p it given.
3534 * @param it The item
3535 * @return The parent of the item or NULL if none
3539 EAPI Elm_Genlist_Item *
3540 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3542 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3547 * Clear all sub-items (children) of the given item
3549 * This clears all items that are children (or their descendants) of the
3552 * @param it The item
3557 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3559 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3560 Eina_List *tl = NULL, *l;
3561 Elm_Genlist_Item *it2;
3563 EINA_LIST_FOREACH(it->items, l, it2)
3564 tl = eina_list_append(tl, it2);
3565 EINA_LIST_FREE(tl, it2)
3566 elm_genlist_item_del(it2);
3570 * Set the selected state of an item
3572 * This sets the selected state (1 selected, 0 not selected) of the given
3575 * @param it The item
3576 * @param selected The selected state
3581 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3584 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3585 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3587 if (it->delete_me) return;
3588 selected = !!selected;
3589 if (it->selected == selected) return;
3595 while (wd->selected)
3596 _item_unselect(wd->selected->data);
3606 * Get the selected state of an item
3608 * This gets the selected state of an item (1 selected, 0 not selected).
3610 * @param it The item
3611 * @return The selected state
3616 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3618 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3619 return it->selected;
3623 * Sets the expanded state of an item (if it's a parent)
3625 * This expands or contracts a parent item (thus showing or hiding the
3628 * @param it The item
3629 * @param expanded The expanded state (1 expanded, 0 not expanded).
3634 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3637 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3638 if (it->expanded == expanded) return;
3639 it->expanded = expanded;
3643 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3644 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3649 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3650 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3655 * Get the expanded state of an item
3657 * This gets the expanded state of an item
3659 * @param it The item
3660 * @return Thre expanded state
3665 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3667 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3668 return it->expanded;
3672 * Get the depth of expanded item
3674 * @param it The genlist item object
3675 * @return The depth of expanded item
3680 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3682 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3683 return it->expanded_depth;
3687 * Sets the disabled state of an item.
3689 * A disabled item cannot be selected or unselected. It will also
3690 * change appearance to appear disabled. This sets the disabled state
3691 * (1 disabled, 0 not disabled).
3693 * @param it The item
3694 * @param disabled The disabled state
3699 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3702 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3703 if (it->disabled == disabled) return;
3704 if (it->delete_me) return;
3705 it->disabled = disabled;
3709 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3711 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3716 * Get the disabled state of an item
3718 * This gets the disabled state of the given item.
3720 * @param it The item
3721 * @return The disabled state
3726 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3728 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3729 if (it->delete_me) return EINA_FALSE;
3730 return it->disabled;
3734 * Sets the display only state of an item.
3736 * A display only item cannot be selected or unselected. It is for
3737 * display only and not selecting or otherwise clicking, dragging
3738 * etc. by the user, thus finger size rules will not be applied to
3741 * @param it The item
3742 * @param display_only The display only state
3747 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3748 Eina_Bool display_only)
3750 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3751 if (!it->block) return;
3752 if (it->display_only == display_only) return;
3753 if (it->delete_me) return;
3754 it->display_only = display_only;
3755 it->mincalcd = EINA_FALSE;
3756 it->updateme = EINA_TRUE;
3757 it->block->updateme = EINA_TRUE;
3758 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3759 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3763 * Get the display only state of an item
3765 * This gets the display only state of the given item.
3767 * @param it The item
3768 * @return The display only state
3773 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3775 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3776 if (it->delete_me) return EINA_FALSE;
3777 return it->display_only;
3781 * Show the given item
3783 * This causes genlist to jump to the given item @p it and show it (by
3784 * scrolling), if it is not fully visible.
3786 * @param it The item
3791 elm_genlist_item_show(Elm_Genlist_Item *it)
3793 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3794 Evas_Coord gith = 0;
3795 if (it->delete_me) return;
3796 if ((it->queued) || (!it->mincalcd))
3798 it->wd->show_item = it;
3799 it->wd->bring_in = EINA_TRUE;
3800 it->showme = EINA_TRUE;
3803 if (it->wd->show_item)
3805 it->wd->show_item->showme = EINA_FALSE;
3806 it->wd->show_item = NULL;
3808 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3809 gith = it->group_item->h;
3810 elm_smart_scroller_child_region_show(it->wd->scr,
3811 it->x + it->block->x,
3812 it->y + it->block->y - gith,
3813 it->block->w, it->h);
3817 * Bring in the given item
3819 * This causes genlist to jump to the given item @p it and show it (by
3820 * scrolling), if it is not fully visible. This may use animation to
3821 * do so and take a period of time
3823 * @param it The item
3828 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3830 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3831 Evas_Coord gith = 0;
3832 if (it->delete_me) return;
3833 if ((it->queued) || (!it->mincalcd))
3835 it->wd->show_item = it;
3836 it->wd->bring_in = EINA_TRUE;
3837 it->showme = EINA_TRUE;
3840 if (it->wd->show_item)
3842 it->wd->show_item->showme = EINA_FALSE;
3843 it->wd->show_item = NULL;
3845 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3846 gith = it->group_item->h;
3847 elm_smart_scroller_region_bring_in(it->wd->scr,
3848 it->x + it->block->x,
3849 it->y + it->block->y - gith,
3850 it->block->w, it->h);
3854 * Show the given item at the top
3856 * This causes genlist to jump to the given item @p it and show it (by
3857 * scrolling), if it is not fully visible.
3859 * @param it The item
3864 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3866 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3868 Evas_Coord gith = 0;
3870 if (it->delete_me) return;
3871 if ((it->queued) || (!it->mincalcd))
3873 it->wd->show_item = it;
3874 it->wd->bring_in = EINA_TRUE;
3875 it->showme = EINA_TRUE;
3878 if (it->wd->show_item)
3880 it->wd->show_item->showme = EINA_FALSE;
3881 it->wd->show_item = NULL;
3883 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3884 if (it->group_item) gith = it->group_item->h;
3885 elm_smart_scroller_child_region_show(it->wd->scr,
3886 it->x + it->block->x,
3887 it->y + it->block->y - gith,
3892 * Bring in the given item at the top
3894 * This causes genlist to jump to the given item @p it and show it (by
3895 * scrolling), if it is not fully visible. This may use animation to
3896 * do so and take a period of time
3898 * @param it The item
3903 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3905 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3907 Evas_Coord gith = 0;
3909 if (it->delete_me) return;
3910 if ((it->queued) || (!it->mincalcd))
3912 it->wd->show_item = it;
3913 it->wd->bring_in = EINA_TRUE;
3914 it->showme = EINA_TRUE;
3917 if (it->wd->show_item)
3919 it->wd->show_item->showme = EINA_FALSE;
3920 it->wd->show_item = NULL;
3922 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3923 if (it->group_item) gith = it->group_item->h;
3924 elm_smart_scroller_region_bring_in(it->wd->scr,
3925 it->x + it->block->x,
3926 it->y + it->block->y - gith,
3931 * Show the given item at the middle
3933 * This causes genlist to jump to the given item @p it and show it (by
3934 * scrolling), if it is not fully visible.
3936 * @param it The item
3941 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3943 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3946 if (it->delete_me) return;
3947 if ((it->queued) || (!it->mincalcd))
3949 it->wd->show_item = it;
3950 it->wd->bring_in = EINA_TRUE;
3951 it->showme = EINA_TRUE;
3954 if (it->wd->show_item)
3956 it->wd->show_item->showme = EINA_FALSE;
3957 it->wd->show_item = NULL;
3959 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3960 elm_smart_scroller_child_region_show(it->wd->scr,
3961 it->x + it->block->x,
3962 it->y + it->block->y - oh / 2 +
3963 it->h / 2, it->block->w, oh);
3967 * Bring in the given item at the middle
3969 * This causes genlist to jump to the given item @p it and show it (by
3970 * scrolling), if it is not fully visible. This may use animation to
3971 * do so and take a period of time
3973 * @param it The item
3978 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3980 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3983 if (it->delete_me) return;
3984 if ((it->queued) || (!it->mincalcd))
3986 it->wd->show_item = it;
3987 it->wd->bring_in = EINA_TRUE;
3988 it->showme = EINA_TRUE;
3991 if (it->wd->show_item)
3993 it->wd->show_item->showme = EINA_FALSE;
3994 it->wd->show_item = NULL;
3996 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3997 elm_smart_scroller_region_bring_in(it->wd->scr,
3998 it->x + it->block->x,
3999 it->y + it->block->y - oh / 2 + it->h / 2,
4004 * Delete a given item
4006 * This deletes the item from genlist and calls the genlist item del
4007 * class callback defined in the item class, if it is set. This clears all
4008 * subitems if it is a tree.
4010 * @param it The item
4015 elm_genlist_item_del(Elm_Genlist_Item *it)
4017 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4018 if ((it->relcount > 0) || (it->walking > 0))
4020 elm_widget_item_pre_notify_del(it);
4021 elm_genlist_item_subitems_clear(it);
4022 it->delete_me = EINA_TRUE;
4023 if (it->wd->show_item == it) it->wd->show_item = NULL;
4025 it->wd->selected = eina_list_remove(it->wd->selected,
4029 if (it->realized) _item_unrealize(it);
4030 it->block->changed = EINA_TRUE;
4031 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4032 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4034 if (it->itc->func.del)
4035 it->itc->func.del((void *)it->base.data, it->base.widget);
4042 * Set the data item from the genlist item
4044 * This set the data value passed on the elm_genlist_item_append() and
4045 * related item addition calls. This function will also call
4046 * elm_genlist_item_update() so the item will be updated to reflect the
4049 * @param it The item
4050 * @param data The new data pointer to set
4055 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4058 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4059 elm_widget_item_data_set(it, data);
4060 elm_genlist_item_update(it);
4064 * Get the data item from the genlist item
4066 * This returns the data value passed on the elm_genlist_item_append()
4067 * and related item addition calls and elm_genlist_item_data_set().
4069 * @param it The item
4070 * @return The data pointer provided when created
4075 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4077 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4078 return elm_widget_item_data_get(it);
4082 * Tells genlist to "orphan" icons fetchs by the item class
4084 * This instructs genlist to release references to icons in the item,
4085 * meaning that they will no longer be managed by genlist and are
4086 * floating "orphans" that can be re-used elsewhere if the user wants
4089 * @param it The item
4094 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4097 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4098 EINA_LIST_FREE(it->icon_objs, icon)
4100 elm_widget_sub_object_del(it->base.widget, icon);
4101 evas_object_smart_member_del(icon);
4102 evas_object_hide(icon);
4107 * Get the real evas object of the genlist item
4109 * This returns the actual evas object used for the specified genlist
4110 * item. This may be NULL as it may not be created, and may be deleted
4111 * at any time by genlist. Do not modify this object (move, resize,
4112 * show, hide etc.) as genlist is controlling it. This function is for
4113 * querying, emitting custom signals or hooking lower level callbacks
4114 * for events. Do not delete this object under any circumstances.
4116 * @param it The item
4117 * @return The object pointer
4121 EAPI const Evas_Object *
4122 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4124 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4125 return it->base.view;
4129 * Update the contents of an item
4131 * This updates an item by calling all the item class functions again
4132 * to get the icons, labels and states. Use this when the original
4133 * item data has changed and the changes are desired to be reflected.
4135 * @param it The item
4140 elm_genlist_item_update(Elm_Genlist_Item *it)
4142 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4143 if (!it->block) return;
4144 if (it->delete_me) return;
4145 it->mincalcd = EINA_FALSE;
4146 it->updateme = EINA_TRUE;
4147 it->block->updateme = EINA_TRUE;
4148 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4149 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4153 * Update the item class of an item
4155 * @param it The item
4156 * @parem itc The item class for the item
4161 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4162 const Elm_Genlist_Item_Class *itc)
4164 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4165 if (!it->block) return;
4166 EINA_SAFETY_ON_NULL_RETURN(itc);
4167 if (it->delete_me) return;
4169 it->nocache = EINA_TRUE;
4170 elm_genlist_item_update(it);
4173 static Evas_Object *
4174 _elm_genlist_item_label_create(void *data,
4176 void *item __UNUSED__)
4178 Evas_Object *label = elm_label_add(obj);
4181 elm_object_style_set(label, "tooltip");
4182 elm_label_label_set(label, data);
4187 _elm_genlist_item_label_del_cb(void *data,
4188 Evas_Object *obj __UNUSED__,
4189 void *event_info __UNUSED__)
4191 eina_stringshare_del(data);
4195 * Set the text to be shown in the genlist item.
4197 * @param item Target item
4198 * @param text The text to set in the content
4200 * Setup the text as tooltip to object. The item can have only one
4201 * tooltip, so any previous tooltip data is removed.
4206 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4209 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4210 text = eina_stringshare_add(text);
4211 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4213 _elm_genlist_item_label_del_cb);
4217 * Set the content to be shown in the tooltip item
4219 * Setup the tooltip to item. The item can have only one tooltip, so
4220 * any previous tooltip data is removed. @p func(with @p data) will be
4221 * called every time that need to show the tooltip and it should return a
4222 * valid Evas_Object. This object is then managed fully by tooltip
4223 * system and is deleted when the tooltip is gone.
4225 * @param item the genlist item being attached by a tooltip.
4226 * @param func the function used to create the tooltip contents.
4227 * @param data what to provide to @a func as callback data/context.
4228 * @param del_cb called when data is not needed anymore, either when
4229 * another callback replaces @func, the tooltip is unset with
4230 * elm_genlist_item_tooltip_unset() or the owner @a item
4231 * dies. This callback receives as the first parameter the
4232 * given @a data, and @c event_info is the item.
4237 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4238 Elm_Tooltip_Item_Content_Cb func,
4240 Evas_Smart_Cb del_cb)
4242 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4244 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4247 if (item->tooltip.del_cb)
4248 item->tooltip.del_cb((void *)item->tooltip.data,
4249 item->base.widget, item);
4251 item->tooltip.content_cb = func;
4252 item->tooltip.data = data;
4253 item->tooltip.del_cb = del_cb;
4255 if (item->base.view)
4257 elm_widget_item_tooltip_content_cb_set(item,
4258 item->tooltip.content_cb,
4259 item->tooltip.data, NULL);
4260 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4266 if (del_cb) del_cb((void *)data, NULL, NULL);
4270 * Unset tooltip from item
4272 * @param item genlist item to remove previously set tooltip.
4274 * Remove tooltip from item. The callback provided as del_cb to
4275 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4276 * it is not used anymore.
4278 * @see elm_genlist_item_tooltip_content_cb_set()
4283 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4285 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4286 if ((item->base.view) && (item->tooltip.content_cb))
4287 elm_widget_item_tooltip_unset(item);
4289 if (item->tooltip.del_cb)
4290 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4291 item->tooltip.del_cb = NULL;
4292 item->tooltip.content_cb = NULL;
4293 item->tooltip.data = NULL;
4294 if (item->tooltip.style)
4295 elm_genlist_item_tooltip_style_set(item, NULL);
4299 * Sets a different style for this item tooltip.
4301 * @note before you set a style you should define a tooltip with
4302 * elm_genlist_item_tooltip_content_cb_set() or
4303 * elm_genlist_item_tooltip_text_set()
4305 * @param item genlist item with tooltip already set.
4306 * @param style the theme style to use (default, transparent, ...)
4311 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4315 eina_stringshare_replace(&item->tooltip.style, style);
4316 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4320 * Get the style for this item tooltip.
4322 * @param item genlist item with tooltip already set.
4323 * @return style the theme style in use, defaults to "default". If the
4324 * object does not have a tooltip set, then NULL is returned.
4329 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4331 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4332 return item->tooltip.style;
4336 * Set the cursor to be shown when mouse is over the genlist item
4338 * @param item Target item
4339 * @param cursor the cursor name to be used.
4341 * @see elm_object_cursor_set()
4345 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4348 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4349 eina_stringshare_replace(&item->mouse_cursor, cursor);
4350 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4354 * Get the cursor to be shown when mouse is over the genlist item
4356 * @param item genlist item with cursor already set.
4357 * @return the cursor name.
4362 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4364 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4365 return elm_widget_item_cursor_get(item);
4369 * Unset the cursor to be shown when mouse is over the genlist item
4371 * @param item Target item
4373 * @see elm_object_cursor_unset()
4377 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4379 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4380 if (!item->mouse_cursor)
4383 if (item->base.view)
4384 elm_widget_item_cursor_unset(item);
4386 eina_stringshare_del(item->mouse_cursor);
4387 item->mouse_cursor = NULL;
4391 * Sets a different style for this item cursor.
4393 * @note before you set a style you should define a cursor with
4394 * elm_genlist_item_cursor_set()
4396 * @param item genlist item with cursor already set.
4397 * @param style the theme style to use (default, transparent, ...)
4402 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4405 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4406 elm_widget_item_cursor_style_set(item, style);
4410 * Get the style for this item cursor.
4412 * @param item genlist item with cursor already set.
4413 * @return style the theme style in use, defaults to "default". If the
4414 * object does not have a cursor set, then NULL is returned.
4419 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4421 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4422 return elm_widget_item_cursor_style_get(item);
4426 * Set if the cursor set should be searched on the theme or should use
4427 * the provided by the engine, only.
4429 * @note before you set if should look on theme you should define a
4430 * cursor with elm_object_cursor_set(). By default it will only look
4431 * for cursors provided by the engine.
4433 * @param item widget item with cursor already set.
4434 * @param engine_only boolean to define it cursors should be looked
4435 * only between the provided by the engine or searched on widget's
4441 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4442 Eina_Bool engine_only)
4444 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4445 elm_widget_item_cursor_engine_only_set(item, engine_only);
4449 * Get the cursor engine only usage for this item cursor.
4451 * @param item widget item with cursor already set.
4452 * @return engine_only boolean to define it cursors should be looked
4453 * only between the provided by the engine or searched on widget's
4454 * theme as well. If the object does not have a cursor set, then
4455 * EINA_FALSE is returned.
4460 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4462 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4463 return elm_widget_item_cursor_engine_only_get(item);
4467 * This sets the horizontal stretching mode
4469 * This sets the mode used for sizing items horizontally. Valid modes
4470 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4471 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4472 * the scroller will scroll horizontally. Otherwise items are expanded
4473 * to fill the width of the viewport of the scroller. If it is
4474 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4475 * limited to that size.
4477 * @param obj The genlist object
4478 * @param mode The mode to use
4483 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4486 ELM_CHECK_WIDTYPE(obj, widtype);
4487 Widget_Data *wd = elm_widget_data_get(obj);
4489 if (wd->mode == mode) return;
4495 * Gets the horizontal stretching mode
4497 * @param obj The genlist object
4498 * @return The mode to use
4499 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4504 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4506 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4507 Widget_Data *wd = elm_widget_data_get(obj);
4508 if (!wd) return ELM_LIST_LAST;
4513 * Set the always select mode.
4515 * Items will only call their selection func and callback when first
4516 * becoming selected. Any further clicks will do nothing, unless you
4517 * enable always select with elm_genlist_always_select_mode_set().
4518 * This means even if selected, every click will make the selected
4519 * callbacks be called.
4521 * @param obj The genlist object
4522 * @param always_select The always select mode
4523 * (EINA_TRUE = on, EINA_FALSE = off)
4528 elm_genlist_always_select_mode_set(Evas_Object *obj,
4529 Eina_Bool always_select)
4531 ELM_CHECK_WIDTYPE(obj, widtype);
4532 Widget_Data *wd = elm_widget_data_get(obj);
4534 wd->always_select = always_select;
4538 * Get the always select mode.
4540 * @param obj The genlist object
4541 * @return The always select mode
4542 * (EINA_TRUE = on, EINA_FALSE = off)
4547 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4549 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4550 Widget_Data *wd = elm_widget_data_get(obj);
4551 if (!wd) return EINA_FALSE;
4552 return wd->always_select;
4556 * Set no select mode
4558 * This will turn off the ability to select items entirely and they
4559 * will neither appear selected nor call selected callback functions.
4561 * @param obj The genlist object
4562 * @param no_select The no select mode
4563 * (EINA_TRUE = on, EINA_FALSE = off)
4568 elm_genlist_no_select_mode_set(Evas_Object *obj,
4569 Eina_Bool no_select)
4571 ELM_CHECK_WIDTYPE(obj, widtype);
4572 Widget_Data *wd = elm_widget_data_get(obj);
4574 wd->no_select = no_select;
4578 * Gets no select mode
4580 * @param obj The genlist object
4581 * @return The no select mode
4582 * (EINA_TRUE = on, EINA_FALSE = off)
4587 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4589 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4590 Widget_Data *wd = elm_widget_data_get(obj);
4591 if (!wd) return EINA_FALSE;
4592 return wd->no_select;
4598 * This will enable the compress mode where items are "compressed"
4599 * horizontally to fit the genlist scrollable viewport width. This is
4600 * special for genlist. Do not rely on
4601 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4602 * work as genlist needs to handle it specially.
4604 * @param obj The genlist object
4605 * @param compress The compress mode
4606 * (EINA_TRUE = on, EINA_FALSE = off)
4611 elm_genlist_compress_mode_set(Evas_Object *obj,
4614 ELM_CHECK_WIDTYPE(obj, widtype);
4615 Widget_Data *wd = elm_widget_data_get(obj);
4617 wd->compress = compress;
4621 * Get the compress mode
4623 * @param obj The genlist object
4624 * @return The compress mode
4625 * (EINA_TRUE = on, EINA_FALSE = off)
4630 elm_genlist_compress_mode_get(const Evas_Object *obj)
4632 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4633 Widget_Data *wd = elm_widget_data_get(obj);
4634 if (!wd) return EINA_FALSE;
4635 return wd->compress;
4639 * Set height-for-width mode
4641 * With height-for-width mode the item width will be fixed (restricted
4642 * to a minimum of) to the list width when calculating its size in
4643 * order to allow the height to be calculated based on it. This allows,
4644 * for instance, text block to wrap lines if the Edje part is
4645 * configured with "text.min: 0 1".
4647 * @note This mode will make list resize slower as it will have to
4648 * recalculate every item height again whenever the list width
4651 * @note When height-for-width mode is enabled, it also enables
4652 * compress mode (see elm_genlist_compress_mode_set()) and
4653 * disables homogeneous (see elm_genlist_homogeneous_set()).
4655 * @param obj The genlist object
4656 * @param setting The height-for-width mode (EINA_TRUE = on,
4662 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4663 Eina_Bool height_for_width)
4665 ELM_CHECK_WIDTYPE(obj, widtype);
4666 Widget_Data *wd = elm_widget_data_get(obj);
4668 wd->height_for_width = !!height_for_width;
4669 if (wd->height_for_width)
4671 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4672 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4677 * Get the height-for-width mode
4679 * @param obj The genlist object
4680 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4686 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4688 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4689 Widget_Data *wd = elm_widget_data_get(obj);
4690 if (!wd) return EINA_FALSE;
4691 return wd->height_for_width;
4697 * This will enable or disable the scroller bounce mode for the
4698 * genlist. See elm_scroller_bounce_set() for details
4700 * @param obj The genlist object
4701 * @param h_bounce Allow bounce horizontally
4702 * @param v_bounce Allow bounce vertically
4707 elm_genlist_bounce_set(Evas_Object *obj,
4711 ELM_CHECK_WIDTYPE(obj, widtype);
4712 Widget_Data *wd = elm_widget_data_get(obj);
4714 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4718 * Get the bounce mode
4720 * @param obj The genlist object
4721 * @param h_bounce Allow bounce horizontally
4722 * @param v_bounce Allow bounce vertically
4727 elm_genlist_bounce_get(const Evas_Object *obj,
4728 Eina_Bool *h_bounce,
4729 Eina_Bool *v_bounce)
4731 ELM_CHECK_WIDTYPE(obj, widtype);
4732 Widget_Data *wd = elm_widget_data_get(obj);
4734 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4738 * Set homogenous mode
4740 * This will enable the homogeneous mode where items are of the same
4741 * height and width so that genlist may do the lazy-loading at its
4742 * maximum. This implies 'compressed' mode.
4744 * @param obj The genlist object
4745 * @param homogeneous Assume the items within the genlist are of the
4746 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4751 elm_genlist_homogeneous_set(Evas_Object *obj,
4752 Eina_Bool homogeneous)
4754 ELM_CHECK_WIDTYPE(obj, widtype);
4755 Widget_Data *wd = elm_widget_data_get(obj);
4757 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4758 wd->homogeneous = homogeneous;
4762 * Get the homogenous mode
4764 * @param obj The genlist object
4765 * @return Assume the items within the genlist are of the same height
4766 * and width (EINA_TRUE = on, EINA_FALSE = off)
4771 elm_genlist_homogeneous_get(const Evas_Object *obj)
4773 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4774 Widget_Data *wd = elm_widget_data_get(obj);
4775 if (!wd) return EINA_FALSE;
4776 return wd->homogeneous;
4780 * Set the maximum number of items within an item block
4782 * This will configure the block count to tune to the target with
4783 * particular performance matrix.
4785 * @param obj The genlist object
4786 * @param n Maximum number of items within an item block
4791 elm_genlist_block_count_set(Evas_Object *obj,
4794 ELM_CHECK_WIDTYPE(obj, widtype);
4795 Widget_Data *wd = elm_widget_data_get(obj);
4797 wd->max_items_per_block = n;
4798 wd->item_cache_max = wd->max_items_per_block * 2;
4799 _item_cache_clean(wd);
4803 * Get the maximum number of items within an item block
4805 * @param obj The genlist object
4806 * @return Maximum number of items within an item block
4811 elm_genlist_block_count_get(const Evas_Object *obj)
4813 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4814 Widget_Data *wd = elm_widget_data_get(obj);
4816 return wd->max_items_per_block;
4820 * Set the timeout in seconds for the longpress event
4822 * @param obj The genlist object
4823 * @param timeout timeout in seconds
4828 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4831 ELM_CHECK_WIDTYPE(obj, widtype);
4832 Widget_Data *wd = elm_widget_data_get(obj);
4834 wd->longpress_timeout = timeout;
4838 * Get the timeout in seconds for the longpress event
4840 * @param obj The genlist object
4841 * @return timeout in seconds
4846 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4848 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4849 Widget_Data *wd = elm_widget_data_get(obj);
4851 return wd->longpress_timeout;
4855 * Set the scrollbar policy
4857 * This sets the scrollbar visibility policy for the given genlist
4858 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
4859 * made visible if it is needed, and otherwise kept hidden.
4860 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
4861 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
4862 * respectively for the horizontal and vertical scrollbars.
4864 * @param obj The genlist object
4865 * @param policy_h Horizontal scrollbar policy
4866 * @param policy_v Vertical scrollbar policy
4871 elm_genlist_scroller_policy_set(Evas_Object *obj,
4872 Elm_Scroller_Policy policy_h,
4873 Elm_Scroller_Policy policy_v)
4875 ELM_CHECK_WIDTYPE(obj, widtype);
4876 Widget_Data *wd = elm_widget_data_get(obj);
4878 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4879 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4882 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4886 * Get the scrollbar policy
4888 * @param obj The genlist object
4889 * @param policy_h Horizontal scrollbar policy
4890 * @param policy_v Vertical scrollbar policy
4895 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4896 Elm_Scroller_Policy *policy_h,
4897 Elm_Scroller_Policy *policy_v)
4899 ELM_CHECK_WIDTYPE(obj, widtype);
4900 Widget_Data *wd = elm_widget_data_get(obj);
4901 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4902 if ((!wd) || (!wd->scr)) return;
4903 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4904 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4905 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;