3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list that 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 * complexity when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * drag,start,up - This is called when the item in the list has been dragged
60 * drag,start,down - This is called when the item in the list has been dragged
61 * (not scrolled) down.
63 * drag,start,left - This is called when the item in the list has been dragged
64 * (not scrolled) left.
66 * drag,start,right - This is called when the item in the list has been dragged
67 * (not scrolled) right.
69 * drag,stop - This is called when the item in the list has stopped being
72 * drag - This is called when the item in the list is being dragged.
74 * Genlist has a fairly large API, mostly because it's relatively complex,
75 * trying to be both expansive, powerful and efficient. First we will begin
76 * an overview o the theory behind genlist.
78 * Evas tracks every object you create. Every time it processes an event
79 * (mouse move, down, up etc.) it needs to walk through objects and find out
80 * what event that affects. Even worse every time it renders display updates,
81 * in order to just calculate what to re-draw, it needs to walk through many
82 * many many objects. Thus, the more objects you keep active, the more
83 * overhead Evas has in just doing its work. It is advisable to keep your
84 * active objects to the minimum working set you need. Also remember that
85 * object creation and deletion carries an overhead, so there is a
86 * middle-ground, which is not easily determined. But don't keep massive lists
87 * of objects you can't see or use. Genlist does this with list objects. It
88 * creates and destroys them dynamically as you scroll around. It groups them
89 * into blocks so it can determine the visibility etc. of a whole block at
90 * once as opposed to having to walk the whole list. This 2-level list allows
91 * for very large numbers of items to be in the list (tests have used up to
92 * 2,000,000 items). Also genlist employs a queue for adding items. As items
93 * may be different sizes, every item added needs to be calculated as to its
94 * size and thus this presents a lot of overhead on populating the list, this
95 * genlist employs a queue. Any item added is queued and spooled off over
96 * time, actually appearing some time later, so if your list has many members
97 * you may find it takes a while for them to all appear, with your process
98 * consuming a lot of CPU while it is busy spooling.
100 * Genlist also implements a tree structure, but it does so with callbacks to
101 * the application, with the application filling in tree structures when
102 * requested (allowing for efficient building of a very deep tree that could
103 * even be used for file-management). See the above smart signal callbacks for
106 * An item in the genlist world can have 0 or more text labels (they can be
107 * regular text or textblock – that's up to the style to determine), 0 or
108 * more icons (which are simply objects swallowed into the genlist item) and
109 * 0 or more boolean states that can be used for check, radio or other
110 * indicators by the edje theme style. An item may be one of several styles
111 * (Elementary provides 2 by default - “default” and “double_label”, but this
112 * can be extended by system or application custom themes/overlays/extensions).
114 * In order to implement the ability to add and delete items on the fly,
115 * Genlist implements a class/callback system where the application provides
116 * a structure with information about that type of item (genlist may contain
117 * multiple different items with different classes, states and styles).
118 * Genlist will call the functions in this struct (methods) when an item is
119 * “realized” (that is created dynamically while scrolling). All objects will
120 * simply be deleted when no longer needed with evas_object_del(). The
121 * Elm_Genlist_Item_Class structure contains the following members:
123 * item_style - This is a constant string and simply defines the name of the
124 * item style. It must be specified and the default should be “default”.
126 * func.label_get - This function is called when an actual item object is
127 * created. The data parameter is the data parameter passed to
128 * elm_genlist_item_append() and related item creation functions. The obj
129 * parameter is the genlist object and the part parameter is the string name
130 * of the text part in the edje design that is listed as one of the possible
131 * labels that can be set. This function must return a strudup()'ed string as
132 * the caller will free() it when done.
134 * func.icon_get - This function is called when an actual item object is
135 * created. The data parameter is the data parameter passed to
136 * elm_genlist_item_append() and related item creation functions. The obj
137 * parameter is the genlist object and the part parameter is the string name
138 * of the icon part in the edje design that is listed as one of the possible
139 * icons that can be set. This must return NULL for no object or a valid
140 * object. The object will be deleted by genlist on shutdown or when the item
143 * func.state_get - This function is called when an actual item object is
144 * created. The data parameter is the data parameter passed to
145 * elm_genlist_item_append() and related item creation functions. The obj
146 * parameter is the genlist object and the part parameter is the string name
147 * of the state part in the edje design that is listed as one of the possible
148 * states that can be set. Return 0 for false or 1 for true. Genlist will
149 * emit a signal to the edje object with “elm,state,XXX,active” “elm” when
150 * true (the default is false), where XXX is the name of the part.
152 * func.del - This is called when elm_genlist_item_del() is called on an
153 * item, elm_genlist_clear() is called on the genlist, or
154 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
155 * intended for use when actual genlist items are deleted, so any backing
156 * data attached to the item (e.g. its data parameter on creation) can be
159 * Items can be added by several calls. All of them return a Elm_Genlist_Item
160 * handle that is an internal member inside the genlist. They all take a data
161 * parameter that is meant to be used for a handle to the applications
162 * internal data (eg the struct with the original item data). The parent
163 * parameter is the parent genlist item this belongs to if it is a tree, and
164 * NULL if there is no parent. The flags can be a bitmask of
165 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
166 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
167 * that is able to expand and have child items. The func parameter is a
168 * convenience callback that is called when the item is selected and the data
169 * parameter will be the func_data parameter, obj be the genlist object and
170 * vent_info will be the genlist item.
172 * elm_genlist_item_append() appends an item to the end of the list, or if
173 * there is a parent, to the end of all the child items of the parent.
174 * elm_genlist_item_prepend() is the same but prepends to the beginning of
175 * the list or children list. elm_genlist_item_insert_before() inserts at
176 * item before another item and elm_genlist_item_insert_after() inserts after
177 * the indicated item.
179 * The application can clear the list with elm_genlist_clear() which deletes
180 * all the items in the list and elm_genlist_item_del() will delete a specific
181 * item. elm_genlist_item_subitems_clear() will clear all items that are
182 * children of the indicated parent item.
184 * If the application wants multiple items to be able to be selected,
185 * elm_genlist_multi_select_set() can enable this. If the list is
186 * single-selection only (the default), then elm_genlist_selected_item_get()
187 * will return the selected item, if any, or NULL I none is selected. If the
188 * list is multi-select then elm_genlist_selected_items_get() will return a
189 * list (that is only valid as long as no items are modified (added, deleted,
190 * selected or unselected).
192 * To help inspect list items you can jump to the item at the top of the list
193 * with elm_genlist_first_item_get() which will return the item pointer, and
194 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
195 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
196 * and previous items respectively relative to the indicated item. Using
197 * these calls you can walk the entire item list/tree. Note that as a tree
198 * the items are flattened in the list, so elm_genlist_item_parent_get() will
199 * let you know which item is the parent (and thus know how to skip them if
202 * There are also convenience functions. elm_genlist_item_genlist_get() will
203 * return the genlist object the item belongs to. elm_genlist_item_show()
204 * will make the scroller scroll to show that specific item so its visible.
205 * elm_genlist_item_data_get() returns the data pointer set by the item
206 * creation functions.
208 * If an item changes (state of boolean changes, label or icons change),
209 * then use elm_genlist_item_update() to have genlist update the item with
210 * the new state. Genlist will re-realize the item thus call the functions
211 * in the _Elm_Genlist_Item_Class for that item.
213 * To programmatically (un)select an item use elm_genlist_item_selected_set().
214 * To get its selected state use elm_genlist_item_selected_get(). Similarly
215 * to expand/contract and item and get its expanded state, use
216 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
217 * again to make an item disabled (unable to be selected and appear
218 * differently) use elm_genlist_item_disabled_set() to set this and
219 * elm_genlist_item_disabled_get() to get the disabled state.
221 * In general to indicate how the genlist should expand items horizontally to
222 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
223 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
224 * mode means that if items are too wide to fit, the scroller will scroll
225 * horizontally. Otherwise items are expanded to fill the width of the
226 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
227 * to the viewport width and limited to that size. This can be combined with
228 * a different style that uses edjes' ellipsis feature (cutting text off like
231 * Items will only call their selection func and callback when first becoming
232 * selected. Any further clicks will do nothing, unless you enable always
233 * select with elm_genlist_always_select_mode_set(). This means even if
234 * selected, every click will make the selected callbacks be called.
235 * elm_genlist_no_select_mode_set() will turn off the ability to select
236 * items entirely and they will neither appear selected nor call selected
237 * callback functions.
239 * Remember that you can create new styles and add you own theme augmentation
240 * per application with elm_theme_extension_add(). If you absolutely must
241 * have a specific style that overrides any theme the user or system sets up
242 * you can use elm_theme_overlay_add() to add such a file.
245 typedef struct _Widget_Data Widget_Data;
246 typedef struct _Item_Block Item_Block;
247 typedef struct _Pan Pan;
251 Evas_Object *obj, *scr, *pan_smart;
252 Eina_Inlist *items, *blocks;
254 Evas_Coord pan_x, pan_y, minw, minh;
255 Ecore_Job *calc_job, *update_job;
256 Ecore_Idler *queue_idler;
257 Eina_List *queue, *selected;
258 Elm_Genlist_Item *show_item;
260 Eina_Bool on_hold : 1;
262 Eina_Bool always_select : 1;
263 Eina_Bool longpressed : 1;
264 Eina_Bool wasselected : 1;
265 Eina_Bool no_select : 1;
266 Eina_Bool bring_in : 1;
267 Eina_Bool compress : 1;
268 Eina_Bool homogeneous : 1;
271 int max_items_per_block;
281 Evas_Coord x, y, w, h, minw, minh;
282 Eina_Bool want_unrealize : 1;
283 Eina_Bool realized : 1;
284 Eina_Bool changed : 1;
285 Eina_Bool updateme : 1;
286 Eina_Bool showme : 1;
289 struct _Elm_Genlist_Item
295 Evas_Coord x, y, w, h, minw, minh;
296 const Elm_Genlist_Item_Class *itc;
298 Elm_Genlist_Item *parent;
299 Elm_Genlist_Item_Flags flags;
306 Evas_Object *base, *spacer;
307 Eina_List *labels, *icons, *states, *icon_objs;
308 Ecore_Timer *long_timer;
311 Elm_Genlist_Item *rel;
314 Eina_Bool before : 1;
316 Eina_Bool want_unrealize : 1;
317 Eina_Bool realized : 1;
318 Eina_Bool selected : 1;
319 Eina_Bool hilighted : 1;
320 Eina_Bool expanded : 1;
321 Eina_Bool disabled : 1;
322 Eina_Bool display_only : 1;
323 Eina_Bool mincalcd : 1;
324 Eina_Bool queued : 1;
325 Eina_Bool showme : 1;
326 Eina_Bool delete_me : 1;
328 Eina_Bool dragging : 1;
329 Eina_Bool updateme : 1;
334 Evas_Object_Smart_Clipped_Data __clipped_data;
338 static const char *widtype = NULL;
339 static void _del_hook(Evas_Object *obj);
340 static void _theme_hook(Evas_Object *obj);
341 //static void _show_region_hook(void *data, Evas_Object *obj);
342 static void _sizing_eval(Evas_Object *obj);
343 static void _item_unrealize(Elm_Genlist_Item *it);
344 static void _item_block_unrealize(Item_Block *itb);
345 static void _calc_job(void *data);
347 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
350 _del_hook(Evas_Object *obj)
352 Widget_Data *wd = elm_widget_data_get(obj);
354 if (wd->calc_job) ecore_job_del(wd->calc_job);
355 if (wd->update_job) ecore_job_del(wd->update_job);
360 _del_pre_hook(Evas_Object *obj)
362 Widget_Data *wd = elm_widget_data_get(obj);
364 evas_object_del(wd->pan_smart);
365 wd->pan_smart = NULL;
366 elm_genlist_clear(obj);
370 _theme_hook(Evas_Object *obj)
372 Widget_Data *wd = elm_widget_data_get(obj);
375 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
376 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
377 EINA_INLIST_FOREACH(wd->blocks, itb)
380 Elm_Genlist_Item *it;
382 if (itb->realized) _item_block_unrealize(itb);
383 EINA_LIST_FOREACH(itb->items, l, it)
384 it->mincalcd = EINA_FALSE;
386 itb->changed = EINA_TRUE;
388 if (wd->calc_job) ecore_job_del(wd->calc_job);
389 wd->calc_job = ecore_job_add(_calc_job, wd);
395 _show_region_hook(void *data, Evas_Object *obj)
397 Widget_Data *wd = elm_widget_data_get(data);
398 Evas_Coord x, y, w, h;
400 elm_widget_show_region_get(obj, &x, &y, &w, &h);
401 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
406 _sizing_eval(Evas_Object *obj)
408 Widget_Data *wd = elm_widget_data_get(obj);
409 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
411 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
412 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
414 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
417 Evas_Coord vmw, vmh, vw, vh;
421 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
422 if ((minw > 0) && (vw < minw)) vw = minw;
423 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
425 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
428 evas_object_size_hint_min_set(obj, minw, minh);
429 evas_object_size_hint_max_set(obj, maxw, maxh);
433 _item_hilight(Elm_Genlist_Item *it)
435 const char *selectraise;
436 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted)) return;
437 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
438 selectraise = edje_object_data_get(it->base, "selectraise");
439 if ((selectraise) && (!strcmp(selectraise, "on")))
440 evas_object_raise(it->base);
441 it->hilighted = EINA_TRUE;
445 _item_block_del(Elm_Genlist_Item *it)
448 Item_Block *itb = it->block;
450 itb->items = eina_list_remove(itb->items, it);
452 itb->changed = EINA_TRUE;
453 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
454 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
457 il = EINA_INLIST_GET(itb);
458 Item_Block *itbn = (Item_Block *)(il->next);
460 it->parent->items = eina_list_remove(it->parent->items, it);
462 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
464 if (itbn) itbn->changed = EINA_TRUE;
470 il = EINA_INLIST_GET(itb);
471 Item_Block *itbp = (Item_Block *)(il->prev);
472 Item_Block *itbn = (Item_Block *)(il->next);
473 if ((itbp) && ((itbp->count + itb->count) < 48))
475 Elm_Genlist_Item *it2;
477 EINA_LIST_FREE(itb->items, it2)
480 itbp->items = eina_list_append(itbp->items, it2);
482 itbp->changed = EINA_TRUE;
484 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
487 else if ((itbn) && ((itbn->count + itb->count) < 48))
491 Eina_List *last = eina_list_last(itb->items);
492 Elm_Genlist_Item *it2 = last->data;
495 itb->items = eina_list_remove_list(itb->items, last);
496 itbn->items = eina_list_prepend(itbn->items, it2);
498 itbn->changed = EINA_TRUE;
501 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
509 _item_del(Elm_Genlist_Item *it)
511 elm_genlist_item_subitems_clear(it);
512 if (it->wd->show_item == it) it->wd->show_item = NULL;
513 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
514 if (it->realized) _item_unrealize(it);
515 if (it->block) _item_block_del(it);
516 if ((!it->delete_me) && (it->itc->func.del))
517 it->itc->func.del(it->data, it->wd->obj);
518 it->delete_me = EINA_TRUE;
520 it->wd->queue = eina_list_remove(it->wd->queue, it);
521 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
523 it->parent->items = eina_list_remove(it->parent->items, it);
524 if (it->long_timer) ecore_timer_del(it->long_timer);
529 _item_select(Elm_Genlist_Item *it)
531 if ((it->wd->no_select) || (it->delete_me)) return;
534 if (it->wd->always_select) goto call;
537 it->selected = EINA_TRUE;
538 it->wd->selected = eina_list_append(it->wd->selected, it);
541 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
543 evas_object_smart_callback_call(it->wd->obj, "selected", it);
545 if ((it->walking == 0) && (it->delete_me))
547 if (it->relcount == 0) _item_del(it);
552 _item_unselect(Elm_Genlist_Item *it)
554 const char *stacking, *selectraise;
556 if ((it->delete_me) || (!it->hilighted)) return;
557 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
558 stacking = edje_object_data_get(it->base, "stacking");
559 selectraise = edje_object_data_get(it->base, "selectraise");
560 if ((selectraise) && (!strcmp(selectraise, "on")))
562 if ((stacking) && (!strcmp(stacking, "below")))
563 evas_object_lower(it->base);
565 it->hilighted = EINA_FALSE;
568 it->selected = EINA_FALSE;
569 it->wd->selected = eina_list_remove(it->wd->selected, it);
570 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
575 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
577 Elm_Genlist_Item *it = data;
578 Evas_Event_Mouse_Move *ev = event_info;
579 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
581 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
583 if (!it->wd->on_hold)
585 it->wd->on_hold = EINA_TRUE;
589 if ((it->dragging) && (it->down))
593 ecore_timer_del(it->long_timer);
594 it->long_timer = NULL;
596 evas_object_smart_callback_call(it->wd->obj, "drag", it);
599 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
603 ecore_timer_del(it->long_timer);
604 it->long_timer = NULL;
608 if (!it->display_only)
609 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
610 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
611 x = ev->cur.canvas.x - x;
612 y = ev->cur.canvas.y - y;
615 if (adx < 0) adx = -dx;
618 if (ady < 0) ady = -dy;
621 if ((adx > minw) || (ady > minh))
626 ecore_timer_del(it->long_timer);
627 it->long_timer = NULL;
629 if (!it->wd->wasselected)
631 it->wd->wasselected = 0;
635 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
639 evas_object_smart_callback_call(it->wd->obj,
640 "drag,start,left", it);
642 evas_object_smart_callback_call(it->wd->obj,
643 "drag,start,right", it);
649 evas_object_smart_callback_call(it->wd->obj,
650 "drag,start,down", it);
654 evas_object_smart_callback_call(it->wd->obj,
655 "drag,start,left", it);
657 evas_object_smart_callback_call(it->wd->obj,
658 "drag,start,right", it);
665 _long_press(void *data)
667 Elm_Genlist_Item *it = data;
669 it->long_timer = NULL;
670 if ((it->disabled) || (it->dragging)) return 0;
671 it->wd->longpressed = EINA_TRUE;
672 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
677 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
679 Elm_Genlist_Item *it = data;
680 Evas_Event_Mouse_Down *ev = event_info;
683 if (ev->button != 1) return;
686 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
687 it->dx = ev->canvas.x - x;
688 it->dy = ev->canvas.y - y;
689 it->wd->longpressed = EINA_FALSE;
690 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
691 else it->wd->on_hold = EINA_FALSE;
692 it->wd->wasselected = it->selected;
694 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
695 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
696 if (it->long_timer) ecore_timer_del(it->long_timer);
698 it->long_timer = ecore_timer_add(1.0, _long_press, it);
700 it->long_timer = NULL;
704 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
706 Elm_Genlist_Item *it = data;
707 Evas_Event_Mouse_Up *ev = event_info;
708 Eina_Bool dragged = EINA_FALSE;
710 if (ev->button != 1) return;
712 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
713 else it->wd->on_hold = EINA_FALSE;
716 ecore_timer_del(it->long_timer);
717 it->long_timer = NULL;
722 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
727 it->wd->longpressed = EINA_FALSE;
728 it->wd->on_hold = EINA_FALSE;
731 if (it->wd->longpressed)
733 it->wd->longpressed = EINA_FALSE;
734 if (!it->wd->wasselected)
736 it->wd->wasselected = 0;
741 if (it->want_unrealize)
744 if (it->block->want_unrealize)
745 _item_block_unrealize(it->block);
748 if ((it->disabled) || (dragged)) return;
756 else _item_unselect(it);
762 Widget_Data *wd = it->wd;
765 while (wd->selected) _item_unselect(wd->selected->data);
770 const Eina_List *l, *l_next;
771 Elm_Genlist_Item *it2;
773 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
774 if (it2 != it) _item_unselect(it2);
775 // _item_hilight(it);
784 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
786 Elm_Genlist_Item *it = data;
789 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
791 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
795 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
797 Elm_Genlist_Item *it = data;
800 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
804 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
806 Elm_Genlist_Item *it = data;
809 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
813 _item_realize(Elm_Genlist_Item *it, int in, int calc)
815 Elm_Genlist_Item *it2;
816 const char *stacking;
817 const char *treesize;
819 int depth, tsize = 20;
821 if ((it->realized) || (it->delete_me)) return;
822 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
823 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
825 evas_object_smart_member_add(it->base, it->wd->pan_smart);
826 elm_widget_sub_object_add(it->wd->obj, it->base);
828 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
829 else strncpy(buf, "item", sizeof(buf));
830 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
832 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
833 strncat(buf, "/", sizeof(buf) - strlen(buf));
834 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
836 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
837 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
838 evas_object_color_set(it->spacer, 0, 0, 0, 0);
839 elm_widget_sub_object_add(it->wd->obj, it->spacer);
840 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
841 treesize = edje_object_data_get(it->base, "treesize");
842 if (treesize) tsize = atoi(treesize);
843 evas_object_size_hint_min_set(it->spacer,
844 (depth * tsize) * _elm_config->scale, 1);
845 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
848 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
849 "elm", _signal_expand_toggle, it);
850 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
852 edje_object_signal_callback_add(it->base, "elm,action,contract",
853 "elm", _signal_contract, it);
854 stacking = edje_object_data_get(it->base, "stacking");
857 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
858 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
860 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
862 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
864 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
867 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
869 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
871 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
874 if (calc && it->wd->homogeneous && it->wd->item_width)
876 /* homogenous genlist shortcut */
879 it->w = it->minw = it->wd->item_width;
880 it->h = it->minh = it->wd->item_height;
881 it->mincalcd = EINA_TRUE;
886 if (it->itc->func.label_get)
891 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
892 EINA_LIST_FOREACH(it->labels, l, key)
894 char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
898 edje_object_part_text_set(it->base, l->data, s);
903 if (it->itc->func.icon_get)
908 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
909 EINA_LIST_FOREACH(it->icons, l, key)
911 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
915 it->icon_objs = eina_list_append(it->icon_objs, ic);
916 edje_object_part_swallow(it->base, key, ic);
917 evas_object_show(ic);
918 elm_widget_sub_object_add(it->wd->obj, ic);
922 if (it->itc->func.state_get)
927 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
928 EINA_LIST_FOREACH(it->states, l, key)
930 Eina_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
934 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
935 edje_object_signal_emit(it->base, buf, "elm");
941 Evas_Coord mw = -1, mh = -1;
943 if (!it->display_only)
944 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
945 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
946 if (!it->display_only)
947 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
948 it->w = it->minw = mw;
949 it->h = it->minh = mh;
950 it->mincalcd = EINA_TRUE;
952 if (in == 0 && it->wd->homogeneous)
954 it->wd->item_width = mw;
955 it->wd->item_height = mh;
958 if (!calc) evas_object_show(it->base);
960 it->realized = EINA_TRUE;
961 it->want_unrealize = EINA_FALSE;
965 _item_unrealize(Elm_Genlist_Item *it)
969 if (!it->realized) return;
972 ecore_timer_del(it->long_timer);
973 it->long_timer = NULL;
975 evas_object_del(it->base);
977 evas_object_del(it->spacer);
979 _elm_stringlist_free(it->labels);
981 _elm_stringlist_free(it->icons);
983 _elm_stringlist_free(it->states);
985 EINA_LIST_FREE(it->icon_objs, icon)
986 evas_object_del(icon);
989 it->realized = EINA_FALSE;
990 it->want_unrealize = EINA_FALSE;
994 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
997 Elm_Genlist_Item *it;
998 Evas_Coord minw = 0, minh = 0;
999 int showme = 0, changed = 0;
1003 EINA_LIST_FOREACH(itb->items, l, it)
1005 if (it->delete_me) continue;
1006 showme |= it->showme;
1011 if (!it->mincalcd) changed = 1;
1014 _item_realize(it, in, 1);
1015 _item_unrealize(it);
1020 _item_realize(it, in, 1);
1021 _item_unrealize(it);
1026 Eina_Bool was_realized = it->realized;
1028 _item_realize(it, in, 0);
1030 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1033 if (minw < it->minw) minw = it->minw;
1041 itb->changed = EINA_FALSE;
1042 /* force an evas norender to garbage collect deleted objects */
1043 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1048 _item_block_realize(Item_Block *itb, int in, int full)
1051 Elm_Genlist_Item *it;
1053 if (itb->realized) return;
1054 EINA_LIST_FOREACH(itb->items, l, it)
1056 if (it->delete_me) continue;
1059 Eina_Bool was_realized = it->realized;
1061 _item_realize(it, in, 0);
1063 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1067 itb->realized = EINA_TRUE;
1068 itb->want_unrealize = EINA_FALSE;
1072 _item_block_unrealize(Item_Block *itb)
1075 Elm_Genlist_Item *it;
1078 if (!itb->realized) return;
1079 EINA_LIST_FOREACH(itb->items, l, it)
1084 it->want_unrealize = EINA_TRUE;
1087 _item_unrealize(it);
1091 itb->realized = EINA_FALSE;
1092 itb->want_unrealize = EINA_TRUE;
1095 itb->want_unrealize = EINA_FALSE;
1099 _item_block_position(Item_Block *itb, int in)
1102 Elm_Genlist_Item *it;
1103 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1106 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1107 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1108 EINA_LIST_FOREACH(itb->items, l, it)
1110 if (it->delete_me) continue;
1114 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
1115 itb->y - it->wd->pan_y + oy,
1117 cvx, cvy, cvw, cvh));
1118 if ((itb->realized) && (!it->realized))
1122 Eina_Bool was_realized = it->realized;
1124 _item_realize(it, in, 0);
1126 evas_object_smart_callback_call(it->wd->obj,
1134 evas_object_resize(it->base, it->w, it->h);
1135 evas_object_move(it->base,
1136 ox + itb->x + it->x - itb->wd->pan_x,
1137 oy + itb->y + it->y - itb->wd->pan_y);
1138 evas_object_show(it->base);
1143 _item_unrealize(it);
1152 _calc_job(void *data)
1154 Widget_Data *wd = data;
1156 Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
1157 Item_Block *chb = NULL;
1158 int in = 0, minw_change = 0;
1160 EINA_INLIST_FOREACH(wd->blocks, itb)
1165 showme = itb->showme;
1169 if (itb->realized) _item_block_unrealize(itb);
1173 if (itb->realized) _item_block_unrealize(itb);
1174 showme = _item_block_recalc(itb, in, 0, 1);
1180 if (minw == -1) minw = itb->minw;
1181 else if (minw < itb->minw)
1192 wd->show_item->showme = 0;
1194 elm_smart_scroller_region_bring_in(wd->scr,
1195 wd->show_item->x + wd->show_item->block->x,
1196 wd->show_item->y + wd->show_item->block->y,
1197 wd->show_item->block->w,
1200 elm_smart_scroller_child_region_show(wd->scr,
1201 wd->show_item->x + wd->show_item->block->x,
1202 wd->show_item->y + wd->show_item->block->y,
1203 wd->show_item->block->w,
1205 wd->show_item = NULL;
1211 EINA_INLIST_FOREACH(wd->blocks, itb)
1217 if ((chb) && (EINA_INLIST_GET(chb)->next))
1219 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1220 if (itb->realized) _item_block_unrealize(itb);
1222 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1223 if (minw < ow) minw = ow;
1224 if ((minw != wd->minw) || (minh != wd->minh))
1228 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1229 _sizing_eval(wd->obj);
1231 wd->calc_job = NULL;
1232 evas_object_smart_changed(wd->pan_smart);
1236 _update_job(void *data)
1238 Widget_Data *wd = data;
1241 int num, num0, position = 0, recalc = 0;
1243 wd->update_job = NULL;
1245 EINA_INLIST_FOREACH(wd->blocks, itb)
1247 Evas_Coord itminw, itminh;
1248 Elm_Genlist_Item *it;
1254 _item_block_position(itb, num);
1259 EINA_LIST_FOREACH(itb->items, l2, it)
1269 _item_unrealize(it);
1270 _item_realize(it, num, 0);
1271 evas_object_smart_callback_call(it->wd->obj,
1276 _item_realize(it, num, 1);
1277 _item_unrealize(it);
1279 if ((it->minw != itminw) || (it->minh != itminh))
1288 itb->changed = EINA_TRUE;
1289 _item_block_recalc(itb, num0, 0, 1);
1290 _item_block_position(itb, num0);
1295 if (wd->calc_job) ecore_job_del(wd->calc_job);
1296 wd->calc_job = ecore_job_add(_calc_job, wd);
1301 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1303 Pan *sd = evas_object_smart_data_get(obj);
1304 // Evas_Coord ow, oh;
1305 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1306 // ow = sd->wd->minw - ow;
1307 // if (ow < 0) ow = 0;
1308 // oh = sd->wd->minh - oh;
1309 // if (oh < 0) oh = 0;
1310 // if (x < 0) x = 0;
1311 // if (y < 0) y = 0;
1312 // if (x > ow) x = ow;
1313 // if (y > oh) y = oh;
1314 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1317 evas_object_smart_changed(obj);
1321 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1323 Pan *sd = evas_object_smart_data_get(obj);
1325 if (x) *x = sd->wd->pan_x;
1326 if (y) *y = sd->wd->pan_y;
1330 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1332 Pan *sd = evas_object_smart_data_get(obj);
1335 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1336 ow = sd->wd->minw - ow;
1338 oh = sd->wd->minh - oh;
1345 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1347 Pan *sd = evas_object_smart_data_get(obj);
1349 if (w) *w = sd->wd->minw;
1350 if (h) *h = sd->wd->minh;
1354 _pan_add(Evas_Object *obj)
1357 Evas_Object_Smart_Clipped_Data *cd;
1360 cd = evas_object_smart_data_get(obj);
1363 sd->__clipped_data = *cd;
1365 evas_object_smart_data_set(obj, sd);
1369 _pan_del(Evas_Object *obj)
1371 Pan *sd = evas_object_smart_data_get(obj);
1378 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1380 Pan *sd = evas_object_smart_data_get(obj);
1383 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1384 if ((ow == w) && (oh == h)) return;
1385 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1386 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1390 _pan_calculate(Evas_Object *obj)
1392 Pan *sd = evas_object_smart_data_get(obj);
1394 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1397 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1398 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
1399 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
1401 itb->w = sd->wd->minw;
1402 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
1403 itb->y - sd->wd->pan_y + oy,
1405 cvx, cvy, cvw, cvh))
1407 if ((!itb->realized) || (itb->changed))
1408 _item_block_realize(itb, in, 0);
1409 _item_block_position(itb, in);
1413 if (itb->realized) _item_block_unrealize(itb);
1420 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1422 Pan *sd = evas_object_smart_data_get(obj);
1424 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1425 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1429 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1431 Widget_Data *wd = elm_widget_data_get(obj);
1433 elm_smart_scroller_hold_set(wd->scr, 1);
1437 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1439 Widget_Data *wd = elm_widget_data_get(obj);
1441 elm_smart_scroller_hold_set(wd->scr, 0);
1445 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1447 Widget_Data *wd = elm_widget_data_get(obj);
1449 elm_smart_scroller_freeze_set(wd->scr, 1);
1453 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1455 Widget_Data *wd = elm_widget_data_get(obj);
1457 elm_smart_scroller_freeze_set(wd->scr, 0);
1461 * Add a new Genlist object
1463 * @param parent The parent object
1464 * @return The new object or NULL if it cannot be created
1469 elm_genlist_add(Evas_Object *parent)
1474 Evas_Coord minw, minh;
1475 static Evas_Smart *smart = NULL;
1477 wd = ELM_NEW(Widget_Data);
1478 e = evas_object_evas_get(parent);
1479 obj = elm_widget_add(e);
1480 ELM_SET_WIDTYPE(widtype, "genlist");
1481 elm_widget_type_set(obj, "genlist");
1482 elm_widget_sub_object_add(parent, obj);
1483 elm_widget_data_set(obj, wd);
1484 elm_widget_del_hook_set(obj, _del_hook);
1485 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1486 elm_widget_theme_hook_set(obj, _theme_hook);
1488 wd->scr = elm_smart_scroller_add(e);
1489 elm_smart_scroller_widget_set(wd->scr, obj);
1490 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
1491 elm_widget_resize_object_set(obj, wd->scr);
1493 elm_smart_scroller_bounce_allow_set(wd->scr, 0, 1);
1496 wd->mode = ELM_LIST_SCROLL;
1497 wd->max_items_per_block = 32;
1499 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1500 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1501 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1502 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1506 static Evas_Smart_Class sc;
1508 evas_object_smart_clipped_smart_set(&_pan_sc);
1510 sc.name = "elm_genlist_pan";
1511 sc.version = EVAS_SMART_CLASS_VERSION;
1514 sc.resize = _pan_resize;
1515 sc.move = _pan_move;
1516 sc.calculate = _pan_calculate;
1517 smart = evas_smart_class_new(&sc);
1521 wd->pan_smart = evas_object_smart_add(e, smart);
1522 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1526 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1528 _pan_max_get, _pan_child_size_get);
1530 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
1532 evas_object_size_hint_min_set(obj, minw, minh);
1538 static Elm_Genlist_Item *
1539 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
1540 const void *data, Elm_Genlist_Item *parent,
1541 Elm_Genlist_Item_Flags flags,
1543 const void *func_data)
1545 Elm_Genlist_Item *it;
1547 it = calloc(1, sizeof(Elm_Genlist_Item));
1548 if (!it) return NULL;
1552 it->parent = parent;
1554 it->func.func = func;
1555 it->func.data = func_data;
1560 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
1562 Item_Block *itb = NULL;
1569 itb = calloc(1, sizeof(Item_Block));
1572 if (!it->rel->block)
1575 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
1576 itb->items = eina_list_append(itb->items, it);
1583 eina_inlist_prepend_relative(wd->blocks,
1584 EINA_INLIST_GET(itb),
1585 EINA_INLIST_GET(it->rel->block));
1587 eina_list_prepend_relative(itb->items, it, it->rel);
1592 eina_inlist_append_relative(wd->blocks,
1593 EINA_INLIST_GET(itb),
1594 EINA_INLIST_GET(it->rel->block));
1596 eina_list_append_relative(itb->items, it, it->rel);
1606 itb = (Item_Block *)(wd->blocks);
1607 if (itb->count >= wd->max_items_per_block)
1609 itb = calloc(1, sizeof(Item_Block));
1613 eina_inlist_prepend(wd->blocks,
1614 EINA_INLIST_GET(itb));
1619 itb = calloc(1, sizeof(Item_Block));
1623 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
1625 itb->items = eina_list_prepend(itb->items, it);
1631 itb = (Item_Block *)(wd->blocks->last);
1632 if (itb->count >= wd->max_items_per_block)
1634 itb = calloc(1, sizeof(Item_Block));
1638 eina_inlist_append(wd->blocks,
1639 EINA_INLIST_GET(itb));
1644 itb = calloc(1, sizeof(Item_Block));
1648 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
1650 itb->items = eina_list_append(itb->items, it);
1656 itb = it->rel->block;
1657 if (!itb) goto newblock;
1659 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
1661 itb->items = eina_list_append_relative(itb->items, it, it->rel);
1664 itb->changed = EINA_TRUE;
1666 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
1667 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
1670 it->rel->relcount--;
1671 if ((it->rel->delete_me) && (it->rel->relcount == 0))
1675 if (itb->count > itb->wd->max_items_per_block)
1679 Elm_Genlist_Item *it2;
1681 newc = itb->count / 2;
1682 itb2 = calloc(1, sizeof(Item_Block));
1686 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
1687 EINA_INLIST_GET(itb));
1688 itb2->changed = EINA_TRUE;
1689 while ((itb->count > newc) && (itb->items))
1693 l = eina_list_last(itb->items);
1695 itb->items = eina_list_remove_list(itb->items, l);
1698 itb2->items = eina_list_prepend(itb2->items, it2);
1706 _queue_proecess(Widget_Data *wd, int norender)
1711 t0 = ecore_time_get();
1712 for (n = 0; (wd->queue) && (n < 128); n++)
1714 Elm_Genlist_Item *it;
1716 it = wd->queue->data;
1717 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
1718 it->queued = EINA_FALSE;
1719 _item_block_add(wd, it);
1720 t = ecore_time_get();
1721 if (it->block->changed)
1723 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
1724 it->block->changed = 0;
1726 if (showme) it->block->showme = 1;
1727 if (eina_inlist_count(wd->blocks) > 1)
1729 if ((t - t0) > (ecore_animator_frametime_get())) break;
1736 _item_idler(void *data)
1738 Widget_Data *wd = data;
1740 if (_queue_proecess(wd, 1) > 0)
1742 if (wd->calc_job) ecore_job_del(wd->calc_job);
1743 wd->calc_job = ecore_job_add(_calc_job, wd);
1747 wd->queue_idler = NULL;
1754 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
1756 if (it->queued) return;
1757 it->queued = EINA_TRUE;
1758 wd->queue = eina_list_append(wd->queue, it);
1759 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
1761 if (wd->queue_idler)
1763 ecore_idler_del(wd->queue_idler);
1764 wd->queue_idler = NULL;
1766 _queue_proecess(wd, 0);
1768 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
1772 * Append item to the end of the genlist
1774 * This appends the given item to the end of the list or the end of the
1775 * children if the parent is given.
1777 * @param obj The genlist object
1778 * @param itc The item class for the item
1779 * @param data The item data
1780 * @param parent The parent item, or NULL if none
1781 * @param flags Item flags
1782 * @param func Convenience function called when item selected
1783 * @param func_data Data passed to @p func above.
1784 * @return A handle to the item added or NULL if not possible
1788 EAPI Elm_Genlist_Item *
1789 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1790 const void *data, Elm_Genlist_Item *parent,
1791 Elm_Genlist_Item_Flags flags,
1792 Evas_Smart_Cb func, const void *func_data)
1794 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1795 Widget_Data *wd = elm_widget_data_get(obj);
1796 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
1797 if (!wd) return NULL;
1798 if (!it) return NULL;
1801 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1807 Elm_Genlist_Item *it2 = NULL;
1808 Eina_List *ll = eina_list_last(it->parent->items);
1809 if (ll) it2 = ll->data;
1810 it->parent->items = eina_list_append(it->parent->items, it);
1811 if (!it2) it2 = it->parent;
1813 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1814 EINA_INLIST_GET(it2));
1816 it->rel->relcount++;
1819 _item_queue(wd, it);
1824 * Prepend item at start of the genlist
1826 * This adds an item to the beginning of the list or beginning of the children
1827 * of the parent if given.
1829 * @param obj The genlist object
1830 * @param itc The item class for the item
1831 * @param data The item data
1832 * @param parent The parent item, or NULL if none
1833 * @param flags Item flags
1834 * @param func Convenience function called when item selected
1835 * @param func_data Data passed to @p func above.
1836 * @return A handle to the item added or NULL if not possible
1840 EAPI Elm_Genlist_Item *
1841 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1842 const void *data, Elm_Genlist_Item *parent,
1843 Elm_Genlist_Item_Flags flags,
1844 Evas_Smart_Cb func, const void *func_data)
1846 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1847 Widget_Data *wd = elm_widget_data_get(obj);
1848 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
1849 if (!wd) return NULL;
1850 if (!it) return NULL;
1852 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1855 printf("FIXME: 12 tree not handled yet\n");
1859 _item_queue(wd, it);
1864 * Insert item before another in the genlist
1866 * This inserts an item before another in the list. It will be in the same tree
1867 * level as the item it is inseted before.
1869 * @param obj The genlist object
1870 * @param itc The item class for the item
1871 * @param data The item data
1872 * @param before The item to insert before
1873 * @param flags Item flags
1874 * @param func Convenience function called when item selected
1875 * @param func_data Data passed to @p func above.
1876 * @return A handle to the item added or NULL if not possible
1880 EAPI Elm_Genlist_Item *
1881 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1882 const void *data, Elm_Genlist_Item *before,
1883 Elm_Genlist_Item_Flags flags,
1884 Evas_Smart_Cb func, const void *func_data)
1886 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1887 Widget_Data *wd = elm_widget_data_get(obj);
1888 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
1889 if (!wd) return NULL;
1890 if (!it) return NULL;
1892 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1893 EINA_INLIST_GET(before));
1896 printf("FIXME: 13 tree not handled yet\n");
1899 it->rel->relcount++;
1901 _item_queue(wd, it);
1906 * Insert and item after another in the genlst
1908 * This inserts an item after another in the list. It will be in the same tree
1909 * level as the item it is inseted after.
1911 * @param obj The genlist object
1912 * @param itc The item class for the item
1913 * @param data The item data
1914 * @param after The item to insert after
1915 * @param flags Item flags
1916 * @param func Convenience function called when item selected
1917 * @param func_data Data passed to @p func above.
1918 * @return A handle to the item added or NULL if not possible
1922 EAPI Elm_Genlist_Item *
1923 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1924 const void *data, Elm_Genlist_Item *after,
1925 Elm_Genlist_Item_Flags flags,
1926 Evas_Smart_Cb func, const void *func_data)
1928 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1929 Widget_Data *wd = elm_widget_data_get(obj);
1930 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
1931 if (!wd) return NULL;
1932 if (!it) return NULL;
1934 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1935 EINA_INLIST_GET(after));
1938 printf("FIXME: 14 tree not handled yet\n");
1941 it->rel->relcount++;
1943 _item_queue(wd, it);
1950 * This clears all items in the list, leaving it empty.
1952 * @param obj The genlist object
1957 elm_genlist_clear(Evas_Object *obj)
1959 ELM_CHECK_WIDTYPE(obj, widtype);
1960 Widget_Data *wd = elm_widget_data_get(obj);
1964 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
1966 wd->items = eina_inlist_remove(wd->items, wd->items);
1967 if (it->realized) _item_unrealize(it);
1968 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
1969 if (it->long_timer) ecore_timer_del(it->long_timer);
1974 Item_Block *itb = (Item_Block *)(wd->blocks);
1976 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
1977 if (itb->items) eina_list_free(itb->items);
1982 ecore_job_del(wd->calc_job);
1983 wd->calc_job = NULL;
1985 if (wd->queue_idler)
1987 ecore_idler_del(wd->queue_idler);
1988 wd->queue_idler = NULL;
1992 eina_list_free(wd->queue);
1997 eina_list_free(wd->selected);
1998 wd->selected = NULL;
2000 wd->show_item = NULL;
2005 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2006 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2011 * Enable or disable multi-select in the genlist
2013 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
2014 * more than 1 item to be selected.
2016 * @param obj The genlist object
2017 * @param multi Multi-select enable/disable
2022 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
2024 ELM_CHECK_WIDTYPE(obj, widtype);
2025 Widget_Data *wd = elm_widget_data_get(obj);
2031 * Gets if multi-select in genlist is enable or disable
2033 * @param obj The genlist object
2034 * @return Multi-select enable/disable
2035 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
2040 elm_genlist_multi_select_get(const Evas_Object *obj)
2042 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2043 Widget_Data *wd = elm_widget_data_get(obj);
2044 if (!wd) return EINA_FALSE;
2050 * Get the selectd item in the genlist
2052 * This gets the selected item in the list (if multi-select is enabled only
2053 * the first item in the list is selected - which is not very useful, so see
2054 * elm_genlist_selected_items_get()for when multi-select is used).
2056 * If no item is selected, NULL is returned.
2058 * @param obj The genlist object
2059 * @return The selected item, or NULL if none.
2063 EAPI Elm_Genlist_Item *
2064 elm_genlist_selected_item_get(const Evas_Object *obj)
2066 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2067 Widget_Data *wd = elm_widget_data_get(obj);
2068 if (!wd) return NULL;
2069 if (wd->selected) return wd->selected->data;
2074 * Get a list of selected items in the genlist
2076 * This retgurns a list of the selected items. This list pointer is only valid
2077 * so long as no items are selected or unselected (or unselected implicitly
2078 * by deletion). The list contains Elm_Genlist_Item pointers.
2080 * @param obj The genlist object
2081 * @return The list of selected items, nor NULL if none are selected.
2085 EAPI const Eina_List *
2086 elm_genlist_selected_items_get(const Evas_Object *obj)
2088 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2089 Widget_Data *wd = elm_widget_data_get(obj);
2090 if (!wd) return NULL;
2091 return wd->selected;
2095 * Get a list of realized items in genlist
2097 * This returns a list of the realized items in the genlist. The list
2098 * contains Elm_Genlist_Item pointers. The list must be freed by the
2099 * caller when done with eina_list_free(). The item pointers in the list
2100 * are only vallid so long as those items are not deleted or the genlist is
2103 * @param obj The genlist object
2104 * @return The list of realized items, nor NULL if none are realized.
2109 elm_genlist_realized_items_get(const Evas_Object *obj)
2111 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2112 Widget_Data *wd = elm_widget_data_get(obj);
2113 Eina_List *list = NULL;
2115 Eina_Bool done = EINA_FALSE;
2116 if (!wd) return NULL;
2117 EINA_INLIST_FOREACH(wd->blocks, itb)
2122 Elm_Genlist_Item *it;
2125 EINA_LIST_FOREACH(itb->items, l, it)
2127 if (it->realized) list = eina_list_append(list, it);
2139 * Get the item that is at the x, y canvas coords
2141 * This returns the item at the given coordinates (which are canvas relative
2142 * not object-relative). If an item is at that coordinate, that item handle
2143 * is returned, and if @p posret is not NULL, the integer pointed to is set
2144 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
2145 * portion of that item (-1), on the middle section (0) or on the lower part
2146 * (1). If NULL is returned as an item (no item found there), then posret
2147 * may indicate -1 or 1 based if the coordinate is above or below all items
2148 * respectively in the genlist.
2150 * @param it The item
2151 * @param x The input x coordinate
2152 * @param y The input y coordinate
2153 * @param posret The position relative to the item returned here
2154 * @return The item at the coordinates or NULL if none
2158 EAPI Elm_Genlist_Item *
2159 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
2161 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2162 Widget_Data *wd = elm_widget_data_get(obj);
2163 Evas_Coord ox, oy, ow, oh;
2166 if (!wd) return NULL;
2167 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
2169 EINA_INLIST_FOREACH(wd->blocks, itb)
2172 Elm_Genlist_Item *it;
2174 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
2175 oy + itb->y - itb->wd->pan_y,
2176 itb->w, itb->h, x, y, 1, 1))
2178 EINA_LIST_FOREACH(itb->items, l, it)
2180 Evas_Coord itx, ity;
2182 itx = ox + itb->x + it->x - itb->wd->pan_x;
2183 ity = oy + itb->y + it->y - itb->wd->pan_y;
2184 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
2188 if (y <= (ity + (it->h / 4))) *posret = -1;
2189 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
2194 lasty = ity + it->h;
2199 if (y > lasty) *posret = 1;
2206 * Get the first item in the genlist
2208 * This returns the first item in the list.
2210 * @param obj The genlist object
2211 * @return The first item, or NULL if none
2215 EAPI Elm_Genlist_Item *
2216 elm_genlist_first_item_get(const Evas_Object *obj)
2218 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2219 Widget_Data *wd = elm_widget_data_get(obj);
2220 if (!wd) return NULL;
2221 if (!wd->items) return NULL;
2222 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2223 while ((it) && (it->delete_me))
2224 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
2229 * Get the last item in the genlist
2231 * This returns the last item in the list.
2233 * @return The last item, or NULL if none
2237 EAPI Elm_Genlist_Item *
2238 elm_genlist_last_item_get(const Evas_Object *obj)
2240 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2241 Widget_Data *wd = elm_widget_data_get(obj);
2242 if (!wd->items) return NULL;
2243 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
2244 if (!wd) return NULL;
2245 while ((it) && (it->delete_me))
2246 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
2251 * Get the next item in the genlist
2253 * This returns the item after the item @p it.
2255 * @param it The item
2256 * @return The item after @p it, or NULL if none
2260 EAPI Elm_Genlist_Item *
2261 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
2265 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
2266 if ((it) && (!it->delete_me)) break;
2268 return (Elm_Genlist_Item *)it;
2272 * Get the previous item in the genlist
2274 * This returns the item before the item @p it.
2276 * @param it The item
2277 * @return The item before @p it, or NULL if none
2281 EAPI Elm_Genlist_Item *
2282 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
2286 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
2287 if ((it) && (!it->delete_me)) break;
2289 return (Elm_Genlist_Item *)it;
2293 * Get the genlist object from an item
2295 * This returns the genlist object itself that an item belongs to.
2297 * @param it The item
2298 * @return The genlist object
2303 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
2305 if (!it) return NULL;
2310 * Get the parent item of the given item
2312 * This returns the prent item of the item @p it given.
2314 * @param it The item
2315 * @return The parent of the item or NULL if none
2319 EAPI Elm_Genlist_Item *
2320 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
2322 if (!it) return NULL;
2327 * Clear all sub-items (children) of the given item
2329 * This clears all items that are children (or their descendants) of the
2332 * @param it The item
2337 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
2339 Eina_List *tl = NULL, *l;
2340 Elm_Genlist_Item *it2;
2343 EINA_LIST_FOREACH(it->items, l, it2)
2344 tl = eina_list_append(tl, it2);
2345 EINA_LIST_FREE(tl, it2)
2346 elm_genlist_item_del(it2);
2350 * Set the selected state of an item
2352 * This sets the selected state (1 selected, 0 not selected) of the given
2355 * @param it The item
2356 * @param selected The slected state
2361 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
2363 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
2366 if (it->delete_me) return;
2367 selected = !!selected;
2368 if (it->selected == selected) return;
2374 while (wd->selected)
2375 _item_unselect(wd->selected->data);
2385 * Get the selected state of an item
2387 * This gets the selected state of an item (1 selected, 0 not selected).
2389 * @param it The item
2390 * @return The selected state
2395 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
2397 if (!it) return EINA_FALSE;
2398 return it->selected;
2402 * Sets the expanded state of an item (if it's a parent)
2404 * This expands or contracts a parent iterm (thus showing or hiding the
2407 * @param it The item
2408 * @param expanded The expanded state (1 expanded, 0 not expanded).
2413 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
2416 if (it->expanded == expanded) return;
2417 it->expanded = expanded;
2421 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
2422 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
2427 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
2428 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
2433 * Get the expanded state of an item
2435 * This gets the expanded state of an item
2437 * @param it The item
2438 * @return Thre expanded state
2443 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
2445 if (!it) return EINA_FALSE;
2446 return it->expanded;
2450 * Sets the disabled state of an item.
2452 * A disabled item cannot be selected or unselected. It will also change
2453 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
2456 * @param it The item
2457 * @param disabled The disabled state
2462 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
2465 if (it->disabled == disabled) return;
2466 if (it->delete_me) return;
2467 it->disabled = disabled;
2471 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
2473 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
2478 * Get the disabled state of an item
2480 * This gets the disabld state of the given item.
2482 * @param it The item
2483 * @return The disabled state
2488 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
2490 if (!it) return EINA_FALSE;
2491 if (it->delete_me) return EINA_FALSE;
2492 return it->disabled;
2496 * Sets the display only state of an item.
2498 * A display only item cannot be selected or unselected. It is for display
2499 * only and not selecting or otherwise clicking, dragging etc. by the user,
2500 * thus finger size rules will not be applied to this item.
2502 * @param it The item
2503 * @param display_only The display only state
2508 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
2511 if (!it->block) return;
2512 if (it->display_only == display_only) return;
2513 if (it->delete_me) return;
2514 it->display_only = display_only;
2515 it->mincalcd = EINA_FALSE;
2516 it->updateme = EINA_TRUE;
2517 it->block->updateme = EINA_TRUE;
2518 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
2519 it->wd->update_job = ecore_job_add(_update_job, it->wd);
2523 * Get the display only state of an item
2525 * This gets the display only state of the given item.
2527 * @param it The item
2528 * @return The display only state
2533 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
2535 if (!it) return EINA_FALSE;
2536 if (it->delete_me) return EINA_FALSE;
2537 return it->display_only;
2541 * Show the given item
2543 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2544 * if it is not fully visible.
2546 * @param it The item
2551 elm_genlist_item_show(Elm_Genlist_Item *it)
2554 if (it->delete_me) return;
2555 if ((it->queued) || (!it->mincalcd))
2557 it->wd->show_item = it;
2558 it->wd->bring_in = 1;
2559 it->showme = EINA_TRUE;
2562 if (it->wd->show_item)
2564 it->wd->show_item->showme = EINA_FALSE;
2565 it->wd->show_item = NULL;
2567 elm_smart_scroller_child_region_show(it->wd->scr,
2568 it->x + it->block->x,
2569 it->y + it->block->y,
2570 it->block->w, it->h);
2574 * Bring in the given item
2576 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2577 * if it is not fully visible. This may use animation to do so and take a
2580 * @param it The item
2585 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
2588 if (it->delete_me) return;
2589 if ((it->queued) || (!it->mincalcd))
2591 it->wd->show_item = it;
2592 it->wd->bring_in = 1;
2593 it->showme = EINA_TRUE;
2596 if (it->wd->show_item)
2598 it->wd->show_item->showme = EINA_FALSE;
2599 it->wd->show_item = NULL;
2601 elm_smart_scroller_region_bring_in(it->wd->scr,
2602 it->x + it->block->x,
2603 it->y + it->block->y,
2604 it->block->w, it->h);
2608 * Show the given item at the top
2610 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2611 * if it is not fully visible.
2613 * @param it The item
2618 elm_genlist_item_top_show(Elm_Genlist_Item *it)
2623 if (it->delete_me) return;
2624 if ((it->queued) || (!it->mincalcd))
2626 it->wd->show_item = it;
2627 it->wd->bring_in = 1;
2628 it->showme = EINA_TRUE;
2631 if (it->wd->show_item)
2633 it->wd->show_item->showme = EINA_FALSE;
2634 it->wd->show_item = NULL;
2636 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2637 elm_smart_scroller_child_region_show(it->wd->scr,
2638 it->x + it->block->x,
2639 it->y + it->block->y,
2644 * Bring in the given item at the top
2646 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2647 * if it is not fully visible. This may use animation to do so and take a
2650 * @param it The item
2655 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
2660 if (it->delete_me) return;
2661 if ((it->queued) || (!it->mincalcd))
2663 it->wd->show_item = it;
2664 it->wd->bring_in = 1;
2665 it->showme = EINA_TRUE;
2668 if (it->wd->show_item)
2670 it->wd->show_item->showme = EINA_FALSE;
2671 it->wd->show_item = NULL;
2673 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2674 elm_smart_scroller_region_bring_in(it->wd->scr,
2675 it->x + it->block->x,
2676 it->y + it->block->y,
2681 * Show the given item at the middle
2683 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2684 * if it is not fully visible.
2686 * @param it The item
2691 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
2696 if (it->delete_me) return;
2697 if ((it->queued) || (!it->mincalcd))
2699 it->wd->show_item = it;
2700 it->wd->bring_in = 1;
2701 it->showme = EINA_TRUE;
2704 if (it->wd->show_item)
2706 it->wd->show_item->showme = EINA_FALSE;
2707 it->wd->show_item = NULL;
2709 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2710 elm_smart_scroller_child_region_show(it->wd->scr,
2711 it->x + it->block->x,
2712 it->y + it->block->y - oh/2 + it->h/2,
2718 * Bring in the given item at the middle
2720 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2721 * if it is not fully visible. This may use animation to do so and take a
2724 * @param it The item
2729 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
2734 if (it->delete_me) return;
2735 if ((it->queued) || (!it->mincalcd))
2737 it->wd->show_item = it;
2738 it->wd->bring_in = 1;
2739 it->showme = EINA_TRUE;
2742 if (it->wd->show_item)
2744 it->wd->show_item->showme = EINA_FALSE;
2745 it->wd->show_item = NULL;
2747 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2748 elm_smart_scroller_region_bring_in(it->wd->scr,
2749 it->x + it->block->x,
2750 it->y + it->block->y - oh/2 + it->h/2,
2755 * Delete a given item
2757 * This deletes the item from genlist and calls the genlist item del class
2758 * callback defined in the item class, if it is set.
2760 * @param it The item
2765 elm_genlist_item_del(Elm_Genlist_Item *it)
2768 if ((it->relcount > 0) || (it->walking > 0))
2770 elm_genlist_item_subitems_clear(it);
2771 it->delete_me = EINA_TRUE;
2772 if (it->wd->show_item == it) it->wd->show_item = NULL;
2773 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
2776 if (it->realized) _item_unrealize(it);
2777 it->block->changed = EINA_TRUE;
2778 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
2779 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
2781 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2788 * Set the data item from the genlist item
2790 * This set the data value passed on the elm_genlist_item_append() and
2791 * related item addition calls. This function will also call
2792 * elm_genlist_item_update() so the item will be updated to reflect the
2795 * @param it The item
2796 * @param data The new data pointer to set
2801 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
2805 elm_genlist_item_update(it);
2809 * Get the data item from the genlist item
2811 * This returns the data value passed on the elm_genlist_item_append() and
2812 * related item addition calls.
2814 * @param it The item
2815 * @return The data pointer provided when created
2820 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
2822 if (!it) return NULL;
2827 * Get the real evas object of the genlist item
2829 * This returns the actual evas object used for the specified genlist item.
2830 * This may be NULL as it may not be created, and ma be deleted at any time
2831 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
2832 * genlist is controlling it. This function is for querying, emitting
2833 * custom signals or hooking lower level callbacks for events. Do not
2834 * delete this object under any circumstances.
2836 * @param it The item
2837 * @return The objct pointer
2841 EAPI const Evas_Object *
2842 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
2844 if (!it) return NULL;
2849 * Update the contents of an item
2851 * This updates an item by calling all the item class functions again to get
2852 * the icons, labels and states. Use this when he original item data has
2853 * changed and the changes are desired to be reflected.
2855 * @param it The item
2860 elm_genlist_item_update(Elm_Genlist_Item *it)
2862 if (!it->block) return;
2863 if (it->delete_me) return;
2864 it->mincalcd = EINA_FALSE;
2865 it->updateme = EINA_TRUE;
2866 it->block->updateme = EINA_TRUE;
2867 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
2868 it->wd->update_job = ecore_job_add(_update_job, it->wd);
2872 * This sets the horizontal stretching mode
2874 * This sets the mode used for sizing items horizontally. Valid modes are
2875 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
2876 * mode means that if items are too wide to fit, the scroller will scroll
2877 * horizontally. Otherwise items are expanded to fill the width of the
2878 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
2879 * to the viewport width and limited to that size.
2881 * @param obj The genlist object
2882 * @param mode The mode to use
2887 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
2889 ELM_CHECK_WIDTYPE(obj, widtype);
2890 Widget_Data *wd = elm_widget_data_get(obj);
2892 if (wd->mode == mode) return;
2898 * Gets the horizontal stretching mode
2900 * @param obj The genlist object
2901 * @return The mode to use
2902 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
2907 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
2909 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
2910 Widget_Data *wd = elm_widget_data_get(obj);
2911 if (!wd) return ELM_LIST_LAST;
2916 * Set the always select mode.
2918 * Items will only call their selection func and callback when first becoming
2919 * selected. Any further clicks will do nothing, unless you enable always
2920 * select with elm_genlist_always_select_mode_set(). This means even if
2921 * selected, every click will make the selected callbacks be called.
2923 * @param obj The genlist object
2924 * @param always_select The always select mode
2925 * (EINA_TRUE = on, EINA_FALSE = off)
2930 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
2932 ELM_CHECK_WIDTYPE(obj, widtype);
2933 Widget_Data *wd = elm_widget_data_get(obj);
2935 wd->always_select = always_select;
2939 * Get the always select mode.
2941 * @param obj The genlist object
2942 * @return The always select mode
2943 * (EINA_TRUE = on, EINA_FALSE = off)
2948 elm_genlist_always_select_mode_get(const Evas_Object *obj)
2950 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2951 Widget_Data *wd = elm_widget_data_get(obj);
2952 if (!wd) return EINA_FALSE;
2953 return wd->always_select;
2957 * Set no select mode
2959 * This will turn off the ability to select items entirely and they will
2960 * neither appear selected nor call selected callback functions.
2962 * @param obj The genlist object
2963 * @param no_select The no select mode
2964 * (EINA_TRUE = on, EINA_FALSE = off)
2969 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
2971 ELM_CHECK_WIDTYPE(obj, widtype);
2972 Widget_Data *wd = elm_widget_data_get(obj);
2974 wd->no_select = no_select;
2978 * Gets no select mode
2980 * @param obj The genlist object
2981 * @return The no select mode
2982 * (EINA_TRUE = on, EINA_FALSE = off)
2987 elm_genlist_no_select_mode_get(const Evas_Object *obj)
2989 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2990 Widget_Data *wd = elm_widget_data_get(obj);
2991 if (!wd) return EINA_FALSE;
2992 return wd->no_select;
2998 * This will enable the compress mode where items are "compressed" horizontally
2999 * to fit the genlist scrollable viewport width.
3001 * @param obj The genlist object
3002 * @param no_select The compress mode
3003 * (EINA_TRUE = on, EINA_FALSE = off)
3008 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
3010 ELM_CHECK_WIDTYPE(obj, widtype);
3011 Widget_Data *wd = elm_widget_data_get(obj);
3013 wd->compress = compress;
3017 * Get the compress mode
3019 * @param obj The genlist object
3020 * @return The compress mode
3021 * (EINA_TRUE = on, EINA_FALSE = off)
3026 elm_genlist_compress_mode_get(const Evas_Object *obj)
3028 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3029 Widget_Data *wd = elm_widget_data_get(obj);
3030 if (!wd) return EINA_FALSE;
3031 return wd->compress;
3037 * This will enable or disable the scroller bounce mode for the genlist. See
3038 * elm_scroller_bounce_set() for details
3040 * @param obj The genlist object
3041 * @param h_bounce Allow bounce horizontally
3042 * @param v_bounce Allow bounce vertically
3047 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3049 ELM_CHECK_WIDTYPE(obj, widtype);
3050 Widget_Data *wd = elm_widget_data_get(obj);
3052 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3056 * Get the bounce mode
3058 * @param obj The genlist object
3059 * @param h_bounce Allow bounce horizontally
3060 * @param v_bounce Allow bounce vertically
3065 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3067 ELM_CHECK_WIDTYPE(obj, widtype);
3068 Widget_Data *wd = elm_widget_data_get(obj);
3070 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
3074 * Set homogenous mode
3076 * This will enable the homogeneous mode where items are of the same height and width
3077 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
3079 * @param obj The genlist object
3080 * @param homogeneous Assume the items within the genlist are of the same height and width
3081 * (EINA_TRUE = on, EINA_FALSE = off)
3086 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
3088 ELM_CHECK_WIDTYPE(obj, widtype);
3089 Widget_Data *wd = elm_widget_data_get(obj);
3091 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
3092 wd->homogeneous = homogeneous;
3096 * Get the homogenous mode
3098 * @param obj The genlist object
3099 * @return Assume the items within the genlist are of the same height and width
3100 * (EINA_TRUE = on, EINA_FALSE = off)
3105 elm_genlist_homogeneous_get(const Evas_Object *obj)
3107 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3108 Widget_Data *wd = elm_widget_data_get(obj);
3109 if (!wd) return EINA_FALSE;
3110 return wd->homogeneous;
3114 * Set the maximum number of items within an item block
3116 * This will configure the block count to tune to the target with particular performance matrix.
3118 * @param obj The genlist object
3119 * @param n Maximum number of items within an item block
3124 elm_genlist_block_count_set(Evas_Object *obj, int n)
3126 ELM_CHECK_WIDTYPE(obj, widtype);
3127 Widget_Data *wd = elm_widget_data_get(obj);
3129 wd->max_items_per_block = n;
3133 * Get the maximum number of items within an item block
3135 * @param obj The genlist object
3136 * @return Maximum number of items within an item block
3141 elm_genlist_block_count_get(const Evas_Object *obj)
3143 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3144 Widget_Data *wd = elm_widget_data_get(obj);
3146 return wd->max_items_per_block;