1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Genlist has a fairly large API, mostly because it's relatively complex,
19 * trying to be both expansive, powerful and efficient. First we will begin
20 * an overview on the theory behind genlist.
22 * Evas tracks every object you create. Every time it processes an event
23 * (mouse move, down, up etc.) it needs to walk through objects and find out
24 * what event that affects. Even worse every time it renders display updates,
25 * in order to just calculate what to re-draw, it needs to walk through many
26 * many many objects. Thus, the more objects you keep active, the more
27 * overhead Evas has in just doing its work. It is advisable to keep your
28 * active objects to the minimum working set you need. Also remember that
29 * object creation and deletion carries an overhead, so there is a
30 * middle-ground, which is not easily determined. But don't keep massive lists
31 * of objects you can't see or use. Genlist does this with list objects. It
32 * creates and destroys them dynamically as you scroll around. It groups them
33 * into blocks so it can determine the visibility etc. of a whole block at
34 * once as opposed to having to walk the whole list. This 2-level list allows
35 * for very large numbers of items to be in the list (tests have used up to
36 * 2,000,000 items). Also genlist employs a queue for adding items. As items
37 * may be different sizes, every item added needs to be calculated as to its
38 * size and thus this presents a lot of overhead on populating the list, this
39 * genlist employs a queue. Any item added is queued and spooled off over
40 * time, actually appearing some time later, so if your list has many members
41 * you may find it takes a while for them to all appear, with your process
42 * consuming a lot of CPU while it is busy spooling.
44 * Genlist also implements a tree structure, but it does so with callbacks to
45 * the application, with the application filling in tree structures when
46 * requested (allowing for efficient building of a very deep tree that could
47 * even be used for file-management). See the above smart signal callbacks for
50 * An item in the genlist world can have 0 or more text labels (they can be
51 * regular text or textblock - that's up to the style to determine), 0 or
52 * more icons (which are simply objects swallowed into the genlist item) and
53 * 0 or more boolean states that can be used for check, radio or other
54 * indicators by the edje theme style. An item may be one of several styles
55 * (Elementary provides 4 by default - "default", "double_label", "group_index"
56 * and "icon_top_text_bottom", but this can be extended by system or
57 * application custom themes/overlays/extensions).
59 * In order to implement the ability to add and delete items on the fly,
60 * Genlist implements a class/callback system where the application provides
61 * a structure with information about that type of item (genlist may contain
62 * multiple different items with different classes, states and styles).
63 * Genlist will call the functions in this struct (methods) when an item is
64 * "realized" (that is created dynamically while scrolling). All objects will
65 * simply be deleted when no longer needed with evas_object_del(). The
66 * Elm_Genlist_Item_Class structure contains the following members:
68 * item_style - This is a constant string and simply defines the name of the
69 * item style. It must be specified and the default should be "default".
71 * func.label_get - This function is called when an actual item object is
72 * created. The data parameter is the data parameter passed to
73 * elm_genlist_item_append() and related item creation functions. The obj
74 * parameter is the genlist object and the part parameter is the string name
75 * of the text part in the edje design that is listed as one of the possible
76 * labels that can be set. This function must return a strudup()'ed string as
77 * the caller will free() it when done.
79 * func.icon_get - This function is called when an actual item object is
80 * created. The data parameter is the data parameter passed to
81 * elm_genlist_item_append() and related item creation functions. The obj
82 * parameter is the genlist object and the part parameter is the string name
83 * of the icon part in the edje design that is listed as one of the possible
84 * icons that can be set. This must return NULL for no object or a valid
85 * object. The object will be deleted by genlist on shutdown or when the item
88 * func.state_get - This function is called when an actual item object is
89 * created. The data parameter is the data parameter passed to
90 * elm_genlist_item_append() and related item creation functions. The obj
91 * parameter is the genlist object and the part parameter is the string name
92 * of the state part in the edje design that is listed as one of the possible
93 * states that can be set. Return 0 for false or 1 for true. Genlist will
94 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95 * true (the default is false), where XXX is the name of the part.
97 * func.del - This is called when elm_genlist_item_del() is called on an
98 * item, elm_genlist_clear() is called on the genlist, or
99 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100 * intended for use when actual genlist items are deleted, so any backing
101 * data attached to the item (e.g. its data parameter on creation) can be
104 * Items can be added by several calls. All of them return a Elm_Genlist_Item
105 * handle that is an internal member inside the genlist. They all take a data
106 * parameter that is meant to be used for a handle to the applications
107 * internal data (eg the struct with the original item data). The parent
108 * parameter is the parent genlist item this belongs to if it is a tree or
109 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112 * is displayed as an item that is able to expand and have child items.
113 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114 * displayed at the top until the next group comes. The func parameter is a
115 * convenience callback that is called when the item is selected and the data
116 * parameter will be the func_data parameter, obj be the genlist object and
117 * event_info will be the genlist item.
119 * elm_genlist_item_append() appends an item to the end of the list, or if
120 * there is a parent, to the end of all the child items of the parent.
121 * elm_genlist_item_prepend() is the same but prepends to the beginning of
122 * the list or children list. elm_genlist_item_insert_before() inserts at
123 * item before another item and elm_genlist_item_insert_after() inserts after
124 * the indicated item.
126 * The application can clear the list with elm_genlist_clear() which deletes
127 * all the items in the list and elm_genlist_item_del() will delete a specific
128 * item. elm_genlist_item_subitems_clear() will clear all items that are
129 * children of the indicated parent item.
131 * If the application wants multiple items to be able to be selected,
132 * elm_genlist_multi_select_set() can enable this. If the list is
133 * single-selection only (the default), then elm_genlist_selected_item_get()
134 * will return the selected item, if any, or NULL I none is selected. If the
135 * list is multi-select then elm_genlist_selected_items_get() will return a
136 * list (that is only valid as long as no items are modified (added, deleted,
137 * selected or unselected)).
139 * To help inspect list items you can jump to the item at the top of the list
140 * with elm_genlist_first_item_get() which will return the item pointer, and
141 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143 * and previous items respectively relative to the indicated item. Using
144 * these calls you can walk the entire item list/tree. Note that as a tree
145 * the items are flattened in the list, so elm_genlist_item_parent_get() will
146 * let you know which item is the parent (and thus know how to skip them if
149 * There are also convenience functions. elm_genlist_item_genlist_get() will
150 * return the genlist object the item belongs to. elm_genlist_item_show()
151 * will make the scroller scroll to show that specific item so its visible.
152 * elm_genlist_item_data_get() returns the data pointer set by the item
153 * creation functions.
155 * If an item changes (state of boolean changes, label or icons change),
156 * then use elm_genlist_item_update() to have genlist update the item with
157 * the new state. Genlist will re-realize the item thus call the functions
158 * in the _Elm_Genlist_Item_Class for that item.
160 * To programmatically (un)select an item use elm_genlist_item_selected_set().
161 * To get its selected state use elm_genlist_item_selected_get(). Similarly
162 * to expand/contract an item and get its expanded state, use
163 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164 * again to make an item disabled (unable to be selected and appear
165 * differently) use elm_genlist_item_disabled_set() to set this and
166 * elm_genlist_item_disabled_get() to get the disabled state.
168 * In general to indicate how the genlist should expand items horizontally to
169 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171 * mode means that if items are too wide to fit, the scroller will scroll
172 * horizontally. Otherwise items are expanded to fill the width of the
173 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174 * to the viewport width and limited to that size. This can be combined with
175 * a different style that uses edjes' ellipsis feature (cutting text off like
178 * Items will only call their selection func and callback when first becoming
179 * selected. Any further clicks will do nothing, unless you enable always
180 * select with elm_genlist_always_select_mode_set(). This means even if
181 * selected, every click will make the selected callbacks be called.
182 * elm_genlist_no_select_mode_set() will turn off the ability to select
183 * items entirely and they will neither appear selected nor call selected
184 * callback functions.
186 * Remember that you can create new styles and add your own theme augmentation
187 * per application with elm_theme_extension_add(). If you absolutely must
188 * have a specific style that overrides any theme the user or system sets up
189 * you can use elm_theme_overlay_add() to add such a file.
191 * Signals that you can add callbacks for are:
193 * "clicked,double" - This is called when a user has double-clicked an item. The
194 * event_info parameter is the genlist item that was double-c
196 * "selected" - This is called when a user has made an item selected. The
197 * event_info parameter is the genlist item that was selected.
198 * "unselected" - This is called when a user has made an item unselected. The
199 * event_info parameter is the genlist item that was unselected.
200 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201 * and the item is now meant to be expanded. The event_info
202 * parameter is the genlist item that was indicated to expand. It
203 * is the job of this callback to then fill in the child items.
204 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205 * and the item is now meant to be contracted. The event_info
206 * parameter is the genlist item that was indicated to contract.
207 * It is the job of this callback to then delete the child items.
208 * "expand,request" - This is called when a user has indicated they want to
209 * expand a tree branch item. The callback should decide if
210 * the item can expand (has any children) and then call
211 * elm_genlist_item_expanded_set() appropriately to set the
212 * state. The event_info parameter is the genlist item that
213 * was indicated to expand.
214 * "contract,request" - This is called when a user has indicated they want to
215 * contract a tree branch item. The callback should decide
216 * if the item can contract (has any children) and then
217 * call elm_genlist_item_expanded_set() appropriately to
218 * set the state. The event_info parameter is the genlist
219 * item that was indicated to contract.
220 * "realized" - This is called when the item in the list is created as a real
221 * evas object. event_info parameter is the genlist item that was
222 * created. The object may be deleted at any time, so it is up to
223 * the caller to not use the object pointer from
224 * elm_genlist_item_object_get() in a way where it may point to
226 * "unrealized" - This is called just before an item is unrealized. After this
227 * call icon objects provided will be deleted and the item object
228 * itself delete or be put into a floating cache.
229 * "drag,start,up" - This is called when the item in the list has been dragged
231 * "drag,start,down" - This is called when the item in the list has been dragged
232 * (not scrolled) down.
233 * "drag,start,left" - This is called when the item in the list has been dragged
234 * (not scrolled) left.
235 * "drag,start,right" - This is called when the item in the list has been
236 * dragged (not scrolled) right.
237 * "drag,stop" - This is called when the item in the list has stopped being
239 * "drag" - This is called when the item in the list is being dragged.
240 * "longpressed" - This is called when the item is pressed for a certain amount
241 * of time. By default it's 1 second.
242 * "scroll,edge,top" - This is called when the genlist is scrolled until the
244 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
246 * "scroll,edge,left" - This is called when the genlist is scrolled until the
248 * "scroll,edge,right" - This is called when the genlist is scrolled until the
250 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
252 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
254 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
257 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
259 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block Item_Block;
264 typedef struct _Pan Pan;
265 typedef struct _Item_Cache Item_Cache;
269 Evas_Object *obj, *scr, *pan_smart;
270 Eina_Inlist *items, *blocks;
271 Eina_List *group_items;
273 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
274 Ecore_Job *calc_job, *update_job;
275 Ecore_Idler *queue_idler;
276 Ecore_Idler *must_recalc_idler;
277 Eina_List *queue, *selected;
278 Elm_Genlist_Item *show_item;
279 Elm_Genlist_Item *last_selected_item;
280 Eina_Inlist *item_cache;
281 Elm_Genlist_Item *anchor_item;
284 Ecore_Timer *multi_timer;
285 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
286 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
287 Eina_Bool mouse_down : 1;
288 Eina_Bool multi_down : 1;
289 Eina_Bool multi_timeout : 1;
290 Eina_Bool multitouched : 1;
291 Eina_Bool on_hold : 1;
293 Eina_Bool always_select : 1;
294 Eina_Bool longpressed : 1;
295 Eina_Bool wasselected : 1;
296 Eina_Bool no_select : 1;
297 Eina_Bool bring_in : 1;
298 Eina_Bool compress : 1;
299 Eina_Bool height_for_width : 1;
300 Eina_Bool homogeneous : 1;
301 Eina_Bool clear_me : 1;
306 } history[SWIPE_MOVES];
308 int item_cache_count;
314 int group_item_width;
315 int group_item_height;
316 int max_items_per_block;
317 double longpress_timeout;
327 Evas_Coord x, y, w, h, minw, minh;
328 Eina_Bool want_unrealize : 1;
329 Eina_Bool realized : 1;
330 Eina_Bool changed : 1;
331 Eina_Bool updateme : 1;
332 Eina_Bool showme : 1;
333 Eina_Bool must_recalc : 1;
336 struct _Elm_Genlist_Item
338 Elm_Widget_Item base;
343 Evas_Coord x, y, w, h, minw, minh;
344 const Elm_Genlist_Item_Class *itc;
345 Elm_Genlist_Item *parent;
346 Elm_Genlist_Item *group_item;
347 Elm_Genlist_Item_Flags flags;
355 Eina_List *labels, *icons, *states, *icon_objs;
356 Ecore_Timer *long_timer;
357 Ecore_Timer *swipe_timer;
359 Evas_Coord scrl_x, scrl_y;
361 Elm_Genlist_Item *rel;
366 Elm_Tooltip_Item_Content_Cb content_cb;
367 Evas_Smart_Cb del_cb;
371 const char *mouse_cursor;
378 Eina_Bool before : 1;
380 Eina_Bool want_unrealize : 1;
381 Eina_Bool want_realize : 1;
382 Eina_Bool realized : 1;
383 Eina_Bool selected : 1;
384 Eina_Bool highlighted : 1;
385 Eina_Bool expanded : 1;
386 Eina_Bool disabled : 1;
387 Eina_Bool display_only : 1;
388 Eina_Bool mincalcd : 1;
389 Eina_Bool queued : 1;
390 Eina_Bool showme : 1;
391 Eina_Bool delete_me : 1;
393 Eina_Bool dragging : 1;
394 Eina_Bool updateme : 1;
395 Eina_Bool nocache : 1;
402 Evas_Object *base_view, *spacer;
404 const char *item_style; // it->itc->item_style
405 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
406 Eina_Bool compress : 1; // it->wd->compress
407 Eina_Bool odd : 1; // in & 0x1
409 Eina_Bool selected : 1; // it->selected
410 Eina_Bool disabled : 1; // it->disabled
411 Eina_Bool expanded : 1; // it->expanded
414 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
415 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
419 Evas_Object_Smart_Clipped_Data __clipped_data;
421 Ecore_Job *resize_job;
424 static const char *widtype = NULL;
425 static void _item_cache_zero(Widget_Data *wd);
426 static void _del_hook(Evas_Object *obj);
427 static void _mirrored_set(Evas_Object *obj,
429 static void _theme_hook(Evas_Object *obj);
430 static void _show_region_hook(void *data,
432 static void _sizing_eval(Evas_Object *obj);
433 static void _item_unrealize(Elm_Genlist_Item *it);
434 static void _item_block_unrealize(Item_Block *itb);
435 static void _calc_job(void *data);
436 static void _on_focus_hook(void *data,
438 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
439 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
440 static Eina_Bool _item_single_select_up(Widget_Data *wd);
441 static Eina_Bool _item_single_select_down(Widget_Data *wd);
442 static Eina_Bool _event_hook(Evas_Object *obj,
444 Evas_Callback_Type type,
446 static Eina_Bool _deselect_all_items(Widget_Data *wd);
447 static void _pan_calculate(Evas_Object *obj);
449 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
452 _event_hook(Evas_Object *obj,
453 Evas_Object *src __UNUSED__,
454 Evas_Callback_Type type,
457 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
458 Evas_Event_Key_Down *ev = event_info;
459 Widget_Data *wd = elm_widget_data_get(obj);
460 if (!wd) return EINA_FALSE;
461 if (!wd->items) return EINA_FALSE;
462 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
463 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
465 Elm_Genlist_Item *it = NULL;
468 Evas_Coord step_x = 0;
469 Evas_Coord step_y = 0;
472 Evas_Coord page_x = 0;
473 Evas_Coord page_y = 0;
475 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
476 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
477 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
478 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
480 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
484 else if ((!strcmp(ev->keyname, "Right")) ||
485 (!strcmp(ev->keyname, "KP_Right")))
489 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
491 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
492 (_item_multi_select_up(wd)))
493 || (_item_single_select_up(wd)))
495 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
501 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
503 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
504 (_item_multi_select_down(wd)))
505 || (_item_single_select_down(wd)))
507 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
513 else if ((!strcmp(ev->keyname, "Home")) ||
514 (!strcmp(ev->keyname, "KP_Home")))
516 it = elm_genlist_first_item_get(obj);
517 elm_genlist_item_bring_in(it);
518 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
521 else if ((!strcmp(ev->keyname, "End")) ||
522 (!strcmp(ev->keyname, "KP_End")))
524 it = elm_genlist_last_item_get(obj);
525 elm_genlist_item_bring_in(it);
526 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
529 else if ((!strcmp(ev->keyname, "Prior")) ||
530 (!strcmp(ev->keyname, "KP_Prior")))
533 y -= -(page_y * v_h) / 100;
537 else if ((!strcmp(ev->keyname, "Next")) ||
538 (!strcmp(ev->keyname, "KP_Next")))
541 y += -(page_y * v_h) / 100;
545 else if(((!strcmp(ev->keyname, "Return")) ||
546 (!strcmp(ev->keyname, "KP_Enter")) ||
547 (!strcmp(ev->keyname, "space")))
548 && (!wd->multi) && (wd->selected))
550 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
551 elm_genlist_item_expanded_set(it,
552 !elm_genlist_item_expanded_get(it));
554 else if (!strcmp(ev->keyname, "Escape"))
556 if (!_deselect_all_items(wd)) return EINA_FALSE;
557 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
560 else return EINA_FALSE;
562 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
563 elm_smart_scroller_child_pos_set(wd->scr, x, y);
568 _deselect_all_items(Widget_Data *wd)
570 if (!wd->selected) return EINA_FALSE;
572 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
578 _item_multi_select_up(Widget_Data *wd)
580 if (!wd->selected) return EINA_FALSE;
581 if (!wd->multi) return EINA_FALSE;
583 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
584 if (!prev) return EINA_TRUE;
586 if (elm_genlist_item_selected_get(prev))
588 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
589 wd->last_selected_item = prev;
590 elm_genlist_item_show(wd->last_selected_item);
594 elm_genlist_item_selected_set(prev, EINA_TRUE);
595 elm_genlist_item_show(prev);
601 _item_multi_select_down(Widget_Data *wd)
603 if (!wd->selected) return EINA_FALSE;
604 if (!wd->multi) return EINA_FALSE;
606 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
607 if (!next) return EINA_TRUE;
609 if (elm_genlist_item_selected_get(next))
611 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
612 wd->last_selected_item = next;
613 elm_genlist_item_show(wd->last_selected_item);
617 elm_genlist_item_selected_set(next, EINA_TRUE);
618 elm_genlist_item_show(next);
624 _item_single_select_up(Widget_Data *wd)
626 Elm_Genlist_Item *prev;
629 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
630 while ((prev) && (prev->delete_me))
631 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
633 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
635 if (!prev) return EINA_FALSE;
637 _deselect_all_items(wd);
639 elm_genlist_item_selected_set(prev, EINA_TRUE);
640 elm_genlist_item_show(prev);
645 _item_single_select_down(Widget_Data *wd)
647 Elm_Genlist_Item *next;
650 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
651 while ((next) && (next->delete_me))
652 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
654 else next = elm_genlist_item_next_get(wd->last_selected_item);
656 if (!next) return EINA_FALSE;
658 _deselect_all_items(wd);
660 elm_genlist_item_selected_set(next, EINA_TRUE);
661 elm_genlist_item_show(next);
666 _on_focus_hook(void *data __UNUSED__,
669 Widget_Data *wd = elm_widget_data_get(obj);
671 if (elm_widget_focus_get(obj))
673 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
674 evas_object_focus_set(wd->obj, EINA_TRUE);
675 if ((wd->selected) && (!wd->last_selected_item))
676 wd->last_selected_item = eina_list_data_get(wd->selected);
680 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
681 evas_object_focus_set(wd->obj, EINA_FALSE);
686 _del_hook(Evas_Object *obj)
688 Widget_Data *wd = elm_widget_data_get(obj);
690 _item_cache_zero(wd);
691 if (wd->calc_job) ecore_job_del(wd->calc_job);
692 if (wd->update_job) ecore_job_del(wd->update_job);
693 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
694 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
699 _del_pre_hook(Evas_Object *obj)
701 Widget_Data *wd = elm_widget_data_get(obj);
703 evas_object_del(wd->pan_smart);
704 wd->pan_smart = NULL;
705 elm_genlist_clear(obj);
709 _mirrored_set(Evas_Object *obj,
712 Widget_Data *wd = elm_widget_data_get(obj);
714 _item_cache_zero(wd);
715 elm_smart_scroller_mirrored_set(wd->scr, rtl);
719 _theme_hook(Evas_Object *obj)
721 Widget_Data *wd = elm_widget_data_get(obj);
724 _item_cache_zero(wd);
725 _elm_widget_mirrored_reload(obj);
726 _mirrored_set(obj, elm_widget_mirrored_get(obj));
727 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
728 elm_widget_style_get(obj));
729 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
730 wd->item_width = wd->item_height = 0;
731 wd->group_item_width = wd->group_item_height = 0;
732 wd->minw = wd->minh = wd->realminw = 0;
733 EINA_INLIST_FOREACH(wd->blocks, itb)
736 Elm_Genlist_Item *it;
738 if (itb->realized) _item_block_unrealize(itb);
739 EINA_LIST_FOREACH(itb->items, l, it)
740 it->mincalcd = EINA_FALSE;
742 itb->changed = EINA_TRUE;
744 if (wd->calc_job) ecore_job_del(wd->calc_job);
745 wd->calc_job = ecore_job_add(_calc_job, wd);
750 _show_region_hook(void *data,
753 Widget_Data *wd = elm_widget_data_get(data);
754 Evas_Coord x, y, w, h;
756 elm_widget_show_region_get(obj, &x, &y, &w, &h);
757 //x & y are screen coordinates, Add with pan coordinates
760 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
764 _sizing_eval(Evas_Object *obj)
766 Widget_Data *wd = elm_widget_data_get(obj);
767 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
769 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
770 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
772 if (wd->height_for_width)
776 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
777 if ((vw != 0) && (vw != wd->prev_viewport_w))
781 wd->prev_viewport_w = vw;
782 EINA_INLIST_FOREACH(wd->blocks, itb)
784 itb->must_recalc = EINA_TRUE;
786 if (wd->calc_job) ecore_job_del(wd->calc_job);
787 wd->calc_job = ecore_job_add(_calc_job, wd);
790 if (wd->mode == ELM_LIST_LIMIT)
792 Evas_Coord vmw, vmh, vw, vh;
796 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
797 if ((minw > 0) && (vw < minw)) vw = minw;
798 else if ((maxw > 0) && (vw > maxw))
800 edje_object_size_min_calc
801 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
808 edje_object_size_min_calc
809 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
813 evas_object_size_hint_min_set(obj, minw, minh);
814 evas_object_size_hint_max_set(obj, maxw, maxh);
818 _item_highlight(Elm_Genlist_Item *it)
820 const char *selectraise;
821 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
822 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
823 selectraise = edje_object_data_get(it->base.view, "selectraise");
824 if ((selectraise) && (!strcmp(selectraise, "on")))
826 evas_object_raise(it->base.view);
827 if ((it->group_item) && (it->group_item->realized))
828 evas_object_raise(it->group_item->base.view);
830 it->highlighted = EINA_TRUE;
834 _item_block_del(Elm_Genlist_Item *it)
837 Item_Block *itb = it->block;
839 itb->items = eina_list_remove(itb->items, it);
841 itb->changed = EINA_TRUE;
842 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
843 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
846 il = EINA_INLIST_GET(itb);
847 Item_Block *itbn = (Item_Block *)(il->next);
849 it->parent->items = eina_list_remove(it->parent->items, it);
851 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
853 if (itbn) itbn->changed = EINA_TRUE;
859 il = EINA_INLIST_GET(itb);
860 Item_Block *itbp = (Item_Block *)(il->prev);
861 Item_Block *itbn = (Item_Block *)(il->next);
862 if ((itbp) && ((itbp->count + itb->count) < 48))
864 Elm_Genlist_Item *it2;
866 EINA_LIST_FREE(itb->items, it2)
869 itbp->items = eina_list_append(itbp->items, it2);
871 itbp->changed = EINA_TRUE;
873 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
874 EINA_INLIST_GET(itb));
877 else if ((itbn) && ((itbn->count + itb->count) < 48))
881 Eina_List *last = eina_list_last(itb->items);
882 Elm_Genlist_Item *it2 = last->data;
885 itb->items = eina_list_remove_list(itb->items, last);
886 itbn->items = eina_list_prepend(itbn->items, it2);
888 itbn->changed = EINA_TRUE;
891 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
899 _item_del(Elm_Genlist_Item *it)
901 elm_widget_item_pre_notify_del(it);
902 elm_genlist_item_subitems_clear(it);
903 it->wd->walking -= it->walking;
904 if (it->wd->show_item == it) it->wd->show_item = NULL;
905 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
906 if (it->realized) _item_unrealize(it);
907 if (it->block) _item_block_del(it);
908 if ((!it->delete_me) && (it->itc->func.del))
909 it->itc->func.del((void *)it->base.data, it->base.widget);
910 it->delete_me = EINA_TRUE;
912 it->wd->queue = eina_list_remove(it->wd->queue, it);
913 if (it->wd->anchor_item == it)
915 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
916 if (!it->wd->anchor_item)
917 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
919 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
921 it->parent->items = eina_list_remove(it->parent->items, it);
922 if (it->flags & ELM_GENLIST_ITEM_GROUP)
923 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
924 if (it->long_timer) ecore_timer_del(it->long_timer);
925 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
927 if (it->tooltip.del_cb)
928 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
930 elm_widget_item_del(it);
934 _item_select(Elm_Genlist_Item *it)
936 if ((it->wd->no_select) || (it->delete_me)) return;
939 if (it->wd->always_select) goto call;
942 it->selected = EINA_TRUE;
943 it->wd->selected = eina_list_append(it->wd->selected, it);
947 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
949 evas_object_smart_callback_call(it->base.widget, "selected", it);
952 if ((it->wd->clear_me) && (!it->wd->walking))
953 elm_genlist_clear(it->base.widget);
956 if ((!it->walking) && (it->delete_me))
958 if (!it->relcount) _item_del(it);
961 it->wd->last_selected_item = it;
965 _item_unselect(Elm_Genlist_Item *it)
967 const char *stacking, *selectraise;
969 if ((it->delete_me) || (!it->highlighted)) return;
970 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
971 stacking = edje_object_data_get(it->base.view, "stacking");
972 selectraise = edje_object_data_get(it->base.view, "selectraise");
973 if ((selectraise) && (!strcmp(selectraise, "on")))
975 if ((stacking) && (!strcmp(stacking, "below")))
976 evas_object_lower(it->base.view);
978 it->highlighted = EINA_FALSE;
981 it->selected = EINA_FALSE;
982 it->wd->selected = eina_list_remove(it->wd->selected, it);
983 evas_object_smart_callback_call(it->base.widget, "unselected", it);
988 _mouse_move(void *data,
989 Evas *evas __UNUSED__,
993 Elm_Genlist_Item *it = data;
994 Evas_Event_Mouse_Move *ev = event_info;
995 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
997 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
999 if (!it->wd->on_hold)
1001 it->wd->on_hold = EINA_TRUE;
1002 if (!it->wd->wasselected)
1006 if (it->wd->multitouched)
1008 it->wd->cur_x = ev->cur.canvas.x;
1009 it->wd->cur_y = ev->cur.canvas.y;
1012 if ((it->dragging) && (it->down))
1014 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1017 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1018 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1019 if (abs((it->wd->history[it->wd->movements].x -
1020 it->wd->history[0].x)) > 40)
1021 it->wd->swipe = EINA_TRUE;
1023 it->wd->movements++;
1027 ecore_timer_del(it->long_timer);
1028 it->long_timer = NULL;
1030 evas_object_smart_callback_call(it->base.widget, "drag", it);
1033 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1037 ecore_timer_del(it->long_timer);
1038 it->long_timer = NULL;
1042 if (!it->display_only)
1043 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1044 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1045 x = ev->cur.canvas.x - x;
1046 y = ev->cur.canvas.y - y;
1049 if (adx < 0) adx = -dx;
1052 if (ady < 0) ady = -dy;
1055 if ((adx > minw) || (ady > minh))
1057 it->dragging = EINA_TRUE;
1060 ecore_timer_del(it->long_timer);
1061 it->long_timer = NULL;
1063 if (!it->wd->wasselected)
1068 evas_object_smart_callback_call(it->base.widget,
1069 "drag,start,up", it);
1073 evas_object_smart_callback_call(it->base.widget,
1074 "drag,start,left", it);
1076 evas_object_smart_callback_call(it->base.widget,
1077 "drag,start,right", it);
1083 evas_object_smart_callback_call(it->base.widget,
1084 "drag,start,down", it);
1088 evas_object_smart_callback_call(it->base.widget,
1089 "drag,start,left", it);
1091 evas_object_smart_callback_call(it->base.widget,
1092 "drag,start,right", it);
1099 _long_press(void *data)
1101 Elm_Genlist_Item *it = data;
1103 it->long_timer = NULL;
1104 if ((it->disabled) || (it->dragging) || (it->display_only))
1105 return ECORE_CALLBACK_CANCEL;
1106 it->wd->longpressed = EINA_TRUE;
1107 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1108 return ECORE_CALLBACK_CANCEL;
1112 _swipe(Elm_Genlist_Item *it)
1117 if ((it->display_only) || (it->disabled)) return;
1118 it->wd->swipe = EINA_FALSE;
1119 for (i = 0; i < it->wd->movements; i++)
1121 sum += it->wd->history[i].x;
1122 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1125 sum /= it->wd->movements;
1126 if (abs(sum - it->wd->history[0].x) <= 10) return;
1127 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1131 _swipe_cancel(void *data)
1133 Elm_Genlist_Item *it = data;
1135 if (!it) return ECORE_CALLBACK_CANCEL;
1136 it->wd->swipe = EINA_FALSE;
1137 it->wd->movements = 0;
1138 return ECORE_CALLBACK_RENEW;
1142 _multi_cancel(void *data)
1144 Widget_Data *wd = data;
1146 if (!wd) return ECORE_CALLBACK_CANCEL;
1147 wd->multi_timeout = EINA_TRUE;
1148 return ECORE_CALLBACK_RENEW;
1152 _multi_touch_gesture_eval(void *data)
1154 Elm_Genlist_Item *it = data;
1156 it->wd->multitouched = EINA_FALSE;
1157 if (it->wd->multi_timer)
1159 ecore_timer_del(it->wd->multi_timer);
1160 it->wd->multi_timer = NULL;
1162 if (it->wd->multi_timeout)
1164 it->wd->multi_timeout = EINA_FALSE;
1168 Evas_Coord minw = 0, minh = 0;
1169 Evas_Coord off_x, off_y, off_mx, off_my;
1171 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1172 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1173 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1174 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1175 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1177 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1179 if ((off_x + off_mx) > (off_y + off_my))
1181 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1182 evas_object_smart_callback_call(it->base.widget,
1183 "multi,swipe,right", it);
1184 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1185 evas_object_smart_callback_call(it->base.widget,
1186 "multi,swipe,left", it);
1187 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1188 evas_object_smart_callback_call(it->base.widget,
1189 "multi,pinch,out", it);
1191 evas_object_smart_callback_call(it->base.widget,
1192 "multi,pinch,in", it);
1196 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1197 evas_object_smart_callback_call(it->base.widget,
1198 "multi,swipe,down", it);
1199 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1200 evas_object_smart_callback_call(it->base.widget,
1201 "multi,swipe,up", it);
1202 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1203 evas_object_smart_callback_call(it->base.widget,
1204 "multi,pinch,out", it);
1206 evas_object_smart_callback_call(it->base.widget,
1207 "multi,pinch,in", it);
1210 it->wd->multi_timeout = EINA_FALSE;
1214 _multi_down(void *data,
1215 Evas *evas __UNUSED__,
1216 Evas_Object *obj __UNUSED__,
1219 Elm_Genlist_Item *it = data;
1220 Evas_Event_Multi_Down *ev = event_info;
1222 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1223 it->wd->multi_device = ev->device;
1224 it->wd->multi_down = EINA_TRUE;
1225 it->wd->multitouched = EINA_TRUE;
1226 it->wd->prev_mx = ev->canvas.x;
1227 it->wd->prev_my = ev->canvas.y;
1228 if (!it->wd->wasselected) _item_unselect(it);
1229 it->wd->wasselected = EINA_FALSE;
1230 it->wd->longpressed = EINA_FALSE;
1233 ecore_timer_del(it->long_timer);
1234 it->long_timer = NULL;
1238 it->dragging = EINA_FALSE;
1239 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1241 if (it->swipe_timer)
1243 ecore_timer_del(it->swipe_timer);
1244 it->swipe_timer = NULL;
1246 if (it->wd->on_hold)
1248 it->wd->swipe = EINA_FALSE;
1249 it->wd->movements = 0;
1250 it->wd->on_hold = EINA_FALSE;
1255 _multi_up(void *data,
1256 Evas *evas __UNUSED__,
1257 Evas_Object *obj __UNUSED__,
1260 Elm_Genlist_Item *it = data;
1261 Evas_Event_Multi_Up *ev = event_info;
1263 if (it->wd->multi_device != ev->device) return;
1264 it->wd->multi_device = 0;
1265 it->wd->multi_down = EINA_FALSE;
1266 if (it->wd->mouse_down) return;
1267 _multi_touch_gesture_eval(data);
1271 _multi_move(void *data,
1272 Evas *evas __UNUSED__,
1273 Evas_Object *obj __UNUSED__,
1276 Elm_Genlist_Item *it = data;
1277 Evas_Event_Multi_Move *ev = event_info;
1279 if (it->wd->multi_device != ev->device) return;
1280 it->wd->cur_mx = ev->cur.canvas.x;
1281 it->wd->cur_my = ev->cur.canvas.y;
1285 _mouse_down(void *data,
1286 Evas *evas __UNUSED__,
1290 Elm_Genlist_Item *it = data;
1291 Evas_Event_Mouse_Down *ev = event_info;
1294 if (ev->button != 1) return;
1295 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1297 it->wd->on_hold = EINA_TRUE;
1300 it->down = EINA_TRUE;
1301 it->dragging = EINA_FALSE;
1302 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1303 it->dx = ev->canvas.x - x;
1304 it->dy = ev->canvas.y - y;
1305 it->wd->mouse_down = EINA_TRUE;
1306 if (!it->wd->multitouched)
1308 it->wd->prev_x = ev->canvas.x;
1309 it->wd->prev_y = ev->canvas.y;
1310 it->wd->multi_timeout = EINA_FALSE;
1311 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1312 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1314 it->wd->longpressed = EINA_FALSE;
1315 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1316 else it->wd->on_hold = EINA_FALSE;
1317 if (it->wd->on_hold) return;
1318 it->wd->wasselected = it->selected;
1319 _item_highlight(it);
1320 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1321 if ((!it->disabled) && (!it->display_only))
1323 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1324 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1326 if (it->long_timer) ecore_timer_del(it->long_timer);
1327 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1328 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1330 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1333 it->long_timer = NULL;
1334 it->wd->swipe = EINA_FALSE;
1335 it->wd->movements = 0;
1339 _mouse_up(void *data,
1340 Evas *evas __UNUSED__,
1341 Evas_Object *obj __UNUSED__,
1344 Elm_Genlist_Item *it = data;
1345 Evas_Event_Mouse_Up *ev = event_info;
1346 Eina_Bool dragged = EINA_FALSE;
1348 if (ev->button != 1) return;
1349 it->down = EINA_FALSE;
1350 it->wd->mouse_down = EINA_FALSE;
1351 if (it->wd->multitouched)
1353 if (it->wd->multi_down) return;
1354 _multi_touch_gesture_eval(data);
1357 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1358 else it->wd->on_hold = EINA_FALSE;
1361 ecore_timer_del(it->long_timer);
1362 it->long_timer = NULL;
1366 it->dragging = EINA_FALSE;
1367 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1370 if (it->swipe_timer)
1372 ecore_timer_del(it->swipe_timer);
1373 it->swipe_timer = NULL;
1375 if (it->wd->multi_timer)
1377 ecore_timer_del(it->wd->multi_timer);
1378 it->wd->multi_timer = NULL;
1379 it->wd->multi_timeout = EINA_FALSE;
1381 if (it->wd->on_hold)
1383 if (it->wd->swipe) _swipe(data);
1384 it->wd->longpressed = EINA_FALSE;
1385 it->wd->on_hold = EINA_FALSE;
1388 if (it->wd->longpressed)
1390 it->wd->longpressed = EINA_FALSE;
1391 if (!it->wd->wasselected)
1393 it->wd->wasselected = EINA_FALSE;
1398 if (it->want_unrealize)
1400 _item_unrealize(it);
1401 if (it->block->want_unrealize)
1402 _item_block_unrealize(it->block);
1405 if ((it->disabled) || (dragged) || (it->display_only)) return;
1406 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1411 _item_highlight(it);
1414 else _item_unselect(it);
1420 Widget_Data *wd = it->wd;
1423 while (wd->selected) _item_unselect(wd->selected->data);
1428 const Eina_List *l, *l_next;
1429 Elm_Genlist_Item *it2;
1431 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1432 if (it2 != it) _item_unselect(it2);
1433 //_item_highlight(it);
1436 _item_highlight(it);
1442 _signal_expand_toggle(void *data,
1443 Evas_Object *obj __UNUSED__,
1444 const char *emission __UNUSED__,
1445 const char *source __UNUSED__)
1447 Elm_Genlist_Item *it = data;
1450 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1452 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1456 _signal_expand(void *data,
1457 Evas_Object *obj __UNUSED__,
1458 const char *emission __UNUSED__,
1459 const char *source __UNUSED__)
1461 Elm_Genlist_Item *it = data;
1464 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1468 _signal_contract(void *data,
1469 Evas_Object *obj __UNUSED__,
1470 const char *emission __UNUSED__,
1471 const char *source __UNUSED__)
1473 Elm_Genlist_Item *it = data;
1476 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1480 _item_cache_clean(Widget_Data *wd)
1482 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1486 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1487 wd->item_cache = eina_inlist_remove(wd->item_cache,
1488 wd->item_cache->last);
1489 wd->item_cache_count--;
1490 if (itc->spacer) evas_object_del(itc->spacer);
1491 if (itc->base_view) evas_object_del(itc->base_view);
1492 if (itc->item_style) eina_stringshare_del(itc->item_style);
1498 _item_cache_zero(Widget_Data *wd)
1500 int pmax = wd->item_cache_max;
1501 wd->item_cache_max = 0;
1502 _item_cache_clean(wd);
1503 wd->item_cache_max = pmax;
1507 _item_cache_add(Elm_Genlist_Item *it)
1511 if (it->wd->item_cache_max <= 0)
1513 evas_object_del(it->base.view);
1514 it->base.view = NULL;
1515 evas_object_del(it->spacer);
1520 it->wd->item_cache_count++;
1521 itc = calloc(1, sizeof(Item_Cache));
1522 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1523 EINA_INLIST_GET(itc));
1524 itc->spacer = it->spacer;
1526 itc->base_view = it->base.view;
1527 it->base.view = NULL;
1528 evas_object_hide(itc->base_view);
1529 evas_object_move(itc->base_view, -9999, -9999);
1530 itc->item_style = eina_stringshare_add(it->itc->item_style);
1531 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1532 itc->compress = (it->wd->compress);
1533 itc->odd = (it->order_num_in & 0x1);
1534 itc->selected = it->selected;
1535 itc->disabled = it->disabled;
1536 itc->expanded = it->expanded;
1539 ecore_timer_del(it->long_timer);
1540 it->long_timer = NULL;
1542 if (it->swipe_timer)
1544 ecore_timer_del(it->swipe_timer);
1545 it->swipe_timer = NULL;
1547 // FIXME: other callbacks?
1548 edje_object_signal_callback_del_full(itc->base_view,
1549 "elm,action,expand,toggle",
1550 "elm", _signal_expand_toggle, it);
1551 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1553 _signal_expand, it);
1554 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1555 "elm", _signal_contract, it);
1556 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1558 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1560 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1562 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1564 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1566 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1568 _item_cache_clean(it->wd);
1572 _item_cache_find(Elm_Genlist_Item *it)
1575 Eina_Bool tree = 0, odd;
1577 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1578 odd = (it->order_num_in & 0x1);
1579 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1581 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1583 if ((itc->tree == tree) &&
1584 (itc->odd == odd) &&
1585 (itc->compress == it->wd->compress) &&
1586 (!strcmp(it->itc->item_style, itc->item_style)))
1588 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1589 EINA_INLIST_GET(itc));
1590 it->wd->item_cache_count--;
1598 _item_cache_free(Item_Cache *itc)
1600 if (itc->spacer) evas_object_del(itc->spacer);
1601 if (itc->base_view) evas_object_del(itc->base_view);
1602 if (itc->item_style) eina_stringshare_del(itc->item_style);
1607 _item_realize(Elm_Genlist_Item *it,
1611 Elm_Genlist_Item *it2;
1612 const char *stacking;
1613 const char *treesize;
1615 int depth, tsize = 20;
1616 Item_Cache *itc = NULL;
1618 if ((it->realized) || (it->delete_me)) return;
1619 it->order_num_in = in;
1622 it->nocache = EINA_FALSE;
1624 itc = _item_cache_find(it);
1627 it->base.view = itc->base_view;
1628 itc->base_view = NULL;
1629 it->spacer = itc->spacer;
1634 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1635 edje_object_scale_set(it->base.view,
1636 elm_widget_scale_get(it->base.widget) *
1637 _elm_config->scale);
1638 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1639 elm_widget_sub_object_add(it->base.widget, it->base.view);
1641 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1642 strncpy(buf, "tree", sizeof(buf));
1643 else strncpy(buf, "item", sizeof(buf));
1644 if (it->wd->compress)
1645 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1647 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1648 strncat(buf, "/", sizeof(buf) - strlen(buf));
1649 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1651 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1652 elm_widget_style_get(it->base.widget));
1653 edje_object_mirrored_set(it->base.view,
1654 elm_widget_mirrored_get(it->base.widget));
1656 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1657 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1658 elm_widget_sub_object_add(it->base.widget, it->spacer);
1660 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1662 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1664 it->expanded_depth = depth;
1665 treesize = edje_object_data_get(it->base.view, "treesize");
1666 if (treesize) tsize = atoi(treesize);
1667 evas_object_size_hint_min_set(it->spacer,
1668 (depth * tsize) * _elm_config->scale, 1);
1669 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1672 edje_object_signal_callback_add(it->base.view,
1673 "elm,action,expand,toggle",
1674 "elm", _signal_expand_toggle, it);
1675 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1676 "elm", _signal_expand, it);
1677 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1678 "elm", _signal_contract, it);
1679 stacking = edje_object_data_get(it->base.view, "stacking");
1682 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1683 else if (!strcmp(stacking, "above"))
1684 evas_object_raise(it->base.view);
1686 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1688 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1690 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1692 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1694 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1696 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1700 if (it->selected != itc->selected)
1703 edje_object_signal_emit(it->base.view,
1704 "elm,state,selected", "elm");
1706 if (it->disabled != itc->disabled)
1709 edje_object_signal_emit(it->base.view,
1710 "elm,state,disabled", "elm");
1712 if (it->expanded != itc->expanded)
1715 edje_object_signal_emit(it->base.view,
1716 "elm,state,expanded", "elm");
1722 edje_object_signal_emit(it->base.view,
1723 "elm,state,selected", "elm");
1725 edje_object_signal_emit(it->base.view,
1726 "elm,state,disabled", "elm");
1728 edje_object_signal_emit(it->base.view,
1729 "elm,state,expanded", "elm");
1733 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1735 /* homogenous genlist shortcut */
1738 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1740 it->w = it->minw = it->wd->group_item_width;
1741 it->h = it->minh = it->wd->group_item_height;
1745 it->w = it->minw = it->wd->item_width;
1746 it->h = it->minh = it->wd->item_height;
1748 it->mincalcd = EINA_TRUE;
1753 if (it->itc->func.label_get)
1759 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1761 EINA_LIST_FOREACH(it->labels, l, key)
1763 char *s = it->itc->func.label_get
1764 ((void *)it->base.data, it->base.widget, l->data);
1768 edje_object_part_text_set(it->base.view, l->data, s);
1772 edje_object_part_text_set(it->base.view, l->data, "");
1775 if (it->itc->func.icon_get)
1781 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1783 EINA_LIST_FOREACH(it->icons, l, key)
1785 Evas_Object *ic = it->itc->func.icon_get
1786 ((void *)it->base.data, it->base.widget, l->data);
1790 it->icon_objs = eina_list_append(it->icon_objs, ic);
1791 edje_object_part_swallow(it->base.view, key, ic);
1792 evas_object_show(ic);
1793 elm_widget_sub_object_add(it->base.widget, ic);
1797 if (it->itc->func.state_get)
1803 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1805 EINA_LIST_FOREACH(it->states, l, key)
1807 Eina_Bool on = it->itc->func.state_get
1808 ((void *)it->base.data, it->base.widget, l->data);
1812 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1813 edje_object_signal_emit(it->base.view, buf, "elm");
1817 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1818 edje_object_signal_emit(it->base.view, buf, "elm");
1824 Evas_Coord mw = -1, mh = -1;
1826 if (it->wd->height_for_width) mw = it->wd->w;
1828 if (!it->display_only)
1829 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1830 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1831 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1833 if (!it->display_only)
1834 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1835 it->w = it->minw = mw;
1836 it->h = it->minh = mh;
1837 it->mincalcd = EINA_TRUE;
1839 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1841 it->wd->group_item_width = mw;
1842 it->wd->group_item_height = mh;
1844 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1846 it->wd->item_width = mw;
1847 it->wd->item_height = mh;
1850 if (!calc) evas_object_show(it->base.view);
1853 if (it->tooltip.content_cb)
1855 elm_widget_item_tooltip_content_cb_set(it,
1856 it->tooltip.content_cb,
1857 it->tooltip.data, NULL);
1858 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1861 if (it->mouse_cursor)
1862 elm_widget_item_cursor_set(it, it->mouse_cursor);
1864 it->realized = EINA_TRUE;
1865 it->want_unrealize = EINA_FALSE;
1867 if (itc) _item_cache_free(itc);
1868 evas_object_smart_callback_call(it->base.widget, "realized", it);
1872 _item_unrealize(Elm_Genlist_Item *it)
1876 if (!it->realized) return;
1877 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1880 ecore_timer_del(it->long_timer);
1881 it->long_timer = NULL;
1885 evas_object_del(it->base.view);
1886 it->base.view = NULL;
1887 evas_object_del(it->spacer);
1892 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1893 _item_cache_add(it);
1895 elm_widget_stringlist_free(it->labels);
1897 elm_widget_stringlist_free(it->icons);
1899 elm_widget_stringlist_free(it->states);
1901 EINA_LIST_FREE(it->icon_objs, icon)
1902 evas_object_del(icon);
1905 it->realized = EINA_FALSE;
1906 it->want_unrealize = EINA_FALSE;
1910 _item_block_recalc(Item_Block *itb,
1916 Elm_Genlist_Item *it;
1917 Evas_Coord minw = 0, minh = 0;
1918 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1922 EINA_LIST_FOREACH(itb->items, l, it)
1924 if (it->delete_me) continue;
1925 showme |= it->showme;
1930 if (!it->mincalcd) changed = EINA_TRUE;
1933 _item_realize(it, in, EINA_TRUE);
1934 _item_unrealize(it);
1939 _item_realize(it, in, EINA_TRUE);
1940 _item_unrealize(it);
1944 _item_realize(it, in, EINA_FALSE);
1946 if (minw < it->minw) minw = it->minw;
1954 itb->changed = EINA_FALSE;
1955 /* force an evas norender to garbage collect deleted objects */
1956 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1961 _item_block_realize(Item_Block *itb,
1966 Elm_Genlist_Item *it;
1968 if (itb->realized) return;
1969 EINA_LIST_FOREACH(itb->items, l, it)
1971 if (it->delete_me) continue;
1972 if (full) _item_realize(it, in, EINA_FALSE);
1975 itb->realized = EINA_TRUE;
1976 itb->want_unrealize = EINA_FALSE;
1980 _item_block_unrealize(Item_Block *itb)
1983 Elm_Genlist_Item *it;
1984 Eina_Bool dragging = EINA_FALSE;
1986 if (!itb->realized) return;
1987 EINA_LIST_FOREACH(itb->items, l, it)
1989 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1993 dragging = EINA_TRUE;
1994 it->want_unrealize = EINA_TRUE;
1997 _item_unrealize(it);
2002 itb->realized = EINA_FALSE;
2003 itb->want_unrealize = EINA_TRUE;
2006 itb->want_unrealize = EINA_FALSE;
2010 _item_block_position(Item_Block *itb,
2014 Elm_Genlist_Item *it;
2015 Elm_Genlist_Item *git;
2016 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2019 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2020 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2022 EINA_LIST_FOREACH(itb->items, l, it)
2024 if (it->delete_me) continue;
2028 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2029 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2031 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2032 cvx, cvy, cvw, cvh));
2033 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2035 if ((itb->realized) && (!it->realized))
2037 if (vis) _item_realize(it, in, EINA_FALSE);
2043 git = it->group_item;
2046 if (git->scrl_y < oy)
2048 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2049 git->scrl_y = (it->scrl_y + it->h) - git->h;
2050 git->want_realize = EINA_TRUE;
2052 evas_object_resize(it->base.view, it->w, it->h);
2053 evas_object_move(it->base.view,
2054 it->scrl_x, it->scrl_y);
2055 evas_object_show(it->base.view);
2059 if (!it->dragging) _item_unrealize(it);
2066 if (vis) it->want_realize = EINA_TRUE;
2073 _group_items_recalc(void *data)
2075 Widget_Data *wd = data;
2077 Elm_Genlist_Item *git;
2079 EINA_LIST_FOREACH(wd->group_items, l, git)
2081 if (git->want_realize)
2084 _item_realize(git, 0, EINA_FALSE);
2085 evas_object_resize(git->base.view, wd->minw, git->h);
2086 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2087 evas_object_show(git->base.view);
2088 evas_object_raise(git->base.view);
2090 else if (!git->want_realize && git->realized)
2093 _item_unrealize(git);
2099 _must_recalc_idler(void *data)
2101 Widget_Data *wd = data;
2102 if (wd->calc_job) ecore_job_del(wd->calc_job);
2103 wd->calc_job = ecore_job_add(_calc_job, wd);
2104 wd->must_recalc_idler = NULL;
2105 return ECORE_CALLBACK_CANCEL;
2109 _calc_job(void *data)
2111 Widget_Data *wd = data;
2113 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2114 Item_Block *chb = NULL;
2115 int in = 0, minw_change = 0;
2116 Eina_Bool changed = EINA_FALSE;
2118 Eina_Bool did_must_recalc = EINA_FALSE;
2121 t0 = ecore_time_get();
2122 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2126 // if (wd->height_for_width) changed = EINA_TRUE;
2129 EINA_INLIST_FOREACH(wd->blocks, itb)
2131 Eina_Bool showme = EINA_FALSE;
2134 showme = itb->showme;
2135 itb->showme = EINA_FALSE;
2138 if (itb->realized) _item_block_unrealize(itb);
2140 if ((itb->changed) || (changed) ||
2141 ((itb->must_recalc) && (!did_must_recalc)))
2143 if ((changed) || (itb->must_recalc))
2146 Elm_Genlist_Item *it;
2147 EINA_LIST_FOREACH(itb->items, l, it)
2148 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2149 itb->changed = EINA_TRUE;
2150 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2151 itb->must_recalc = EINA_FALSE;
2153 if (itb->realized) _item_block_unrealize(itb);
2154 showme = _item_block_recalc(itb, in, 0, 1);
2160 if (minw == -1) minw = itb->minw;
2161 else if ((!itb->must_recalc) && (minw < itb->minw))
2170 if ((showme) && (wd->show_item))
2172 wd->show_item->showme = EINA_FALSE;
2174 elm_smart_scroller_region_bring_in(wd->scr,
2176 wd->show_item->block->x,
2178 wd->show_item->block->y,
2179 wd->show_item->block->w,
2182 elm_smart_scroller_child_region_show(wd->scr,
2184 wd->show_item->block->x,
2186 wd->show_item->block->y,
2187 wd->show_item->block->w,
2189 wd->show_item = NULL;
2194 EINA_INLIST_FOREACH(wd->blocks, itb)
2200 if ((chb) && (EINA_INLIST_GET(chb)->next))
2202 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2204 if (itb->realized) _item_block_unrealize(itb);
2207 wd->realminw = minw;
2208 if (minw < wd->w) minw = wd->w;
2209 if ((minw != wd->minw) || (minh != wd->minh))
2213 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2214 _sizing_eval(wd->obj);
2215 if ((wd->anchor_item) && (wd->anchor_item->block))
2217 Elm_Genlist_Item *it;
2220 it = wd->anchor_item;
2221 it_y = wd->anchor_y;
2222 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2223 it->block->y + it->y + it_y);
2224 wd->anchor_item = it;
2225 wd->anchor_y = it_y;
2228 t = ecore_time_get();
2229 if (did_must_recalc)
2231 if (!wd->must_recalc_idler)
2232 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2234 wd->calc_job = NULL;
2235 evas_object_smart_changed(wd->pan_smart);
2239 _update_job(void *data)
2241 Widget_Data *wd = data;
2244 int num, num0, position = 0, recalc = 0;
2246 wd->update_job = NULL;
2248 EINA_INLIST_FOREACH(wd->blocks, itb)
2250 Evas_Coord itminw, itminh;
2251 Elm_Genlist_Item *it;
2257 _item_block_position(itb, num);
2262 EINA_LIST_FOREACH(itb->items, l2, it)
2269 it->updateme = EINA_FALSE;
2272 _item_unrealize(it);
2273 _item_realize(it, num, EINA_FALSE);
2278 _item_realize(it, num, EINA_TRUE);
2279 _item_unrealize(it);
2281 if ((it->minw != itminw) || (it->minh != itminh))
2286 itb->updateme = EINA_FALSE;
2290 itb->changed = EINA_TRUE;
2291 _item_block_recalc(itb, num0, 0, 1);
2292 _item_block_position(itb, num0);
2297 if (wd->calc_job) ecore_job_del(wd->calc_job);
2298 wd->calc_job = ecore_job_add(_calc_job, wd);
2303 _pan_set(Evas_Object *obj,
2307 Pan *sd = evas_object_smart_data_get(obj);
2310 // Evas_Coord ow, oh;
2311 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2312 // ow = sd->wd->minw - ow;
2313 // if (ow < 0) ow = 0;
2314 // oh = sd->wd->minh - oh;
2315 // if (oh < 0) oh = 0;
2316 // if (x < 0) x = 0;
2317 // if (y < 0) y = 0;
2318 // if (x > ow) x = ow;
2319 // if (y > oh) y = oh;
2320 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2324 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2326 if ((itb->y + itb->h) > y)
2328 Elm_Genlist_Item *it;
2331 EINA_LIST_FOREACH(itb->items, l2, it)
2333 if ((itb->y + it->y) >= y)
2335 sd->wd->anchor_item = it;
2336 sd->wd->anchor_y = -(itb->y + it->y - y);
2343 evas_object_smart_changed(obj);
2347 _pan_get(Evas_Object *obj,
2351 Pan *sd = evas_object_smart_data_get(obj);
2353 if (x) *x = sd->wd->pan_x;
2354 if (y) *y = sd->wd->pan_y;
2358 _pan_max_get(Evas_Object *obj,
2362 Pan *sd = evas_object_smart_data_get(obj);
2365 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2366 ow = sd->wd->minw - ow;
2368 oh = sd->wd->minh - oh;
2375 _pan_min_get(Evas_Object *obj __UNUSED__,
2384 _pan_child_size_get(Evas_Object *obj,
2388 Pan *sd = evas_object_smart_data_get(obj);
2390 if (w) *w = sd->wd->minw;
2391 if (h) *h = sd->wd->minh;
2395 _pan_add(Evas_Object *obj)
2398 Evas_Object_Smart_Clipped_Data *cd;
2401 cd = evas_object_smart_data_get(obj);
2404 sd->__clipped_data = *cd;
2406 evas_object_smart_data_set(obj, sd);
2410 _pan_del(Evas_Object *obj)
2412 Pan *sd = evas_object_smart_data_get(obj);
2417 ecore_job_del(sd->resize_job);
2418 sd->resize_job = NULL;
2424 _pan_resize_job(void *data)
2427 _sizing_eval(sd->wd->obj);
2428 sd->resize_job = NULL;
2432 _pan_resize(Evas_Object *obj,
2436 Pan *sd = evas_object_smart_data_get(obj);
2439 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2440 if ((ow == w) && (oh == h)) return;
2441 if ((sd->wd->height_for_width) && (ow != w))
2443 if (sd->resize_job) ecore_job_del(sd->resize_job);
2444 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2446 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2447 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2451 _pan_calculate(Evas_Object *obj)
2453 Pan *sd = evas_object_smart_data_get(obj);
2455 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2457 Elm_Genlist_Item *git;
2460 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2461 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2462 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2464 git->want_realize = EINA_FALSE;
2466 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2468 itb->w = sd->wd->minw;
2469 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2470 itb->y - sd->wd->pan_y + oy,
2472 cvx, cvy, cvw, cvh))
2474 if ((!itb->realized) || (itb->changed))
2475 _item_block_realize(itb, in, 0);
2476 _item_block_position(itb, in);
2480 if (itb->realized) _item_block_unrealize(itb);
2484 _group_items_recalc(sd->wd);
2488 _pan_move(Evas_Object *obj,
2489 Evas_Coord x __UNUSED__,
2490 Evas_Coord y __UNUSED__)
2492 Pan *sd = evas_object_smart_data_get(obj);
2494 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2495 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2499 _hold_on(void *data __UNUSED__,
2501 void *event_info __UNUSED__)
2503 Widget_Data *wd = elm_widget_data_get(obj);
2505 elm_smart_scroller_hold_set(wd->scr, 1);
2509 _hold_off(void *data __UNUSED__,
2511 void *event_info __UNUSED__)
2513 Widget_Data *wd = elm_widget_data_get(obj);
2515 elm_smart_scroller_hold_set(wd->scr, 0);
2519 _freeze_on(void *data __UNUSED__,
2521 void *event_info __UNUSED__)
2523 Widget_Data *wd = elm_widget_data_get(obj);
2525 elm_smart_scroller_freeze_set(wd->scr, 1);
2529 _freeze_off(void *data __UNUSED__,
2531 void *event_info __UNUSED__)
2533 Widget_Data *wd = elm_widget_data_get(obj);
2535 elm_smart_scroller_freeze_set(wd->scr, 0);
2539 _scroll_edge_left(void *data,
2540 Evas_Object *scr __UNUSED__,
2541 void *event_info __UNUSED__)
2543 Evas_Object *obj = data;
2544 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2548 _scroll_edge_right(void *data,
2549 Evas_Object *scr __UNUSED__,
2550 void *event_info __UNUSED__)
2552 Evas_Object *obj = data;
2553 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2557 _scroll_edge_top(void *data,
2558 Evas_Object *scr __UNUSED__,
2559 void *event_info __UNUSED__)
2561 Evas_Object *obj = data;
2562 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2566 _scroll_edge_bottom(void *data,
2567 Evas_Object *scr __UNUSED__,
2568 void *event_info __UNUSED__)
2570 Evas_Object *obj = data;
2571 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2575 * Add a new Genlist object
2577 * @param parent The parent object
2578 * @return The new object or NULL if it cannot be created
2583 elm_genlist_add(Evas_Object *parent)
2588 Evas_Coord minw, minh;
2589 static Evas_Smart *smart = NULL;
2593 static Evas_Smart_Class sc;
2595 evas_object_smart_clipped_smart_set(&_pan_sc);
2597 sc.name = "elm_genlist_pan";
2598 sc.version = EVAS_SMART_CLASS_VERSION;
2601 sc.resize = _pan_resize;
2602 sc.move = _pan_move;
2603 sc.calculate = _pan_calculate;
2604 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2607 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2609 ELM_SET_WIDTYPE(widtype, "genlist");
2610 elm_widget_type_set(obj, "genlist");
2611 elm_widget_sub_object_add(parent, obj);
2612 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2613 elm_widget_data_set(obj, wd);
2614 elm_widget_del_hook_set(obj, _del_hook);
2615 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2616 elm_widget_theme_hook_set(obj, _theme_hook);
2617 elm_widget_can_focus_set(obj, EINA_TRUE);
2618 elm_widget_event_hook_set(obj, _event_hook);
2619 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2621 wd->scr = elm_smart_scroller_add(e);
2622 elm_smart_scroller_widget_set(wd->scr, obj);
2623 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2624 elm_widget_style_get(obj));
2625 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2626 _elm_config->thumbscroll_bounce_enable);
2627 elm_widget_resize_object_set(obj, wd->scr);
2629 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2630 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2632 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2633 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2637 wd->mode = ELM_LIST_SCROLL;
2638 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2639 wd->item_cache_max = wd->max_items_per_block * 2;
2640 wd->longpress_timeout = _elm_config->longpress_timeout;
2642 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2643 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2644 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2645 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2647 wd->pan_smart = evas_object_smart_add(e, smart);
2648 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2651 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2652 _pan_set, _pan_get, _pan_max_get,
2653 _pan_min_get, _pan_child_size_get);
2655 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2657 evas_object_size_hint_min_set(obj, minw, minh);
2659 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2664 static Elm_Genlist_Item *
2665 _item_new(Widget_Data *wd,
2666 const Elm_Genlist_Item_Class *itc,
2668 Elm_Genlist_Item *parent,
2669 Elm_Genlist_Item_Flags flags,
2671 const void *func_data)
2673 Elm_Genlist_Item *it;
2675 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2676 if (!it) return NULL;
2679 it->base.data = data;
2680 it->parent = parent;
2682 it->func.func = func;
2683 it->func.data = func_data;
2684 it->mouse_cursor = NULL;
2685 it->expanded_depth = 0;
2690 _item_block_add(Widget_Data *wd,
2691 Elm_Genlist_Item *it)
2693 Item_Block *itb = NULL;
2700 itb = calloc(1, sizeof(Item_Block));
2703 if (!it->rel->block)
2706 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2707 itb->items = eina_list_append(itb->items, it);
2713 wd->blocks = eina_inlist_prepend_relative
2714 (wd->blocks, EINA_INLIST_GET(itb),
2715 EINA_INLIST_GET(it->rel->block));
2717 eina_list_prepend_relative(itb->items, it, it->rel);
2721 wd->blocks = eina_inlist_append_relative
2722 (wd->blocks, EINA_INLIST_GET(itb),
2723 EINA_INLIST_GET(it->rel->block));
2725 eina_list_append_relative(itb->items, it, it->rel);
2735 itb = (Item_Block *)(wd->blocks);
2736 if (itb->count >= wd->max_items_per_block)
2738 itb = calloc(1, sizeof(Item_Block));
2742 eina_inlist_prepend(wd->blocks,
2743 EINA_INLIST_GET(itb));
2748 itb = calloc(1, sizeof(Item_Block));
2752 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2754 itb->items = eina_list_prepend(itb->items, it);
2760 itb = (Item_Block *)(wd->blocks->last);
2761 if (itb->count >= wd->max_items_per_block)
2763 itb = calloc(1, sizeof(Item_Block));
2767 eina_inlist_append(wd->blocks,
2768 EINA_INLIST_GET(itb));
2773 itb = calloc(1, sizeof(Item_Block));
2777 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2779 itb->items = eina_list_append(itb->items, it);
2785 itb = it->rel->block;
2786 if (!itb) goto newblock;
2788 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2790 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2793 itb->changed = EINA_TRUE;
2795 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2796 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2799 it->rel->relcount--;
2800 if ((it->rel->delete_me) && (!it->rel->relcount))
2804 if (itb->count > itb->wd->max_items_per_block)
2808 Elm_Genlist_Item *it2;
2810 newc = itb->count / 2;
2811 itb2 = calloc(1, sizeof(Item_Block));
2815 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2816 EINA_INLIST_GET(itb));
2817 itb2->changed = EINA_TRUE;
2818 while ((itb->count > newc) && (itb->items))
2822 l = eina_list_last(itb->items);
2824 itb->items = eina_list_remove_list(itb->items, l);
2827 itb2->items = eina_list_prepend(itb2->items, it2);
2835 _queue_process(Widget_Data *wd,
2839 Eina_Bool showme = EINA_FALSE;
2842 t0 = ecore_time_get();
2843 for (n = 0; (wd->queue) && (n < 128); n++)
2845 Elm_Genlist_Item *it;
2847 it = wd->queue->data;
2848 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2849 it->queued = EINA_FALSE;
2850 _item_block_add(wd, it);
2851 t = ecore_time_get();
2852 if (it->block->changed)
2854 showme = _item_block_recalc(it->block, it->block->num, 1,
2856 it->block->changed = 0;
2858 if (showme) it->block->showme = EINA_TRUE;
2859 if (eina_inlist_count(wd->blocks) > 1)
2861 if ((t - t0) > (ecore_animator_frametime_get())) break;
2868 _item_idler(void *data)
2870 Widget_Data *wd = data;
2873 //static double q_start = 0.0;
2874 //if (q_start == 0.0) q_start = ecore_time_get();
2877 if (_queue_process(wd, 1) > 0)
2879 if (wd->calc_job) ecore_job_del(wd->calc_job);
2880 wd->calc_job = ecore_job_add(_calc_job, wd);
2885 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2887 wd->queue_idler = NULL;
2888 return ECORE_CALLBACK_CANCEL;
2890 return ECORE_CALLBACK_RENEW;
2894 _item_queue(Widget_Data *wd,
2895 Elm_Genlist_Item *it)
2897 if (it->queued) return;
2898 it->queued = EINA_TRUE;
2899 wd->queue = eina_list_append(wd->queue, it);
2900 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2902 if (wd->queue_idler)
2904 ecore_idler_del(wd->queue_idler);
2905 wd->queue_idler = NULL;
2907 _queue_process(wd, 0);
2909 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2913 * Append item to the end of the genlist
2915 * This appends the given item to the end of the list or the end of
2916 * the children if the parent is given.
2918 * @param obj The genlist object
2919 * @param itc The item class for the item
2920 * @param data The item data
2921 * @param parent The parent item, or NULL if none
2922 * @param flags Item flags
2923 * @param func Convenience function called when item selected
2924 * @param func_data Data passed to @p func above.
2925 * @return A handle to the item added or NULL if not possible
2929 EAPI Elm_Genlist_Item *
2930 elm_genlist_item_append(Evas_Object *obj,
2931 const Elm_Genlist_Item_Class *itc,
2933 Elm_Genlist_Item *parent,
2934 Elm_Genlist_Item_Flags flags,
2936 const void *func_data)
2938 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2939 Widget_Data *wd = elm_widget_data_get(obj);
2940 if (!wd) return NULL;
2941 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2943 if (!it) return NULL;
2946 if (flags & ELM_GENLIST_ITEM_GROUP)
2947 wd->group_items = eina_list_append(wd->group_items, it);
2948 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2953 Elm_Genlist_Item *it2 = NULL;
2954 Eina_List *ll = eina_list_last(it->parent->items);
2955 if (ll) it2 = ll->data;
2956 it->parent->items = eina_list_append(it->parent->items, it);
2957 if (!it2) it2 = it->parent;
2959 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2960 EINA_INLIST_GET(it2));
2962 it->rel->relcount++;
2964 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2965 it->group_item = parent;
2966 else if (it->parent->group_item)
2967 it->group_item = it->parent->group_item;
2969 it->before = EINA_FALSE;
2970 _item_queue(wd, it);
2975 * Prepend item at start of the genlist
2977 * This adds an item to the beginning of the list or beginning of the
2978 * children of the parent if given.
2980 * @param obj The genlist object
2981 * @param itc The item class for the item
2982 * @param data The item data
2983 * @param parent The parent item, or NULL if none
2984 * @param flags Item flags
2985 * @param func Convenience function called when item selected
2986 * @param func_data Data passed to @p func above.
2987 * @return A handle to the item added or NULL if not possible
2991 EAPI Elm_Genlist_Item *
2992 elm_genlist_item_prepend(Evas_Object *obj,
2993 const Elm_Genlist_Item_Class *itc,
2995 Elm_Genlist_Item *parent,
2996 Elm_Genlist_Item_Flags flags,
2998 const void *func_data)
3000 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3001 Widget_Data *wd = elm_widget_data_get(obj);
3002 if (!wd) return NULL;
3003 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3005 if (!it) return NULL;
3008 if (flags & ELM_GENLIST_ITEM_GROUP)
3009 wd->group_items = eina_list_prepend(wd->group_items, it);
3010 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3015 Elm_Genlist_Item *it2 = NULL;
3016 Eina_List *ll = it->parent->items;
3017 if (ll) it2 = ll->data;
3018 it->parent->items = eina_list_prepend(it->parent->items, it);
3019 if (!it2) it2 = it->parent;
3021 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3022 EINA_INLIST_GET(it2));
3024 it->rel->relcount++;
3026 it->before = EINA_TRUE;
3027 _item_queue(wd, it);
3032 * Insert item before another in the genlist
3034 * This inserts an item before another in the list. It will be in the
3035 * same tree level or group as the item it is inseted before.
3037 * @param obj The genlist object
3038 * @param itc The item class for the item
3039 * @param data The item data
3040 * @param before The item to insert before
3041 * @param flags Item flags
3042 * @param func Convenience function called when item selected
3043 * @param func_data Data passed to @p func above.
3044 * @return A handle to the item added or NULL if not possible
3048 EAPI Elm_Genlist_Item *
3049 elm_genlist_item_insert_before(Evas_Object *obj,
3050 const Elm_Genlist_Item_Class *itc,
3052 Elm_Genlist_Item *parent,
3053 Elm_Genlist_Item *before,
3054 Elm_Genlist_Item_Flags flags,
3056 const void *func_data)
3058 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3059 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3060 Widget_Data *wd = elm_widget_data_get(obj);
3061 if (!wd) return NULL;
3062 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3064 if (!it) return NULL;
3067 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3070 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3071 EINA_INLIST_GET(before));
3073 it->rel->relcount++;
3074 it->before = EINA_TRUE;
3075 _item_queue(wd, it);
3080 * Insert an item after another in the genlst
3082 * This inserts an item after another in the list. It will be in the
3083 * same tree level or group as the item it is inseted after.
3085 * @param obj The genlist object
3086 * @param itc The item class for the item
3087 * @param data The item data
3088 * @param after The item to insert after
3089 * @param flags Item flags
3090 * @param func Convenience function called when item selected
3091 * @param func_data Data passed to @p func above.
3092 * @return A handle to the item added or NULL if not possible
3096 EAPI Elm_Genlist_Item *
3097 elm_genlist_item_insert_after(Evas_Object *obj,
3098 const Elm_Genlist_Item_Class *itc,
3100 Elm_Genlist_Item *parent,
3101 Elm_Genlist_Item *after,
3102 Elm_Genlist_Item_Flags flags,
3104 const void *func_data)
3106 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3107 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3108 Widget_Data *wd = elm_widget_data_get(obj);
3109 if (!wd) return NULL;
3110 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3112 if (!it) return NULL;
3113 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3114 EINA_INLIST_GET(after));
3117 it->parent->items = eina_list_append_relative(it->parent->items, it,
3121 it->rel->relcount++;
3122 it->before = EINA_FALSE;
3123 _item_queue(wd, it);
3130 * This clears all items in the list, leaving it empty.
3132 * @param obj The genlist object
3137 elm_genlist_clear(Evas_Object *obj)
3139 ELM_CHECK_WIDTYPE(obj, widtype);
3140 Widget_Data *wd = elm_widget_data_get(obj);
3142 if (wd->walking > 0)
3144 Elm_Genlist_Item *it;
3146 wd->clear_me = EINA_TRUE;
3147 EINA_INLIST_FOREACH(wd->items, it)
3149 it->delete_me = EINA_TRUE;
3155 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3157 if (wd->anchor_item == it)
3159 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3160 if (!wd->anchor_item)
3162 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3164 wd->items = eina_inlist_remove(wd->items, wd->items);
3165 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3166 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3167 elm_widget_item_pre_notify_del(it);
3168 if (it->realized) _item_unrealize(it);
3169 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3170 it->itc->func.del((void *)it->base.data, it->base.widget);
3171 if (it->long_timer) ecore_timer_del(it->long_timer);
3172 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3173 elm_widget_item_del(it);
3175 wd->clear_me = EINA_FALSE;
3176 wd->anchor_item = NULL;
3179 Item_Block *itb = (Item_Block *)(wd->blocks);
3181 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3182 if (itb->items) eina_list_free(itb->items);
3187 ecore_job_del(wd->calc_job);
3188 wd->calc_job = NULL;
3190 if (wd->queue_idler)
3192 ecore_idler_del(wd->queue_idler);
3193 wd->queue_idler = NULL;
3195 if (wd->must_recalc_idler)
3197 ecore_idler_del(wd->must_recalc_idler);
3198 wd->must_recalc_idler = NULL;
3202 eina_list_free(wd->queue);
3207 eina_list_free(wd->selected);
3208 wd->selected = NULL;
3210 wd->show_item = NULL;
3217 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3218 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3224 * Enable or disable multi-select in the genlist
3226 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3227 * the list. This allows more than 1 item to be selected.
3229 * @param obj The genlist object
3230 * @param multi Multi-select enable/disable
3235 elm_genlist_multi_select_set(Evas_Object *obj,
3238 ELM_CHECK_WIDTYPE(obj, widtype);
3239 Widget_Data *wd = elm_widget_data_get(obj);
3245 * Gets if multi-select in genlist is enable or disable
3247 * @param obj The genlist object
3248 * @return Multi-select enable/disable
3249 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3254 elm_genlist_multi_select_get(const Evas_Object *obj)
3256 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3257 Widget_Data *wd = elm_widget_data_get(obj);
3258 if (!wd) return EINA_FALSE;
3263 * Get the selectd item in the genlist
3265 * This gets the selected item in the list (if multi-select is enabled
3266 * only the first item in the list is selected - which is not very
3267 * useful, so see elm_genlist_selected_items_get() for when
3268 * multi-select is used).
3270 * If no item is selected, NULL is returned.
3272 * @param obj The genlist object
3273 * @return The selected item, or NULL if none.
3277 EAPI Elm_Genlist_Item *
3278 elm_genlist_selected_item_get(const Evas_Object *obj)
3280 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3281 Widget_Data *wd = elm_widget_data_get(obj);
3282 if (!wd) return NULL;
3283 if (wd->selected) return wd->selected->data;
3288 * Get a list of selected items in the genlist
3290 * This returns a list of the selected items. This list pointer is
3291 * only valid so long as no items are selected or unselected (or
3292 * unselected implicitly by deletion). The list contains
3293 * Elm_Genlist_Item pointers.
3295 * @param obj The genlist object
3296 * @return The list of selected items, nor NULL if none are selected.
3300 EAPI const Eina_List *
3301 elm_genlist_selected_items_get(const Evas_Object *obj)
3303 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3304 Widget_Data *wd = elm_widget_data_get(obj);
3305 if (!wd) return NULL;
3306 return wd->selected;
3310 * Get a list of realized items in genlist
3312 * This returns a list of the realized items in the genlist. The list
3313 * contains Elm_Genlist_Item pointers. The list must be freed by the
3314 * caller when done with eina_list_free(). The item pointers in the
3315 * list are only valid so long as those items are not deleted or the
3316 * genlist is not deleted.
3318 * @param obj The genlist object
3319 * @return The list of realized items, nor NULL if none are realized.
3324 elm_genlist_realized_items_get(const Evas_Object *obj)
3326 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3327 Widget_Data *wd = elm_widget_data_get(obj);
3328 Eina_List *list = NULL;
3330 Eina_Bool done = EINA_FALSE;
3331 if (!wd) return NULL;
3332 EINA_INLIST_FOREACH(wd->blocks, itb)
3337 Elm_Genlist_Item *it;
3340 EINA_LIST_FOREACH(itb->items, l, it)
3342 if (it->realized) list = eina_list_append(list, it);
3354 * Get the item that is at the x, y canvas coords
3356 * This returns the item at the given coordinates (which are canvas
3357 * relative not object-relative). If an item is at that coordinate,
3358 * that item handle is returned, and if @p posret is not NULL, the
3359 * integer pointed to is set to a value of -1, 0 or 1, depending if
3360 * the coordinate is on the upper portion of that item (-1), on the
3361 * middle section (0) or on the lower part (1). If NULL is returned as
3362 * an item (no item found there), then posret may indicate -1 or 1
3363 * based if the coordinate is above or below all items respectively in
3366 * @param it The item
3367 * @param x The input x coordinate
3368 * @param y The input y coordinate
3369 * @param posret The position relative to the item returned here
3370 * @return The item at the coordinates or NULL if none
3374 EAPI Elm_Genlist_Item *
3375 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3380 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3381 Widget_Data *wd = elm_widget_data_get(obj);
3382 Evas_Coord ox, oy, ow, oh;
3385 if (!wd) return NULL;
3386 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3388 EINA_INLIST_FOREACH(wd->blocks, itb)
3391 Elm_Genlist_Item *it;
3393 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3394 oy + itb->y - itb->wd->pan_y,
3395 itb->w, itb->h, x, y, 1, 1))
3397 EINA_LIST_FOREACH(itb->items, l, it)
3399 Evas_Coord itx, ity;
3401 itx = ox + itb->x + it->x - itb->wd->pan_x;
3402 ity = oy + itb->y + it->y - itb->wd->pan_y;
3403 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3407 if (y <= (ity + (it->h / 4))) *posret = -1;
3408 else if (y >= (ity + it->h - (it->h / 4)))
3414 lasty = ity + it->h;
3419 if (y > lasty) *posret = 1;
3426 * Get the first item in the genlist
3428 * This returns the first item in the list.
3430 * @param obj The genlist object
3431 * @return The first item, or NULL if none
3435 EAPI Elm_Genlist_Item *
3436 elm_genlist_first_item_get(const Evas_Object *obj)
3438 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3439 Widget_Data *wd = elm_widget_data_get(obj);
3440 if (!wd) return NULL;
3441 if (!wd->items) return NULL;
3442 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3443 while ((it) && (it->delete_me))
3444 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3449 * Get the last item in the genlist
3451 * This returns the last item in the list.
3453 * @return The last item, or NULL if none
3457 EAPI Elm_Genlist_Item *
3458 elm_genlist_last_item_get(const Evas_Object *obj)
3460 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3461 Widget_Data *wd = elm_widget_data_get(obj);
3462 if (!wd) return NULL;
3463 if (!wd->items) return NULL;
3464 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3465 while ((it) && (it->delete_me))
3466 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3471 * Get the next item in the genlist
3473 * This returns the item after the item @p it.
3475 * @param it The item
3476 * @return The item after @p it, or NULL if none
3480 EAPI Elm_Genlist_Item *
3481 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3483 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3486 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3487 if ((it) && (!it->delete_me)) break;
3489 return (Elm_Genlist_Item *)it;
3493 * Get the previous item in the genlist
3495 * This returns the item before the item @p it.
3497 * @param it The item
3498 * @return The item before @p it, or NULL if none
3502 EAPI Elm_Genlist_Item *
3503 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3505 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3508 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3509 if ((it) && (!it->delete_me)) break;
3511 return (Elm_Genlist_Item *)it;
3515 * Get the genlist object from an item
3517 * This returns the genlist object itself that an item belongs to.
3519 * @param it The item
3520 * @return The genlist object
3525 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3528 return it->base.widget;
3532 * Get the parent item of the given item
3534 * This returns the parent item of the item @p it given.
3536 * @param it The item
3537 * @return The parent of the item or NULL if none
3541 EAPI Elm_Genlist_Item *
3542 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3549 * Clear all sub-items (children) of the given item
3551 * This clears all items that are children (or their descendants) of the
3554 * @param it The item
3559 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3561 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3562 Eina_List *tl = NULL, *l;
3563 Elm_Genlist_Item *it2;
3565 EINA_LIST_FOREACH(it->items, l, it2)
3566 tl = eina_list_append(tl, it2);
3567 EINA_LIST_FREE(tl, it2)
3568 elm_genlist_item_del(it2);
3572 * Set the selected state of an item
3574 * This sets the selected state (1 selected, 0 not selected) of the given
3577 * @param it The item
3578 * @param selected The selected state
3583 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3586 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3587 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3589 if (it->delete_me) return;
3590 selected = !!selected;
3591 if (it->selected == selected) return;
3597 while (wd->selected)
3598 _item_unselect(wd->selected->data);
3600 _item_highlight(it);
3608 * Get the selected state of an item
3610 * This gets the selected state of an item (1 selected, 0 not selected).
3612 * @param it The item
3613 * @return The selected state
3618 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3620 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3621 return it->selected;
3625 * Sets the expanded state of an item (if it's a parent)
3627 * This expands or contracts a parent item (thus showing or hiding the
3630 * @param it The item
3631 * @param expanded The expanded state (1 expanded, 0 not expanded).
3636 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3639 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3640 if (it->expanded == expanded) return;
3641 it->expanded = expanded;
3645 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3646 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3651 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3652 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3657 * Get the expanded state of an item
3659 * This gets the expanded state of an item
3661 * @param it The item
3662 * @return Thre expanded state
3667 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3669 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3670 return it->expanded;
3674 * Get the depth of expanded item
3676 * @param it The genlist item object
3677 * @return The depth of expanded item
3682 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3684 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3685 return it->expanded_depth;
3689 * Sets the disabled state of an item.
3691 * A disabled item cannot be selected or unselected. It will also
3692 * change appearance to appear disabled. This sets the disabled state
3693 * (1 disabled, 0 not disabled).
3695 * @param it The item
3696 * @param disabled The disabled state
3701 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3704 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3705 if (it->disabled == disabled) return;
3706 if (it->delete_me) return;
3707 it->disabled = disabled;
3711 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3713 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3718 * Get the disabled state of an item
3720 * This gets the disabled state of the given item.
3722 * @param it The item
3723 * @return The disabled state
3728 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3730 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3731 if (it->delete_me) return EINA_FALSE;
3732 return it->disabled;
3736 * Sets the display only state of an item.
3738 * A display only item cannot be selected or unselected. It is for
3739 * display only and not selecting or otherwise clicking, dragging
3740 * etc. by the user, thus finger size rules will not be applied to
3743 * @param it The item
3744 * @param display_only The display only state
3749 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3750 Eina_Bool display_only)
3752 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3753 if (it->display_only == display_only) return;
3754 if (it->delete_me) return;
3755 it->display_only = display_only;
3756 it->mincalcd = EINA_FALSE;
3757 it->updateme = EINA_TRUE;
3758 if (it->block) it->block->updateme = EINA_TRUE;
3759 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3760 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3764 * Get the display only state of an item
3766 * This gets the display only state of the given item.
3768 * @param it The item
3769 * @return The display only state
3774 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3776 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3777 if (it->delete_me) return EINA_FALSE;
3778 return it->display_only;
3782 * Show the given item
3784 * This causes genlist to jump to the given item @p it and show it (by
3785 * scrolling), if it is not fully visible.
3787 * @param it The item
3792 elm_genlist_item_show(Elm_Genlist_Item *it)
3794 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3795 Evas_Coord gith = 0;
3796 if (it->delete_me) return;
3797 if ((it->queued) || (!it->mincalcd))
3799 it->wd->show_item = it;
3800 it->wd->bring_in = EINA_TRUE;
3801 it->showme = EINA_TRUE;
3804 if (it->wd->show_item)
3806 it->wd->show_item->showme = EINA_FALSE;
3807 it->wd->show_item = NULL;
3809 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3810 gith = it->group_item->h;
3811 elm_smart_scroller_child_region_show(it->wd->scr,
3812 it->x + it->block->x,
3813 it->y + it->block->y - gith,
3814 it->block->w, it->h);
3818 * Bring in the given item
3820 * This causes genlist to jump to the given item @p it and show it (by
3821 * scrolling), if it is not fully visible. This may use animation to
3822 * do so and take a period of time
3824 * @param it The item
3829 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3831 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3832 Evas_Coord gith = 0;
3833 if (it->delete_me) return;
3834 if ((it->queued) || (!it->mincalcd))
3836 it->wd->show_item = it;
3837 it->wd->bring_in = EINA_TRUE;
3838 it->showme = EINA_TRUE;
3841 if (it->wd->show_item)
3843 it->wd->show_item->showme = EINA_FALSE;
3844 it->wd->show_item = NULL;
3846 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3847 gith = it->group_item->h;
3848 elm_smart_scroller_region_bring_in(it->wd->scr,
3849 it->x + it->block->x,
3850 it->y + it->block->y - gith,
3851 it->block->w, it->h);
3855 * Show the given item at the top
3857 * This causes genlist to jump to the given item @p it and show it (by
3858 * scrolling), if it is not fully visible.
3860 * @param it The item
3865 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3867 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3869 Evas_Coord gith = 0;
3871 if (it->delete_me) return;
3872 if ((it->queued) || (!it->mincalcd))
3874 it->wd->show_item = it;
3875 it->wd->bring_in = EINA_TRUE;
3876 it->showme = EINA_TRUE;
3879 if (it->wd->show_item)
3881 it->wd->show_item->showme = EINA_FALSE;
3882 it->wd->show_item = NULL;
3884 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3885 if (it->group_item) gith = it->group_item->h;
3886 elm_smart_scroller_child_region_show(it->wd->scr,
3887 it->x + it->block->x,
3888 it->y + it->block->y - gith,
3893 * Bring in the given item at the top
3895 * This causes genlist to jump to the given item @p it and show it (by
3896 * scrolling), if it is not fully visible. This may use animation to
3897 * do so and take a period of time
3899 * @param it The item
3904 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3906 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3908 Evas_Coord gith = 0;
3910 if (it->delete_me) return;
3911 if ((it->queued) || (!it->mincalcd))
3913 it->wd->show_item = it;
3914 it->wd->bring_in = EINA_TRUE;
3915 it->showme = EINA_TRUE;
3918 if (it->wd->show_item)
3920 it->wd->show_item->showme = EINA_FALSE;
3921 it->wd->show_item = NULL;
3923 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3924 if (it->group_item) gith = it->group_item->h;
3925 elm_smart_scroller_region_bring_in(it->wd->scr,
3926 it->x + it->block->x,
3927 it->y + it->block->y - gith,
3932 * Show the given item at the middle
3934 * This causes genlist to jump to the given item @p it and show it (by
3935 * scrolling), if it is not fully visible.
3937 * @param it The item
3942 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3944 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3947 if (it->delete_me) return;
3948 if ((it->queued) || (!it->mincalcd))
3950 it->wd->show_item = it;
3951 it->wd->bring_in = EINA_TRUE;
3952 it->showme = EINA_TRUE;
3955 if (it->wd->show_item)
3957 it->wd->show_item->showme = EINA_FALSE;
3958 it->wd->show_item = NULL;
3960 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3961 elm_smart_scroller_child_region_show(it->wd->scr,
3962 it->x + it->block->x,
3963 it->y + it->block->y - oh / 2 +
3964 it->h / 2, it->block->w, oh);
3968 * Bring in the given item at the middle
3970 * This causes genlist to jump to the given item @p it and show it (by
3971 * scrolling), if it is not fully visible. This may use animation to
3972 * do so and take a period of time
3974 * @param it The item
3979 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3981 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3984 if (it->delete_me) return;
3985 if ((it->queued) || (!it->mincalcd))
3987 it->wd->show_item = it;
3988 it->wd->bring_in = EINA_TRUE;
3989 it->showme = EINA_TRUE;
3992 if (it->wd->show_item)
3994 it->wd->show_item->showme = EINA_FALSE;
3995 it->wd->show_item = NULL;
3997 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3998 elm_smart_scroller_region_bring_in(it->wd->scr,
3999 it->x + it->block->x,
4000 it->y + it->block->y - oh / 2 + it->h / 2,
4005 * Delete a given item
4007 * This deletes the item from genlist and calls the genlist item del
4008 * class callback defined in the item class, if it is set. This clears all
4009 * subitems if it is a tree.
4011 * @param it The item
4016 elm_genlist_item_del(Elm_Genlist_Item *it)
4018 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4019 if ((it->relcount > 0) || (it->walking > 0))
4021 elm_widget_item_pre_notify_del(it);
4022 elm_genlist_item_subitems_clear(it);
4023 it->delete_me = EINA_TRUE;
4024 if (it->wd->show_item == it) it->wd->show_item = NULL;
4026 it->wd->selected = eina_list_remove(it->wd->selected,
4030 if (it->realized) _item_unrealize(it);
4031 it->block->changed = EINA_TRUE;
4032 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4033 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4035 if (it->itc->func.del)
4036 it->itc->func.del((void *)it->base.data, it->base.widget);
4043 * Set the data item from the genlist item
4045 * This set the data value passed on the elm_genlist_item_append() and
4046 * related item addition calls. This function will also call
4047 * elm_genlist_item_update() so the item will be updated to reflect the
4050 * @param it The item
4051 * @param data The new data pointer to set
4056 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4059 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4060 elm_widget_item_data_set(it, data);
4061 elm_genlist_item_update(it);
4065 * Get the data item from the genlist item
4067 * This returns the data value passed on the elm_genlist_item_append()
4068 * and related item addition calls and elm_genlist_item_data_set().
4070 * @param it The item
4071 * @return The data pointer provided when created
4076 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4078 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4079 return elm_widget_item_data_get(it);
4083 * Tells genlist to "orphan" icons fetchs by the item class
4085 * This instructs genlist to release references to icons in the item,
4086 * meaning that they will no longer be managed by genlist and are
4087 * floating "orphans" that can be re-used elsewhere if the user wants
4090 * @param it The item
4095 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4099 EINA_LIST_FREE(it->icon_objs, icon)
4101 elm_widget_sub_object_del(it->base.widget, icon);
4102 evas_object_smart_member_del(icon);
4103 evas_object_hide(icon);
4108 * Get the real evas object of the genlist item
4110 * This returns the actual evas object used for the specified genlist
4111 * item. This may be NULL as it may not be created, and may be deleted
4112 * at any time by genlist. Do not modify this object (move, resize,
4113 * show, hide etc.) as genlist is controlling it. This function is for
4114 * querying, emitting custom signals or hooking lower level callbacks
4115 * for events. Do not delete this object under any circumstances.
4117 * @param it The item
4118 * @return The object pointer
4122 EAPI const Evas_Object *
4123 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4125 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4126 return it->base.view;
4130 * Update the contents of an item
4132 * This updates an item by calling all the item class functions again
4133 * to get the icons, labels and states. Use this when the original
4134 * item data has changed and the changes are desired to be reflected.
4136 * @param it The item
4141 elm_genlist_item_update(Elm_Genlist_Item *it)
4143 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4144 if (!it->block) return;
4145 if (it->delete_me) return;
4146 it->mincalcd = EINA_FALSE;
4147 it->updateme = EINA_TRUE;
4148 it->block->updateme = EINA_TRUE;
4149 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4150 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4154 * Update the item class of an item
4156 * @param it The item
4157 * @parem itc The item class for the item
4162 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4163 const Elm_Genlist_Item_Class *itc)
4165 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4166 if (!it->block) return;
4167 EINA_SAFETY_ON_NULL_RETURN(itc);
4168 if (it->delete_me) return;
4170 it->nocache = EINA_TRUE;
4171 elm_genlist_item_update(it);
4174 static Evas_Object *
4175 _elm_genlist_item_label_create(void *data,
4177 void *item __UNUSED__)
4179 Evas_Object *label = elm_label_add(obj);
4182 elm_object_style_set(label, "tooltip");
4183 elm_label_label_set(label, data);
4188 _elm_genlist_item_label_del_cb(void *data,
4189 Evas_Object *obj __UNUSED__,
4190 void *event_info __UNUSED__)
4192 eina_stringshare_del(data);
4196 * Set the text to be shown in the genlist item.
4198 * @param item Target item
4199 * @param text The text to set in the content
4201 * Setup the text as tooltip to object. The item can have only one
4202 * tooltip, so any previous tooltip data is removed.
4207 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4210 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4211 text = eina_stringshare_add(text);
4212 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4214 _elm_genlist_item_label_del_cb);
4218 * Set the content to be shown in the tooltip item
4220 * Setup the tooltip to item. The item can have only one tooltip, so
4221 * any previous tooltip data is removed. @p func(with @p data) will be
4222 * called every time that need to show the tooltip and it should return a
4223 * valid Evas_Object. This object is then managed fully by tooltip
4224 * system and is deleted when the tooltip is gone.
4226 * @param item the genlist item being attached by a tooltip.
4227 * @param func the function used to create the tooltip contents.
4228 * @param data what to provide to @a func as callback data/context.
4229 * @param del_cb called when data is not needed anymore, either when
4230 * another callback replaces @func, the tooltip is unset with
4231 * elm_genlist_item_tooltip_unset() or the owner @a item
4232 * dies. This callback receives as the first parameter the
4233 * given @a data, and @c event_info is the item.
4238 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4239 Elm_Tooltip_Item_Content_Cb func,
4241 Evas_Smart_Cb del_cb)
4243 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4245 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4248 if (item->tooltip.del_cb)
4249 item->tooltip.del_cb((void *)item->tooltip.data,
4250 item->base.widget, item);
4252 item->tooltip.content_cb = func;
4253 item->tooltip.data = data;
4254 item->tooltip.del_cb = del_cb;
4256 if (item->base.view)
4258 elm_widget_item_tooltip_content_cb_set(item,
4259 item->tooltip.content_cb,
4260 item->tooltip.data, NULL);
4261 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4267 if (del_cb) del_cb((void *)data, NULL, NULL);
4271 * Unset tooltip from item
4273 * @param item genlist item to remove previously set tooltip.
4275 * Remove tooltip from item. The callback provided as del_cb to
4276 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4277 * it is not used anymore.
4279 * @see elm_genlist_item_tooltip_content_cb_set()
4284 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4286 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4287 if ((item->base.view) && (item->tooltip.content_cb))
4288 elm_widget_item_tooltip_unset(item);
4290 if (item->tooltip.del_cb)
4291 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4292 item->tooltip.del_cb = NULL;
4293 item->tooltip.content_cb = NULL;
4294 item->tooltip.data = NULL;
4295 if (item->tooltip.style)
4296 elm_genlist_item_tooltip_style_set(item, NULL);
4300 * Sets a different style for this item tooltip.
4302 * @note before you set a style you should define a tooltip with
4303 * elm_genlist_item_tooltip_content_cb_set() or
4304 * elm_genlist_item_tooltip_text_set()
4306 * @param item genlist item with tooltip already set.
4307 * @param style the theme style to use (default, transparent, ...)
4312 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4316 eina_stringshare_replace(&item->tooltip.style, style);
4317 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4321 * Get the style for this item tooltip.
4323 * @param item genlist item with tooltip already set.
4324 * @return style the theme style in use, defaults to "default". If the
4325 * object does not have a tooltip set, then NULL is returned.
4330 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4332 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4333 return item->tooltip.style;
4337 * Set the cursor to be shown when mouse is over the genlist item
4339 * @param item Target item
4340 * @param cursor the cursor name to be used.
4342 * @see elm_object_cursor_set()
4346 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4349 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4350 eina_stringshare_replace(&item->mouse_cursor, cursor);
4351 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4355 * Get the cursor to be shown when mouse is over the genlist item
4357 * @param item genlist item with cursor already set.
4358 * @return the cursor name.
4363 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4365 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4366 return elm_widget_item_cursor_get(item);
4370 * Unset the cursor to be shown when mouse is over the genlist item
4372 * @param item Target item
4374 * @see elm_object_cursor_unset()
4378 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4380 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4381 if (!item->mouse_cursor)
4384 if (item->base.view)
4385 elm_widget_item_cursor_unset(item);
4387 eina_stringshare_del(item->mouse_cursor);
4388 item->mouse_cursor = NULL;
4392 * Sets a different style for this item cursor.
4394 * @note before you set a style you should define a cursor with
4395 * elm_genlist_item_cursor_set()
4397 * @param item genlist item with cursor already set.
4398 * @param style the theme style to use (default, transparent, ...)
4403 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4406 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4407 elm_widget_item_cursor_style_set(item, style);
4411 * Get the style for this item cursor.
4413 * @param item genlist item with cursor already set.
4414 * @return style the theme style in use, defaults to "default". If the
4415 * object does not have a cursor set, then NULL is returned.
4420 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4422 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4423 return elm_widget_item_cursor_style_get(item);
4427 * Set if the cursor set should be searched on the theme or should use
4428 * the provided by the engine, only.
4430 * @note before you set if should look on theme you should define a
4431 * cursor with elm_object_cursor_set(). By default it will only look
4432 * for cursors provided by the engine.
4434 * @param item widget item with cursor already set.
4435 * @param engine_only boolean to define it cursors should be looked
4436 * only between the provided by the engine or searched on widget's
4442 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4443 Eina_Bool engine_only)
4445 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4446 elm_widget_item_cursor_engine_only_set(item, engine_only);
4450 * Get the cursor engine only usage for this item cursor.
4452 * @param item widget item with cursor already set.
4453 * @return engine_only boolean to define it cursors should be looked
4454 * only between the provided by the engine or searched on widget's
4455 * theme as well. If the object does not have a cursor set, then
4456 * EINA_FALSE is returned.
4461 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4463 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4464 return elm_widget_item_cursor_engine_only_get(item);
4468 * This sets the horizontal stretching mode
4470 * This sets the mode used for sizing items horizontally. Valid modes
4471 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4472 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4473 * the scroller will scroll horizontally. Otherwise items are expanded
4474 * to fill the width of the viewport of the scroller. If it is
4475 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4476 * limited to that size.
4478 * @param obj The genlist object
4479 * @param mode The mode to use
4484 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4487 ELM_CHECK_WIDTYPE(obj, widtype);
4488 Widget_Data *wd = elm_widget_data_get(obj);
4490 if (wd->mode == mode) return;
4496 * Gets the horizontal stretching mode
4498 * @param obj The genlist object
4499 * @return The mode to use
4500 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4505 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4507 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4508 Widget_Data *wd = elm_widget_data_get(obj);
4509 if (!wd) return ELM_LIST_LAST;
4514 * Set the always select mode.
4516 * Items will only call their selection func and callback when first
4517 * becoming selected. Any further clicks will do nothing, unless you
4518 * enable always select with elm_genlist_always_select_mode_set().
4519 * This means even if selected, every click will make the selected
4520 * callbacks be called.
4522 * @param obj The genlist object
4523 * @param always_select The always select mode
4524 * (EINA_TRUE = on, EINA_FALSE = off)
4529 elm_genlist_always_select_mode_set(Evas_Object *obj,
4530 Eina_Bool always_select)
4532 ELM_CHECK_WIDTYPE(obj, widtype);
4533 Widget_Data *wd = elm_widget_data_get(obj);
4535 wd->always_select = always_select;
4539 * Get the always select mode.
4541 * @param obj The genlist object
4542 * @return The always select mode
4543 * (EINA_TRUE = on, EINA_FALSE = off)
4548 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4550 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4551 Widget_Data *wd = elm_widget_data_get(obj);
4552 if (!wd) return EINA_FALSE;
4553 return wd->always_select;
4557 * Set no select mode
4559 * This will turn off the ability to select items entirely and they
4560 * will neither appear selected nor call selected callback functions.
4562 * @param obj The genlist object
4563 * @param no_select The no select mode
4564 * (EINA_TRUE = on, EINA_FALSE = off)
4569 elm_genlist_no_select_mode_set(Evas_Object *obj,
4570 Eina_Bool no_select)
4572 ELM_CHECK_WIDTYPE(obj, widtype);
4573 Widget_Data *wd = elm_widget_data_get(obj);
4575 wd->no_select = no_select;
4579 * Gets no select mode
4581 * @param obj The genlist object
4582 * @return The no select mode
4583 * (EINA_TRUE = on, EINA_FALSE = off)
4588 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4590 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4591 Widget_Data *wd = elm_widget_data_get(obj);
4592 if (!wd) return EINA_FALSE;
4593 return wd->no_select;
4599 * This will enable the compress mode where items are "compressed"
4600 * horizontally to fit the genlist scrollable viewport width. This is
4601 * special for genlist. Do not rely on
4602 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4603 * work as genlist needs to handle it specially.
4605 * @param obj The genlist object
4606 * @param compress The compress mode
4607 * (EINA_TRUE = on, EINA_FALSE = off)
4612 elm_genlist_compress_mode_set(Evas_Object *obj,
4615 ELM_CHECK_WIDTYPE(obj, widtype);
4616 Widget_Data *wd = elm_widget_data_get(obj);
4618 wd->compress = compress;
4622 * Get the compress mode
4624 * @param obj The genlist object
4625 * @return The compress mode
4626 * (EINA_TRUE = on, EINA_FALSE = off)
4631 elm_genlist_compress_mode_get(const Evas_Object *obj)
4633 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4634 Widget_Data *wd = elm_widget_data_get(obj);
4635 if (!wd) return EINA_FALSE;
4636 return wd->compress;
4640 * Set height-for-width mode
4642 * With height-for-width mode the item width will be fixed (restricted
4643 * to a minimum of) to the list width when calculating its size in
4644 * order to allow the height to be calculated based on it. This allows,
4645 * for instance, text block to wrap lines if the Edje part is
4646 * configured with "text.min: 0 1".
4648 * @note This mode will make list resize slower as it will have to
4649 * recalculate every item height again whenever the list width
4652 * @note When height-for-width mode is enabled, it also enables
4653 * compress mode (see elm_genlist_compress_mode_set()) and
4654 * disables homogeneous (see elm_genlist_homogeneous_set()).
4656 * @param obj The genlist object
4657 * @param setting The height-for-width mode (EINA_TRUE = on,
4663 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4664 Eina_Bool height_for_width)
4666 ELM_CHECK_WIDTYPE(obj, widtype);
4667 Widget_Data *wd = elm_widget_data_get(obj);
4669 wd->height_for_width = !!height_for_width;
4670 if (wd->height_for_width)
4672 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4673 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4678 * Get the height-for-width mode
4680 * @param obj The genlist object
4681 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4687 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4689 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4690 Widget_Data *wd = elm_widget_data_get(obj);
4691 if (!wd) return EINA_FALSE;
4692 return wd->height_for_width;
4698 * This will enable or disable the scroller bounce mode for the
4699 * genlist. See elm_scroller_bounce_set() for details
4701 * @param obj The genlist object
4702 * @param h_bounce Allow bounce horizontally
4703 * @param v_bounce Allow bounce vertically
4708 elm_genlist_bounce_set(Evas_Object *obj,
4712 ELM_CHECK_WIDTYPE(obj, widtype);
4713 Widget_Data *wd = elm_widget_data_get(obj);
4715 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4719 * Get the bounce mode
4721 * @param obj The genlist object
4722 * @param h_bounce Allow bounce horizontally
4723 * @param v_bounce Allow bounce vertically
4728 elm_genlist_bounce_get(const Evas_Object *obj,
4729 Eina_Bool *h_bounce,
4730 Eina_Bool *v_bounce)
4732 ELM_CHECK_WIDTYPE(obj, widtype);
4733 Widget_Data *wd = elm_widget_data_get(obj);
4735 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4739 * Set homogenous mode
4741 * This will enable the homogeneous mode where items are of the same
4742 * height and width so that genlist may do the lazy-loading at its
4743 * maximum. This implies 'compressed' mode.
4745 * @param obj The genlist object
4746 * @param homogeneous Assume the items within the genlist are of the
4747 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4752 elm_genlist_homogeneous_set(Evas_Object *obj,
4753 Eina_Bool homogeneous)
4755 ELM_CHECK_WIDTYPE(obj, widtype);
4756 Widget_Data *wd = elm_widget_data_get(obj);
4758 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4759 wd->homogeneous = homogeneous;
4763 * Get the homogenous mode
4765 * @param obj The genlist object
4766 * @return Assume the items within the genlist are of the same height
4767 * and width (EINA_TRUE = on, EINA_FALSE = off)
4772 elm_genlist_homogeneous_get(const Evas_Object *obj)
4774 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4775 Widget_Data *wd = elm_widget_data_get(obj);
4776 if (!wd) return EINA_FALSE;
4777 return wd->homogeneous;
4781 * Set the maximum number of items within an item block
4783 * This will configure the block count to tune to the target with
4784 * particular performance matrix.
4786 * @param obj The genlist object
4787 * @param n Maximum number of items within an item block
4792 elm_genlist_block_count_set(Evas_Object *obj,
4795 ELM_CHECK_WIDTYPE(obj, widtype);
4796 Widget_Data *wd = elm_widget_data_get(obj);
4798 wd->max_items_per_block = n;
4799 wd->item_cache_max = wd->max_items_per_block * 2;
4800 _item_cache_clean(wd);
4804 * Get the maximum number of items within an item block
4806 * @param obj The genlist object
4807 * @return Maximum number of items within an item block
4812 elm_genlist_block_count_get(const Evas_Object *obj)
4814 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4815 Widget_Data *wd = elm_widget_data_get(obj);
4817 return wd->max_items_per_block;
4821 * Set the timeout in seconds for the longpress event
4823 * @param obj The genlist object
4824 * @param timeout timeout in seconds
4829 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4832 ELM_CHECK_WIDTYPE(obj, widtype);
4833 Widget_Data *wd = elm_widget_data_get(obj);
4835 wd->longpress_timeout = timeout;
4839 * Get the timeout in seconds for the longpress event
4841 * @param obj The genlist object
4842 * @return timeout in seconds
4847 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4849 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4850 Widget_Data *wd = elm_widget_data_get(obj);
4852 return wd->longpress_timeout;
4856 * Set the scrollbar policy
4858 * This sets the scrollbar visibility policy for the given genlist
4859 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
4860 * made visible if it is needed, and otherwise kept hidden.
4861 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
4862 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
4863 * respectively for the horizontal and vertical scrollbars.
4865 * @param obj The genlist object
4866 * @param policy_h Horizontal scrollbar policy
4867 * @param policy_v Vertical scrollbar policy
4872 elm_genlist_scroller_policy_set(Evas_Object *obj,
4873 Elm_Scroller_Policy policy_h,
4874 Elm_Scroller_Policy policy_v)
4876 ELM_CHECK_WIDTYPE(obj, widtype);
4877 Widget_Data *wd = elm_widget_data_get(obj);
4879 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4880 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4883 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4887 * Get the scrollbar policy
4889 * @param obj The genlist object
4890 * @param policy_h Horizontal scrollbar policy
4891 * @param policy_v Vertical scrollbar policy
4896 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4897 Elm_Scroller_Policy *policy_h,
4898 Elm_Scroller_Policy *policy_v)
4900 ELM_CHECK_WIDTYPE(obj, widtype);
4901 Widget_Data *wd = elm_widget_data_get(obj);
4902 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4903 if ((!wd) || (!wd->scr)) return;
4904 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4905 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4906 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;