1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
7 #define LONGPRESS_TIMEOUT 1.0
10 * @defgroup Genlist Genlist
12 * The aim was to have more expansive list than the simple list in
13 * Elementary that could have more flexible items and allow many more entries
14 * while still being fast and low on memory usage. At the same time it was
15 * also made to be able to do tree structures. But the price to pay is more
16 * complex when it comes to usage. If all you want is a simple list with
17 * icons and a single label, use the normal List object.
19 * Signals that you can add callbacks for are:
21 * clicked - This is called when a user has double-clicked an item. The
22 * event_info parameter is the genlist item that was double-clicked.
24 * selected - This is called when a user has made an item selected. The
25 * event_info parameter is the genlist item that was selected.
27 * unselected - This is called when a user has made an item unselected. The
28 * event_info parameter is the genlist item that was unselected.
30 * expanded - This is called when elm_genlist_item_expanded_set() is called
31 * and the item is now meant to be expanded. The event_info parameter is the
32 * genlist item that was indicated to expand. It is the job of this callback
33 * to then fill in the child items.
35 * contracted - This is called when elm_genlist_item_expanded_set() is called
36 * and the item is now meant to be contracted. The event_info parameter is
37 * the genlist item that was indicated to contract. It is the job of this
38 * callback to then delete the child items.
40 * expand,request - This is called when a user has indicated they want to
41 * expand a tree branch item. The callback should decide if the item can
42 * expand (has any children) and then call elm_genlist_item_expanded_set()
43 * appropriately to set the state. The event_info parameter is the genlist
44 * item that was indicated to expand.
46 * contract,request - This is called when a user has indicated they want to
47 * contract a tree branch item. The callback should decide if the item can
48 * contract (has any children) and then call elm_genlist_item_expanded_set()
49 * appropriately to set the state. The event_info parameter is the genlist
50 * item that was indicated to contract.
52 * realized - This is called when the item in the list is created as a real
53 * evas object. event_info parameter is the genlist item that was created.
54 * The object may be deleted at any time, so it is up to the caller to
55 * not use the object pointer from elm_genlist_item_object_get() in a way
56 * where it may point to freed objects.
58 * unrealized - This is called just before an item is unrealized. After
59 * this call icon objects provided will be deleted and the item object
60 * itself delete or be put into a floating cache.
62 * drag,start,up - This is called when the item in the list has been dragged
65 * drag,start,down - This is called when the item in the list has been dragged
66 * (not scrolled) down.
68 * drag,start,left - This is called when the item in the list has been dragged
69 * (not scrolled) left.
71 * drag,start,right - This is called when the item in the list has been dragged
72 * (not scrolled) right.
74 * drag,stop - This is called when the item in the list has stopped being
77 * drag - This is called when the item in the list is being dragged.
79 * longpressed - This is called when the item is pressed for a certain amount
80 * of time. By default it's 1 second.
82 * scroll,edge,top - This is called when the genlist is scrolled until the top
85 * scroll,edge,bottom - This is called when the genlist is scrolled until the
88 * scroll,edge,left - This is called when the genlist is scrolled until the
91 * scroll,edge,right - This is called when the genlist is scrolled until the
94 * multi,swipe,left - This is called when the genlist is multi-touch swiped
97 * multi,swipe,right - This is called when the genlist is multi-touch swiped
100 * multi,swipe,up - This is called when the genlist is multi-touch swiped
103 * multi,swipe,down - This is called when the genlist is multi-touch swiped
106 * multi,pinch,out - This is called when the genlist is multi-touch pinched
109 * multi,pinch,in - This is called when the genlist is multi-touch pinched
112 * Genlist has a fairly large API, mostly because it's relatively complex,
113 * trying to be both expansive, powerful and efficient. First we will begin
114 * an overview on the theory behind genlist.
116 * Evas tracks every object you create. Every time it processes an event
117 * (mouse move, down, up etc.) it needs to walk through objects and find out
118 * what event that affects. Even worse every time it renders display updates,
119 * in order to just calculate what to re-draw, it needs to walk through many
120 * many many objects. Thus, the more objects you keep active, the more
121 * overhead Evas has in just doing its work. It is advisable to keep your
122 * active objects to the minimum working set you need. Also remember that
123 * object creation and deletion carries an overhead, so there is a
124 * middle-ground, which is not easily determined. But don't keep massive lists
125 * of objects you can't see or use. Genlist does this with list objects. It
126 * creates and destroys them dynamically as you scroll around. It groups them
127 * into blocks so it can determine the visibility etc. of a whole block at
128 * once as opposed to having to walk the whole list. This 2-level list allows
129 * for very large numbers of items to be in the list (tests have used up to
130 * 2,000,000 items). Also genlist employs a queue for adding items. As items
131 * may be different sizes, every item added needs to be calculated as to its
132 * size and thus this presents a lot of overhead on populating the list, this
133 * genlist employs a queue. Any item added is queued and spooled off over
134 * time, actually appearing some time later, so if your list has many members
135 * you may find it takes a while for them to all appear, with your process
136 * consuming a lot of CPU while it is busy spooling.
138 * Genlist also implements a tree structure, but it does so with callbacks to
139 * the application, with the application filling in tree structures when
140 * requested (allowing for efficient building of a very deep tree that could
141 * even be used for file-management). See the above smart signal callbacks for
144 * An item in the genlist world can have 0 or more text labels (they can be
145 * regular text or textblock – that's up to the style to determine), 0 or
146 * more icons (which are simply objects swallowed into the genlist item) and
147 * 0 or more boolean states that can be used for check, radio or other
148 * indicators by the edje theme style. An item may be one of several styles
149 * (Elementary provides 4 by default - “default”, “double_label”, "group_index"
150 * and "icon_top_text_bottom", but this can be extended by system or
151 * application custom themes/overlays/extensions).
153 * In order to implement the ability to add and delete items on the fly,
154 * Genlist implements a class/callback system where the application provides
155 * a structure with information about that type of item (genlist may contain
156 * multiple different items with different classes, states and styles).
157 * Genlist will call the functions in this struct (methods) when an item is
158 * “realized” (that is created dynamically while scrolling). All objects will
159 * simply be deleted when no longer needed with evas_object_del(). The
160 * Elm_Genlist_Item_Class structure contains the following members:
162 * item_style - This is a constant string and simply defines the name of the
163 * item style. It must be specified and the default should be “default”.
165 * func.label_get - This function is called when an actual item object is
166 * created. The data parameter is the data parameter passed to
167 * elm_genlist_item_append() and related item creation functions. The obj
168 * parameter is the genlist object and the part parameter is the string name
169 * of the text part in the edje design that is listed as one of the possible
170 * labels that can be set. This function must return a strudup()'ed string as
171 * the caller will free() it when done.
173 * func.icon_get - This function is called when an actual item object is
174 * created. The data parameter is the data parameter passed to
175 * elm_genlist_item_append() and related item creation functions. The obj
176 * parameter is the genlist object and the part parameter is the string name
177 * of the icon part in the edje design that is listed as one of the possible
178 * icons that can be set. This must return NULL for no object or a valid
179 * object. The object will be deleted by genlist on shutdown or when the item
182 * func.state_get - This function is called when an actual item object is
183 * created. The data parameter is the data parameter passed to
184 * elm_genlist_item_append() and related item creation functions. The obj
185 * parameter is the genlist object and the part parameter is the string name
186 * of the state part in the edje design that is listed as one of the possible
187 * states that can be set. Return 0 for false or 1 for true. Genlist will
188 * emit a signal to the edje object with “elm,state,XXX,active” “elm” when
189 * true (the default is false), where XXX is the name of the part.
191 * func.del - This is called when elm_genlist_item_del() is called on an
192 * item, elm_genlist_clear() is called on the genlist, or
193 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
194 * intended for use when actual genlist items are deleted, so any backing
195 * data attached to the item (e.g. its data parameter on creation) can be
198 * Items can be added by several calls. All of them return a Elm_Genlist_Item
199 * handle that is an internal member inside the genlist. They all take a data
200 * parameter that is meant to be used for a handle to the applications
201 * internal data (eg the struct with the original item data). The parent
202 * parameter is the parent genlist item this belongs to if it is a tree or
203 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
204 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
205 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
206 * is displayed as an item that is able to expand and have child items.
207 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
208 * displayed at the top until the next group comes. The func parameter is a
209 * convenience callback that is called when the item is selected and the data
210 * parameter will be the func_data parameter, obj be the genlist object and
211 * event_info will be the genlist item.
213 * elm_genlist_item_append() appends an item to the end of the list, or if
214 * there is a parent, to the end of all the child items of the parent.
215 * elm_genlist_item_prepend() is the same but prepends to the beginning of
216 * the list or children list. elm_genlist_item_insert_before() inserts at
217 * item before another item and elm_genlist_item_insert_after() inserts after
218 * the indicated item.
220 * The application can clear the list with elm_genlist_clear() which deletes
221 * all the items in the list and elm_genlist_item_del() will delete a specific
222 * item. elm_genlist_item_subitems_clear() will clear all items that are
223 * children of the indicated parent item.
225 * If the application wants multiple items to be able to be selected,
226 * elm_genlist_multi_select_set() can enable this. If the list is
227 * single-selection only (the default), then elm_genlist_selected_item_get()
228 * will return the selected item, if any, or NULL I none is selected. If the
229 * list is multi-select then elm_genlist_selected_items_get() will return a
230 * list (that is only valid as long as no items are modified (added, deleted,
231 * selected or unselected)).
233 * To help inspect list items you can jump to the item at the top of the list
234 * with elm_genlist_first_item_get() which will return the item pointer, and
235 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
236 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
237 * and previous items respectively relative to the indicated item. Using
238 * these calls you can walk the entire item list/tree. Note that as a tree
239 * the items are flattened in the list, so elm_genlist_item_parent_get() will
240 * let you know which item is the parent (and thus know how to skip them if
243 * There are also convenience functions. elm_genlist_item_genlist_get() will
244 * return the genlist object the item belongs to. elm_genlist_item_show()
245 * will make the scroller scroll to show that specific item so its visible.
246 * elm_genlist_item_data_get() returns the data pointer set by the item
247 * creation functions.
249 * If an item changes (state of boolean changes, label or icons change),
250 * then use elm_genlist_item_update() to have genlist update the item with
251 * the new state. Genlist will re-realize the item thus call the functions
252 * in the _Elm_Genlist_Item_Class for that item.
254 * To programmatically (un)select an item use elm_genlist_item_selected_set().
255 * To get its selected state use elm_genlist_item_selected_get(). Similarly
256 * to expand/contract an item and get its expanded state, use
257 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
258 * again to make an item disabled (unable to be selected and appear
259 * differently) use elm_genlist_item_disabled_set() to set this and
260 * elm_genlist_item_disabled_get() to get the disabled state.
262 * In general to indicate how the genlist should expand items horizontally to
263 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
264 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
265 * mode means that if items are too wide to fit, the scroller will scroll
266 * horizontally. Otherwise items are expanded to fill the width of the
267 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
268 * to the viewport width and limited to that size. This can be combined with
269 * a different style that uses edjes' ellipsis feature (cutting text off like
272 * Items will only call their selection func and callback when first becoming
273 * selected. Any further clicks will do nothing, unless you enable always
274 * select with elm_genlist_always_select_mode_set(). This means even if
275 * selected, every click will make the selected callbacks be called.
276 * elm_genlist_no_select_mode_set() will turn off the ability to select
277 * items entirely and they will neither appear selected nor call selected
278 * callback functions.
280 * Remember that you can create new styles and add your own theme augmentation
281 * per application with elm_theme_extension_add(). If you absolutely must
282 * have a specific style that overrides any theme the user or system sets up
283 * you can use elm_theme_overlay_add() to add such a file.
286 typedef struct _Widget_Data Widget_Data;
287 typedef struct _Item_Block Item_Block;
288 typedef struct _Pan Pan;
289 typedef struct _Item_Cache Item_Cache;
293 Evas_Object *obj, *scr, *pan_smart;
294 Eina_Inlist *items, *blocks;
295 Eina_List *group_items;
297 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
298 Ecore_Job *calc_job, *update_job;
299 Ecore_Idler *queue_idler;
300 Ecore_Idler *must_recalc_idler;
301 Eina_List *queue, *selected;
302 Elm_Genlist_Item *show_item;
303 Elm_Genlist_Item *last_selected_item;
304 Eina_Inlist *item_cache;
305 Elm_Genlist_Item *anchor_item;
308 Ecore_Timer *multi_timer;
309 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
310 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
311 Eina_Bool mouse_down : 1;
312 Eina_Bool multi_down : 1;
313 Eina_Bool multi_timeout : 1;
314 Eina_Bool multitouched : 1;
315 Eina_Bool on_hold : 1;
317 Eina_Bool always_select : 1;
318 Eina_Bool longpressed : 1;
319 Eina_Bool wasselected : 1;
320 Eina_Bool no_select : 1;
321 Eina_Bool bring_in : 1;
322 Eina_Bool compress : 1;
323 Eina_Bool height_for_width : 1;
324 Eina_Bool homogeneous : 1;
325 Eina_Bool clear_me : 1;
330 } history[SWIPE_MOVES];
332 int item_cache_count;
338 int max_items_per_block;
339 double longpress_timeout;
349 Evas_Coord x, y, w, h, minw, minh;
350 Eina_Bool want_unrealize : 1;
351 Eina_Bool realized : 1;
352 Eina_Bool changed : 1;
353 Eina_Bool updateme : 1;
354 Eina_Bool showme : 1;
355 Eina_Bool must_recalc : 1;
358 struct _Elm_Genlist_Item
360 Elm_Widget_Item base;
365 Evas_Coord x, y, w, h, minw, minh;
366 const Elm_Genlist_Item_Class *itc;
367 Elm_Genlist_Item *parent;
368 Elm_Genlist_Item *group_item;
369 Elm_Genlist_Item_Flags flags;
377 Eina_List *labels, *icons, *states, *icon_objs;
378 Ecore_Timer *long_timer;
379 Ecore_Timer *swipe_timer;
381 Evas_Coord scrl_x, scrl_y;
383 Elm_Genlist_Item *rel;
388 Elm_Tooltip_Item_Content_Cb content_cb;
389 Evas_Smart_Cb del_cb;
393 const char *mouse_cursor;
400 Eina_Bool before : 1;
402 Eina_Bool want_unrealize : 1;
403 Eina_Bool want_realize : 1;
404 Eina_Bool realized : 1;
405 Eina_Bool selected : 1;
406 Eina_Bool hilighted : 1;
407 Eina_Bool expanded : 1;
408 Eina_Bool disabled : 1;
409 Eina_Bool display_only : 1;
410 Eina_Bool mincalcd : 1;
411 Eina_Bool queued : 1;
412 Eina_Bool showme : 1;
413 Eina_Bool delete_me : 1;
415 Eina_Bool dragging : 1;
416 Eina_Bool updateme : 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 _theme_hook(Evas_Object *obj);
449 //static void _show_region_hook(void *data, Evas_Object *obj);
450 static void _sizing_eval(Evas_Object *obj);
451 static void _item_unrealize(Elm_Genlist_Item *it);
452 static void _item_block_unrealize(Item_Block *itb);
453 static void _calc_job(void *data);
454 static void _on_focus_hook(void *data,
456 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
457 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
458 static Eina_Bool _item_single_select_up(Widget_Data *wd);
459 static Eina_Bool _item_single_select_down(Widget_Data *wd);
460 static Eina_Bool _event_hook(Evas_Object *obj,
462 Evas_Callback_Type type,
464 static Eina_Bool _deselect_all_items(Widget_Data *wd);
465 static void _pan_calculate(Evas_Object *obj);
467 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
470 _event_hook(Evas_Object *obj,
471 Evas_Object *src __UNUSED__,
472 Evas_Callback_Type type,
475 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
476 Evas_Event_Key_Down *ev = event_info;
477 Widget_Data *wd = elm_widget_data_get(obj);
478 if (!wd) return EINA_FALSE;
479 if (!wd->items) return EINA_FALSE;
480 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
481 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
483 Elm_Genlist_Item *it = NULL;
486 Evas_Coord step_x = 0;
487 Evas_Coord step_y = 0;
490 Evas_Coord page_x = 0;
491 Evas_Coord page_y = 0;
493 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
494 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
495 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
496 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
498 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
502 else if ((!strcmp(ev->keyname, "Right")) ||
503 (!strcmp(ev->keyname, "KP_Right")))
507 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
509 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
510 (_item_multi_select_up(wd)))
511 || (_item_single_select_up(wd)))
513 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
519 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
521 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
522 (_item_multi_select_down(wd)))
523 || (_item_single_select_down(wd)))
525 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
531 else if ((!strcmp(ev->keyname, "Home")) ||
532 (!strcmp(ev->keyname, "KP_Home")))
534 it = elm_genlist_first_item_get(obj);
535 elm_genlist_item_bring_in(it);
536 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
539 else if ((!strcmp(ev->keyname, "End")) ||
540 (!strcmp(ev->keyname, "KP_End")))
542 it = elm_genlist_last_item_get(obj);
543 elm_genlist_item_bring_in(it);
544 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
547 else if ((!strcmp(ev->keyname, "Prior")) ||
548 (!strcmp(ev->keyname, "KP_Prior")))
551 y -= -(page_y * v_h) / 100;
555 else if ((!strcmp(ev->keyname, "Next")) ||
556 (!strcmp(ev->keyname, "KP_Next")))
559 y += -(page_y * v_h) / 100;
563 else if(((!strcmp(ev->keyname, "Return")) ||
564 (!strcmp(ev->keyname, "KP_Enter")) ||
565 (!strcmp(ev->keyname, "space")))
566 && (!wd->multi) && (wd->selected))
568 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
569 elm_genlist_item_expanded_set(it,
570 !elm_genlist_item_expanded_get(it));
572 else if (!strcmp(ev->keyname, "Escape"))
574 if (!_deselect_all_items(wd)) return EINA_FALSE;
575 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
578 else return EINA_FALSE;
580 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
581 elm_smart_scroller_child_pos_set(wd->scr, x, y);
586 _deselect_all_items(Widget_Data *wd)
588 if (!wd->selected) return EINA_FALSE;
590 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
596 _item_multi_select_up(Widget_Data *wd)
598 if (!wd->selected) return EINA_FALSE;
599 if (!wd->multi) return EINA_FALSE;
601 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
602 if (!prev) return EINA_TRUE;
604 if (elm_genlist_item_selected_get(prev))
606 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
607 wd->last_selected_item = prev;
608 elm_genlist_item_show(wd->last_selected_item);
612 elm_genlist_item_selected_set(prev, EINA_TRUE);
613 elm_genlist_item_show(prev);
619 _item_multi_select_down(Widget_Data *wd)
621 if (!wd->selected) return EINA_FALSE;
622 if (!wd->multi) return EINA_FALSE;
624 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
625 if (!next) return EINA_TRUE;
627 if (elm_genlist_item_selected_get(next))
629 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
630 wd->last_selected_item = next;
631 elm_genlist_item_show(wd->last_selected_item);
635 elm_genlist_item_selected_set(next, EINA_TRUE);
636 elm_genlist_item_show(next);
642 _item_single_select_up(Widget_Data *wd)
644 Elm_Genlist_Item *prev;
647 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
648 while ((prev) && (prev->delete_me))
649 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
651 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
653 if (!prev) return EINA_FALSE;
655 _deselect_all_items(wd);
657 elm_genlist_item_selected_set(prev, EINA_TRUE);
658 elm_genlist_item_show(prev);
663 _item_single_select_down(Widget_Data *wd)
665 Elm_Genlist_Item *next;
668 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
669 while ((next) && (next->delete_me))
670 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
672 else next = elm_genlist_item_next_get(wd->last_selected_item);
674 if (!next) return EINA_FALSE;
676 _deselect_all_items(wd);
678 elm_genlist_item_selected_set(next, EINA_TRUE);
679 elm_genlist_item_show(next);
684 _on_focus_hook(void *data __UNUSED__,
687 Widget_Data *wd = elm_widget_data_get(obj);
689 if (elm_widget_focus_get(obj))
691 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
692 evas_object_focus_set(wd->obj, EINA_TRUE);
693 if ((wd->selected) && (!wd->last_selected_item))
694 wd->last_selected_item = eina_list_data_get(wd->selected);
698 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
699 evas_object_focus_set(wd->obj, EINA_FALSE);
704 _del_hook(Evas_Object *obj)
706 Widget_Data *wd = elm_widget_data_get(obj);
708 _item_cache_zero(wd);
709 if (wd->calc_job) ecore_job_del(wd->calc_job);
710 if (wd->update_job) ecore_job_del(wd->update_job);
711 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
712 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
717 _del_pre_hook(Evas_Object *obj)
719 Widget_Data *wd = elm_widget_data_get(obj);
721 evas_object_del(wd->pan_smart);
722 wd->pan_smart = NULL;
723 elm_genlist_clear(obj);
727 _theme_hook(Evas_Object *obj)
729 Widget_Data *wd = elm_widget_data_get(obj);
732 _item_cache_zero(wd);
733 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
734 elm_widget_style_get(obj));
735 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
736 wd->item_width = wd->item_height = 0;
737 wd->minw = wd->minh = wd->realminw = 0;
738 EINA_INLIST_FOREACH(wd->blocks, itb)
741 Elm_Genlist_Item *it;
743 if (itb->realized) _item_block_unrealize(itb);
744 EINA_LIST_FOREACH(itb->items, l, it)
745 it->mincalcd = EINA_FALSE;
747 itb->changed = EINA_TRUE;
749 if (wd->calc_job) ecore_job_del(wd->calc_job);
750 wd->calc_job = ecore_job_add(_calc_job, wd);
756 _show_region_hook(void *data, Evas_Object *obj)
758 Widget_Data *wd = elm_widget_data_get(data);
759 Evas_Coord x, y, w, h;
761 elm_widget_show_region_get(obj, &x, &y, &w, &h);
762 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
767 _sizing_eval(Evas_Object *obj)
769 Widget_Data *wd = elm_widget_data_get(obj);
770 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
772 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
773 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
775 if (wd->height_for_width)
779 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
780 if ((vw != 0) && (vw != wd->prev_viewport_w))
784 wd->prev_viewport_w = vw;
785 EINA_INLIST_FOREACH(wd->blocks, itb)
787 itb->must_recalc = EINA_TRUE;
789 if (wd->calc_job) ecore_job_del(wd->calc_job);
790 wd->calc_job = ecore_job_add(_calc_job, wd);
793 if (wd->mode == ELM_LIST_LIMIT)
795 Evas_Coord vmw, vmh, vw, vh;
799 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
800 if ((minw > 0) && (vw < minw)) vw = minw;
801 else if ((maxw > 0) && (vw > maxw))
803 edje_object_size_min_calc
804 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
811 edje_object_size_min_calc
812 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
816 evas_object_size_hint_min_set(obj, minw, minh);
817 evas_object_size_hint_max_set(obj, maxw, maxh);
821 _item_hilight(Elm_Genlist_Item *it)
823 const char *selectraise;
824 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted)) return;
825 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
826 selectraise = edje_object_data_get(it->base.view, "selectraise");
827 if ((selectraise) && (!strcmp(selectraise, "on")))
829 evas_object_raise(it->base.view);
830 if ((it->group_item) && (it->group_item->realized))
831 evas_object_raise(it->group_item->base.view);
833 it->hilighted = EINA_TRUE;
837 _item_block_del(Elm_Genlist_Item *it)
840 Item_Block *itb = it->block;
842 itb->items = eina_list_remove(itb->items, it);
844 itb->changed = EINA_TRUE;
845 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
846 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
849 il = EINA_INLIST_GET(itb);
850 Item_Block *itbn = (Item_Block *)(il->next);
852 it->parent->items = eina_list_remove(it->parent->items, it);
854 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
856 if (itbn) itbn->changed = EINA_TRUE;
862 il = EINA_INLIST_GET(itb);
863 Item_Block *itbp = (Item_Block *)(il->prev);
864 Item_Block *itbn = (Item_Block *)(il->next);
865 if ((itbp) && ((itbp->count + itb->count) < 48))
867 Elm_Genlist_Item *it2;
869 EINA_LIST_FREE(itb->items, it2)
872 itbp->items = eina_list_append(itbp->items, it2);
874 itbp->changed = EINA_TRUE;
876 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
877 EINA_INLIST_GET(itb));
880 else if ((itbn) && ((itbn->count + itb->count) < 48))
884 Eina_List *last = eina_list_last(itb->items);
885 Elm_Genlist_Item *it2 = last->data;
888 itb->items = eina_list_remove_list(itb->items, last);
889 itbn->items = eina_list_prepend(itbn->items, it2);
891 itbn->changed = EINA_TRUE;
894 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
902 _item_del(Elm_Genlist_Item *it)
904 elm_widget_item_pre_notify_del(it);
905 elm_genlist_item_subitems_clear(it);
906 it->wd->walking -= it->walking;
907 if (it->wd->show_item == it) it->wd->show_item = NULL;
908 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
909 if (it->realized) _item_unrealize(it);
910 if (it->block) _item_block_del(it);
911 if ((!it->delete_me) && (it->itc->func.del))
912 it->itc->func.del((void *)it->base.data, it->base.widget);
913 it->delete_me = EINA_TRUE;
915 it->wd->queue = eina_list_remove(it->wd->queue, it);
916 if (it->wd->anchor_item == it)
918 it->wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
919 if (!it->wd->anchor_item)
920 it->wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
922 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
924 it->parent->items = eina_list_remove(it->parent->items, it);
925 if (it->flags & ELM_GENLIST_ITEM_GROUP)
926 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
927 if (it->long_timer) ecore_timer_del(it->long_timer);
928 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
930 if (it->tooltip.del_cb)
931 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
933 elm_widget_item_del(it);
937 _item_select(Elm_Genlist_Item *it)
939 if ((it->wd->no_select) || (it->delete_me)) return;
942 if (it->wd->always_select) goto call;
945 it->selected = EINA_TRUE;
946 it->wd->selected = eina_list_append(it->wd->selected, it);
950 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
952 evas_object_smart_callback_call(it->base.widget, "selected", it);
955 if ((it->wd->clear_me) && (!it->wd->walking))
956 elm_genlist_clear(it->base.widget);
959 if ((!it->walking) && (it->delete_me))
961 if (!it->relcount) _item_del(it);
964 it->wd->last_selected_item = it;
968 _item_unselect(Elm_Genlist_Item *it)
970 const char *stacking, *selectraise;
972 if ((it->delete_me) || (!it->hilighted)) return;
973 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
974 stacking = edje_object_data_get(it->base.view, "stacking");
975 selectraise = edje_object_data_get(it->base.view, "selectraise");
976 if ((selectraise) && (!strcmp(selectraise, "on")))
978 if ((stacking) && (!strcmp(stacking, "below")))
979 evas_object_lower(it->base.view);
981 it->hilighted = EINA_FALSE;
984 it->selected = EINA_FALSE;
985 it->wd->selected = eina_list_remove(it->wd->selected, it);
986 evas_object_smart_callback_call(it->base.widget, "unselected", it);
991 _mouse_move(void *data,
992 Evas *evas __UNUSED__,
996 Elm_Genlist_Item *it = data;
997 Evas_Event_Mouse_Move *ev = event_info;
998 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1000 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1002 if (!it->wd->on_hold)
1004 it->wd->on_hold = EINA_TRUE;
1005 if (!it->wd->wasselected)
1009 if (it->wd->multitouched)
1011 it->wd->cur_x = ev->cur.canvas.x;
1012 it->wd->cur_y = ev->cur.canvas.y;
1015 if ((it->dragging) && (it->down))
1017 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1020 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1021 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1022 if (abs((it->wd->history[it->wd->movements].x -
1023 it->wd->history[0].x)) > 40)
1024 it->wd->swipe = EINA_TRUE;
1026 it->wd->movements++;
1030 ecore_timer_del(it->long_timer);
1031 it->long_timer = NULL;
1033 evas_object_smart_callback_call(it->base.widget, "drag", it);
1036 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1040 ecore_timer_del(it->long_timer);
1041 it->long_timer = NULL;
1045 if (!it->display_only)
1046 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1047 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1048 x = ev->cur.canvas.x - x;
1049 y = ev->cur.canvas.y - y;
1052 if (adx < 0) adx = -dx;
1055 if (ady < 0) ady = -dy;
1058 if ((adx > minw) || (ady > minh))
1060 it->dragging = EINA_TRUE;
1063 ecore_timer_del(it->long_timer);
1064 it->long_timer = NULL;
1066 if (!it->wd->wasselected)
1071 evas_object_smart_callback_call(it->base.widget,
1072 "drag,start,up", it);
1076 evas_object_smart_callback_call(it->base.widget,
1077 "drag,start,left", it);
1079 evas_object_smart_callback_call(it->base.widget,
1080 "drag,start,right", it);
1086 evas_object_smart_callback_call(it->base.widget,
1087 "drag,start,down", it);
1091 evas_object_smart_callback_call(it->base.widget,
1092 "drag,start,left", it);
1094 evas_object_smart_callback_call(it->base.widget,
1095 "drag,start,right", it);
1102 _long_press(void *data)
1104 Elm_Genlist_Item *it = data;
1106 it->long_timer = NULL;
1107 if ((it->disabled) || (it->dragging) || (it->display_only))
1108 return ECORE_CALLBACK_CANCEL;
1109 it->wd->longpressed = EINA_TRUE;
1110 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1111 return ECORE_CALLBACK_CANCEL;
1115 _swipe(Elm_Genlist_Item *it)
1120 it->wd->swipe = EINA_FALSE;
1121 for (i = 0; i < it->wd->movements; i++)
1123 sum += it->wd->history[i].x;
1124 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1127 sum /= it->wd->movements;
1128 if (abs(sum - it->wd->history[0].x) <= 10) return;
1129 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1133 _swipe_cancel(void *data)
1135 Elm_Genlist_Item *it = data;
1137 if (!it) return ECORE_CALLBACK_CANCEL;
1138 it->wd->swipe = EINA_FALSE;
1139 it->wd->movements = 0;
1140 return ECORE_CALLBACK_RENEW;
1144 _multi_cancel(void *data)
1146 Widget_Data *wd = data;
1148 if (!wd) return ECORE_CALLBACK_CANCEL;
1149 wd->multi_timeout = EINA_TRUE;
1150 return ECORE_CALLBACK_RENEW;
1154 _multi_touch_gesture_eval(void *data)
1156 Elm_Genlist_Item *it = data;
1158 it->wd->multitouched = EINA_FALSE;
1159 if (it->wd->multi_timer)
1161 ecore_timer_del(it->wd->multi_timer);
1162 it->wd->multi_timer = NULL;
1164 if (it->wd->multi_timeout)
1166 it->wd->multi_timeout = EINA_FALSE;
1170 Evas_Coord minw = 0, minh = 0;
1171 Evas_Coord off_x, off_y, off_mx, off_my;
1173 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1174 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1175 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1176 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1177 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1179 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1181 if ((off_x + off_mx) > (off_y + off_my))
1183 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1184 evas_object_smart_callback_call(it->base.widget,
1185 "multi,swipe,right", it);
1186 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1187 evas_object_smart_callback_call(it->base.widget,
1188 "multi,swipe,left", it);
1189 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1190 evas_object_smart_callback_call(it->base.widget,
1191 "multi,pinch,out", it);
1193 evas_object_smart_callback_call(it->base.widget,
1194 "multi,pinch,in", it);
1198 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1199 evas_object_smart_callback_call(it->base.widget,
1200 "multi,swipe,down", it);
1201 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1202 evas_object_smart_callback_call(it->base.widget,
1203 "multi,swipe,up", it);
1204 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1205 evas_object_smart_callback_call(it->base.widget,
1206 "multi,pinch,out", it);
1208 evas_object_smart_callback_call(it->base.widget,
1209 "multi,pinch,in", it);
1212 it->wd->multi_timeout = EINA_FALSE;
1216 _multi_down(void *data,
1217 Evas *evas __UNUSED__,
1218 Evas_Object *obj __UNUSED__,
1221 Elm_Genlist_Item *it = data;
1222 Evas_Event_Multi_Down *ev = event_info;
1224 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1225 it->wd->multi_device = ev->device;
1226 it->wd->multi_down = EINA_TRUE;
1227 it->wd->multitouched = EINA_TRUE;
1228 it->wd->prev_mx = ev->canvas.x;
1229 it->wd->prev_my = ev->canvas.y;
1230 if (!it->wd->wasselected) _item_unselect(it);
1231 it->wd->wasselected = EINA_FALSE;
1232 it->wd->longpressed = EINA_FALSE;
1235 ecore_timer_del(it->long_timer);
1236 it->long_timer = NULL;
1240 it->dragging = EINA_FALSE;
1241 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1243 if (it->swipe_timer)
1245 ecore_timer_del(it->swipe_timer);
1246 it->swipe_timer = NULL;
1248 if (it->wd->on_hold)
1250 it->wd->swipe = EINA_FALSE;
1251 it->wd->movements = 0;
1252 it->wd->on_hold = EINA_FALSE;
1257 _multi_up(void *data,
1258 Evas *evas __UNUSED__,
1259 Evas_Object *obj __UNUSED__,
1262 Elm_Genlist_Item *it = data;
1263 Evas_Event_Multi_Up *ev = event_info;
1265 if (it->wd->multi_device != ev->device) return;
1266 it->wd->multi_device = 0;
1267 it->wd->multi_down = EINA_FALSE;
1268 if (it->wd->mouse_down) return;
1269 _multi_touch_gesture_eval(data);
1273 _multi_move(void *data,
1274 Evas *evas __UNUSED__,
1275 Evas_Object *obj __UNUSED__,
1278 Elm_Genlist_Item *it = data;
1279 Evas_Event_Multi_Move *ev = event_info;
1281 if (it->wd->multi_device != ev->device) return;
1282 it->wd->cur_mx = ev->cur.canvas.x;
1283 it->wd->cur_my = ev->cur.canvas.y;
1287 _mouse_down(void *data,
1288 Evas *evas __UNUSED__,
1292 Elm_Genlist_Item *it = data;
1293 Evas_Event_Mouse_Down *ev = event_info;
1296 if (ev->button != 1) return;
1297 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1299 it->wd->on_hold = EINA_TRUE;
1302 it->down = EINA_TRUE;
1303 it->dragging = EINA_FALSE;
1304 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1305 it->dx = ev->canvas.x - x;
1306 it->dy = ev->canvas.y - y;
1307 it->wd->mouse_down = EINA_TRUE;
1308 if (!it->wd->multitouched)
1310 it->wd->prev_x = ev->canvas.x;
1311 it->wd->prev_y = ev->canvas.y;
1312 it->wd->multi_timeout = EINA_FALSE;
1313 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1314 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1316 it->wd->longpressed = EINA_FALSE;
1317 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1318 else it->wd->on_hold = EINA_FALSE;
1319 if (it->wd->on_hold) return;
1320 it->wd->wasselected = it->selected;
1322 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1323 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1324 if (it->long_timer) ecore_timer_del(it->long_timer);
1325 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1326 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1328 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1331 it->long_timer = NULL;
1332 it->wd->swipe = EINA_FALSE;
1333 it->wd->movements = 0;
1337 _mouse_up(void *data,
1338 Evas *evas __UNUSED__,
1339 Evas_Object *obj __UNUSED__,
1342 Elm_Genlist_Item *it = data;
1343 Evas_Event_Mouse_Up *ev = event_info;
1344 Eina_Bool dragged = EINA_FALSE;
1346 if (ev->button != 1) return;
1347 it->down = EINA_FALSE;
1348 it->wd->mouse_down = EINA_FALSE;
1349 if (it->wd->multitouched)
1351 if (it->wd->multi_down) return;
1352 _multi_touch_gesture_eval(data);
1355 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1356 else it->wd->on_hold = EINA_FALSE;
1359 ecore_timer_del(it->long_timer);
1360 it->long_timer = NULL;
1364 it->dragging = EINA_FALSE;
1365 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1368 if (it->swipe_timer)
1370 ecore_timer_del(it->swipe_timer);
1371 it->swipe_timer = NULL;
1373 if (it->wd->multi_timer)
1375 ecore_timer_del(it->wd->multi_timer);
1376 it->wd->multi_timer = NULL;
1377 it->wd->multi_timeout = EINA_FALSE;
1379 if (it->wd->on_hold)
1381 if (it->wd->swipe) _swipe(data);
1382 it->wd->longpressed = EINA_FALSE;
1383 it->wd->on_hold = EINA_FALSE;
1386 if (it->wd->longpressed)
1388 it->wd->longpressed = EINA_FALSE;
1389 if (!it->wd->wasselected)
1391 it->wd->wasselected = EINA_FALSE;
1396 if (it->want_unrealize)
1398 _item_unrealize(it);
1399 if (it->block->want_unrealize)
1400 _item_block_unrealize(it->block);
1403 if ((it->disabled) || (dragged) || (it->display_only)) return;
1404 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1412 else _item_unselect(it);
1418 Widget_Data *wd = it->wd;
1421 while (wd->selected) _item_unselect(wd->selected->data);
1426 const Eina_List *l, *l_next;
1427 Elm_Genlist_Item *it2;
1429 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1430 if (it2 != it) _item_unselect(it2);
1431 //_item_hilight(it);
1440 _signal_expand_toggle(void *data,
1441 Evas_Object *obj __UNUSED__,
1442 const char *emission __UNUSED__,
1443 const char *source __UNUSED__)
1445 Elm_Genlist_Item *it = data;
1448 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1450 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1454 _signal_expand(void *data,
1455 Evas_Object *obj __UNUSED__,
1456 const char *emission __UNUSED__,
1457 const char *source __UNUSED__)
1459 Elm_Genlist_Item *it = data;
1462 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1466 _signal_contract(void *data,
1467 Evas_Object *obj __UNUSED__,
1468 const char *emission __UNUSED__,
1469 const char *source __UNUSED__)
1471 Elm_Genlist_Item *it = data;
1474 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1478 _item_cache_clean(Widget_Data *wd)
1480 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1484 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1485 wd->item_cache = eina_inlist_remove(wd->item_cache,
1486 wd->item_cache->last);
1487 wd->item_cache_count--;
1488 if (itc->spacer) evas_object_del(itc->spacer);
1489 if (itc->base_view) evas_object_del(itc->base_view);
1490 if (itc->item_style) eina_stringshare_del(itc->item_style);
1496 _item_cache_zero(Widget_Data *wd)
1498 int pmax = wd->item_cache_max;
1499 wd->item_cache_max = 0;
1500 _item_cache_clean(wd);
1501 wd->item_cache_max = pmax;
1505 _item_cache_add(Elm_Genlist_Item *it)
1509 if (it->wd->item_cache_max <= 0)
1511 evas_object_del(it->base.view);
1512 it->base.view = NULL;
1513 evas_object_del(it->spacer);
1518 it->wd->item_cache_count++;
1519 itc = calloc(1, sizeof(Item_Cache));
1520 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1521 EINA_INLIST_GET(itc));
1522 itc->spacer = it->spacer;
1524 itc->base_view = it->base.view;
1525 it->base.view = NULL;
1526 evas_object_hide(itc->base_view);
1527 evas_object_move(itc->base_view, -9999, -9999);
1528 itc->item_style = eina_stringshare_add(it->itc->item_style);
1529 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1530 itc->compress = (it->wd->compress);
1531 itc->odd = (it->order_num_in & 0x1);
1532 itc->selected = it->selected;
1533 itc->disabled = it->disabled;
1534 itc->expanded = it->expanded;
1537 ecore_timer_del(it->long_timer);
1538 it->long_timer = NULL;
1540 if (it->swipe_timer)
1542 ecore_timer_del(it->swipe_timer);
1543 it->swipe_timer = NULL;
1545 // FIXME: other callbacks?
1546 edje_object_signal_callback_del_full(itc->base_view,
1547 "elm,action,expand,toggle",
1548 "elm", _signal_expand_toggle, it);
1549 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1551 _signal_expand, it);
1552 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1553 "elm", _signal_contract, it);
1554 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1556 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1558 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1560 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1562 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1564 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1566 _item_cache_clean(it->wd);
1570 _item_cache_find(Elm_Genlist_Item *it)
1573 Eina_Bool tree = 0, odd;
1575 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1576 odd = (it->order_num_in & 0x1);
1577 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1579 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1581 if ((itc->tree == tree) &&
1582 (itc->odd == odd) &&
1583 (itc->compress == it->wd->compress) &&
1584 (!strcmp(it->itc->item_style, itc->item_style)))
1586 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1587 EINA_INLIST_GET(itc));
1588 it->wd->item_cache_count--;
1596 _item_cache_free(Item_Cache *itc)
1598 if (itc->spacer) evas_object_del(itc->spacer);
1599 if (itc->base_view) evas_object_del(itc->base_view);
1600 if (itc->item_style) eina_stringshare_del(itc->item_style);
1605 _item_realize(Elm_Genlist_Item *it,
1609 Elm_Genlist_Item *it2;
1610 const char *stacking;
1611 const char *treesize;
1613 int depth, tsize = 20;
1616 if ((it->realized) || (it->delete_me)) return;
1617 it->order_num_in = in;
1619 itc = _item_cache_find(it);
1622 it->base.view = itc->base_view;
1623 itc->base_view = NULL;
1624 it->spacer = itc->spacer;
1629 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1630 edje_object_scale_set(it->base.view,
1631 elm_widget_scale_get(it->base.widget) *
1632 _elm_config->scale);
1633 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1634 elm_widget_sub_object_add(it->base.widget, it->base.view);
1636 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1637 strncpy(buf, "tree", sizeof(buf));
1638 else strncpy(buf, "item", sizeof(buf));
1639 if (it->wd->compress)
1640 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1642 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1643 strncat(buf, "/", sizeof(buf) - strlen(buf));
1644 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1646 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1647 elm_widget_style_get(it->base.widget));
1649 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1650 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1651 elm_widget_sub_object_add(it->base.widget, it->spacer);
1653 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1655 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1657 it->expanded_depth = depth;
1658 treesize = edje_object_data_get(it->base.view, "treesize");
1659 if (treesize) tsize = atoi(treesize);
1660 evas_object_size_hint_min_set(it->spacer,
1661 (depth * tsize) * _elm_config->scale, 1);
1662 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1665 edje_object_signal_callback_add(it->base.view,
1666 "elm,action,expand,toggle",
1667 "elm", _signal_expand_toggle, it);
1668 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1669 "elm", _signal_expand, it);
1670 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1671 "elm", _signal_contract, it);
1672 stacking = edje_object_data_get(it->base.view, "stacking");
1675 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1676 else if (!strcmp(stacking, "above"))
1677 evas_object_raise(it->base.view);
1679 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1681 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1683 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1685 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1687 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1689 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1693 if (it->selected != itc->selected)
1696 edje_object_signal_emit(it->base.view,
1697 "elm,state,selected", "elm");
1699 if (it->disabled != itc->disabled)
1702 edje_object_signal_emit(it->base.view,
1703 "elm,state,disabled", "elm");
1705 if (it->expanded != itc->expanded)
1708 edje_object_signal_emit(it->base.view,
1709 "elm,state,expanded", "elm");
1715 edje_object_signal_emit(it->base.view,
1716 "elm,state,selected", "elm");
1718 edje_object_signal_emit(it->base.view,
1719 "elm,state,disabled", "elm");
1721 edje_object_signal_emit(it->base.view,
1722 "elm,state,expanded", "elm");
1726 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1728 /* homogenous genlist shortcut */
1731 it->w = it->minw = it->wd->item_width;
1732 it->h = it->minh = it->wd->item_height;
1733 it->mincalcd = EINA_TRUE;
1738 if (it->itc->func.label_get)
1744 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1746 EINA_LIST_FOREACH(it->labels, l, key)
1748 char *s = it->itc->func.label_get
1749 ((void *)it->base.data, it->base.widget, l->data);
1753 edje_object_part_text_set(it->base.view, l->data, s);
1757 edje_object_part_text_set(it->base.view, l->data, "");
1760 if (it->itc->func.icon_get)
1766 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1768 EINA_LIST_FOREACH(it->icons, l, key)
1770 Evas_Object *ic = it->itc->func.icon_get
1771 ((void *)it->base.data, it->base.widget, l->data);
1775 it->icon_objs = eina_list_append(it->icon_objs, ic);
1776 edje_object_part_swallow(it->base.view, key, ic);
1777 evas_object_show(ic);
1778 elm_widget_sub_object_add(it->base.widget, ic);
1782 if (it->itc->func.state_get)
1788 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1790 EINA_LIST_FOREACH(it->states, l, key)
1792 Eina_Bool on = it->itc->func.state_get
1793 ((void *)it->base.data, it->base.widget, l->data);
1797 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1798 edje_object_signal_emit(it->base.view, buf, "elm");
1802 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1803 edje_object_signal_emit(it->base.view, buf, "elm");
1809 Evas_Coord mw = -1, mh = -1;
1811 if (it->wd->height_for_width) mw = it->wd->w;
1813 if (!it->display_only)
1814 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1815 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1816 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1818 if (!it->display_only)
1819 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1820 it->w = it->minw = mw;
1821 it->h = it->minh = mh;
1822 it->mincalcd = EINA_TRUE;
1824 if ((!in) && (it->wd->homogeneous))
1826 it->wd->item_width = mw;
1827 it->wd->item_height = mh;
1830 if (!calc) evas_object_show(it->base.view);
1833 if (it->tooltip.content_cb)
1835 elm_widget_item_tooltip_content_cb_set(it,
1836 it->tooltip.content_cb,
1837 it->tooltip.data, NULL);
1838 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1841 if (it->mouse_cursor)
1842 elm_widget_item_cursor_set(it, it->mouse_cursor);
1844 it->realized = EINA_TRUE;
1845 it->want_unrealize = EINA_FALSE;
1847 if (itc) _item_cache_free(itc);
1848 evas_object_smart_callback_call(it->base.widget, "realized", it);
1852 _item_unrealize(Elm_Genlist_Item *it)
1856 if (!it->realized) return;
1857 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1860 ecore_timer_del(it->long_timer);
1861 it->long_timer = NULL;
1863 _item_cache_add(it);
1864 elm_widget_stringlist_free(it->labels);
1866 elm_widget_stringlist_free(it->icons);
1868 elm_widget_stringlist_free(it->states);
1870 EINA_LIST_FREE(it->icon_objs, icon)
1871 evas_object_del(icon);
1874 it->realized = EINA_FALSE;
1875 it->want_unrealize = EINA_FALSE;
1879 _item_block_recalc(Item_Block *itb,
1885 Elm_Genlist_Item *it;
1886 Evas_Coord minw = 0, minh = 0;
1887 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1891 EINA_LIST_FOREACH(itb->items, l, it)
1893 if (it->delete_me) continue;
1894 showme |= it->showme;
1899 if (!it->mincalcd) changed = EINA_TRUE;
1902 _item_realize(it, in, 1);
1903 _item_unrealize(it);
1908 _item_realize(it, in, 1);
1909 _item_unrealize(it);
1913 _item_realize(it, in, 0);
1915 if (minw < it->minw) minw = it->minw;
1923 itb->changed = EINA_FALSE;
1924 /* force an evas norender to garbage collect deleted objects */
1925 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1930 _item_block_realize(Item_Block *itb,
1935 Elm_Genlist_Item *it;
1937 if (itb->realized) return;
1938 EINA_LIST_FOREACH(itb->items, l, it)
1940 if (it->delete_me) continue;
1941 if (full) _item_realize(it, in, 0);
1944 itb->realized = EINA_TRUE;
1945 itb->want_unrealize = EINA_FALSE;
1949 _item_block_unrealize(Item_Block *itb)
1952 Elm_Genlist_Item *it;
1953 Eina_Bool dragging = EINA_FALSE;
1955 if (!itb->realized) return;
1956 EINA_LIST_FOREACH(itb->items, l, it)
1958 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1962 dragging = EINA_TRUE;
1963 it->want_unrealize = EINA_TRUE;
1966 _item_unrealize(it);
1971 itb->realized = EINA_FALSE;
1972 itb->want_unrealize = EINA_TRUE;
1975 itb->want_unrealize = EINA_FALSE;
1979 _item_block_position(Item_Block *itb,
1983 Elm_Genlist_Item *it;
1984 Elm_Genlist_Item *git;
1985 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1988 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1989 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
1991 EINA_LIST_FOREACH(itb->items, l, it)
1993 if (it->delete_me) continue;
1997 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
1998 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2000 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2002 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2003 cvx, cvy, cvw, cvh));
2004 if ((itb->realized) && (!it->realized))
2006 if (vis) _item_realize(it, in, 0);
2012 git = it->group_item;
2015 if (git->scrl_y < oy)
2017 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2018 git->scrl_y = (it->scrl_y + it->h) - git->h;
2019 git->want_realize = EINA_TRUE;
2021 evas_object_resize(it->base.view, it->w, it->h);
2022 evas_object_move(it->base.view,
2023 it->scrl_x, it->scrl_y);
2024 evas_object_show(it->base.view);
2028 if (!it->dragging) _item_unrealize(it);
2038 _group_items_recalc(void *data)
2040 Widget_Data *wd = data;
2042 Elm_Genlist_Item *git;
2044 EINA_LIST_FOREACH(wd->group_items, l, git)
2046 if (git->want_realize)
2049 _item_realize(git, 0, 0);
2050 evas_object_resize(git->base.view, wd->minw, git->h);
2051 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2052 evas_object_show(git->base.view);
2053 evas_object_raise(git->base.view);
2055 else if (!git->want_realize && git->realized)
2058 _item_unrealize(git);
2064 _must_recalc_idler(void *data)
2066 Widget_Data *wd = data;
2067 if (wd->calc_job) ecore_job_del(wd->calc_job);
2068 wd->calc_job = ecore_job_add(_calc_job, wd);
2069 wd->must_recalc_idler = NULL;
2070 return ECORE_CALLBACK_CANCEL;
2074 _calc_job(void *data)
2076 Widget_Data *wd = data;
2078 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2079 Item_Block *chb = NULL;
2080 int in = 0, minw_change = 0;
2081 Eina_Bool changed = EINA_FALSE;
2083 Eina_Bool did_must_recalc = EINA_FALSE;
2086 t0 = ecore_time_get();
2087 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2091 // if (wd->height_for_width) changed = EINA_TRUE;
2094 EINA_INLIST_FOREACH(wd->blocks, itb)
2096 Eina_Bool showme = EINA_FALSE;
2099 showme = itb->showme;
2100 itb->showme = EINA_FALSE;
2103 if (itb->realized) _item_block_unrealize(itb);
2105 if ((itb->changed) || (changed) ||
2106 ((itb->must_recalc) && (!did_must_recalc)))
2108 if ((changed) || (itb->must_recalc))
2111 Elm_Genlist_Item *it;
2112 EINA_LIST_FOREACH(itb->items, l, it)
2113 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2114 itb->changed = EINA_TRUE;
2115 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2116 itb->must_recalc = EINA_FALSE;
2118 if (itb->realized) _item_block_unrealize(itb);
2119 showme = _item_block_recalc(itb, in, 0, 1);
2125 if (minw == -1) minw = itb->minw;
2126 else if ((!itb->must_recalc) && (minw < itb->minw))
2135 if ((showme) && (wd->show_item))
2137 wd->show_item->showme = EINA_FALSE;
2139 elm_smart_scroller_region_bring_in(wd->scr,
2141 wd->show_item->block->x,
2143 wd->show_item->block->y,
2144 wd->show_item->block->w,
2147 elm_smart_scroller_child_region_show(wd->scr,
2149 wd->show_item->block->x,
2151 wd->show_item->block->y,
2152 wd->show_item->block->w,
2154 wd->show_item = NULL;
2159 EINA_INLIST_FOREACH(wd->blocks, itb)
2165 if ((chb) && (EINA_INLIST_GET(chb)->next))
2167 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2169 if (itb->realized) _item_block_unrealize(itb);
2172 wd->realminw = minw;
2173 if (minw < wd->w) minw = wd->w;
2174 if ((minw != wd->minw) || (minh != wd->minh))
2178 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2179 _sizing_eval(wd->obj);
2180 if ((wd->anchor_item) && (wd->anchor_item->block))
2182 Elm_Genlist_Item *it;
2185 it = wd->anchor_item;
2186 it_y = wd->anchor_y;
2187 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2188 it->block->y + it->y + it_y);
2189 wd->anchor_item = it;
2190 wd->anchor_y = it_y;
2193 t = ecore_time_get();
2194 if (did_must_recalc)
2196 if (!wd->must_recalc_idler)
2197 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2199 wd->calc_job = NULL;
2200 evas_object_smart_changed(wd->pan_smart);
2204 _update_job(void *data)
2206 Widget_Data *wd = data;
2209 int num, num0, position = 0, recalc = 0;
2211 wd->update_job = NULL;
2213 EINA_INLIST_FOREACH(wd->blocks, itb)
2215 Evas_Coord itminw, itminh;
2216 Elm_Genlist_Item *it;
2222 _item_block_position(itb, num);
2227 EINA_LIST_FOREACH(itb->items, l2, it)
2234 it->updateme = EINA_FALSE;
2237 _item_unrealize(it);
2238 _item_realize(it, num, 0);
2243 _item_realize(it, num, 1);
2244 _item_unrealize(it);
2246 if ((it->minw != itminw) || (it->minh != itminh))
2251 itb->updateme = EINA_FALSE;
2255 itb->changed = EINA_TRUE;
2256 _item_block_recalc(itb, num0, 0, 1);
2257 _item_block_position(itb, num0);
2262 if (wd->calc_job) ecore_job_del(wd->calc_job);
2263 wd->calc_job = ecore_job_add(_calc_job, wd);
2268 _pan_set(Evas_Object *obj,
2272 Pan *sd = evas_object_smart_data_get(obj);
2275 // Evas_Coord ow, oh;
2276 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2277 // ow = sd->wd->minw - ow;
2278 // if (ow < 0) ow = 0;
2279 // oh = sd->wd->minh - oh;
2280 // if (oh < 0) oh = 0;
2281 // if (x < 0) x = 0;
2282 // if (y < 0) y = 0;
2283 // if (x > ow) x = ow;
2284 // if (y > oh) y = oh;
2285 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2289 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2291 if ((itb->y + itb->h) > y)
2293 Elm_Genlist_Item *it;
2296 EINA_LIST_FOREACH(itb->items, l2, it)
2298 if ((itb->y + it->y) >= y)
2300 sd->wd->anchor_item = it;
2301 sd->wd->anchor_y = -(itb->y + it->y - y);
2308 evas_object_smart_changed(obj);
2312 _pan_get(Evas_Object *obj,
2316 Pan *sd = evas_object_smart_data_get(obj);
2318 if (x) *x = sd->wd->pan_x;
2319 if (y) *y = sd->wd->pan_y;
2323 _pan_max_get(Evas_Object *obj,
2327 Pan *sd = evas_object_smart_data_get(obj);
2330 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2331 ow = sd->wd->minw - ow;
2333 oh = sd->wd->minh - oh;
2340 _pan_min_get(Evas_Object *obj __UNUSED__,
2349 _pan_child_size_get(Evas_Object *obj,
2353 Pan *sd = evas_object_smart_data_get(obj);
2355 if (w) *w = sd->wd->minw;
2356 if (h) *h = sd->wd->minh;
2360 _pan_add(Evas_Object *obj)
2363 Evas_Object_Smart_Clipped_Data *cd;
2366 cd = evas_object_smart_data_get(obj);
2369 sd->__clipped_data = *cd;
2371 evas_object_smart_data_set(obj, sd);
2375 _pan_del(Evas_Object *obj)
2377 Pan *sd = evas_object_smart_data_get(obj);
2382 ecore_job_del(sd->resize_job);
2383 sd->resize_job = NULL;
2389 _pan_resize_job(void *data)
2392 _sizing_eval(sd->wd->obj);
2393 sd->resize_job = NULL;
2397 _pan_resize(Evas_Object *obj,
2401 Pan *sd = evas_object_smart_data_get(obj);
2404 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2405 if ((ow == w) && (oh == h)) return;
2406 if ((sd->wd->height_for_width) && (ow != w))
2408 if (sd->resize_job) ecore_job_del(sd->resize_job);
2409 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2411 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2412 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2416 _pan_calculate(Evas_Object *obj)
2418 Pan *sd = evas_object_smart_data_get(obj);
2420 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2422 Elm_Genlist_Item *git;
2425 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2426 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2427 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2429 git->want_realize = EINA_FALSE;
2431 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2433 itb->w = sd->wd->minw;
2434 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2435 itb->y - sd->wd->pan_y + oy,
2437 cvx, cvy, cvw, cvh))
2439 if ((!itb->realized) || (itb->changed))
2440 _item_block_realize(itb, in, 0);
2441 _item_block_position(itb, in);
2445 if (itb->realized) _item_block_unrealize(itb);
2449 _group_items_recalc(sd->wd);
2453 _pan_move(Evas_Object *obj,
2454 Evas_Coord x __UNUSED__,
2455 Evas_Coord y __UNUSED__)
2457 Pan *sd = evas_object_smart_data_get(obj);
2459 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2460 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2464 _hold_on(void *data __UNUSED__,
2466 void *event_info __UNUSED__)
2468 Widget_Data *wd = elm_widget_data_get(obj);
2470 elm_smart_scroller_hold_set(wd->scr, 1);
2474 _hold_off(void *data __UNUSED__,
2476 void *event_info __UNUSED__)
2478 Widget_Data *wd = elm_widget_data_get(obj);
2480 elm_smart_scroller_hold_set(wd->scr, 0);
2484 _freeze_on(void *data __UNUSED__,
2486 void *event_info __UNUSED__)
2488 Widget_Data *wd = elm_widget_data_get(obj);
2490 elm_smart_scroller_freeze_set(wd->scr, 1);
2494 _freeze_off(void *data __UNUSED__,
2496 void *event_info __UNUSED__)
2498 Widget_Data *wd = elm_widget_data_get(obj);
2500 elm_smart_scroller_freeze_set(wd->scr, 0);
2504 _scroll_edge_left(void *data,
2505 Evas_Object *scr __UNUSED__,
2506 void *event_info __UNUSED__)
2508 Evas_Object *obj = data;
2509 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2513 _scroll_edge_right(void *data,
2514 Evas_Object *scr __UNUSED__,
2515 void *event_info __UNUSED__)
2517 Evas_Object *obj = data;
2518 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2522 _scroll_edge_top(void *data,
2523 Evas_Object *scr __UNUSED__,
2524 void *event_info __UNUSED__)
2526 Evas_Object *obj = data;
2527 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2531 _scroll_edge_bottom(void *data,
2532 Evas_Object *scr __UNUSED__,
2533 void *event_info __UNUSED__)
2535 Evas_Object *obj = data;
2536 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2540 * Add a new Genlist object
2542 * @param parent The parent object
2543 * @return The new object or NULL if it cannot be created
2548 elm_genlist_add(Evas_Object *parent)
2553 Evas_Coord minw, minh;
2554 static Evas_Smart *smart = NULL;
2556 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2560 static Evas_Smart_Class sc;
2562 evas_object_smart_clipped_smart_set(&_pan_sc);
2564 sc.name = "elm_genlist_pan";
2565 sc.version = EVAS_SMART_CLASS_VERSION;
2568 sc.resize = _pan_resize;
2569 sc.move = _pan_move;
2570 sc.calculate = _pan_calculate;
2571 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2573 wd = ELM_NEW(Widget_Data);
2574 e = evas_object_evas_get(parent);
2575 if (!e) return NULL;
2576 obj = elm_widget_add(e);
2577 ELM_SET_WIDTYPE(widtype, "genlist");
2578 elm_widget_type_set(obj, "genlist");
2579 elm_widget_sub_object_add(parent, obj);
2580 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2581 elm_widget_data_set(obj, wd);
2582 elm_widget_del_hook_set(obj, _del_hook);
2583 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2584 elm_widget_theme_hook_set(obj, _theme_hook);
2585 elm_widget_can_focus_set(obj, EINA_TRUE);
2586 elm_widget_event_hook_set(obj, _event_hook);
2588 wd->scr = elm_smart_scroller_add(e);
2589 elm_smart_scroller_widget_set(wd->scr, obj);
2590 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2591 elm_widget_style_get(obj));
2592 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2593 _elm_config->thumbscroll_bounce_enable);
2594 elm_widget_resize_object_set(obj, wd->scr);
2596 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2597 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2599 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2600 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2604 wd->mode = ELM_LIST_SCROLL;
2605 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2606 wd->item_cache_max = wd->max_items_per_block * 2;
2607 wd->longpress_timeout = _elm_config->longpress_timeout;
2609 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2610 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2611 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2612 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2614 wd->pan_smart = evas_object_smart_add(e, smart);
2615 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2618 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2619 _pan_set, _pan_get, _pan_max_get,
2620 _pan_min_get, _pan_child_size_get);
2622 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2624 evas_object_size_hint_min_set(obj, minw, minh);
2630 static Elm_Genlist_Item *
2631 _item_new(Widget_Data *wd,
2632 const Elm_Genlist_Item_Class *itc,
2634 Elm_Genlist_Item *parent,
2635 Elm_Genlist_Item_Flags flags,
2637 const void *func_data)
2639 Elm_Genlist_Item *it;
2641 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2642 if (!it) return NULL;
2645 it->base.data = data;
2646 it->parent = parent;
2648 it->func.func = func;
2649 it->func.data = func_data;
2650 it->mouse_cursor = NULL;
2651 it->expanded_depth = 0;
2656 _item_block_add(Widget_Data *wd,
2657 Elm_Genlist_Item *it)
2659 Item_Block *itb = NULL;
2666 itb = calloc(1, sizeof(Item_Block));
2669 if (!it->rel->block)
2672 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2673 itb->items = eina_list_append(itb->items, it);
2679 wd->blocks = eina_inlist_prepend_relative
2680 (wd->blocks, EINA_INLIST_GET(itb),
2681 EINA_INLIST_GET(it->rel->block));
2683 eina_list_prepend_relative(itb->items, it, it->rel);
2687 wd->blocks = eina_inlist_append_relative
2688 (wd->blocks, EINA_INLIST_GET(itb),
2689 EINA_INLIST_GET(it->rel->block));
2691 eina_list_append_relative(itb->items, it, it->rel);
2701 itb = (Item_Block *)(wd->blocks);
2702 if (itb->count >= wd->max_items_per_block)
2704 itb = calloc(1, sizeof(Item_Block));
2708 eina_inlist_prepend(wd->blocks,
2709 EINA_INLIST_GET(itb));
2714 itb = calloc(1, sizeof(Item_Block));
2718 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2720 itb->items = eina_list_prepend(itb->items, it);
2726 itb = (Item_Block *)(wd->blocks->last);
2727 if (itb->count >= wd->max_items_per_block)
2729 itb = calloc(1, sizeof(Item_Block));
2733 eina_inlist_append(wd->blocks,
2734 EINA_INLIST_GET(itb));
2739 itb = calloc(1, sizeof(Item_Block));
2743 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2745 itb->items = eina_list_append(itb->items, it);
2751 itb = it->rel->block;
2752 if (!itb) goto newblock;
2754 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2756 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2759 itb->changed = EINA_TRUE;
2761 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2762 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2765 it->rel->relcount--;
2766 if ((it->rel->delete_me) && (!it->rel->relcount))
2770 if (itb->count > itb->wd->max_items_per_block)
2774 Elm_Genlist_Item *it2;
2776 newc = itb->count / 2;
2777 itb2 = calloc(1, sizeof(Item_Block));
2781 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2782 EINA_INLIST_GET(itb));
2783 itb2->changed = EINA_TRUE;
2784 while ((itb->count > newc) && (itb->items))
2788 l = eina_list_last(itb->items);
2790 itb->items = eina_list_remove_list(itb->items, l);
2793 itb2->items = eina_list_prepend(itb2->items, it2);
2801 _queue_proecess(Widget_Data *wd,
2805 Eina_Bool showme = EINA_FALSE;
2808 t0 = ecore_time_get();
2809 for (n = 0; (wd->queue) && (n < 128); n++)
2811 Elm_Genlist_Item *it;
2813 it = wd->queue->data;
2814 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2815 it->queued = EINA_FALSE;
2816 _item_block_add(wd, it);
2817 t = ecore_time_get();
2818 if (it->block->changed)
2820 showme = _item_block_recalc(it->block, it->block->num, 1,
2822 it->block->changed = 0;
2824 if (showme) it->block->showme = EINA_TRUE;
2825 if (eina_inlist_count(wd->blocks) > 1)
2827 if ((t - t0) > (ecore_animator_frametime_get())) break;
2834 _item_idler(void *data)
2836 Widget_Data *wd = data;
2839 //static double q_start = 0.0;
2840 //if (q_start == 0.0) q_start = ecore_time_get();
2843 if (_queue_proecess(wd, 1) > 0)
2845 if (wd->calc_job) ecore_job_del(wd->calc_job);
2846 wd->calc_job = ecore_job_add(_calc_job, wd);
2851 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2853 wd->queue_idler = NULL;
2854 return ECORE_CALLBACK_CANCEL;
2856 return ECORE_CALLBACK_RENEW;
2860 _item_queue(Widget_Data *wd,
2861 Elm_Genlist_Item *it)
2863 if (it->queued) return;
2864 it->queued = EINA_TRUE;
2865 wd->queue = eina_list_append(wd->queue, it);
2866 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2868 if (wd->queue_idler)
2870 ecore_idler_del(wd->queue_idler);
2871 wd->queue_idler = NULL;
2873 _queue_proecess(wd, 0);
2875 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2879 * Append item to the end of the genlist
2881 * This appends the given item to the end of the list or the end of
2882 * the children if the parent is given.
2884 * @param obj The genlist object
2885 * @param itc The item class for the item
2886 * @param data The item data
2887 * @param parent The parent item, or NULL if none
2888 * @param flags Item flags
2889 * @param func Convenience function called when item selected
2890 * @param func_data Data passed to @p func above.
2891 * @return A handle to the item added or NULL if not possible
2895 EAPI Elm_Genlist_Item *
2896 elm_genlist_item_append(Evas_Object *obj,
2897 const Elm_Genlist_Item_Class *itc,
2899 Elm_Genlist_Item *parent,
2900 Elm_Genlist_Item_Flags flags,
2902 const void *func_data)
2904 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2905 Widget_Data *wd = elm_widget_data_get(obj);
2906 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2908 if (!wd) return NULL;
2909 if (!it) return NULL;
2912 if (flags & ELM_GENLIST_ITEM_GROUP)
2913 wd->group_items = eina_list_append(wd->group_items, it);
2914 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2919 Elm_Genlist_Item *it2 = NULL;
2920 Eina_List *ll = eina_list_last(it->parent->items);
2921 if (ll) it2 = ll->data;
2922 it->parent->items = eina_list_append(it->parent->items, it);
2923 if (!it2) it2 = it->parent;
2925 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2926 EINA_INLIST_GET(it2));
2928 it->rel->relcount++;
2930 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2931 it->group_item = parent;
2932 else if (it->parent->group_item)
2933 it->group_item = it->parent->group_item;
2935 it->before = EINA_FALSE;
2936 _item_queue(wd, it);
2941 * Prepend item at start of the genlist
2943 * This adds an item to the beginning of the list or beginning of the
2944 * children of the parent if given.
2946 * @param obj The genlist object
2947 * @param itc The item class for the item
2948 * @param data The item data
2949 * @param parent The parent item, or NULL if none
2950 * @param flags Item flags
2951 * @param func Convenience function called when item selected
2952 * @param func_data Data passed to @p func above.
2953 * @return A handle to the item added or NULL if not possible
2957 EAPI Elm_Genlist_Item *
2958 elm_genlist_item_prepend(Evas_Object *obj,
2959 const Elm_Genlist_Item_Class *itc,
2961 Elm_Genlist_Item *parent,
2962 Elm_Genlist_Item_Flags flags,
2964 const void *func_data)
2966 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2967 Widget_Data *wd = elm_widget_data_get(obj);
2968 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2970 if (!wd) return NULL;
2971 if (!it) return NULL;
2974 if (flags & ELM_GENLIST_ITEM_GROUP)
2975 wd->group_items = eina_list_prepend(wd->group_items, it);
2976 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2981 Elm_Genlist_Item *it2 = NULL;
2982 Eina_List *ll = it->parent->items;
2983 if (ll) it2 = ll->data;
2984 it->parent->items = eina_list_prepend(it->parent->items, it);
2985 if (!it2) it2 = it->parent;
2987 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2988 EINA_INLIST_GET(it2));
2990 it->rel->relcount++;
2992 it->before = EINA_TRUE;
2993 _item_queue(wd, it);
2998 * Insert item before another in the genlist
3000 * This inserts an item before another in the list. It will be in the
3001 * same tree level or group as the item it is inseted before.
3003 * @param obj The genlist object
3004 * @param itc The item class for the item
3005 * @param data The item data
3006 * @param before The item to insert before
3007 * @param flags Item flags
3008 * @param func Convenience function called when item selected
3009 * @param func_data Data passed to @p func above.
3010 * @return A handle to the item added or NULL if not possible
3014 EAPI Elm_Genlist_Item *
3015 elm_genlist_item_insert_before(Evas_Object *obj,
3016 const Elm_Genlist_Item_Class *itc,
3018 Elm_Genlist_Item *parent,
3019 Elm_Genlist_Item *before,
3020 Elm_Genlist_Item_Flags flags,
3022 const void *func_data)
3024 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3025 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3026 Widget_Data *wd = elm_widget_data_get(obj);
3027 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3029 if (!wd) return NULL;
3030 if (!it) return NULL;
3033 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3036 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3037 EINA_INLIST_GET(before));
3039 it->rel->relcount++;
3040 it->before = EINA_TRUE;
3041 _item_queue(wd, it);
3046 * Insert an item after another in the genlst
3048 * This inserts an item after another in the list. It will be in the
3049 * same tree level or group as the item it is inseted after.
3051 * @param obj The genlist object
3052 * @param itc The item class for the item
3053 * @param data The item data
3054 * @param after The item to insert after
3055 * @param flags Item flags
3056 * @param func Convenience function called when item selected
3057 * @param func_data Data passed to @p func above.
3058 * @return A handle to the item added or NULL if not possible
3062 EAPI Elm_Genlist_Item *
3063 elm_genlist_item_insert_after(Evas_Object *obj,
3064 const Elm_Genlist_Item_Class *itc,
3066 Elm_Genlist_Item *parent,
3067 Elm_Genlist_Item *after,
3068 Elm_Genlist_Item_Flags flags,
3070 const void *func_data)
3072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3073 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3074 Widget_Data *wd = elm_widget_data_get(obj);
3075 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3077 if (!wd) return NULL;
3078 if (!it) return NULL;
3079 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3080 EINA_INLIST_GET(after));
3083 it->parent->items = eina_list_append_relative(it->parent->items, it,
3087 it->rel->relcount++;
3088 it->before = EINA_FALSE;
3089 _item_queue(wd, it);
3096 * This clears all items in the list, leaving it empty.
3098 * @param obj The genlist object
3103 elm_genlist_clear(Evas_Object *obj)
3105 ELM_CHECK_WIDTYPE(obj, widtype);
3106 Widget_Data *wd = elm_widget_data_get(obj);
3108 if (wd->walking > 0)
3110 Elm_Genlist_Item *it;
3112 wd->clear_me = EINA_TRUE;
3113 EINA_INLIST_FOREACH(wd->items, it)
3115 it->delete_me = EINA_TRUE;
3119 wd->clear_me = EINA_FALSE;
3122 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3124 if (wd->anchor_item == it)
3126 wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3127 if (!wd->anchor_item)
3129 (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3131 wd->items = eina_inlist_remove(wd->items, wd->items);
3132 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3133 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3134 elm_widget_item_pre_notify_del(it);
3135 if (it->realized) _item_unrealize(it);
3136 if (it->itc->func.del)
3137 it->itc->func.del((void *)it->base.data, it->base.widget);
3138 if (it->long_timer) ecore_timer_del(it->long_timer);
3139 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3140 elm_widget_item_del(it);
3142 wd->anchor_item = NULL;
3145 Item_Block *itb = (Item_Block *)(wd->blocks);
3147 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3148 if (itb->items) eina_list_free(itb->items);
3153 ecore_job_del(wd->calc_job);
3154 wd->calc_job = NULL;
3156 if (wd->queue_idler)
3158 ecore_idler_del(wd->queue_idler);
3159 wd->queue_idler = NULL;
3161 if (wd->must_recalc_idler)
3163 ecore_idler_del(wd->must_recalc_idler);
3164 wd->must_recalc_idler = NULL;
3168 eina_list_free(wd->queue);
3173 eina_list_free(wd->selected);
3174 wd->selected = NULL;
3176 wd->show_item = NULL;
3183 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3184 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3190 * Enable or disable multi-select in the genlist
3192 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3193 * the list. This allows more than 1 item to be selected.
3195 * @param obj The genlist object
3196 * @param multi Multi-select enable/disable
3201 elm_genlist_multi_select_set(Evas_Object *obj,
3204 ELM_CHECK_WIDTYPE(obj, widtype);
3205 Widget_Data *wd = elm_widget_data_get(obj);
3211 * Gets if multi-select in genlist is enable or disable
3213 * @param obj The genlist object
3214 * @return Multi-select enable/disable
3215 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3220 elm_genlist_multi_select_get(const Evas_Object *obj)
3222 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3223 Widget_Data *wd = elm_widget_data_get(obj);
3224 if (!wd) return EINA_FALSE;
3229 * Get the selectd item in the genlist
3231 * This gets the selected item in the list (if multi-select is enabled
3232 * only the first item in the list is selected - which is not very
3233 * useful, so see elm_genlist_selected_items_get() for when
3234 * multi-select is used).
3236 * If no item is selected, NULL is returned.
3238 * @param obj The genlist object
3239 * @return The selected item, or NULL if none.
3243 EAPI Elm_Genlist_Item *
3244 elm_genlist_selected_item_get(const Evas_Object *obj)
3246 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3247 Widget_Data *wd = elm_widget_data_get(obj);
3248 if (!wd) return NULL;
3249 if (wd->selected) return wd->selected->data;
3254 * Get a list of selected items in the genlist
3256 * This returns a list of the selected items. This list pointer is
3257 * only valid so long as no items are selected or unselected (or
3258 * unselected implicitly by deletion). The list contains
3259 * Elm_Genlist_Item pointers.
3261 * @param obj The genlist object
3262 * @return The list of selected items, nor NULL if none are selected.
3266 EAPI const Eina_List *
3267 elm_genlist_selected_items_get(const Evas_Object *obj)
3269 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3270 Widget_Data *wd = elm_widget_data_get(obj);
3271 if (!wd) return NULL;
3272 return wd->selected;
3276 * Get a list of realized items in genlist
3278 * This returns a list of the realized items in the genlist. The list
3279 * contains Elm_Genlist_Item pointers. The list must be freed by the
3280 * caller when done with eina_list_free(). The item pointers in the
3281 * list are only valid so long as those items are not deleted or the
3282 * genlist is not deleted.
3284 * @param obj The genlist object
3285 * @return The list of realized items, nor NULL if none are realized.
3290 elm_genlist_realized_items_get(const Evas_Object *obj)
3292 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3293 Widget_Data *wd = elm_widget_data_get(obj);
3294 Eina_List *list = NULL;
3296 Eina_Bool done = EINA_FALSE;
3297 if (!wd) return NULL;
3298 EINA_INLIST_FOREACH(wd->blocks, itb)
3303 Elm_Genlist_Item *it;
3306 EINA_LIST_FOREACH(itb->items, l, it)
3308 if (it->realized) list = eina_list_append(list, it);
3320 * Get the item that is at the x, y canvas coords
3322 * This returns the item at the given coordinates (which are canvas
3323 * relative not object-relative). If an item is at that coordinate,
3324 * that item handle is returned, and if @p posret is not NULL, the
3325 * integer pointed to is set to a value of -1, 0 or 1, depending if
3326 * the coordinate is on the upper portion of that item (-1), on the
3327 * middle section (0) or on the lower part (1). If NULL is returned as
3328 * an item (no item found there), then posret may indicate -1 or 1
3329 * based if the coordinate is above or below all items respectively in
3332 * @param it The item
3333 * @param x The input x coordinate
3334 * @param y The input y coordinate
3335 * @param posret The position relative to the item returned here
3336 * @return The item at the coordinates or NULL if none
3340 EAPI Elm_Genlist_Item *
3341 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3346 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3347 Widget_Data *wd = elm_widget_data_get(obj);
3348 Evas_Coord ox, oy, ow, oh;
3351 if (!wd) return NULL;
3352 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3354 EINA_INLIST_FOREACH(wd->blocks, itb)
3357 Elm_Genlist_Item *it;
3359 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3360 oy + itb->y - itb->wd->pan_y,
3361 itb->w, itb->h, x, y, 1, 1))
3363 EINA_LIST_FOREACH(itb->items, l, it)
3365 Evas_Coord itx, ity;
3367 itx = ox + itb->x + it->x - itb->wd->pan_x;
3368 ity = oy + itb->y + it->y - itb->wd->pan_y;
3369 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3373 if (y <= (ity + (it->h / 4))) *posret = -1;
3374 else if (y >= (ity + it->h - (it->h / 4)))
3380 lasty = ity + it->h;
3385 if (y > lasty) *posret = 1;
3392 * Get the first item in the genlist
3394 * This returns the first item in the list.
3396 * @param obj The genlist object
3397 * @return The first item, or NULL if none
3401 EAPI Elm_Genlist_Item *
3402 elm_genlist_first_item_get(const Evas_Object *obj)
3404 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3405 Widget_Data *wd = elm_widget_data_get(obj);
3406 if (!wd) return NULL;
3407 if (!wd->items) return NULL;
3408 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3409 while ((it) && (it->delete_me))
3410 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3415 * Get the last item in the genlist
3417 * This returns the last item in the list.
3419 * @return The last item, or NULL if none
3423 EAPI Elm_Genlist_Item *
3424 elm_genlist_last_item_get(const Evas_Object *obj)
3426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3427 Widget_Data *wd = elm_widget_data_get(obj);
3428 if (!wd->items) return NULL;
3429 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3430 if (!wd) return NULL;
3431 while ((it) && (it->delete_me))
3432 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3437 * Get the next item in the genlist
3439 * This returns the item after the item @p it.
3441 * @param it The item
3442 * @return The item after @p it, or NULL if none
3446 EAPI Elm_Genlist_Item *
3447 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3452 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3453 if ((it) && (!it->delete_me)) break;
3455 return (Elm_Genlist_Item *)it;
3459 * Get the previous item in the genlist
3461 * This returns the item before the item @p it.
3463 * @param it The item
3464 * @return The item before @p it, or NULL if none
3468 EAPI Elm_Genlist_Item *
3469 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3471 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3474 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3475 if ((it) && (!it->delete_me)) break;
3477 return (Elm_Genlist_Item *)it;
3481 * Get the genlist object from an item
3483 * This returns the genlist object itself that an item belongs to.
3485 * @param it The item
3486 * @return The genlist object
3491 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3493 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3494 return it->base.widget;
3498 * Get the parent item of the given item
3500 * This returns the parent item of the item @p it given.
3502 * @param it The item
3503 * @return The parent of the item or NULL if none
3507 EAPI Elm_Genlist_Item *
3508 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3510 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3515 * Clear all sub-items (children) of the given item
3517 * This clears all items that are children (or their descendants) of the
3520 * @param it The item
3525 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3528 Eina_List *tl = NULL, *l;
3529 Elm_Genlist_Item *it2;
3531 EINA_LIST_FOREACH(it->items, l, it2)
3532 tl = eina_list_append(tl, it2);
3533 EINA_LIST_FREE(tl, it2)
3534 elm_genlist_item_del(it2);
3538 * Set the selected state of an item
3540 * This sets the selected state (1 selected, 0 not selected) of the given
3543 * @param it The item
3544 * @param selected The selected state
3549 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3552 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3553 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3555 if (it->delete_me) return;
3556 selected = !!selected;
3557 if (it->selected == selected) return;
3563 while (wd->selected)
3564 _item_unselect(wd->selected->data);
3574 * Get the selected state of an item
3576 * This gets the selected state of an item (1 selected, 0 not selected).
3578 * @param it The item
3579 * @return The selected state
3584 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3586 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3587 return it->selected;
3591 * Sets the expanded state of an item (if it's a parent)
3593 * This expands or contracts a parent item (thus showing or hiding the
3596 * @param it The item
3597 * @param expanded The expanded state (1 expanded, 0 not expanded).
3602 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3605 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3606 if (it->expanded == expanded) return;
3607 it->expanded = expanded;
3611 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3612 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3617 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3618 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3623 * Get the expanded state of an item
3625 * This gets the expanded state of an item
3627 * @param it The item
3628 * @return Thre expanded state
3633 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3635 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3636 return it->expanded;
3640 * Get the depth of expanded item
3642 * @param it The genlist item object
3643 * @return The depth of expanded item
3648 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3650 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3651 return it->expanded_depth;
3655 * Sets the disabled state of an item.
3657 * A disabled item cannot be selected or unselected. It will also
3658 * change appearance to appear disabled. This sets the disabled state
3659 * (1 disabled, 0 not disabled).
3661 * @param it The item
3662 * @param disabled The disabled state
3667 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3670 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3671 if (it->disabled == disabled) return;
3672 if (it->delete_me) return;
3673 it->disabled = disabled;
3677 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3679 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3684 * Get the disabled state of an item
3686 * This gets the disabled state of the given item.
3688 * @param it The item
3689 * @return The disabled state
3694 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3696 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3697 if (it->delete_me) return EINA_FALSE;
3698 return it->disabled;
3702 * Sets the display only state of an item.
3704 * A display only item cannot be selected or unselected. It is for
3705 * display only and not selecting or otherwise clicking, dragging
3706 * etc. by the user, thus finger size rules will not be applied to
3709 * @param it The item
3710 * @param display_only The display only state
3715 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3716 Eina_Bool display_only)
3718 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3719 if (!it->block) return;
3720 if (it->display_only == display_only) return;
3721 if (it->delete_me) return;
3722 it->display_only = display_only;
3723 it->mincalcd = EINA_FALSE;
3724 it->updateme = EINA_TRUE;
3725 it->block->updateme = EINA_TRUE;
3726 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3727 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3731 * Get the display only state of an item
3733 * This gets the display only state of the given item.
3735 * @param it The item
3736 * @return The display only state
3741 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3743 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3744 if (it->delete_me) return EINA_FALSE;
3745 return it->display_only;
3749 * Show the given item
3751 * This causes genlist to jump to the given item @p it and show it (by
3752 * scrolling), if it is not fully visible.
3754 * @param it The item
3759 elm_genlist_item_show(Elm_Genlist_Item *it)
3761 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3762 Evas_Coord gith = 0;
3763 if (it->delete_me) return;
3764 if ((it->queued) || (!it->mincalcd))
3766 it->wd->show_item = it;
3767 it->wd->bring_in = EINA_TRUE;
3768 it->showme = EINA_TRUE;
3771 if (it->wd->show_item)
3773 it->wd->show_item->showme = EINA_FALSE;
3774 it->wd->show_item = NULL;
3776 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3777 gith = it->group_item->h;
3778 elm_smart_scroller_child_region_show(it->wd->scr,
3779 it->x + it->block->x,
3780 it->y + it->block->y - gith,
3781 it->block->w, it->h);
3785 * Bring in the given item
3787 * This causes genlist to jump to the given item @p it and show it (by
3788 * scrolling), if it is not fully visible. This may use animation to
3789 * do so and take a period of time
3791 * @param it The item
3796 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3798 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3799 Evas_Coord gith = 0;
3800 if (it->delete_me) return;
3801 if ((it->queued) || (!it->mincalcd))
3803 it->wd->show_item = it;
3804 it->wd->bring_in = EINA_TRUE;
3805 it->showme = EINA_TRUE;
3808 if (it->wd->show_item)
3810 it->wd->show_item->showme = EINA_FALSE;
3811 it->wd->show_item = NULL;
3813 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3814 gith = it->group_item->h;
3815 elm_smart_scroller_region_bring_in(it->wd->scr,
3816 it->x + it->block->x,
3817 it->y + it->block->y - gith,
3818 it->block->w, it->h);
3822 * Show the given item at the top
3824 * This causes genlist to jump to the given item @p it and show it (by
3825 * scrolling), if it is not fully visible.
3827 * @param it The item
3832 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3834 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3836 Evas_Coord gith = 0;
3838 if (it->delete_me) return;
3839 if ((it->queued) || (!it->mincalcd))
3841 it->wd->show_item = it;
3842 it->wd->bring_in = EINA_TRUE;
3843 it->showme = EINA_TRUE;
3846 if (it->wd->show_item)
3848 it->wd->show_item->showme = EINA_FALSE;
3849 it->wd->show_item = NULL;
3851 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3852 if (it->group_item) gith = it->group_item->h;
3853 elm_smart_scroller_child_region_show(it->wd->scr,
3854 it->x + it->block->x,
3855 it->y + it->block->y - gith,
3860 * Bring in the given item at the top
3862 * This causes genlist to jump to the given item @p it and show it (by
3863 * scrolling), if it is not fully visible. This may use animation to
3864 * do so and take a period of time
3866 * @param it The item
3871 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3873 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3875 Evas_Coord gith = 0;
3877 if (it->delete_me) return;
3878 if ((it->queued) || (!it->mincalcd))
3880 it->wd->show_item = it;
3881 it->wd->bring_in = EINA_TRUE;
3882 it->showme = EINA_TRUE;
3885 if (it->wd->show_item)
3887 it->wd->show_item->showme = EINA_FALSE;
3888 it->wd->show_item = NULL;
3890 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3891 if (it->group_item) gith = it->group_item->h;
3892 elm_smart_scroller_region_bring_in(it->wd->scr,
3893 it->x + it->block->x,
3894 it->y + it->block->y - gith,
3899 * Show the given item at the middle
3901 * This causes genlist to jump to the given item @p it and show it (by
3902 * scrolling), if it is not fully visible.
3904 * @param it The item
3909 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3911 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3914 if (it->delete_me) return;
3915 if ((it->queued) || (!it->mincalcd))
3917 it->wd->show_item = it;
3918 it->wd->bring_in = EINA_TRUE;
3919 it->showme = EINA_TRUE;
3922 if (it->wd->show_item)
3924 it->wd->show_item->showme = EINA_FALSE;
3925 it->wd->show_item = NULL;
3927 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3928 elm_smart_scroller_child_region_show(it->wd->scr,
3929 it->x + it->block->x,
3930 it->y + it->block->y - oh / 2 +
3931 it->h / 2, it->block->w, oh);
3935 * Bring in the given item at the middle
3937 * This causes genlist to jump to the given item @p it and show it (by
3938 * scrolling), if it is not fully visible. This may use animation to
3939 * do so and take a period of time
3941 * @param it The item
3946 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3948 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3951 if (it->delete_me) return;
3952 if ((it->queued) || (!it->mincalcd))
3954 it->wd->show_item = it;
3955 it->wd->bring_in = EINA_TRUE;
3956 it->showme = EINA_TRUE;
3959 if (it->wd->show_item)
3961 it->wd->show_item->showme = EINA_FALSE;
3962 it->wd->show_item = NULL;
3964 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3965 elm_smart_scroller_region_bring_in(it->wd->scr,
3966 it->x + it->block->x,
3967 it->y + it->block->y - oh / 2 + it->h / 2,
3972 * Delete a given item
3974 * This deletes the item from genlist and calls the genlist item del
3975 * class callback defined in the item class, if it is set. This clears all
3976 * subitems if it is a tree.
3978 * @param it The item
3983 elm_genlist_item_del(Elm_Genlist_Item *it)
3985 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3986 if ((it->relcount > 0) || (it->walking > 0))
3988 elm_widget_item_pre_notify_del(it);
3989 elm_genlist_item_subitems_clear(it);
3990 it->delete_me = EINA_TRUE;
3991 if (it->wd->show_item == it) it->wd->show_item = NULL;
3993 it->wd->selected = eina_list_remove(it->wd->selected,
3997 if (it->realized) _item_unrealize(it);
3998 it->block->changed = EINA_TRUE;
3999 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4000 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4002 if (it->itc->func.del)
4003 it->itc->func.del((void *)it->base.data, it->base.widget);
4010 * Set the data item from the genlist item
4012 * This set the data value passed on the elm_genlist_item_append() and
4013 * related item addition calls. This function will also call
4014 * elm_genlist_item_update() so the item will be updated to reflect the
4017 * @param it The item
4018 * @param data The new data pointer to set
4023 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4026 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4027 elm_widget_item_data_set(it, data);
4028 elm_genlist_item_update(it);
4032 * Get the data item from the genlist item
4034 * This returns the data value passed on the elm_genlist_item_append()
4035 * and related item addition calls and elm_genlist_item_data_set().
4037 * @param it The item
4038 * @return The data pointer provided when created
4043 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4045 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4046 return elm_widget_item_data_get(it);
4050 * Tells genlist to "orphan" icons fetchs by the item class
4052 * This instructs genlist to release references to icons in the item,
4053 * meaning that they will no longer be managed by genlist and are
4054 * floating "orphans" that can be re-used elsewhere if the user wants
4057 * @param it The item
4062 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4065 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4066 EINA_LIST_FREE(it->icon_objs, icon)
4068 elm_widget_sub_object_del(it->base.widget, icon);
4069 evas_object_smart_member_del(icon);
4070 evas_object_hide(icon);
4075 * Get the real evas object of the genlist item
4077 * This returns the actual evas object used for the specified genlist
4078 * item. This may be NULL as it may not be created, and may be deleted
4079 * at any time by genlist. Do not modify this object (move, resize,
4080 * show, hide etc.) as genlist is controlling it. This function is for
4081 * querying, emitting custom signals or hooking lower level callbacks
4082 * for events. Do not delete this object under any circumstances.
4084 * @param it The item
4085 * @return The object pointer
4089 EAPI const Evas_Object *
4090 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4092 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4093 return it->base.view;
4097 * Update the contents of an item
4099 * This updates an item by calling all the item class functions again
4100 * to get the icons, labels and states. Use this when the original
4101 * item data has changed and the changes are desired to be reflected.
4103 * @param it The item
4108 elm_genlist_item_update(Elm_Genlist_Item *it)
4110 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4111 if (!it->block) return;
4112 if (it->delete_me) return;
4113 it->mincalcd = EINA_FALSE;
4114 it->updateme = EINA_TRUE;
4115 it->block->updateme = EINA_TRUE;
4116 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4117 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4121 * Update the item class of an item
4123 * @param it The item
4124 * @parem itc The item class for the item
4129 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4130 const Elm_Genlist_Item_Class *itc)
4132 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4133 if (!it->block) return;
4134 EINA_SAFETY_ON_NULL_RETURN(itc);
4135 if (it->delete_me) return;
4137 elm_genlist_item_update(it);
4140 static Evas_Object *
4141 _elm_genlist_item_label_create(void *data,
4143 void *item __UNUSED__)
4145 Evas_Object *label = elm_label_add(obj);
4148 elm_object_style_set(label, "tooltip");
4149 elm_label_label_set(label, data);
4154 _elm_genlist_item_label_del_cb(void *data,
4155 Evas_Object *obj __UNUSED__,
4156 void *event_info __UNUSED__)
4158 eina_stringshare_del(data);
4162 * Set the text to be shown in the genlist item.
4164 * @param item Target item
4165 * @param text The text to set in the content
4167 * Setup the text as tooltip to object. The item can have only one
4168 * tooltip, so any previous tooltip data is removed.
4173 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4176 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4177 text = eina_stringshare_add(text);
4178 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4180 _elm_genlist_item_label_del_cb);
4184 * Set the content to be shown in the tooltip item
4186 * Setup the tooltip to item. The item can have only one tooltip, so
4187 * any previous tooltip data is removed. @p func(with @p data) will be
4188 * called every time that need to show the tooltip and it should return a
4189 * valid Evas_Object. This object is then managed fully by tooltip
4190 * system and is deleted when the tooltip is gone.
4192 * @param item the genlist item being attached by a tooltip.
4193 * @param func the function used to create the tooltip contents.
4194 * @param data what to provide to @a func as callback data/context.
4195 * @param del_cb called when data is not needed anymore, either when
4196 * another callback replaces @func, the tooltip is unset with
4197 * elm_genlist_item_tooltip_unset() or the owner @a item
4198 * dies. This callback receives as the first parameter the
4199 * given @a data, and @c event_info is the item.
4204 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4205 Elm_Tooltip_Item_Content_Cb func,
4207 Evas_Smart_Cb del_cb)
4209 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4211 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4214 if (item->tooltip.del_cb)
4215 item->tooltip.del_cb((void *)item->tooltip.data,
4216 item->base.widget, item);
4218 item->tooltip.content_cb = func;
4219 item->tooltip.data = data;
4220 item->tooltip.del_cb = del_cb;
4222 if (item->base.view)
4224 elm_widget_item_tooltip_content_cb_set(item,
4225 item->tooltip.content_cb,
4226 item->tooltip.data, NULL);
4227 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4233 if (del_cb) del_cb((void *)data, NULL, NULL);
4237 * Unset tooltip from item
4239 * @param item genlist item to remove previously set tooltip.
4241 * Remove tooltip from item. The callback provided as del_cb to
4242 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4243 * it is not used anymore.
4245 * @see elm_genlist_item_tooltip_content_cb_set()
4250 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4252 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4253 if ((item->base.view) && (item->tooltip.content_cb))
4254 elm_widget_item_tooltip_unset(item);
4256 if (item->tooltip.del_cb)
4257 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4258 item->tooltip.del_cb = NULL;
4259 item->tooltip.content_cb = NULL;
4260 item->tooltip.data = NULL;
4261 if (item->tooltip.style)
4262 elm_genlist_item_tooltip_style_set(item, NULL);
4266 * Sets a different style for this item tooltip.
4268 * @note before you set a style you should define a tooltip with
4269 * elm_genlist_item_tooltip_content_cb_set() or
4270 * elm_genlist_item_tooltip_text_set()
4272 * @param item genlist item with tooltip already set.
4273 * @param style the theme style to use (default, transparent, ...)
4278 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4281 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4282 eina_stringshare_replace(&item->tooltip.style, style);
4283 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4287 * Get the style for this item tooltip.
4289 * @param item genlist item with tooltip already set.
4290 * @return style the theme style in use, defaults to "default". If the
4291 * object does not have a tooltip set, then NULL is returned.
4296 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4299 return item->tooltip.style;
4303 * Set the cursor to be shown when mouse is over the genlist item
4305 * @param item Target item
4306 * @param cursor the cursor name to be used.
4308 * @see elm_object_cursor_set()
4312 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4316 eina_stringshare_replace(&item->mouse_cursor, cursor);
4317 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4321 * Get the cursor to be shown when mouse is over the genlist item
4323 * @param item genlist item with cursor already set.
4324 * @return the cursor name.
4329 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4331 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4332 return elm_widget_item_cursor_get(item);
4336 * Unset the cursor to be shown when mouse is over the genlist item
4338 * @param item Target item
4340 * @see elm_object_cursor_unset()
4344 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4346 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4347 if (!item->mouse_cursor)
4350 if (item->base.view)
4351 elm_widget_item_cursor_unset(item);
4353 eina_stringshare_del(item->mouse_cursor);
4354 item->mouse_cursor = NULL;
4358 * Sets a different style for this item cursor.
4360 * @note before you set a style you should define a cursor with
4361 * elm_genlist_item_cursor_set()
4363 * @param item genlist item with cursor already set.
4364 * @param style the theme style to use (default, transparent, ...)
4369 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4372 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4373 elm_widget_item_cursor_style_set(item, style);
4377 * Get the style for this item cursor.
4379 * @param item genlist item with cursor already set.
4380 * @return style the theme style in use, defaults to "default". If the
4381 * object does not have a cursor set, then NULL is returned.
4386 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4388 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4389 return elm_widget_item_cursor_style_get(item);
4393 * Set if the cursor set should be searched on the theme or should use
4394 * the provided by the engine, only.
4396 * @note before you set if should look on theme you should define a
4397 * cursor with elm_object_cursor_set(). By default it will only look
4398 * for cursors provided by the engine.
4400 * @param item widget item with cursor already set.
4401 * @param engine_only boolean to define it cursors should be looked
4402 * only between the provided by the engine or searched on widget's
4408 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4409 Eina_Bool engine_only)
4411 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4412 elm_widget_item_cursor_engine_only_set(item, engine_only);
4416 * Get the cursor engine only usage for this item cursor.
4418 * @param item widget item with cursor already set.
4419 * @return engine_only boolean to define it cursors should be looked
4420 * only between the provided by the engine or searched on widget's
4421 * theme as well. If the object does not have a cursor set, then
4422 * EINA_FALSE is returned.
4427 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4429 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4430 return elm_widget_item_cursor_engine_only_get(item);
4434 * This sets the horizontal stretching mode
4436 * This sets the mode used for sizing items horizontally. Valid modes
4437 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4438 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4439 * the scroller will scroll horizontally. Otherwise items are expanded
4440 * to fill the width of the viewport of the scroller. If it is
4441 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4442 * limited to that size.
4444 * @param obj The genlist object
4445 * @param mode The mode to use
4450 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4453 ELM_CHECK_WIDTYPE(obj, widtype);
4454 Widget_Data *wd = elm_widget_data_get(obj);
4456 if (wd->mode == mode) return;
4462 * Gets the horizontal stretching mode
4464 * @param obj The genlist object
4465 * @return The mode to use
4466 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4471 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4473 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4474 Widget_Data *wd = elm_widget_data_get(obj);
4475 if (!wd) return ELM_LIST_LAST;
4480 * Set the always select mode.
4482 * Items will only call their selection func and callback when first
4483 * becoming selected. Any further clicks will do nothing, unless you
4484 * enable always select with elm_genlist_always_select_mode_set().
4485 * This means even if selected, every click will make the selected
4486 * callbacks be called.
4488 * @param obj The genlist object
4489 * @param always_select The always select mode
4490 * (EINA_TRUE = on, EINA_FALSE = off)
4495 elm_genlist_always_select_mode_set(Evas_Object *obj,
4496 Eina_Bool always_select)
4498 ELM_CHECK_WIDTYPE(obj, widtype);
4499 Widget_Data *wd = elm_widget_data_get(obj);
4501 wd->always_select = always_select;
4505 * Get the always select mode.
4507 * @param obj The genlist object
4508 * @return The always select mode
4509 * (EINA_TRUE = on, EINA_FALSE = off)
4514 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4516 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4517 Widget_Data *wd = elm_widget_data_get(obj);
4518 if (!wd) return EINA_FALSE;
4519 return wd->always_select;
4523 * Set no select mode
4525 * This will turn off the ability to select items entirely and they
4526 * will neither appear selected nor call selected callback functions.
4528 * @param obj The genlist object
4529 * @param no_select The no select mode
4530 * (EINA_TRUE = on, EINA_FALSE = off)
4535 elm_genlist_no_select_mode_set(Evas_Object *obj,
4536 Eina_Bool no_select)
4538 ELM_CHECK_WIDTYPE(obj, widtype);
4539 Widget_Data *wd = elm_widget_data_get(obj);
4541 wd->no_select = no_select;
4545 * Gets no select mode
4547 * @param obj The genlist object
4548 * @return The no select mode
4549 * (EINA_TRUE = on, EINA_FALSE = off)
4554 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4556 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4557 Widget_Data *wd = elm_widget_data_get(obj);
4558 if (!wd) return EINA_FALSE;
4559 return wd->no_select;
4565 * This will enable the compress mode where items are "compressed"
4566 * horizontally to fit the genlist scrollable viewport width. This is
4567 * special for genlist. Do not rely on
4568 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4569 * work as genlist needs to handle it specially.
4571 * @param obj The genlist object
4572 * @param compress The compress mode
4573 * (EINA_TRUE = on, EINA_FALSE = off)
4578 elm_genlist_compress_mode_set(Evas_Object *obj,
4581 ELM_CHECK_WIDTYPE(obj, widtype);
4582 Widget_Data *wd = elm_widget_data_get(obj);
4584 wd->compress = compress;
4588 * Get the compress mode
4590 * @param obj The genlist object
4591 * @return The compress mode
4592 * (EINA_TRUE = on, EINA_FALSE = off)
4597 elm_genlist_compress_mode_get(const Evas_Object *obj)
4599 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4600 Widget_Data *wd = elm_widget_data_get(obj);
4601 if (!wd) return EINA_FALSE;
4602 return wd->compress;
4606 * Set height-for-width mode
4608 * With height-for-width mode the item width will be fixed (restricted
4609 * to a minimum of) to the list width when calculating its size in
4610 * order to allow the height to be calculated based on it. This allows,
4611 * for instance, text block to wrap lines if the Edje part is
4612 * configured with "text.min: 0 1".
4614 * @note This mode will make list resize slower as it will have to
4615 * recalculate every item height again whenever the list width
4618 * @note When height-for-width mode is enabled, it also enables
4619 * compress mode (see elm_genlist_compress_mode_set()) and
4620 * disables homogeneous (see elm_genlist_homogeneous_set()).
4622 * @param obj The genlist object
4623 * @param setting The height-for-width mode (EINA_TRUE = on,
4629 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4630 Eina_Bool height_for_width)
4632 ELM_CHECK_WIDTYPE(obj, widtype);
4633 Widget_Data *wd = elm_widget_data_get(obj);
4635 wd->height_for_width = !!height_for_width;
4636 if (wd->height_for_width)
4638 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4639 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4644 * Get the height-for-width mode
4646 * @param obj The genlist object
4647 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4653 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4655 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4656 Widget_Data *wd = elm_widget_data_get(obj);
4657 if (!wd) return EINA_FALSE;
4658 return wd->height_for_width;
4664 * This will enable or disable the scroller bounce mode for the
4665 * genlist. See elm_scroller_bounce_set() for details
4667 * @param obj The genlist object
4668 * @param h_bounce Allow bounce horizontally
4669 * @param v_bounce Allow bounce vertically
4674 elm_genlist_bounce_set(Evas_Object *obj,
4678 ELM_CHECK_WIDTYPE(obj, widtype);
4679 Widget_Data *wd = elm_widget_data_get(obj);
4681 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4685 * Get the bounce mode
4687 * @param obj The genlist object
4688 * @param h_bounce Allow bounce horizontally
4689 * @param v_bounce Allow bounce vertically
4694 elm_genlist_bounce_get(const Evas_Object *obj,
4695 Eina_Bool *h_bounce,
4696 Eina_Bool *v_bounce)
4698 ELM_CHECK_WIDTYPE(obj, widtype);
4699 Widget_Data *wd = elm_widget_data_get(obj);
4701 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4705 * Set homogenous mode
4707 * This will enable the homogeneous mode where items are of the same
4708 * height and width so that genlist may do the lazy-loading at its
4709 * maximum. This implies 'compressed' mode.
4711 * @param obj The genlist object
4712 * @param homogeneous Assume the items within the genlist are of the
4713 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4718 elm_genlist_homogeneous_set(Evas_Object *obj,
4719 Eina_Bool homogeneous)
4721 ELM_CHECK_WIDTYPE(obj, widtype);
4722 Widget_Data *wd = elm_widget_data_get(obj);
4724 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4725 wd->homogeneous = homogeneous;
4729 * Get the homogenous mode
4731 * @param obj The genlist object
4732 * @return Assume the items within the genlist are of the same height
4733 * and width (EINA_TRUE = on, EINA_FALSE = off)
4738 elm_genlist_homogeneous_get(const Evas_Object *obj)
4740 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4741 Widget_Data *wd = elm_widget_data_get(obj);
4742 if (!wd) return EINA_FALSE;
4743 return wd->homogeneous;
4747 * Set the maximum number of items within an item block
4749 * This will configure the block count to tune to the target with
4750 * particular performance matrix.
4752 * @param obj The genlist object
4753 * @param n Maximum number of items within an item block
4758 elm_genlist_block_count_set(Evas_Object *obj,
4761 ELM_CHECK_WIDTYPE(obj, widtype);
4762 Widget_Data *wd = elm_widget_data_get(obj);
4764 wd->max_items_per_block = n;
4765 wd->item_cache_max = wd->max_items_per_block * 2;
4766 _item_cache_clean(wd);
4770 * Get the maximum number of items within an item block
4772 * @param obj The genlist object
4773 * @return Maximum number of items within an item block
4778 elm_genlist_block_count_get(const Evas_Object *obj)
4780 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4781 Widget_Data *wd = elm_widget_data_get(obj);
4783 return wd->max_items_per_block;
4787 * Set the timeout in seconds for the longpress event
4789 * @param obj The genlist object
4790 * @param timeout timeout in seconds
4795 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4798 ELM_CHECK_WIDTYPE(obj, widtype);
4799 Widget_Data *wd = elm_widget_data_get(obj);
4801 wd->longpress_timeout = timeout;
4805 * Get the timeout in seconds for the longpress event
4807 * @param obj The genlist object
4808 * @return timeout in seconds
4813 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4815 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4816 Widget_Data *wd = elm_widget_data_get(obj);
4818 return wd->longpress_timeout;
4822 * Set the scrollbar policy
4824 * This sets the scrollbar visibility policy for the given genlist
4825 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
4826 * made visible if it is needed, and otherwise kept hidden.
4827 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
4828 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
4829 * respectively for the horizontal and vertical scrollbars.
4831 * @param obj The genlist object
4832 * @param policy_h Horizontal scrollbar policy
4833 * @param policy_v Vertical scrollbar policy
4838 elm_genlist_scroller_policy_set(Evas_Object *obj,
4839 Elm_Scroller_Policy policy_h,
4840 Elm_Scroller_Policy policy_v)
4842 ELM_CHECK_WIDTYPE(obj, widtype);
4843 Widget_Data *wd = elm_widget_data_get(obj);
4845 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4846 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4849 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4853 * Get the scrollbar policy
4855 * @param obj The genlist object
4856 * @param policy_h Horizontal scrollbar policy
4857 * @param policy_v Vertical scrollbar policy
4862 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4863 Elm_Scroller_Policy *policy_h,
4864 Elm_Scroller_Policy *policy_v)
4866 ELM_CHECK_WIDTYPE(obj, widtype);
4867 Widget_Data *wd = elm_widget_data_get(obj);
4868 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4869 if ((!wd) || (!wd->scr)) return;
4870 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4871 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4872 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;