1 #include <Elementary.h>
5 * @defgroup Genlist Genlist
7 * The aim was to have more expansive list that the simple list in
8 * Elementary that could have more flexible items and allow many more entries
9 * while still being fast and low on memory usage. At the same time it was
10 * also made to be able to do tree structures. But the price to pay is more
11 * complexity when it comes to usage. If all you want is a simple list with
12 * icons and a single label, use the normal List object.
14 * Signals that you can add callbacks for are:
16 * clicked - This is called when a user has double-clicked an item. The
17 * event_info parameter is the genlist item that was double-clicked.
19 * selected - This is called when a user has made an item selected. The
20 * event_info parameter is the genlist item that was selected.
22 * unselected - This is called when a user has made an item unselected. The
23 * event_info parameter is the genlist item that was unselected.
25 * expanded - This is called when elm_genlist_item_expanded_set() is called
26 * and the item is now meant to be expanded. The event_info parameter is the
27 * genlist item that was indicated to expand. It is the job of this callback
28 * to then fill in the child items.
30 * contracted - This is called when elm_genlist_item_expanded_set() is called
31 * and the item is now meant to be contracted. The event_info parameter is
32 * the genlist item that was indicated to contract. It is the job of this
33 * callback to then delete the child items
35 * expand,request - This is called when a user has indicated they want to
36 * expand a tree branch item. The callback should decide if the item can
37 * expand (has any children) and then call elm_genlist_item_expanded_set()
38 * appropriately to set the state. The event_info parameter is the genlist
39 * item that was indicated to expand.
41 * contract,request - This is called when a user has indicated they want to
42 * contract a tree branch item. The callback should decide if the item can
43 * contract (has any children) and then call elm_genlist_item_expanded_set()
44 * appropriately to set the state. The event_info parameter is the genlist
45 * item that was indicated to contract.
47 * realized - This is called when the item in the list is created as a real
48 * evas object. event_info parameter is the genlist item that was created.
49 * The object may be deleted at any time, so it is up to the caller to
50 * not use the object pointer from elm_genlist_item_object_get() in a way
51 * where it may point to freed objects.
53 * drag,start,up - This is called when the item in the list has been dragged
56 * drag,start,down - This is called when the item in the list has been dragged
57 * (not scrolled) down.
59 * drag,start,left - This is called when the item in the list has been dragged
60 * (not scrolled) left.
62 * drag,start,right - This is called when the item in the list has been dragged
63 * (not scrolled) right.
65 * drag,stop - This is called when the item in the list has stopped being
68 * drag - This is called when the item in the list is being dragged.
70 * Genlist has a fairly large API, mostly because it's relatively complex,
71 * trying to be both expansive, powerful and efficient. First we will begin
72 * an overview o the theory behind genlist.
74 * Evas tracks every object you create. Every time it processes an event
75 * (mouse move, down, up etc.) it needs to walk through objects and find out
76 * what event that affects. Even worse every time it renders display updates,
77 * in order to just calculate what to re-draw, it needs to walk through many
78 * many many objects. Thus, the more objects you keep active, the more
79 * overhead Evas has in just doing its work. It is advisable to keep your
80 * active objects to the minimum working set you need. Also remember that
81 * object creation and deletion carries an overhead, so there is a
82 * middle-ground, which is not easily determined. But don't keep massive lists
83 * of objects you can't see or use. Genlist does this with list objects. It
84 * creates and destroys them dynamically as you scroll around. It groups them
85 * into blocks so it can determine the visibility etc. of a whole block at
86 * once as opposed to having to walk the whole list. This 2-level list allows
87 * for very large numbers of items to be in the list (tests have used up to
88 * 2,000,000 items). Also genlist employs a queue for adding items. As items
89 * may be different sizes, every item added needs to be calculated as to its
90 * size and thus this presents a lot of overhead on populating the list, this
91 * genlist employs a queue. Any item added is queued and spooled off over
92 * time, actually appearing some time later, so if your list has many members
93 * you may find it takes a while for them to all appear, with your process
94 * consuming a lot of CPU while it is busy spooling.
96 * Genlist also implements a tree structure, but it does so with callbacks to
97 * the application, with the application filling in tree structures when
98 * requested (allowing for efficient building of a very deep tree that could
99 * even be used for file-management). See the above smart signal callbacks for
102 * An item in the genlist world can have 0 or more text labels (they can be
103 * regular text or textblock – that's up to the style to determine), 0 or
104 * more icons (which are simply objects swallowed into the genlist item) and
105 * 0 or more boolean states that can be used for check, radio or other
106 * indicators by the edje theme style. An item may be one of several styles
107 * (Elementary provides 2 by default - “default” and “double_label”, but this
108 * can be extended by system or application custom themes/overlays/extensions).
110 * In order to implement the ability to add and delete items on the fly,
111 * Genlist implements a class/callback system where the application provides
112 * a structure with information about that type of item (genlist may contain
113 * multiple different items with different classes, states and styles).
114 * Genlist will call the functions in this struct (methods) when an item is
115 * “realized” (that is created dynamically while scrolling). All objects will
116 * simply be deleted when no longer needed with evas_object_del(). The
117 * Elm_Genlist_Item_Class structure contains the following members:
119 * item_style - This is a constant string and simply defines the name of the
120 * item style. It must be specified and the default should be “default”.
122 * func.label_get - This function is called when an actual item object is
123 * created. The data parameter is the data parameter passed to
124 * elm_genlist_item_append() and related item creation functions. The obj
125 * parameter is the genlist object and the part parameter is the string name
126 * of the text part in the edje design that is listed as one of the possible
127 * labels that can be set. This function must return a strudup()'ed string as
128 * the caller will free() it when done.
130 * func.icon_get - This function is called when an actual item object is
131 * created. The data parameter is the data parameter passed to
132 * elm_genlist_item_append() and related item creation functions. The obj
133 * parameter is the genlist object and the part parameter is the string name
134 * of the icon part in the edje design that is listed as one of the possible
135 * icons that can be set. This must return NULL for no object or a valid
136 * object. The object will be deleted by genlist on shutdown or when the item
139 * func.state_get - This function is called when an actual item object is
140 * created. The data parameter is the data parameter passed to
141 * elm_genlist_item_append() and related item creation functions. The obj
142 * parameter is the genlist object and the part parameter is the string name
143 * of the state part in the edje design that is listed as one of the possible
144 * states that can be set. Return 0 for false or 1 for true. Genlist will
145 * emit a signal to the edje object with “elm,state,XXX,active” “elm” when
146 * true (the default is false), where XXX is the name of the part.
148 * func.del - This is called when elm_genlist_item_del() is called on an
149 * item, elm_genlist_clear() is called on the genlist, or
150 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
151 * intended for use when actual genlist items are deleted, so any backing
152 * data attached to the item (e.g. its data parameter on creation) can be
155 * Items can be added by several calls. All of them return a Elm_Genlist_Item
156 * handle that is an internal member inside the genlist. They all take a data
157 * parameter that is meant to be used for a handle to the applications
158 * internal data (eg the struct with the original item data). The parent
159 * parameter is the parent genlist item this belongs to if it is a tree, and
160 * NULL if there is no parent. The flags can be a bitmask of
161 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
162 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
163 * that is able to expand and have child items. The func parameter is a
164 * convenience callback that is called when the item is selected and the data
165 * parameter will be the func_data parameter, obj be the genlist object and
166 * vent_info will be the genlist item.
168 * elm_genlist_item_append() appends an item to the end of the list, or if
169 * there is a parent, to the end of all the child items of the parent.
170 * elm_genlist_item_prepend() is the same but prepends to the beginning of
171 * the list or children list. elm_genlist_item_insert_before() inserts at
172 * item before another item and elm_genlist_item_insert_after() inserts after
173 * the indicated item.
175 * The application can clear the list with elm_genlist_clear() which deletes
176 * all the items in the list and elm_genlist_item_del() will delete a specific
177 * item. elm_genlist_item_subitems_clear() will clear all items that are
178 * children of the indicated parent item.
180 * If the application wants multiple items to be able to be selected,
181 * elm_genlist_multi_select_set() can enable this. If the list is
182 * single-selection only (the default), then elm_genlist_selected_item_get()
183 * will return the selected item, if any, or NULL I none is selected. If the
184 * list is multi-select then elm_genlist_selected_items_get() will return a
185 * list (that is only valid as long as no items are modified (added, deleted,
186 * selected or unselected).
188 * To help inspect list items you can jump to the item at the top of the list
189 * with elm_genlist_first_item_get() which will return the item pointer, and
190 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
191 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
192 * and previous items respectively relative to the indicated item. Using
193 * these calls you can walk the entire item list/tree. Note that as a tree
194 * the items are flattened in the list, so elm_genlist_item_parent_get() will
195 * let you know which item is the parent (and thus know how to skip them if
198 * There are also convenience functions. elm_genlist_item_genlist_get() will
199 * return the genlist object the item belongs to. elm_genlist_item_show()
200 * will make the scroller scroll to show that specific item so its visible.
201 * elm_genlist_item_data_get() returns the data pointer set by the item
202 * creation functions.
204 * If an item changes (state of boolean changes, label or icons change),
205 * then use elm_genlist_item_update() to have genlist update the item with
206 * the new state. Genlist will re-realize the item thus call the functions
207 * in the _Elm_Genlist_Item_Class for that item.
209 * To programmatically (un)select an item use elm_genlist_item_selected_set().
210 * To get its selected state use elm_genlist_item_selected_get(). Similarly
211 * to expand/contract and item and get its expanded state, use
212 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
213 * again to make an item disabled (unable to be selected and appear
214 * differently) use elm_genlist_item_disabled_set() to set this and
215 * elm_genlist_item_disabled_get() to get the disabled state.
217 * In general to indicate how the genlist should expand items horizontally to
218 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
219 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
220 * mode means that if items are too wide to fit, the scroller will scroll
221 * horizontally. Otherwise items are expanded to fill the width of the
222 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
223 * to the viewport width and limited to that size. This can be combined with
224 * a different style that uses edjes' ellipsis feature (cutting text off like
227 * Items will only call their selection func and callback when first becoming
228 * selected. Any further clicks will do nothing, unless you enable always
229 * select with elm_genlist_always_select_mode_set(). This means even if
230 * selected, every click will make the selected callbacks be called.
231 * elm_genlist_no_select_mode_set() will turn off the ability to select
232 * items entirely and they will neither appear selected nor call selected
233 * callback functions.
235 * Remember that you can create new styles and add you own theme augmentation
236 * per application with elm_theme_extension_add(). If you absolutely must
237 * have a specific style that overrides any theme the user or system sets up
238 * you can use elm_theme_overlay_add() to add such a file.
241 typedef struct _Widget_Data Widget_Data;
242 typedef struct _Item_Block Item_Block;
243 typedef struct _Pan Pan;
247 Evas_Object *obj, *scr, *pan_smart;
248 Eina_Inlist *items, *blocks;
250 Evas_Coord pan_x, pan_y, minw, minh;
251 Ecore_Job *calc_job, *update_job;
252 Ecore_Idler *queue_idler;
253 Eina_List *queue, *selected;
254 Elm_Genlist_Item *show_item;
256 Eina_Bool on_hold : 1;
258 Eina_Bool always_select : 1;
259 Eina_Bool longpressed : 1;
260 Eina_Bool wasselected : 1;
261 Eina_Bool no_select : 1;
262 Eina_Bool bring_in : 1;
263 Eina_Bool compress : 1;
264 Eina_Bool homogeneous : 1;
265 Eina_Bool clear_me : 1;
269 int max_items_per_block;
270 double longpress_timeout;
280 Evas_Coord x, y, w, h, minw, minh;
281 Eina_Bool want_unrealize : 1;
282 Eina_Bool realized : 1;
283 Eina_Bool changed : 1;
284 Eina_Bool updateme : 1;
285 Eina_Bool showme : 1;
288 struct _Elm_Genlist_Item
294 Evas_Coord x, y, w, h, minw, minh;
295 const Elm_Genlist_Item_Class *itc;
297 Elm_Genlist_Item *parent;
298 Elm_Genlist_Item_Flags flags;
305 Evas_Object *base, *spacer;
306 Eina_List *labels, *icons, *states, *icon_objs;
307 Ecore_Timer *long_timer;
310 Elm_Genlist_Item *rel;
313 Eina_Bool before : 1;
315 Eina_Bool want_unrealize : 1;
316 Eina_Bool realized : 1;
317 Eina_Bool selected : 1;
318 Eina_Bool hilighted : 1;
319 Eina_Bool expanded : 1;
320 Eina_Bool disabled : 1;
321 Eina_Bool display_only : 1;
322 Eina_Bool mincalcd : 1;
323 Eina_Bool queued : 1;
324 Eina_Bool showme : 1;
325 Eina_Bool delete_me : 1;
327 Eina_Bool dragging : 1;
328 Eina_Bool updateme : 1;
333 Evas_Object_Smart_Clipped_Data __clipped_data;
337 static const char *widtype = NULL;
338 static void _del_hook(Evas_Object *obj);
339 static void _theme_hook(Evas_Object *obj);
340 //static void _show_region_hook(void *data, Evas_Object *obj);
341 static void _sizing_eval(Evas_Object *obj);
342 static void _item_unrealize(Elm_Genlist_Item *it);
343 static void _item_block_unrealize(Item_Block *itb);
344 static void _calc_job(void *data);
346 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
349 _del_hook(Evas_Object *obj)
351 Widget_Data *wd = elm_widget_data_get(obj);
353 if (wd->calc_job) ecore_job_del(wd->calc_job);
354 if (wd->update_job) ecore_job_del(wd->update_job);
359 _del_pre_hook(Evas_Object *obj)
361 Widget_Data *wd = elm_widget_data_get(obj);
363 evas_object_del(wd->pan_smart);
364 wd->pan_smart = NULL;
365 elm_genlist_clear(obj);
369 _theme_hook(Evas_Object *obj)
371 Widget_Data *wd = elm_widget_data_get(obj);
374 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
375 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
376 EINA_INLIST_FOREACH(wd->blocks, itb)
379 Elm_Genlist_Item *it;
381 if (itb->realized) _item_block_unrealize(itb);
382 EINA_LIST_FOREACH(itb->items, l, it)
383 it->mincalcd = EINA_FALSE;
385 itb->changed = EINA_TRUE;
387 if (wd->calc_job) ecore_job_del(wd->calc_job);
388 wd->calc_job = ecore_job_add(_calc_job, wd);
394 _show_region_hook(void *data, Evas_Object *obj)
396 Widget_Data *wd = elm_widget_data_get(data);
397 Evas_Coord x, y, w, h;
399 elm_widget_show_region_get(obj, &x, &y, &w, &h);
400 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
405 _sizing_eval(Evas_Object *obj)
407 Widget_Data *wd = elm_widget_data_get(obj);
408 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
410 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
411 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
413 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
416 Evas_Coord vmw, vmh, vw, vh;
420 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
421 if ((minw > 0) && (vw < minw)) vw = minw;
422 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
424 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
427 evas_object_size_hint_min_set(obj, minw, minh);
428 evas_object_size_hint_max_set(obj, maxw, maxh);
432 _item_hilight(Elm_Genlist_Item *it)
434 const char *selectraise;
435 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted)) return;
436 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
437 selectraise = edje_object_data_get(it->base, "selectraise");
438 if ((selectraise) && (!strcmp(selectraise, "on")))
439 evas_object_raise(it->base);
440 it->hilighted = EINA_TRUE;
444 _item_block_del(Elm_Genlist_Item *it)
447 Item_Block *itb = it->block;
449 itb->items = eina_list_remove(itb->items, it);
451 itb->changed = EINA_TRUE;
452 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
453 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
456 il = EINA_INLIST_GET(itb);
457 Item_Block *itbn = (Item_Block *)(il->next);
459 it->parent->items = eina_list_remove(it->parent->items, it);
461 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
463 if (itbn) itbn->changed = EINA_TRUE;
469 il = EINA_INLIST_GET(itb);
470 Item_Block *itbp = (Item_Block *)(il->prev);
471 Item_Block *itbn = (Item_Block *)(il->next);
472 if ((itbp) && ((itbp->count + itb->count) < 48))
474 Elm_Genlist_Item *it2;
476 EINA_LIST_FREE(itb->items, it2)
479 itbp->items = eina_list_append(itbp->items, it2);
481 itbp->changed = EINA_TRUE;
483 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
486 else if ((itbn) && ((itbn->count + itb->count) < 48))
490 Eina_List *last = eina_list_last(itb->items);
491 Elm_Genlist_Item *it2 = last->data;
494 itb->items = eina_list_remove_list(itb->items, last);
495 itbn->items = eina_list_prepend(itbn->items, it2);
497 itbn->changed = EINA_TRUE;
500 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
508 _item_del(Elm_Genlist_Item *it)
510 elm_genlist_item_subitems_clear(it);
511 it->wd->walking -= it->walking;
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);
542 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
544 evas_object_smart_callback_call(it->wd->obj, "selected", it);
547 if ((it->wd->clear_me) && (it->wd->walking == 0))
548 elm_genlist_clear(it->wd->obj);
551 if ((it->walking == 0) && (it->delete_me))
553 if (it->relcount == 0) _item_del(it);
559 _item_unselect(Elm_Genlist_Item *it)
561 const char *stacking, *selectraise;
563 if ((it->delete_me) || (!it->hilighted)) return;
564 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
565 stacking = edje_object_data_get(it->base, "stacking");
566 selectraise = edje_object_data_get(it->base, "selectraise");
567 if ((selectraise) && (!strcmp(selectraise, "on")))
569 if ((stacking) && (!strcmp(stacking, "below")))
570 evas_object_lower(it->base);
572 it->hilighted = EINA_FALSE;
575 it->selected = EINA_FALSE;
576 it->wd->selected = eina_list_remove(it->wd->selected, it);
577 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
582 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
584 Elm_Genlist_Item *it = data;
585 Evas_Event_Mouse_Move *ev = event_info;
586 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
588 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
590 if (!it->wd->on_hold)
592 it->wd->on_hold = EINA_TRUE;
593 if (!it->wd->wasselected)
597 if ((it->dragging) && (it->down))
601 ecore_timer_del(it->long_timer);
602 it->long_timer = NULL;
604 evas_object_smart_callback_call(it->wd->obj, "drag", it);
607 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
611 ecore_timer_del(it->long_timer);
612 it->long_timer = NULL;
616 if (!it->display_only)
617 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
618 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
619 x = ev->cur.canvas.x - x;
620 y = ev->cur.canvas.y - y;
623 if (adx < 0) adx = -dx;
626 if (ady < 0) ady = -dy;
629 if ((adx > minw) || (ady > minh))
634 ecore_timer_del(it->long_timer);
635 it->long_timer = NULL;
637 if (!it->wd->wasselected)
642 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
646 evas_object_smart_callback_call(it->wd->obj,
647 "drag,start,left", it);
649 evas_object_smart_callback_call(it->wd->obj,
650 "drag,start,right", it);
656 evas_object_smart_callback_call(it->wd->obj,
657 "drag,start,down", it);
661 evas_object_smart_callback_call(it->wd->obj,
662 "drag,start,left", it);
664 evas_object_smart_callback_call(it->wd->obj,
665 "drag,start,right", it);
672 _long_press(void *data)
674 Elm_Genlist_Item *it = data;
676 it->long_timer = NULL;
677 if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
678 it->wd->longpressed = EINA_TRUE;
679 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
680 return ECORE_CALLBACK_CANCEL;
684 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
686 Elm_Genlist_Item *it = data;
687 Evas_Event_Mouse_Down *ev = event_info;
690 if (ev->button != 1) return;
694 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
695 it->dx = ev->canvas.x - x;
696 it->dy = ev->canvas.y - y;
697 it->wd->longpressed = EINA_FALSE;
698 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
699 else it->wd->on_hold = EINA_FALSE;
700 it->wd->wasselected = it->selected;
702 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
703 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
704 if (it->long_timer) ecore_timer_del(it->long_timer);
706 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it);
708 it->long_timer = NULL;
712 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
714 Elm_Genlist_Item *it = data;
715 Evas_Event_Mouse_Up *ev = event_info;
716 Eina_Bool dragged = EINA_FALSE;
718 if (ev->button != 1) return;
720 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
721 else it->wd->on_hold = EINA_FALSE;
724 ecore_timer_del(it->long_timer);
725 it->long_timer = NULL;
730 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
735 it->wd->longpressed = EINA_FALSE;
736 it->wd->on_hold = EINA_FALSE;
739 if (it->wd->longpressed)
741 it->wd->longpressed = EINA_FALSE;
742 if (!it->wd->wasselected)
744 it->wd->wasselected = 0;
749 if (it->want_unrealize)
752 if (it->block->want_unrealize)
753 _item_block_unrealize(it->block);
756 if ((it->disabled) || (dragged)) return;
764 else _item_unselect(it);
770 Widget_Data *wd = it->wd;
773 while (wd->selected) _item_unselect(wd->selected->data);
778 const Eina_List *l, *l_next;
779 Elm_Genlist_Item *it2;
781 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
782 if (it2 != it) _item_unselect(it2);
783 // _item_hilight(it);
792 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
794 Elm_Genlist_Item *it = data;
797 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
799 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
803 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
805 Elm_Genlist_Item *it = data;
808 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
812 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
814 Elm_Genlist_Item *it = data;
817 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
821 _item_realize(Elm_Genlist_Item *it, int in, int calc)
823 Elm_Genlist_Item *it2;
824 const char *stacking;
825 const char *treesize;
827 int depth, tsize = 20;
829 if ((it->realized) || (it->delete_me)) return;
830 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
831 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
833 evas_object_smart_member_add(it->base, it->wd->pan_smart);
834 elm_widget_sub_object_add(it->wd->obj, it->base);
836 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
837 else strncpy(buf, "item", sizeof(buf));
838 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
840 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
841 strncat(buf, "/", sizeof(buf) - strlen(buf));
842 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
844 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
845 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
846 evas_object_color_set(it->spacer, 0, 0, 0, 0);
847 elm_widget_sub_object_add(it->wd->obj, it->spacer);
848 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
849 treesize = edje_object_data_get(it->base, "treesize");
850 if (treesize) tsize = atoi(treesize);
851 evas_object_size_hint_min_set(it->spacer,
852 (depth * tsize) * _elm_config->scale, 1);
853 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
856 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
857 "elm", _signal_expand_toggle, it);
858 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
860 edje_object_signal_callback_add(it->base, "elm,action,contract",
861 "elm", _signal_contract, it);
862 stacking = edje_object_data_get(it->base, "stacking");
865 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
866 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
868 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
870 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
872 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
875 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
877 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
879 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
882 if (calc && it->wd->homogeneous && it->wd->item_width)
884 /* homogenous genlist shortcut */
887 it->w = it->minw = it->wd->item_width;
888 it->h = it->minh = it->wd->item_height;
889 it->mincalcd = EINA_TRUE;
894 if (it->itc->func.label_get)
899 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
900 EINA_LIST_FOREACH(it->labels, l, key)
902 char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
906 edje_object_part_text_set(it->base, l->data, s);
911 if (it->itc->func.icon_get)
916 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
917 EINA_LIST_FOREACH(it->icons, l, key)
919 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
923 it->icon_objs = eina_list_append(it->icon_objs, ic);
924 edje_object_part_swallow(it->base, key, ic);
925 evas_object_show(ic);
926 elm_widget_sub_object_add(it->wd->obj, ic);
930 if (it->itc->func.state_get)
935 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
936 EINA_LIST_FOREACH(it->states, l, key)
938 Eina_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
942 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
943 edje_object_signal_emit(it->base, buf, "elm");
949 Evas_Coord mw = -1, mh = -1;
951 if (!it->display_only)
952 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
953 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
954 if (!it->display_only)
955 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
956 it->w = it->minw = mw;
957 it->h = it->minh = mh;
958 it->mincalcd = EINA_TRUE;
960 if (in == 0 && it->wd->homogeneous)
962 it->wd->item_width = mw;
963 it->wd->item_height = mh;
966 if (!calc) evas_object_show(it->base);
968 it->realized = EINA_TRUE;
969 it->want_unrealize = EINA_FALSE;
973 _item_unrealize(Elm_Genlist_Item *it)
977 if (!it->realized) return;
980 ecore_timer_del(it->long_timer);
981 it->long_timer = NULL;
983 evas_object_del(it->base);
985 evas_object_del(it->spacer);
987 _elm_stringlist_free(it->labels);
989 _elm_stringlist_free(it->icons);
991 _elm_stringlist_free(it->states);
993 EINA_LIST_FREE(it->icon_objs, icon)
994 evas_object_del(icon);
997 it->realized = EINA_FALSE;
998 it->want_unrealize = EINA_FALSE;
1002 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1005 Elm_Genlist_Item *it;
1006 Evas_Coord minw = 0, minh = 0;
1007 int showme = 0, changed = 0;
1011 EINA_LIST_FOREACH(itb->items, l, it)
1013 if (it->delete_me) continue;
1014 showme |= it->showme;
1019 if (!it->mincalcd) changed = 1;
1022 _item_realize(it, in, 1);
1023 _item_unrealize(it);
1028 _item_realize(it, in, 1);
1029 _item_unrealize(it);
1034 Eina_Bool was_realized = it->realized;
1036 _item_realize(it, in, 0);
1038 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1041 if (minw < it->minw) minw = it->minw;
1049 itb->changed = EINA_FALSE;
1050 /* force an evas norender to garbage collect deleted objects */
1051 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1056 _item_block_realize(Item_Block *itb, int in, int full)
1059 Elm_Genlist_Item *it;
1061 if (itb->realized) return;
1062 EINA_LIST_FOREACH(itb->items, l, it)
1064 if (it->delete_me) continue;
1067 Eina_Bool was_realized = it->realized;
1069 _item_realize(it, in, 0);
1071 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1075 itb->realized = EINA_TRUE;
1076 itb->want_unrealize = EINA_FALSE;
1080 _item_block_unrealize(Item_Block *itb)
1083 Elm_Genlist_Item *it;
1086 if (!itb->realized) return;
1087 EINA_LIST_FOREACH(itb->items, l, it)
1092 it->want_unrealize = EINA_TRUE;
1095 _item_unrealize(it);
1099 itb->realized = EINA_FALSE;
1100 itb->want_unrealize = EINA_TRUE;
1103 itb->want_unrealize = EINA_FALSE;
1107 _item_block_position(Item_Block *itb, int in)
1110 Elm_Genlist_Item *it;
1111 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1114 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1115 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1116 EINA_LIST_FOREACH(itb->items, l, it)
1118 if (it->delete_me) continue;
1122 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
1123 itb->y - it->wd->pan_y + oy,
1125 cvx, cvy, cvw, cvh));
1126 if ((itb->realized) && (!it->realized))
1130 Eina_Bool was_realized = it->realized;
1132 _item_realize(it, in, 0);
1134 evas_object_smart_callback_call(it->wd->obj,
1142 evas_object_resize(it->base, it->w, it->h);
1143 evas_object_move(it->base,
1144 ox + itb->x + it->x - itb->wd->pan_x,
1145 oy + itb->y + it->y - itb->wd->pan_y);
1146 evas_object_show(it->base);
1151 _item_unrealize(it);
1160 _calc_job(void *data)
1162 Widget_Data *wd = data;
1164 Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
1165 Item_Block *chb = NULL;
1166 int in = 0, minw_change = 0;
1168 EINA_INLIST_FOREACH(wd->blocks, itb)
1173 showme = itb->showme;
1177 if (itb->realized) _item_block_unrealize(itb);
1181 if (itb->realized) _item_block_unrealize(itb);
1182 showme = _item_block_recalc(itb, in, 0, 1);
1188 if (minw == -1) minw = itb->minw;
1189 else if (minw < itb->minw)
1200 wd->show_item->showme = 0;
1202 elm_smart_scroller_region_bring_in(wd->scr,
1203 wd->show_item->x + wd->show_item->block->x,
1204 wd->show_item->y + wd->show_item->block->y,
1205 wd->show_item->block->w,
1208 elm_smart_scroller_child_region_show(wd->scr,
1209 wd->show_item->x + wd->show_item->block->x,
1210 wd->show_item->y + wd->show_item->block->y,
1211 wd->show_item->block->w,
1213 wd->show_item = NULL;
1219 EINA_INLIST_FOREACH(wd->blocks, itb)
1225 if ((chb) && (EINA_INLIST_GET(chb)->next))
1227 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1228 if (itb->realized) _item_block_unrealize(itb);
1230 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1231 if (minw < ow) minw = ow;
1232 if ((minw != wd->minw) || (minh != wd->minh))
1236 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1237 _sizing_eval(wd->obj);
1239 wd->calc_job = NULL;
1240 evas_object_smart_changed(wd->pan_smart);
1244 _update_job(void *data)
1246 Widget_Data *wd = data;
1249 int num, num0, position = 0, recalc = 0;
1251 wd->update_job = NULL;
1253 EINA_INLIST_FOREACH(wd->blocks, itb)
1255 Evas_Coord itminw, itminh;
1256 Elm_Genlist_Item *it;
1262 _item_block_position(itb, num);
1267 EINA_LIST_FOREACH(itb->items, l2, it)
1277 _item_unrealize(it);
1278 _item_realize(it, num, 0);
1279 evas_object_smart_callback_call(it->wd->obj,
1284 _item_realize(it, num, 1);
1285 _item_unrealize(it);
1287 if ((it->minw != itminw) || (it->minh != itminh))
1296 itb->changed = EINA_TRUE;
1297 _item_block_recalc(itb, num0, 0, 1);
1298 _item_block_position(itb, num0);
1303 if (wd->calc_job) ecore_job_del(wd->calc_job);
1304 wd->calc_job = ecore_job_add(_calc_job, wd);
1309 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1311 Pan *sd = evas_object_smart_data_get(obj);
1312 // Evas_Coord ow, oh;
1313 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1314 // ow = sd->wd->minw - ow;
1315 // if (ow < 0) ow = 0;
1316 // oh = sd->wd->minh - oh;
1317 // if (oh < 0) oh = 0;
1318 // if (x < 0) x = 0;
1319 // if (y < 0) y = 0;
1320 // if (x > ow) x = ow;
1321 // if (y > oh) y = oh;
1322 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1325 evas_object_smart_changed(obj);
1329 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1331 Pan *sd = evas_object_smart_data_get(obj);
1333 if (x) *x = sd->wd->pan_x;
1334 if (y) *y = sd->wd->pan_y;
1338 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1340 Pan *sd = evas_object_smart_data_get(obj);
1343 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1344 ow = sd->wd->minw - ow;
1346 oh = sd->wd->minh - oh;
1353 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1355 Pan *sd = evas_object_smart_data_get(obj);
1357 if (w) *w = sd->wd->minw;
1358 if (h) *h = sd->wd->minh;
1362 _pan_add(Evas_Object *obj)
1365 Evas_Object_Smart_Clipped_Data *cd;
1368 cd = evas_object_smart_data_get(obj);
1371 sd->__clipped_data = *cd;
1373 evas_object_smart_data_set(obj, sd);
1377 _pan_del(Evas_Object *obj)
1379 Pan *sd = evas_object_smart_data_get(obj);
1386 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1388 Pan *sd = evas_object_smart_data_get(obj);
1391 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1392 if ((ow == w) && (oh == h)) return;
1393 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1394 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1398 _pan_calculate(Evas_Object *obj)
1400 Pan *sd = evas_object_smart_data_get(obj);
1402 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1405 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1406 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
1407 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
1409 itb->w = sd->wd->minw;
1410 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
1411 itb->y - sd->wd->pan_y + oy,
1413 cvx, cvy, cvw, cvh))
1415 if ((!itb->realized) || (itb->changed))
1416 _item_block_realize(itb, in, 0);
1417 _item_block_position(itb, in);
1421 if (itb->realized) _item_block_unrealize(itb);
1428 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1430 Pan *sd = evas_object_smart_data_get(obj);
1432 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1433 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1437 _hold_on(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, 1);
1445 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1447 Widget_Data *wd = elm_widget_data_get(obj);
1449 elm_smart_scroller_hold_set(wd->scr, 0);
1453 _freeze_on(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, 1);
1461 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1463 Widget_Data *wd = elm_widget_data_get(obj);
1465 elm_smart_scroller_freeze_set(wd->scr, 0);
1469 * Add a new Genlist object
1471 * @param parent The parent object
1472 * @return The new object or NULL if it cannot be created
1477 elm_genlist_add(Evas_Object *parent)
1482 Evas_Coord minw, minh;
1483 static Evas_Smart *smart = NULL;
1485 wd = ELM_NEW(Widget_Data);
1486 e = evas_object_evas_get(parent);
1487 obj = elm_widget_add(e);
1488 ELM_SET_WIDTYPE(widtype, "genlist");
1489 elm_widget_type_set(obj, "genlist");
1490 elm_widget_sub_object_add(parent, obj);
1491 elm_widget_data_set(obj, wd);
1492 elm_widget_del_hook_set(obj, _del_hook);
1493 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1494 elm_widget_theme_hook_set(obj, _theme_hook);
1496 wd->scr = elm_smart_scroller_add(e);
1497 elm_smart_scroller_widget_set(wd->scr, obj);
1498 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
1499 elm_widget_resize_object_set(obj, wd->scr);
1501 elm_smart_scroller_bounce_allow_set(wd->scr, 0, 1);
1504 wd->mode = ELM_LIST_SCROLL;
1505 wd->max_items_per_block = 32;
1506 wd->longpress_timeout = 1.0;
1508 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1509 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1510 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1511 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1515 static Evas_Smart_Class sc;
1517 evas_object_smart_clipped_smart_set(&_pan_sc);
1519 sc.name = "elm_genlist_pan";
1520 sc.version = EVAS_SMART_CLASS_VERSION;
1523 sc.resize = _pan_resize;
1524 sc.move = _pan_move;
1525 sc.calculate = _pan_calculate;
1526 smart = evas_smart_class_new(&sc);
1530 wd->pan_smart = evas_object_smart_add(e, smart);
1531 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1535 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1537 _pan_max_get, _pan_child_size_get);
1539 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
1541 evas_object_size_hint_min_set(obj, minw, minh);
1547 static Elm_Genlist_Item *
1548 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
1549 const void *data, Elm_Genlist_Item *parent,
1550 Elm_Genlist_Item_Flags flags,
1552 const void *func_data)
1554 Elm_Genlist_Item *it;
1556 it = calloc(1, sizeof(Elm_Genlist_Item));
1557 if (!it) return NULL;
1561 it->parent = parent;
1563 it->func.func = func;
1564 it->func.data = func_data;
1569 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
1571 Item_Block *itb = NULL;
1578 itb = calloc(1, sizeof(Item_Block));
1581 if (!it->rel->block)
1584 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
1585 itb->items = eina_list_append(itb->items, it);
1592 eina_inlist_prepend_relative(wd->blocks,
1593 EINA_INLIST_GET(itb),
1594 EINA_INLIST_GET(it->rel->block));
1596 eina_list_prepend_relative(itb->items, it, it->rel);
1601 eina_inlist_append_relative(wd->blocks,
1602 EINA_INLIST_GET(itb),
1603 EINA_INLIST_GET(it->rel->block));
1605 eina_list_append_relative(itb->items, it, it->rel);
1615 itb = (Item_Block *)(wd->blocks);
1616 if (itb->count >= wd->max_items_per_block)
1618 itb = calloc(1, sizeof(Item_Block));
1622 eina_inlist_prepend(wd->blocks,
1623 EINA_INLIST_GET(itb));
1628 itb = calloc(1, sizeof(Item_Block));
1632 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
1634 itb->items = eina_list_prepend(itb->items, it);
1640 itb = (Item_Block *)(wd->blocks->last);
1641 if (itb->count >= wd->max_items_per_block)
1643 itb = calloc(1, sizeof(Item_Block));
1647 eina_inlist_append(wd->blocks,
1648 EINA_INLIST_GET(itb));
1653 itb = calloc(1, sizeof(Item_Block));
1657 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
1659 itb->items = eina_list_append(itb->items, it);
1665 itb = it->rel->block;
1666 if (!itb) goto newblock;
1668 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
1670 itb->items = eina_list_append_relative(itb->items, it, it->rel);
1673 itb->changed = EINA_TRUE;
1675 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
1676 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
1679 it->rel->relcount--;
1680 if ((it->rel->delete_me) && (it->rel->relcount == 0))
1684 if (itb->count > itb->wd->max_items_per_block)
1688 Elm_Genlist_Item *it2;
1690 newc = itb->count / 2;
1691 itb2 = calloc(1, sizeof(Item_Block));
1695 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
1696 EINA_INLIST_GET(itb));
1697 itb2->changed = EINA_TRUE;
1698 while ((itb->count > newc) && (itb->items))
1702 l = eina_list_last(itb->items);
1704 itb->items = eina_list_remove_list(itb->items, l);
1707 itb2->items = eina_list_prepend(itb2->items, it2);
1715 _queue_proecess(Widget_Data *wd, int norender)
1720 t0 = ecore_time_get();
1721 for (n = 0; (wd->queue) && (n < 128); n++)
1723 Elm_Genlist_Item *it;
1725 it = wd->queue->data;
1726 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
1727 it->queued = EINA_FALSE;
1728 _item_block_add(wd, it);
1729 t = ecore_time_get();
1730 if (it->block->changed)
1732 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
1733 it->block->changed = 0;
1735 if (showme) it->block->showme = 1;
1736 if (eina_inlist_count(wd->blocks) > 1)
1738 if ((t - t0) > (ecore_animator_frametime_get())) break;
1745 _item_idler(void *data)
1747 Widget_Data *wd = data;
1749 if (_queue_proecess(wd, 1) > 0)
1751 if (wd->calc_job) ecore_job_del(wd->calc_job);
1752 wd->calc_job = ecore_job_add(_calc_job, wd);
1756 wd->queue_idler = NULL;
1757 return ECORE_CALLBACK_CANCEL;
1759 return ECORE_CALLBACK_RENEW;
1763 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
1765 if (it->queued) return;
1766 it->queued = EINA_TRUE;
1767 wd->queue = eina_list_append(wd->queue, it);
1768 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
1770 if (wd->queue_idler)
1772 ecore_idler_del(wd->queue_idler);
1773 wd->queue_idler = NULL;
1775 _queue_proecess(wd, 0);
1777 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
1781 * Append item to the end of the genlist
1783 * This appends the given item to the end of the list or the end of the
1784 * children if the parent is given.
1786 * @param obj The genlist object
1787 * @param itc The item class for the item
1788 * @param data The item data
1789 * @param parent The parent item, or NULL if none
1790 * @param flags Item flags
1791 * @param func Convenience function called when item selected
1792 * @param func_data Data passed to @p func above.
1793 * @return A handle to the item added or NULL if not possible
1797 EAPI Elm_Genlist_Item *
1798 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1799 const void *data, Elm_Genlist_Item *parent,
1800 Elm_Genlist_Item_Flags flags,
1801 Evas_Smart_Cb func, const void *func_data)
1803 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1804 Widget_Data *wd = elm_widget_data_get(obj);
1805 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
1806 if (!wd) return NULL;
1807 if (!it) return NULL;
1810 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1816 Elm_Genlist_Item *it2 = NULL;
1817 Eina_List *ll = eina_list_last(it->parent->items);
1818 if (ll) it2 = ll->data;
1819 it->parent->items = eina_list_append(it->parent->items, it);
1820 if (!it2) it2 = it->parent;
1822 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1823 EINA_INLIST_GET(it2));
1825 it->rel->relcount++;
1828 _item_queue(wd, it);
1833 * Prepend item at start of the genlist
1835 * This adds an item to the beginning of the list or beginning of the children
1836 * of the parent if given.
1838 * @param obj The genlist object
1839 * @param itc The item class for the item
1840 * @param data The item data
1841 * @param parent The parent item, or NULL if none
1842 * @param flags Item flags
1843 * @param func Convenience function called when item selected
1844 * @param func_data Data passed to @p func above.
1845 * @return A handle to the item added or NULL if not possible
1849 EAPI Elm_Genlist_Item *
1850 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1851 const void *data, Elm_Genlist_Item *parent,
1852 Elm_Genlist_Item_Flags flags,
1853 Evas_Smart_Cb func, const void *func_data)
1855 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1856 Widget_Data *wd = elm_widget_data_get(obj);
1857 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
1858 if (!wd) return NULL;
1859 if (!it) return NULL;
1861 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1864 printf("FIXME: 12 tree not handled yet\n");
1868 _item_queue(wd, it);
1873 * Insert item before another in the genlist
1875 * This inserts an item before another in the list. It will be in the same tree
1876 * level as the item it is inseted before.
1878 * @param obj The genlist object
1879 * @param itc The item class for the item
1880 * @param data The item data
1881 * @param before The item to insert before
1882 * @param flags Item flags
1883 * @param func Convenience function called when item selected
1884 * @param func_data Data passed to @p func above.
1885 * @return A handle to the item added or NULL if not possible
1889 EAPI Elm_Genlist_Item *
1890 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1891 const void *data, Elm_Genlist_Item *before,
1892 Elm_Genlist_Item_Flags flags,
1893 Evas_Smart_Cb func, const void *func_data)
1895 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1896 Widget_Data *wd = elm_widget_data_get(obj);
1897 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
1898 if (!wd) return NULL;
1899 if (!it) return NULL;
1901 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1902 EINA_INLIST_GET(before));
1905 printf("FIXME: 13 tree not handled yet\n");
1908 it->rel->relcount++;
1910 _item_queue(wd, it);
1915 * Insert and item after another in the genlst
1917 * This inserts an item after another in the list. It will be in the same tree
1918 * level as the item it is inseted after.
1920 * @param obj The genlist object
1921 * @param itc The item class for the item
1922 * @param data The item data
1923 * @param after The item to insert after
1924 * @param flags Item flags
1925 * @param func Convenience function called when item selected
1926 * @param func_data Data passed to @p func above.
1927 * @return A handle to the item added or NULL if not possible
1931 EAPI Elm_Genlist_Item *
1932 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
1933 const void *data, Elm_Genlist_Item *after,
1934 Elm_Genlist_Item_Flags flags,
1935 Evas_Smart_Cb func, const void *func_data)
1937 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1938 Widget_Data *wd = elm_widget_data_get(obj);
1939 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
1940 if (!wd) return NULL;
1941 if (!it) return NULL;
1943 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1944 EINA_INLIST_GET(after));
1947 printf("FIXME: 14 tree not handled yet\n");
1950 it->rel->relcount++;
1952 _item_queue(wd, it);
1959 * This clears all items in the list, leaving it empty.
1961 * @param obj The genlist object
1966 elm_genlist_clear(Evas_Object *obj)
1968 ELM_CHECK_WIDTYPE(obj, widtype);
1969 Widget_Data *wd = elm_widget_data_get(obj);
1971 if (wd->walking > 0)
1973 Elm_Genlist_Item *it;
1976 EINA_INLIST_FOREACH(wd->items, it)
1985 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
1987 wd->items = eina_inlist_remove(wd->items, wd->items);
1988 if (it->realized) _item_unrealize(it);
1989 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
1990 if (it->long_timer) ecore_timer_del(it->long_timer);
1995 Item_Block *itb = (Item_Block *)(wd->blocks);
1997 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
1998 if (itb->items) eina_list_free(itb->items);
2003 ecore_job_del(wd->calc_job);
2004 wd->calc_job = NULL;
2006 if (wd->queue_idler)
2008 ecore_idler_del(wd->queue_idler);
2009 wd->queue_idler = NULL;
2013 eina_list_free(wd->queue);
2018 eina_list_free(wd->selected);
2019 wd->selected = NULL;
2021 wd->show_item = NULL;
2026 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2027 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2032 * Enable or disable multi-select in the genlist
2034 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
2035 * more than 1 item to be selected.
2037 * @param obj The genlist object
2038 * @param multi Multi-select enable/disable
2043 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
2045 ELM_CHECK_WIDTYPE(obj, widtype);
2046 Widget_Data *wd = elm_widget_data_get(obj);
2052 * Gets if multi-select in genlist is enable or disable
2054 * @param obj The genlist object
2055 * @return Multi-select enable/disable
2056 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
2061 elm_genlist_multi_select_get(const Evas_Object *obj)
2063 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2064 Widget_Data *wd = elm_widget_data_get(obj);
2065 if (!wd) return EINA_FALSE;
2071 * Get the selectd item in the genlist
2073 * This gets the selected item in the list (if multi-select is enabled only
2074 * the first item in the list is selected - which is not very useful, so see
2075 * elm_genlist_selected_items_get()for when multi-select is used).
2077 * If no item is selected, NULL is returned.
2079 * @param obj The genlist object
2080 * @return The selected item, or NULL if none.
2084 EAPI Elm_Genlist_Item *
2085 elm_genlist_selected_item_get(const Evas_Object *obj)
2087 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2088 Widget_Data *wd = elm_widget_data_get(obj);
2089 if (!wd) return NULL;
2090 if (wd->selected) return wd->selected->data;
2095 * Get a list of selected items in the genlist
2097 * This retgurns a list of the selected items. This list pointer is only valid
2098 * so long as no items are selected or unselected (or unselected implicitly
2099 * by deletion). The list contains Elm_Genlist_Item pointers.
2101 * @param obj The genlist object
2102 * @return The list of selected items, nor NULL if none are selected.
2106 EAPI const Eina_List *
2107 elm_genlist_selected_items_get(const Evas_Object *obj)
2109 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2110 Widget_Data *wd = elm_widget_data_get(obj);
2111 if (!wd) return NULL;
2112 return wd->selected;
2116 * Get a list of realized items in genlist
2118 * This returns a list of the realized items in the genlist. The list
2119 * contains Elm_Genlist_Item pointers. The list must be freed by the
2120 * caller when done with eina_list_free(). The item pointers in the list
2121 * are only vallid so long as those items are not deleted or the genlist is
2124 * @param obj The genlist object
2125 * @return The list of realized items, nor NULL if none are realized.
2130 elm_genlist_realized_items_get(const Evas_Object *obj)
2132 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2133 Widget_Data *wd = elm_widget_data_get(obj);
2134 Eina_List *list = NULL;
2136 Eina_Bool done = EINA_FALSE;
2137 if (!wd) return NULL;
2138 EINA_INLIST_FOREACH(wd->blocks, itb)
2143 Elm_Genlist_Item *it;
2146 EINA_LIST_FOREACH(itb->items, l, it)
2148 if (it->realized) list = eina_list_append(list, it);
2160 * Get the item that is at the x, y canvas coords
2162 * This returns the item at the given coordinates (which are canvas relative
2163 * not object-relative). If an item is at that coordinate, that item handle
2164 * is returned, and if @p posret is not NULL, the integer pointed to is set
2165 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
2166 * portion of that item (-1), on the middle section (0) or on the lower part
2167 * (1). If NULL is returned as an item (no item found there), then posret
2168 * may indicate -1 or 1 based if the coordinate is above or below all items
2169 * respectively in the genlist.
2171 * @param it The item
2172 * @param x The input x coordinate
2173 * @param y The input y coordinate
2174 * @param posret The position relative to the item returned here
2175 * @return The item at the coordinates or NULL if none
2179 EAPI Elm_Genlist_Item *
2180 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
2182 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2183 Widget_Data *wd = elm_widget_data_get(obj);
2184 Evas_Coord ox, oy, ow, oh;
2187 if (!wd) return NULL;
2188 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
2190 EINA_INLIST_FOREACH(wd->blocks, itb)
2193 Elm_Genlist_Item *it;
2195 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
2196 oy + itb->y - itb->wd->pan_y,
2197 itb->w, itb->h, x, y, 1, 1))
2199 EINA_LIST_FOREACH(itb->items, l, it)
2201 Evas_Coord itx, ity;
2203 itx = ox + itb->x + it->x - itb->wd->pan_x;
2204 ity = oy + itb->y + it->y - itb->wd->pan_y;
2205 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
2209 if (y <= (ity + (it->h / 4))) *posret = -1;
2210 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
2215 lasty = ity + it->h;
2220 if (y > lasty) *posret = 1;
2227 * Get the first item in the genlist
2229 * This returns the first item in the list.
2231 * @param obj The genlist object
2232 * @return The first item, or NULL if none
2236 EAPI Elm_Genlist_Item *
2237 elm_genlist_first_item_get(const Evas_Object *obj)
2239 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2240 Widget_Data *wd = elm_widget_data_get(obj);
2241 if (!wd) return NULL;
2242 if (!wd->items) return NULL;
2243 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2244 while ((it) && (it->delete_me))
2245 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
2250 * Get the last item in the genlist
2252 * This returns the last item in the list.
2254 * @return The last item, or NULL if none
2258 EAPI Elm_Genlist_Item *
2259 elm_genlist_last_item_get(const Evas_Object *obj)
2261 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2262 Widget_Data *wd = elm_widget_data_get(obj);
2263 if (!wd->items) return NULL;
2264 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
2265 if (!wd) return NULL;
2266 while ((it) && (it->delete_me))
2267 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
2272 * Get the next item in the genlist
2274 * This returns the item after the item @p it.
2276 * @param it The item
2277 * @return The item after @p it, or NULL if none
2281 EAPI Elm_Genlist_Item *
2282 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
2286 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
2287 if ((it) && (!it->delete_me)) break;
2289 return (Elm_Genlist_Item *)it;
2293 * Get the previous item in the genlist
2295 * This returns the item before the item @p it.
2297 * @param it The item
2298 * @return The item before @p it, or NULL if none
2302 EAPI Elm_Genlist_Item *
2303 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
2307 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
2308 if ((it) && (!it->delete_me)) break;
2310 return (Elm_Genlist_Item *)it;
2314 * Get the genlist object from an item
2316 * This returns the genlist object itself that an item belongs to.
2318 * @param it The item
2319 * @return The genlist object
2324 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
2326 if (!it) return NULL;
2331 * Get the parent item of the given item
2333 * This returns the prent item of the item @p it given.
2335 * @param it The item
2336 * @return The parent of the item or NULL if none
2340 EAPI Elm_Genlist_Item *
2341 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
2343 if (!it) return NULL;
2348 * Clear all sub-items (children) of the given item
2350 * This clears all items that are children (or their descendants) of the
2353 * @param it The item
2358 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
2360 Eina_List *tl = NULL, *l;
2361 Elm_Genlist_Item *it2;
2364 EINA_LIST_FOREACH(it->items, l, it2)
2365 tl = eina_list_append(tl, it2);
2366 EINA_LIST_FREE(tl, it2)
2367 elm_genlist_item_del(it2);
2371 * Set the selected state of an item
2373 * This sets the selected state (1 selected, 0 not selected) of the given
2376 * @param it The item
2377 * @param selected The slected state
2382 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
2384 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
2387 if (it->delete_me) return;
2388 selected = !!selected;
2389 if (it->selected == selected) return;
2395 while (wd->selected)
2396 _item_unselect(wd->selected->data);
2406 * Get the selected state of an item
2408 * This gets the selected state of an item (1 selected, 0 not selected).
2410 * @param it The item
2411 * @return The selected state
2416 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
2418 if (!it) return EINA_FALSE;
2419 return it->selected;
2423 * Sets the expanded state of an item (if it's a parent)
2425 * This expands or contracts a parent iterm (thus showing or hiding the
2428 * @param it The item
2429 * @param expanded The expanded state (1 expanded, 0 not expanded).
2434 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
2437 if (it->expanded == expanded) return;
2438 it->expanded = expanded;
2442 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
2443 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
2448 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
2449 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
2454 * Get the expanded state of an item
2456 * This gets the expanded state of an item
2458 * @param it The item
2459 * @return Thre expanded state
2464 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
2466 if (!it) return EINA_FALSE;
2467 return it->expanded;
2471 * Sets the disabled state of an item.
2473 * A disabled item cannot be selected or unselected. It will also change
2474 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
2477 * @param it The item
2478 * @param disabled The disabled state
2483 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
2486 if (it->disabled == disabled) return;
2487 if (it->delete_me) return;
2488 it->disabled = disabled;
2492 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
2494 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
2499 * Get the disabled state of an item
2501 * This gets the disabld state of the given item.
2503 * @param it The item
2504 * @return The disabled state
2509 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
2511 if (!it) return EINA_FALSE;
2512 if (it->delete_me) return EINA_FALSE;
2513 return it->disabled;
2517 * Sets the display only state of an item.
2519 * A display only item cannot be selected or unselected. It is for display
2520 * only and not selecting or otherwise clicking, dragging etc. by the user,
2521 * thus finger size rules will not be applied to this item.
2523 * @param it The item
2524 * @param display_only The display only state
2529 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
2532 if (!it->block) return;
2533 if (it->display_only == display_only) return;
2534 if (it->delete_me) return;
2535 it->display_only = display_only;
2536 it->mincalcd = EINA_FALSE;
2537 it->updateme = EINA_TRUE;
2538 it->block->updateme = EINA_TRUE;
2539 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
2540 it->wd->update_job = ecore_job_add(_update_job, it->wd);
2544 * Get the display only state of an item
2546 * This gets the display only state of the given item.
2548 * @param it The item
2549 * @return The display only state
2554 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
2556 if (!it) return EINA_FALSE;
2557 if (it->delete_me) return EINA_FALSE;
2558 return it->display_only;
2562 * Show the given item
2564 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2565 * if it is not fully visible.
2567 * @param it The item
2572 elm_genlist_item_show(Elm_Genlist_Item *it)
2575 if (it->delete_me) return;
2576 if ((it->queued) || (!it->mincalcd))
2578 it->wd->show_item = it;
2579 it->wd->bring_in = 1;
2580 it->showme = EINA_TRUE;
2583 if (it->wd->show_item)
2585 it->wd->show_item->showme = EINA_FALSE;
2586 it->wd->show_item = NULL;
2588 elm_smart_scroller_child_region_show(it->wd->scr,
2589 it->x + it->block->x,
2590 it->y + it->block->y,
2591 it->block->w, it->h);
2595 * Bring in the given item
2597 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2598 * if it is not fully visible. This may use animation to do so and take a
2601 * @param it The item
2606 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
2609 if (it->delete_me) return;
2610 if ((it->queued) || (!it->mincalcd))
2612 it->wd->show_item = it;
2613 it->wd->bring_in = 1;
2614 it->showme = EINA_TRUE;
2617 if (it->wd->show_item)
2619 it->wd->show_item->showme = EINA_FALSE;
2620 it->wd->show_item = NULL;
2622 elm_smart_scroller_region_bring_in(it->wd->scr,
2623 it->x + it->block->x,
2624 it->y + it->block->y,
2625 it->block->w, it->h);
2629 * Show the given item at the top
2631 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2632 * if it is not fully visible.
2634 * @param it The item
2639 elm_genlist_item_top_show(Elm_Genlist_Item *it)
2644 if (it->delete_me) return;
2645 if ((it->queued) || (!it->mincalcd))
2647 it->wd->show_item = it;
2648 it->wd->bring_in = 1;
2649 it->showme = EINA_TRUE;
2652 if (it->wd->show_item)
2654 it->wd->show_item->showme = EINA_FALSE;
2655 it->wd->show_item = NULL;
2657 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2658 elm_smart_scroller_child_region_show(it->wd->scr,
2659 it->x + it->block->x,
2660 it->y + it->block->y,
2665 * Bring in the given item at the top
2667 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2668 * if it is not fully visible. This may use animation to do so and take a
2671 * @param it The item
2676 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
2681 if (it->delete_me) return;
2682 if ((it->queued) || (!it->mincalcd))
2684 it->wd->show_item = it;
2685 it->wd->bring_in = 1;
2686 it->showme = EINA_TRUE;
2689 if (it->wd->show_item)
2691 it->wd->show_item->showme = EINA_FALSE;
2692 it->wd->show_item = NULL;
2694 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2695 elm_smart_scroller_region_bring_in(it->wd->scr,
2696 it->x + it->block->x,
2697 it->y + it->block->y,
2702 * Show the given item at the middle
2704 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2705 * if it is not fully visible.
2707 * @param it The item
2712 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
2717 if (it->delete_me) return;
2718 if ((it->queued) || (!it->mincalcd))
2720 it->wd->show_item = it;
2721 it->wd->bring_in = 1;
2722 it->showme = EINA_TRUE;
2725 if (it->wd->show_item)
2727 it->wd->show_item->showme = EINA_FALSE;
2728 it->wd->show_item = NULL;
2730 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2731 elm_smart_scroller_child_region_show(it->wd->scr,
2732 it->x + it->block->x,
2733 it->y + it->block->y - oh/2 + it->h/2,
2739 * Bring in the given item at the middle
2741 * This causes genlist to jump to the given item @p it and show it (by scrolling),
2742 * if it is not fully visible. This may use animation to do so and take a
2745 * @param it The item
2750 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
2755 if (it->delete_me) return;
2756 if ((it->queued) || (!it->mincalcd))
2758 it->wd->show_item = it;
2759 it->wd->bring_in = 1;
2760 it->showme = EINA_TRUE;
2763 if (it->wd->show_item)
2765 it->wd->show_item->showme = EINA_FALSE;
2766 it->wd->show_item = NULL;
2768 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
2769 elm_smart_scroller_region_bring_in(it->wd->scr,
2770 it->x + it->block->x,
2771 it->y + it->block->y - oh/2 + it->h/2,
2776 * Delete a given item
2778 * This deletes the item from genlist and calls the genlist item del class
2779 * callback defined in the item class, if it is set.
2781 * @param it The item
2786 elm_genlist_item_del(Elm_Genlist_Item *it)
2789 if ((it->relcount > 0) || (it->walking > 0))
2791 elm_genlist_item_subitems_clear(it);
2792 it->delete_me = EINA_TRUE;
2793 if (it->wd->show_item == it) it->wd->show_item = NULL;
2794 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
2797 if (it->realized) _item_unrealize(it);
2798 it->block->changed = EINA_TRUE;
2799 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
2800 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
2802 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2809 * Set the data item from the genlist item
2811 * This set the data value passed on the elm_genlist_item_append() and
2812 * related item addition calls. This function will also call
2813 * elm_genlist_item_update() so the item will be updated to reflect the
2816 * @param it The item
2817 * @param data The new data pointer to set
2822 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
2826 elm_genlist_item_update(it);
2830 * Get the data item from the genlist item
2832 * This returns the data value passed on the elm_genlist_item_append() and
2833 * related item addition calls.
2835 * @param it The item
2836 * @return The data pointer provided when created
2841 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
2843 if (!it) return NULL;
2848 * Get the real evas object of the genlist item
2850 * This returns the actual evas object used for the specified genlist item.
2851 * This may be NULL as it may not be created, and ma be deleted at any time
2852 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
2853 * genlist is controlling it. This function is for querying, emitting
2854 * custom signals or hooking lower level callbacks for events. Do not
2855 * delete this object under any circumstances.
2857 * @param it The item
2858 * @return The objct pointer
2862 EAPI const Evas_Object *
2863 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
2865 if (!it) return NULL;
2870 * Update the contents of an item
2872 * This updates an item by calling all the item class functions again to get
2873 * the icons, labels and states. Use this when he original item data has
2874 * changed and the changes are desired to be reflected.
2876 * @param it The item
2881 elm_genlist_item_update(Elm_Genlist_Item *it)
2883 if (!it->block) return;
2884 if (it->delete_me) return;
2885 it->mincalcd = EINA_FALSE;
2886 it->updateme = EINA_TRUE;
2887 it->block->updateme = EINA_TRUE;
2888 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
2889 it->wd->update_job = ecore_job_add(_update_job, it->wd);
2893 * This sets the horizontal stretching mode
2895 * This sets the mode used for sizing items horizontally. Valid modes are
2896 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
2897 * mode means that if items are too wide to fit, the scroller will scroll
2898 * horizontally. Otherwise items are expanded to fill the width of the
2899 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
2900 * to the viewport width and limited to that size.
2902 * @param obj The genlist object
2903 * @param mode The mode to use
2908 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
2910 ELM_CHECK_WIDTYPE(obj, widtype);
2911 Widget_Data *wd = elm_widget_data_get(obj);
2913 if (wd->mode == mode) return;
2919 * Gets the horizontal stretching mode
2921 * @param obj The genlist object
2922 * @return The mode to use
2923 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
2928 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
2930 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
2931 Widget_Data *wd = elm_widget_data_get(obj);
2932 if (!wd) return ELM_LIST_LAST;
2937 * Set the always select mode.
2939 * Items will only call their selection func and callback when first becoming
2940 * selected. Any further clicks will do nothing, unless you enable always
2941 * select with elm_genlist_always_select_mode_set(). This means even if
2942 * selected, every click will make the selected callbacks be called.
2944 * @param obj The genlist object
2945 * @param always_select The always select mode
2946 * (EINA_TRUE = on, EINA_FALSE = off)
2951 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
2953 ELM_CHECK_WIDTYPE(obj, widtype);
2954 Widget_Data *wd = elm_widget_data_get(obj);
2956 wd->always_select = always_select;
2960 * Get the always select mode.
2962 * @param obj The genlist object
2963 * @return The always select mode
2964 * (EINA_TRUE = on, EINA_FALSE = off)
2969 elm_genlist_always_select_mode_get(const Evas_Object *obj)
2971 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2972 Widget_Data *wd = elm_widget_data_get(obj);
2973 if (!wd) return EINA_FALSE;
2974 return wd->always_select;
2978 * Set no select mode
2980 * This will turn off the ability to select items entirely and they will
2981 * neither appear selected nor call selected callback functions.
2983 * @param obj The genlist object
2984 * @param no_select The no select mode
2985 * (EINA_TRUE = on, EINA_FALSE = off)
2990 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
2992 ELM_CHECK_WIDTYPE(obj, widtype);
2993 Widget_Data *wd = elm_widget_data_get(obj);
2995 wd->no_select = no_select;
2999 * Gets no select mode
3001 * @param obj The genlist object
3002 * @return The no select mode
3003 * (EINA_TRUE = on, EINA_FALSE = off)
3008 elm_genlist_no_select_mode_get(const Evas_Object *obj)
3010 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3011 Widget_Data *wd = elm_widget_data_get(obj);
3012 if (!wd) return EINA_FALSE;
3013 return wd->no_select;
3019 * This will enable the compress mode where items are "compressed" horizontally
3020 * to fit the genlist scrollable viewport width.
3022 * @param obj The genlist object
3023 * @param no_select The compress mode
3024 * (EINA_TRUE = on, EINA_FALSE = off)
3029 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
3031 ELM_CHECK_WIDTYPE(obj, widtype);
3032 Widget_Data *wd = elm_widget_data_get(obj);
3034 wd->compress = compress;
3038 * Get the compress mode
3040 * @param obj The genlist object
3041 * @return The compress mode
3042 * (EINA_TRUE = on, EINA_FALSE = off)
3047 elm_genlist_compress_mode_get(const Evas_Object *obj)
3049 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3050 Widget_Data *wd = elm_widget_data_get(obj);
3051 if (!wd) return EINA_FALSE;
3052 return wd->compress;
3058 * This will enable or disable the scroller bounce mode for the genlist. See
3059 * elm_scroller_bounce_set() for details
3061 * @param obj The genlist object
3062 * @param h_bounce Allow bounce horizontally
3063 * @param v_bounce Allow bounce vertically
3068 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3070 ELM_CHECK_WIDTYPE(obj, widtype);
3071 Widget_Data *wd = elm_widget_data_get(obj);
3073 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3077 * Get the bounce mode
3079 * @param obj The genlist object
3080 * @param h_bounce Allow bounce horizontally
3081 * @param v_bounce Allow bounce vertically
3086 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3088 ELM_CHECK_WIDTYPE(obj, widtype);
3089 Widget_Data *wd = elm_widget_data_get(obj);
3091 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
3095 * Set homogenous mode
3097 * This will enable the homogeneous mode where items are of the same height and width
3098 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
3100 * @param obj The genlist object
3101 * @param homogeneous Assume the items within the genlist are of the same height and width
3102 * (EINA_TRUE = on, EINA_FALSE = off)
3107 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
3109 ELM_CHECK_WIDTYPE(obj, widtype);
3110 Widget_Data *wd = elm_widget_data_get(obj);
3112 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
3113 wd->homogeneous = homogeneous;
3117 * Get the homogenous mode
3119 * @param obj The genlist object
3120 * @return Assume the items within the genlist are of the same height and width
3121 * (EINA_TRUE = on, EINA_FALSE = off)
3126 elm_genlist_homogeneous_get(const Evas_Object *obj)
3128 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3129 Widget_Data *wd = elm_widget_data_get(obj);
3130 if (!wd) return EINA_FALSE;
3131 return wd->homogeneous;
3135 * Set the maximum number of items within an item block
3137 * This will configure the block count to tune to the target with particular performance matrix.
3139 * @param obj The genlist object
3140 * @param n Maximum number of items within an item block
3145 elm_genlist_block_count_set(Evas_Object *obj, int n)
3147 ELM_CHECK_WIDTYPE(obj, widtype);
3148 Widget_Data *wd = elm_widget_data_get(obj);
3150 wd->max_items_per_block = n;
3154 * Get the maximum number of items within an item block
3156 * @param obj The genlist object
3157 * @return Maximum number of items within an item block
3162 elm_genlist_block_count_get(const Evas_Object *obj)
3164 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3165 Widget_Data *wd = elm_widget_data_get(obj);
3167 return wd->max_items_per_block;
3171 * Set the timeout in seconds for the longpress event
3173 * @param obj The genlist object
3174 * @param timeout timeout in seconds
3179 elm_genlist_longpress_timeout_set(const Evas_Object *obj, double timeout)
3181 ELM_CHECK_WIDTYPE(obj, widtype);
3182 Widget_Data *wd = elm_widget_data_get(obj);
3184 wd->longpress_timeout = timeout;
3188 * Get the timeout in seconds for the longpress event
3190 * @param obj The genlist object
3191 * @return timeout in seconds
3196 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
3198 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3199 Widget_Data *wd = elm_widget_data_get(obj);
3201 return wd->longpress_timeout;