1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Genlist has a fairly large API, mostly because it's relatively complex,
19 * trying to be both expansive, powerful and efficient. First we will begin
20 * an overview on the theory behind genlist.
22 * Evas tracks every object you create. Every time it processes an event
23 * (mouse move, down, up etc.) it needs to walk through objects and find out
24 * what event that affects. Even worse every time it renders display updates,
25 * in order to just calculate what to re-draw, it needs to walk through many
26 * many many objects. Thus, the more objects you keep active, the more
27 * overhead Evas has in just doing its work. It is advisable to keep your
28 * active objects to the minimum working set you need. Also remember that
29 * object creation and deletion carries an overhead, so there is a
30 * middle-ground, which is not easily determined. But don't keep massive lists
31 * of objects you can't see or use. Genlist does this with list objects. It
32 * creates and destroys them dynamically as you scroll around. It groups them
33 * into blocks so it can determine the visibility etc. of a whole block at
34 * once as opposed to having to walk the whole list. This 2-level list allows
35 * for very large numbers of items to be in the list (tests have used up to
36 * 2,000,000 items). Also genlist employs a queue for adding items. As items
37 * may be different sizes, every item added needs to be calculated as to its
38 * size and thus this presents a lot of overhead on populating the list, this
39 * genlist employs a queue. Any item added is queued and spooled off over
40 * time, actually appearing some time later, so if your list has many members
41 * you may find it takes a while for them to all appear, with your process
42 * consuming a lot of CPU while it is busy spooling.
44 * Genlist also implements a tree structure, but it does so with callbacks to
45 * the application, with the application filling in tree structures when
46 * requested (allowing for efficient building of a very deep tree that could
47 * even be used for file-management). See the above smart signal callbacks for
50 * An item in the genlist world can have 0 or more text labels (they can be
51 * regular text or textblock - that's up to the style to determine), 0 or
52 * more icons (which are simply objects swallowed into the genlist item) and
53 * 0 or more boolean states that can be used for check, radio or other
54 * indicators by the edje theme style. An item may be one of several styles
55 * (Elementary provides 4 by default - "default", "double_label", "group_index"
56 * and "icon_top_text_bottom", but this can be extended by system or
57 * application custom themes/overlays/extensions).
59 * In order to implement the ability to add and delete items on the fly,
60 * Genlist implements a class/callback system where the application provides
61 * a structure with information about that type of item (genlist may contain
62 * multiple different items with different classes, states and styles).
63 * Genlist will call the functions in this struct (methods) when an item is
64 * "realized" (that is created dynamically while scrolling). All objects will
65 * simply be deleted when no longer needed with evas_object_del(). The
66 * Elm_Genlist_Item_Class structure contains the following members:
68 * item_style - This is a constant string and simply defines the name of the
69 * item style. It must be specified and the default should be "default".
71 * func.label_get - This function is called when an actual item object is
72 * created. The data parameter is the data parameter passed to
73 * elm_genlist_item_append() and related item creation functions. The obj
74 * parameter is the genlist object and the part parameter is the string name
75 * of the text part in the edje design that is listed as one of the possible
76 * labels that can be set. This function must return a strudup()'ed string as
77 * the caller will free() it when done.
79 * func.icon_get - This function is called when an actual item object is
80 * created. The data parameter is the data parameter passed to
81 * elm_genlist_item_append() and related item creation functions. The obj
82 * parameter is the genlist object and the part parameter is the string name
83 * of the icon part in the edje design that is listed as one of the possible
84 * icons that can be set. This must return NULL for no object or a valid
85 * object. The object will be deleted by genlist on shutdown or when the item
88 * func.state_get - This function is called when an actual item object is
89 * created. The data parameter is the data parameter passed to
90 * elm_genlist_item_append() and related item creation functions. The obj
91 * parameter is the genlist object and the part parameter is the string name
92 * of the state part in the edje design that is listed as one of the possible
93 * states that can be set. Return 0 for false or 1 for true. Genlist will
94 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95 * true (the default is false), where XXX is the name of the part.
97 * func.del - This is called when elm_genlist_item_del() is called on an
98 * item, elm_genlist_clear() is called on the genlist, or
99 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100 * intended for use when actual genlist items are deleted, so any backing
101 * data attached to the item (e.g. its data parameter on creation) can be
104 * Items can be added by several calls. All of them return a Elm_Genlist_Item
105 * handle that is an internal member inside the genlist. They all take a data
106 * parameter that is meant to be used for a handle to the applications
107 * internal data (eg the struct with the original item data). The parent
108 * parameter is the parent genlist item this belongs to if it is a tree or
109 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112 * is displayed as an item that is able to expand and have child items.
113 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114 * displayed at the top until the next group comes. The func parameter is a
115 * convenience callback that is called when the item is selected and the data
116 * parameter will be the func_data parameter, obj be the genlist object and
117 * event_info will be the genlist item.
119 * elm_genlist_item_append() appends an item to the end of the list, or if
120 * there is a parent, to the end of all the child items of the parent.
121 * elm_genlist_item_prepend() is the same but prepends to the beginning of
122 * the list or children list. elm_genlist_item_insert_before() inserts at
123 * item before another item and elm_genlist_item_insert_after() inserts after
124 * the indicated item.
126 * The application can clear the list with elm_genlist_clear() which deletes
127 * all the items in the list and elm_genlist_item_del() will delete a specific
128 * item. elm_genlist_item_subitems_clear() will clear all items that are
129 * children of the indicated parent item.
131 * If the application wants multiple items to be able to be selected,
132 * elm_genlist_multi_select_set() can enable this. If the list is
133 * single-selection only (the default), then elm_genlist_selected_item_get()
134 * will return the selected item, if any, or NULL I none is selected. If the
135 * list is multi-select then elm_genlist_selected_items_get() will return a
136 * list (that is only valid as long as no items are modified (added, deleted,
137 * selected or unselected)).
139 * To help inspect list items you can jump to the item at the top of the list
140 * with elm_genlist_first_item_get() which will return the item pointer, and
141 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143 * and previous items respectively relative to the indicated item. Using
144 * these calls you can walk the entire item list/tree. Note that as a tree
145 * the items are flattened in the list, so elm_genlist_item_parent_get() will
146 * let you know which item is the parent (and thus know how to skip them if
149 * There are also convenience functions. elm_genlist_item_genlist_get() will
150 * return the genlist object the item belongs to. elm_genlist_item_show()
151 * will make the scroller scroll to show that specific item so its visible.
152 * elm_genlist_item_data_get() returns the data pointer set by the item
153 * creation functions.
155 * If an item changes (state of boolean changes, label or icons change),
156 * then use elm_genlist_item_update() to have genlist update the item with
157 * the new state. Genlist will re-realize the item thus call the functions
158 * in the _Elm_Genlist_Item_Class for that item.
160 * To programmatically (un)select an item use elm_genlist_item_selected_set().
161 * To get its selected state use elm_genlist_item_selected_get(). Similarly
162 * to expand/contract an item and get its expanded state, use
163 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164 * again to make an item disabled (unable to be selected and appear
165 * differently) use elm_genlist_item_disabled_set() to set this and
166 * elm_genlist_item_disabled_get() to get the disabled state.
168 * In general to indicate how the genlist should expand items horizontally to
169 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171 * mode means that if items are too wide to fit, the scroller will scroll
172 * horizontally. Otherwise items are expanded to fill the width of the
173 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174 * to the viewport width and limited to that size. This can be combined with
175 * a different style that uses edjes' ellipsis feature (cutting text off like
178 * Items will only call their selection func and callback when first becoming
179 * selected. Any further clicks will do nothing, unless you enable always
180 * select with elm_genlist_always_select_mode_set(). This means even if
181 * selected, every click will make the selected callbacks be called.
182 * elm_genlist_no_select_mode_set() will turn off the ability to select
183 * items entirely and they will neither appear selected nor call selected
184 * callback functions.
186 * Remember that you can create new styles and add your own theme augmentation
187 * per application with elm_theme_extension_add(). If you absolutely must
188 * have a specific style that overrides any theme the user or system sets up
189 * you can use elm_theme_overlay_add() to add such a file.
191 * Signals that you can add callbacks for are:
193 * "clicked,double" - This is called when a user has double-clicked an item. The
194 * event_info parameter is the genlist item that was double-c
196 * "selected" - This is called when a user has made an item selected. The
197 * event_info parameter is the genlist item that was selected.
198 * "unselected" - This is called when a user has made an item unselected. The
199 * event_info parameter is the genlist item that was unselected.
200 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201 * and the item is now meant to be expanded. The event_info
202 * parameter is the genlist item that was indicated to expand. It
203 * is the job of this callback to then fill in the child items.
204 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205 * and the item is now meant to be contracted. The event_info
206 * parameter is the genlist item that was indicated to contract.
207 * It is the job of this callback to then delete the child items.
208 * "expand,request" - This is called when a user has indicated they want to
209 * expand a tree branch item. The callback should decide if
210 * the item can expand (has any children) and then call
211 * elm_genlist_item_expanded_set() appropriately to set the
212 * state. The event_info parameter is the genlist item that
213 * was indicated to expand.
214 * "contract,request" - This is called when a user has indicated they want to
215 * contract a tree branch item. The callback should decide
216 * if the item can contract (has any children) and then
217 * call elm_genlist_item_expanded_set() appropriately to
218 * set the state. The event_info parameter is the genlist
219 * item that was indicated to contract.
220 * "realized" - This is called when the item in the list is created as a real
221 * evas object. event_info parameter is the genlist item that was
222 * created. The object may be deleted at any time, so it is up to
223 * the caller to not use the object pointer from
224 * elm_genlist_item_object_get() in a way where it may point to
226 * "unrealized" - This is called just before an item is unrealized. After this
227 * call icon objects provided will be deleted and the item object
228 * itself delete or be put into a floating cache.
229 * "drag,start,up" - This is called when the item in the list has been dragged
231 * "drag,start,down" - This is called when the item in the list has been dragged
232 * (not scrolled) down.
233 * "drag,start,left" - This is called when the item in the list has been dragged
234 * (not scrolled) left.
235 * "drag,start,right" - This is called when the item in the list has been
236 * dragged (not scrolled) right.
237 * "drag,stop" - This is called when the item in the list has stopped being
239 * "drag" - This is called when the item in the list is being dragged.
240 * "longpressed" - This is called when the item is pressed for a certain amount
241 * of time. By default it's 1 second.
242 * "scroll,edge,top" - This is called when the genlist is scrolled until the
244 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
246 * "scroll,edge,left" - This is called when the genlist is scrolled until the
248 * "scroll,edge,right" - This is called when the genlist is scrolled until the
250 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
252 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
254 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
257 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
259 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block Item_Block;
264 typedef struct _Pan Pan;
265 typedef struct _Item_Cache Item_Cache;
269 Evas_Object *obj, *scr, *pan_smart;
270 Eina_Inlist *items, *blocks;
271 Eina_List *group_items;
273 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
274 Ecore_Job *calc_job, *update_job;
275 Ecore_Idler *queue_idler;
276 Ecore_Idler *must_recalc_idler;
277 Eina_List *queue, *selected;
278 Elm_Genlist_Item *show_item;
279 Elm_Genlist_Item *last_selected_item;
280 Eina_Inlist *item_cache;
281 Elm_Genlist_Item *anchor_item;
284 Ecore_Timer *multi_timer;
285 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
286 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
287 Eina_Bool mouse_down : 1;
288 Eina_Bool multi_down : 1;
289 Eina_Bool multi_timeout : 1;
290 Eina_Bool multitouched : 1;
291 Eina_Bool on_hold : 1;
293 Eina_Bool always_select : 1;
294 Eina_Bool longpressed : 1;
295 Eina_Bool wasselected : 1;
296 Eina_Bool no_select : 1;
297 Eina_Bool bring_in : 1;
298 Eina_Bool compress : 1;
299 Eina_Bool height_for_width : 1;
300 Eina_Bool homogeneous : 1;
301 Eina_Bool clear_me : 1;
306 } history[SWIPE_MOVES];
308 int item_cache_count;
314 int group_item_width;
315 int group_item_height;
316 int max_items_per_block;
317 double longpress_timeout;
327 Evas_Coord x, y, w, h, minw, minh;
328 Eina_Bool want_unrealize : 1;
329 Eina_Bool realized : 1;
330 Eina_Bool changed : 1;
331 Eina_Bool updateme : 1;
332 Eina_Bool showme : 1;
333 Eina_Bool must_recalc : 1;
336 struct _Elm_Genlist_Item
338 Elm_Widget_Item base;
343 Evas_Coord x, y, w, h, minw, minh;
344 const Elm_Genlist_Item_Class *itc;
345 Elm_Genlist_Item *parent;
346 Elm_Genlist_Item *group_item;
347 Elm_Genlist_Item_Flags flags;
355 Eina_List *labels, *icons, *states, *icon_objs;
356 Ecore_Timer *long_timer;
357 Ecore_Timer *swipe_timer;
359 Evas_Coord scrl_x, scrl_y;
361 Elm_Genlist_Item *rel;
366 Elm_Tooltip_Item_Content_Cb content_cb;
367 Evas_Smart_Cb del_cb;
371 const char *mouse_cursor;
378 Eina_Bool before : 1;
380 Eina_Bool want_unrealize : 1;
381 Eina_Bool want_realize : 1;
382 Eina_Bool realized : 1;
383 Eina_Bool selected : 1;
384 Eina_Bool highlighted : 1;
385 Eina_Bool expanded : 1;
386 Eina_Bool disabled : 1;
387 Eina_Bool display_only : 1;
388 Eina_Bool mincalcd : 1;
389 Eina_Bool queued : 1;
390 Eina_Bool showme : 1;
391 Eina_Bool delete_me : 1;
393 Eina_Bool dragging : 1;
394 Eina_Bool updateme : 1;
395 Eina_Bool nocache : 1;
402 Evas_Object *base_view, *spacer;
404 const char *item_style; // it->itc->item_style
405 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
406 Eina_Bool compress : 1; // it->wd->compress
407 Eina_Bool odd : 1; // in & 0x1
409 Eina_Bool selected : 1; // it->selected
410 Eina_Bool disabled : 1; // it->disabled
411 Eina_Bool expanded : 1; // it->expanded
414 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
415 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
419 Evas_Object_Smart_Clipped_Data __clipped_data;
421 Ecore_Job *resize_job;
424 static const char *widtype = NULL;
425 static void _item_cache_zero(Widget_Data *wd);
426 static void _del_hook(Evas_Object *obj);
427 static void _mirrored_set(Evas_Object *obj,
429 static void _theme_hook(Evas_Object *obj);
430 static void _show_region_hook(void *data,
432 static void _sizing_eval(Evas_Object *obj);
433 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
434 static void _item_block_unrealize(Item_Block *itb);
435 static void _calc_job(void *data);
436 static void _on_focus_hook(void *data,
438 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
439 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
440 static Eina_Bool _item_single_select_up(Widget_Data *wd);
441 static Eina_Bool _item_single_select_down(Widget_Data *wd);
442 static Eina_Bool _event_hook(Evas_Object *obj,
444 Evas_Callback_Type type,
446 static void _signal_emit_hook(Evas_Object *obj,
447 const char *emission,
449 static Eina_Bool _deselect_all_items(Widget_Data *wd);
450 static void _pan_calculate(Evas_Object *obj);
452 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
455 _event_hook(Evas_Object *obj,
456 Evas_Object *src __UNUSED__,
457 Evas_Callback_Type type,
460 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
461 Evas_Event_Key_Down *ev = event_info;
462 Widget_Data *wd = elm_widget_data_get(obj);
463 if (!wd) return EINA_FALSE;
464 if (!wd->items) return EINA_FALSE;
465 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
466 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
468 Elm_Genlist_Item *it = NULL;
471 Evas_Coord step_x = 0;
472 Evas_Coord step_y = 0;
475 Evas_Coord page_x = 0;
476 Evas_Coord page_y = 0;
478 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
479 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
480 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
481 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
483 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
487 else if ((!strcmp(ev->keyname, "Right")) ||
488 (!strcmp(ev->keyname, "KP_Right")))
492 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
494 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
495 (_item_multi_select_up(wd)))
496 || (_item_single_select_up(wd)))
498 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
504 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
506 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
507 (_item_multi_select_down(wd)))
508 || (_item_single_select_down(wd)))
510 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
516 else if ((!strcmp(ev->keyname, "Home")) ||
517 (!strcmp(ev->keyname, "KP_Home")))
519 it = elm_genlist_first_item_get(obj);
520 elm_genlist_item_bring_in(it);
521 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
524 else if ((!strcmp(ev->keyname, "End")) ||
525 (!strcmp(ev->keyname, "KP_End")))
527 it = elm_genlist_last_item_get(obj);
528 elm_genlist_item_bring_in(it);
529 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
532 else if ((!strcmp(ev->keyname, "Prior")) ||
533 (!strcmp(ev->keyname, "KP_Prior")))
536 y -= -(page_y * v_h) / 100;
540 else if ((!strcmp(ev->keyname, "Next")) ||
541 (!strcmp(ev->keyname, "KP_Next")))
544 y += -(page_y * v_h) / 100;
548 else if(((!strcmp(ev->keyname, "Return")) ||
549 (!strcmp(ev->keyname, "KP_Enter")) ||
550 (!strcmp(ev->keyname, "space")))
551 && (!wd->multi) && (wd->selected))
553 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
554 elm_genlist_item_expanded_set(it,
555 !elm_genlist_item_expanded_get(it));
557 else if (!strcmp(ev->keyname, "Escape"))
559 if (!_deselect_all_items(wd)) return EINA_FALSE;
560 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
563 else return EINA_FALSE;
565 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
566 elm_smart_scroller_child_pos_set(wd->scr, x, y);
571 _deselect_all_items(Widget_Data *wd)
573 if (!wd->selected) return EINA_FALSE;
575 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
581 _item_multi_select_up(Widget_Data *wd)
583 if (!wd->selected) return EINA_FALSE;
584 if (!wd->multi) return EINA_FALSE;
586 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
587 if (!prev) return EINA_TRUE;
589 if (elm_genlist_item_selected_get(prev))
591 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
592 wd->last_selected_item = prev;
593 elm_genlist_item_show(wd->last_selected_item);
597 elm_genlist_item_selected_set(prev, EINA_TRUE);
598 elm_genlist_item_show(prev);
604 _item_multi_select_down(Widget_Data *wd)
606 if (!wd->selected) return EINA_FALSE;
607 if (!wd->multi) return EINA_FALSE;
609 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
610 if (!next) return EINA_TRUE;
612 if (elm_genlist_item_selected_get(next))
614 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
615 wd->last_selected_item = next;
616 elm_genlist_item_show(wd->last_selected_item);
620 elm_genlist_item_selected_set(next, EINA_TRUE);
621 elm_genlist_item_show(next);
627 _item_single_select_up(Widget_Data *wd)
629 Elm_Genlist_Item *prev;
632 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
633 while ((prev) && (prev->delete_me))
634 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
636 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
638 if (!prev) return EINA_FALSE;
640 _deselect_all_items(wd);
642 elm_genlist_item_selected_set(prev, EINA_TRUE);
643 elm_genlist_item_show(prev);
648 _item_single_select_down(Widget_Data *wd)
650 Elm_Genlist_Item *next;
653 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
654 while ((next) && (next->delete_me))
655 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
657 else next = elm_genlist_item_next_get(wd->last_selected_item);
659 if (!next) return EINA_FALSE;
661 _deselect_all_items(wd);
663 elm_genlist_item_selected_set(next, EINA_TRUE);
664 elm_genlist_item_show(next);
669 _on_focus_hook(void *data __UNUSED__,
672 Widget_Data *wd = elm_widget_data_get(obj);
674 if (elm_widget_focus_get(obj))
676 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
677 evas_object_focus_set(wd->obj, EINA_TRUE);
678 if ((wd->selected) && (!wd->last_selected_item))
679 wd->last_selected_item = eina_list_data_get(wd->selected);
683 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
684 evas_object_focus_set(wd->obj, EINA_FALSE);
689 _del_hook(Evas_Object *obj)
691 Widget_Data *wd = elm_widget_data_get(obj);
693 _item_cache_zero(wd);
694 if (wd->calc_job) ecore_job_del(wd->calc_job);
695 if (wd->update_job) ecore_job_del(wd->update_job);
696 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
697 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
702 _del_pre_hook(Evas_Object *obj)
704 Widget_Data *wd = elm_widget_data_get(obj);
706 evas_object_del(wd->pan_smart);
707 wd->pan_smart = NULL;
708 elm_genlist_clear(obj);
712 _mirrored_set(Evas_Object *obj,
715 Widget_Data *wd = elm_widget_data_get(obj);
717 _item_cache_zero(wd);
718 elm_smart_scroller_mirrored_set(wd->scr, rtl);
722 _theme_hook(Evas_Object *obj)
724 Widget_Data *wd = elm_widget_data_get(obj);
727 _item_cache_zero(wd);
728 _elm_widget_mirrored_reload(obj);
729 _mirrored_set(obj, elm_widget_mirrored_get(obj));
730 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
731 elm_widget_style_get(obj));
732 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
733 wd->item_width = wd->item_height = 0;
734 wd->group_item_width = wd->group_item_height = 0;
735 wd->minw = wd->minh = wd->realminw = 0;
736 EINA_INLIST_FOREACH(wd->blocks, itb)
739 Elm_Genlist_Item *it;
741 if (itb->realized) _item_block_unrealize(itb);
742 EINA_LIST_FOREACH(itb->items, l, it)
743 it->mincalcd = EINA_FALSE;
745 itb->changed = EINA_TRUE;
747 if (wd->calc_job) ecore_job_del(wd->calc_job);
748 wd->calc_job = ecore_job_add(_calc_job, wd);
753 _show_region_hook(void *data,
756 Widget_Data *wd = elm_widget_data_get(data);
757 Evas_Coord x, y, w, h;
759 elm_widget_show_region_get(obj, &x, &y, &w, &h);
760 //x & y are screen coordinates, Add with pan coordinates
763 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
767 _sizing_eval(Evas_Object *obj)
769 Widget_Data *wd = elm_widget_data_get(obj);
770 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
772 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
773 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
775 if (wd->height_for_width)
779 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
780 if ((vw != 0) && (vw != wd->prev_viewport_w))
784 wd->prev_viewport_w = vw;
785 EINA_INLIST_FOREACH(wd->blocks, itb)
787 itb->must_recalc = EINA_TRUE;
789 if (wd->calc_job) ecore_job_del(wd->calc_job);
790 wd->calc_job = ecore_job_add(_calc_job, wd);
793 if (wd->mode == ELM_LIST_LIMIT)
795 Evas_Coord vmw, vmh, vw, vh;
799 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
800 if ((minw > 0) && (vw < minw)) vw = minw;
801 else if ((maxw > 0) && (vw > maxw))
803 edje_object_size_min_calc
804 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
811 edje_object_size_min_calc
812 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
816 evas_object_size_hint_min_set(obj, minw, minh);
817 evas_object_size_hint_max_set(obj, maxw, maxh);
821 _signal_emit_hook(Evas_Object *obj,
822 const char *emission,
825 Widget_Data *wd = elm_widget_data_get(obj);
826 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
831 _item_highlight(Elm_Genlist_Item *it)
833 const char *selectraise;
834 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
835 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
836 selectraise = edje_object_data_get(it->base.view, "selectraise");
837 if ((selectraise) && (!strcmp(selectraise, "on")))
839 evas_object_raise(it->base.view);
840 if ((it->group_item) && (it->group_item->realized))
841 evas_object_raise(it->group_item->base.view);
843 it->highlighted = EINA_TRUE;
847 _item_block_del(Elm_Genlist_Item *it)
850 Item_Block *itb = it->block;
852 itb->items = eina_list_remove(itb->items, it);
854 itb->changed = EINA_TRUE;
855 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
856 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
859 il = EINA_INLIST_GET(itb);
860 Item_Block *itbn = (Item_Block *)(il->next);
862 it->parent->items = eina_list_remove(it->parent->items, it);
864 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
866 if (itbn) itbn->changed = EINA_TRUE;
872 il = EINA_INLIST_GET(itb);
873 Item_Block *itbp = (Item_Block *)(il->prev);
874 Item_Block *itbn = (Item_Block *)(il->next);
875 if ((itbp) && ((itbp->count + itb->count) < 48))
877 Elm_Genlist_Item *it2;
879 EINA_LIST_FREE(itb->items, it2)
882 itbp->items = eina_list_append(itbp->items, it2);
884 itbp->changed = EINA_TRUE;
886 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
887 EINA_INLIST_GET(itb));
890 else if ((itbn) && ((itbn->count + itb->count) < 48))
894 Eina_List *last = eina_list_last(itb->items);
895 Elm_Genlist_Item *it2 = last->data;
898 itb->items = eina_list_remove_list(itb->items, last);
899 itbn->items = eina_list_prepend(itbn->items, it2);
901 itbn->changed = EINA_TRUE;
904 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
912 _item_del(Elm_Genlist_Item *it)
914 elm_widget_item_pre_notify_del(it);
915 elm_genlist_item_subitems_clear(it);
916 it->wd->walking -= it->walking;
917 if (it->wd->show_item == it) it->wd->show_item = NULL;
918 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
919 if (it->realized) _item_unrealize(it, EINA_FALSE);
920 if (it->block) _item_block_del(it);
921 if ((!it->delete_me) && (it->itc->func.del))
922 it->itc->func.del((void *)it->base.data, it->base.widget);
923 it->delete_me = EINA_TRUE;
925 it->wd->queue = eina_list_remove(it->wd->queue, it);
926 if (it->wd->anchor_item == it)
928 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
929 if (!it->wd->anchor_item)
930 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
932 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
934 it->parent->items = eina_list_remove(it->parent->items, it);
935 if (it->flags & ELM_GENLIST_ITEM_GROUP)
936 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
937 if (it->long_timer) ecore_timer_del(it->long_timer);
938 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
940 if (it->tooltip.del_cb)
941 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
943 elm_widget_item_del(it);
947 _item_select(Elm_Genlist_Item *it)
949 if ((it->wd->no_select) || (it->delete_me)) return;
952 if (it->wd->always_select) goto call;
955 it->selected = EINA_TRUE;
956 it->wd->selected = eina_list_append(it->wd->selected, it);
960 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
962 evas_object_smart_callback_call(it->base.widget, "selected", it);
965 if ((it->wd->clear_me) && (!it->wd->walking))
966 elm_genlist_clear(it->base.widget);
969 if ((!it->walking) && (it->delete_me))
971 if (!it->relcount) _item_del(it);
974 it->wd->last_selected_item = it;
978 _item_unselect(Elm_Genlist_Item *it)
980 const char *stacking, *selectraise;
982 if ((it->delete_me) || (!it->highlighted)) return;
983 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
984 stacking = edje_object_data_get(it->base.view, "stacking");
985 selectraise = edje_object_data_get(it->base.view, "selectraise");
986 if ((selectraise) && (!strcmp(selectraise, "on")))
988 if ((stacking) && (!strcmp(stacking, "below")))
989 evas_object_lower(it->base.view);
991 it->highlighted = EINA_FALSE;
994 it->selected = EINA_FALSE;
995 it->wd->selected = eina_list_remove(it->wd->selected, it);
996 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1001 _mouse_move(void *data,
1002 Evas *evas __UNUSED__,
1006 Elm_Genlist_Item *it = data;
1007 Evas_Event_Mouse_Move *ev = event_info;
1008 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1010 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1012 if (!it->wd->on_hold)
1014 it->wd->on_hold = EINA_TRUE;
1015 if (!it->wd->wasselected)
1019 if (it->wd->multitouched)
1021 it->wd->cur_x = ev->cur.canvas.x;
1022 it->wd->cur_y = ev->cur.canvas.y;
1025 if ((it->dragging) && (it->down))
1027 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1030 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1031 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1032 if (abs((it->wd->history[it->wd->movements].x -
1033 it->wd->history[0].x)) > 40)
1034 it->wd->swipe = EINA_TRUE;
1036 it->wd->movements++;
1040 ecore_timer_del(it->long_timer);
1041 it->long_timer = NULL;
1043 evas_object_smart_callback_call(it->base.widget, "drag", it);
1046 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1050 ecore_timer_del(it->long_timer);
1051 it->long_timer = NULL;
1055 if (!it->display_only)
1056 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1057 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1058 x = ev->cur.canvas.x - x;
1059 y = ev->cur.canvas.y - y;
1062 if (adx < 0) adx = -dx;
1065 if (ady < 0) ady = -dy;
1068 if ((adx > minw) || (ady > minh))
1070 it->dragging = EINA_TRUE;
1073 ecore_timer_del(it->long_timer);
1074 it->long_timer = NULL;
1076 if (!it->wd->wasselected)
1081 evas_object_smart_callback_call(it->base.widget,
1082 "drag,start,up", it);
1086 evas_object_smart_callback_call(it->base.widget,
1087 "drag,start,left", it);
1089 evas_object_smart_callback_call(it->base.widget,
1090 "drag,start,right", it);
1096 evas_object_smart_callback_call(it->base.widget,
1097 "drag,start,down", it);
1101 evas_object_smart_callback_call(it->base.widget,
1102 "drag,start,left", it);
1104 evas_object_smart_callback_call(it->base.widget,
1105 "drag,start,right", it);
1112 _long_press(void *data)
1114 Elm_Genlist_Item *it = data;
1116 it->long_timer = NULL;
1117 if ((it->disabled) || (it->dragging) || (it->display_only))
1118 return ECORE_CALLBACK_CANCEL;
1119 it->wd->longpressed = EINA_TRUE;
1120 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1121 return ECORE_CALLBACK_CANCEL;
1125 _swipe(Elm_Genlist_Item *it)
1130 if ((it->display_only) || (it->disabled)) return;
1131 it->wd->swipe = EINA_FALSE;
1132 for (i = 0; i < it->wd->movements; i++)
1134 sum += it->wd->history[i].x;
1135 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1138 sum /= it->wd->movements;
1139 if (abs(sum - it->wd->history[0].x) <= 10) return;
1140 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1144 _swipe_cancel(void *data)
1146 Elm_Genlist_Item *it = data;
1148 if (!it) return ECORE_CALLBACK_CANCEL;
1149 it->wd->swipe = EINA_FALSE;
1150 it->wd->movements = 0;
1151 return ECORE_CALLBACK_RENEW;
1155 _multi_cancel(void *data)
1157 Widget_Data *wd = data;
1159 if (!wd) return ECORE_CALLBACK_CANCEL;
1160 wd->multi_timeout = EINA_TRUE;
1161 return ECORE_CALLBACK_RENEW;
1165 _multi_touch_gesture_eval(void *data)
1167 Elm_Genlist_Item *it = data;
1169 it->wd->multitouched = EINA_FALSE;
1170 if (it->wd->multi_timer)
1172 ecore_timer_del(it->wd->multi_timer);
1173 it->wd->multi_timer = NULL;
1175 if (it->wd->multi_timeout)
1177 it->wd->multi_timeout = EINA_FALSE;
1181 Evas_Coord minw = 0, minh = 0;
1182 Evas_Coord off_x, off_y, off_mx, off_my;
1184 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1185 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1186 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1187 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1188 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1190 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1192 if ((off_x + off_mx) > (off_y + off_my))
1194 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1195 evas_object_smart_callback_call(it->base.widget,
1196 "multi,swipe,right", it);
1197 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1198 evas_object_smart_callback_call(it->base.widget,
1199 "multi,swipe,left", it);
1200 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1201 evas_object_smart_callback_call(it->base.widget,
1202 "multi,pinch,out", it);
1204 evas_object_smart_callback_call(it->base.widget,
1205 "multi,pinch,in", it);
1209 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1210 evas_object_smart_callback_call(it->base.widget,
1211 "multi,swipe,down", it);
1212 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1213 evas_object_smart_callback_call(it->base.widget,
1214 "multi,swipe,up", it);
1215 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1216 evas_object_smart_callback_call(it->base.widget,
1217 "multi,pinch,out", it);
1219 evas_object_smart_callback_call(it->base.widget,
1220 "multi,pinch,in", it);
1223 it->wd->multi_timeout = EINA_FALSE;
1227 _multi_down(void *data,
1228 Evas *evas __UNUSED__,
1229 Evas_Object *obj __UNUSED__,
1232 Elm_Genlist_Item *it = data;
1233 Evas_Event_Multi_Down *ev = event_info;
1235 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1236 it->wd->multi_device = ev->device;
1237 it->wd->multi_down = EINA_TRUE;
1238 it->wd->multitouched = EINA_TRUE;
1239 it->wd->prev_mx = ev->canvas.x;
1240 it->wd->prev_my = ev->canvas.y;
1241 if (!it->wd->wasselected) _item_unselect(it);
1242 it->wd->wasselected = EINA_FALSE;
1243 it->wd->longpressed = EINA_FALSE;
1246 ecore_timer_del(it->long_timer);
1247 it->long_timer = NULL;
1251 it->dragging = EINA_FALSE;
1252 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1254 if (it->swipe_timer)
1256 ecore_timer_del(it->swipe_timer);
1257 it->swipe_timer = NULL;
1259 if (it->wd->on_hold)
1261 it->wd->swipe = EINA_FALSE;
1262 it->wd->movements = 0;
1263 it->wd->on_hold = EINA_FALSE;
1268 _multi_up(void *data,
1269 Evas *evas __UNUSED__,
1270 Evas_Object *obj __UNUSED__,
1273 Elm_Genlist_Item *it = data;
1274 Evas_Event_Multi_Up *ev = event_info;
1276 if (it->wd->multi_device != ev->device) return;
1277 it->wd->multi_device = 0;
1278 it->wd->multi_down = EINA_FALSE;
1279 if (it->wd->mouse_down) return;
1280 _multi_touch_gesture_eval(data);
1284 _multi_move(void *data,
1285 Evas *evas __UNUSED__,
1286 Evas_Object *obj __UNUSED__,
1289 Elm_Genlist_Item *it = data;
1290 Evas_Event_Multi_Move *ev = event_info;
1292 if (it->wd->multi_device != ev->device) return;
1293 it->wd->cur_mx = ev->cur.canvas.x;
1294 it->wd->cur_my = ev->cur.canvas.y;
1298 _mouse_down(void *data,
1299 Evas *evas __UNUSED__,
1303 Elm_Genlist_Item *it = data;
1304 Evas_Event_Mouse_Down *ev = event_info;
1307 if (ev->button != 1) return;
1308 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1310 it->wd->on_hold = EINA_TRUE;
1313 it->down = EINA_TRUE;
1314 it->dragging = EINA_FALSE;
1315 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1316 it->dx = ev->canvas.x - x;
1317 it->dy = ev->canvas.y - y;
1318 it->wd->mouse_down = EINA_TRUE;
1319 if (!it->wd->multitouched)
1321 it->wd->prev_x = ev->canvas.x;
1322 it->wd->prev_y = ev->canvas.y;
1323 it->wd->multi_timeout = EINA_FALSE;
1324 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1325 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1327 it->wd->longpressed = EINA_FALSE;
1328 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1329 else it->wd->on_hold = EINA_FALSE;
1330 if (it->wd->on_hold) return;
1331 it->wd->wasselected = it->selected;
1332 _item_highlight(it);
1333 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1334 if ((!it->disabled) && (!it->display_only))
1336 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1337 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1339 if (it->long_timer) ecore_timer_del(it->long_timer);
1340 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1341 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1343 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1346 it->long_timer = NULL;
1347 it->wd->swipe = EINA_FALSE;
1348 it->wd->movements = 0;
1352 _mouse_up(void *data,
1353 Evas *evas __UNUSED__,
1354 Evas_Object *obj __UNUSED__,
1357 Elm_Genlist_Item *it = data;
1358 Evas_Event_Mouse_Up *ev = event_info;
1359 Eina_Bool dragged = EINA_FALSE;
1361 if (ev->button != 1) return;
1362 it->down = EINA_FALSE;
1363 it->wd->mouse_down = EINA_FALSE;
1364 if (it->wd->multitouched)
1366 if (it->wd->multi_down) return;
1367 _multi_touch_gesture_eval(data);
1370 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1371 else it->wd->on_hold = EINA_FALSE;
1374 ecore_timer_del(it->long_timer);
1375 it->long_timer = NULL;
1379 it->dragging = EINA_FALSE;
1380 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1383 if (it->swipe_timer)
1385 ecore_timer_del(it->swipe_timer);
1386 it->swipe_timer = NULL;
1388 if (it->wd->multi_timer)
1390 ecore_timer_del(it->wd->multi_timer);
1391 it->wd->multi_timer = NULL;
1392 it->wd->multi_timeout = EINA_FALSE;
1394 if (it->wd->on_hold)
1396 if (it->wd->swipe) _swipe(data);
1397 it->wd->longpressed = EINA_FALSE;
1398 it->wd->on_hold = EINA_FALSE;
1401 if (it->wd->longpressed)
1403 it->wd->longpressed = EINA_FALSE;
1404 if (!it->wd->wasselected)
1406 it->wd->wasselected = EINA_FALSE;
1411 if (it->want_unrealize)
1413 _item_unrealize(it, EINA_FALSE);
1414 if (it->block->want_unrealize)
1415 _item_block_unrealize(it->block);
1418 if ((it->disabled) || (dragged) || (it->display_only)) return;
1419 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1424 _item_highlight(it);
1427 else _item_unselect(it);
1433 Widget_Data *wd = it->wd;
1436 while (wd->selected) _item_unselect(wd->selected->data);
1441 const Eina_List *l, *l_next;
1442 Elm_Genlist_Item *it2;
1444 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1445 if (it2 != it) _item_unselect(it2);
1446 //_item_highlight(it);
1449 _item_highlight(it);
1455 _signal_expand_toggle(void *data,
1456 Evas_Object *obj __UNUSED__,
1457 const char *emission __UNUSED__,
1458 const char *source __UNUSED__)
1460 Elm_Genlist_Item *it = data;
1463 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1465 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1469 _signal_expand(void *data,
1470 Evas_Object *obj __UNUSED__,
1471 const char *emission __UNUSED__,
1472 const char *source __UNUSED__)
1474 Elm_Genlist_Item *it = data;
1477 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1481 _signal_contract(void *data,
1482 Evas_Object *obj __UNUSED__,
1483 const char *emission __UNUSED__,
1484 const char *source __UNUSED__)
1486 Elm_Genlist_Item *it = data;
1489 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1493 _item_cache_clean(Widget_Data *wd)
1495 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1499 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1500 wd->item_cache = eina_inlist_remove(wd->item_cache,
1501 wd->item_cache->last);
1502 wd->item_cache_count--;
1503 if (itc->spacer) evas_object_del(itc->spacer);
1504 if (itc->base_view) evas_object_del(itc->base_view);
1505 if (itc->item_style) eina_stringshare_del(itc->item_style);
1511 _item_cache_zero(Widget_Data *wd)
1513 int pmax = wd->item_cache_max;
1514 wd->item_cache_max = 0;
1515 _item_cache_clean(wd);
1516 wd->item_cache_max = pmax;
1520 _item_cache_add(Elm_Genlist_Item *it)
1524 if (it->wd->item_cache_max <= 0)
1526 evas_object_del(it->base.view);
1527 it->base.view = NULL;
1528 evas_object_del(it->spacer);
1533 it->wd->item_cache_count++;
1534 itc = calloc(1, sizeof(Item_Cache));
1535 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1536 EINA_INLIST_GET(itc));
1537 itc->spacer = it->spacer;
1539 itc->base_view = it->base.view;
1540 it->base.view = NULL;
1541 evas_object_hide(itc->base_view);
1542 evas_object_move(itc->base_view, -9999, -9999);
1543 itc->item_style = eina_stringshare_add(it->itc->item_style);
1544 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1545 itc->compress = (it->wd->compress);
1546 itc->odd = (it->order_num_in & 0x1);
1547 itc->selected = it->selected;
1548 itc->disabled = it->disabled;
1549 itc->expanded = it->expanded;
1552 ecore_timer_del(it->long_timer);
1553 it->long_timer = NULL;
1555 if (it->swipe_timer)
1557 ecore_timer_del(it->swipe_timer);
1558 it->swipe_timer = NULL;
1560 // FIXME: other callbacks?
1561 edje_object_signal_callback_del_full(itc->base_view,
1562 "elm,action,expand,toggle",
1563 "elm", _signal_expand_toggle, it);
1564 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1566 _signal_expand, it);
1567 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1568 "elm", _signal_contract, it);
1569 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1571 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1573 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1575 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1577 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1579 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1581 _item_cache_clean(it->wd);
1585 _item_cache_find(Elm_Genlist_Item *it)
1588 Eina_Bool tree = 0, odd;
1590 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1591 odd = (it->order_num_in & 0x1);
1592 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1594 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1596 if ((itc->tree == tree) &&
1597 (itc->odd == odd) &&
1598 (itc->compress == it->wd->compress) &&
1599 (!strcmp(it->itc->item_style, itc->item_style)))
1601 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1602 EINA_INLIST_GET(itc));
1603 it->wd->item_cache_count--;
1611 _item_cache_free(Item_Cache *itc)
1613 if (itc->spacer) evas_object_del(itc->spacer);
1614 if (itc->base_view) evas_object_del(itc->base_view);
1615 if (itc->item_style) eina_stringshare_del(itc->item_style);
1620 _item_realize(Elm_Genlist_Item *it,
1624 Elm_Genlist_Item *it2;
1625 const char *stacking;
1626 const char *treesize;
1628 int depth, tsize = 20;
1629 Item_Cache *itc = NULL;
1631 if ((it->realized) || (it->delete_me)) return;
1632 it->order_num_in = in;
1635 it->nocache = EINA_FALSE;
1637 itc = _item_cache_find(it);
1640 it->base.view = itc->base_view;
1641 itc->base_view = NULL;
1642 it->spacer = itc->spacer;
1647 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1648 edje_object_scale_set(it->base.view,
1649 elm_widget_scale_get(it->base.widget) *
1650 _elm_config->scale);
1651 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1652 elm_widget_sub_object_add(it->base.widget, it->base.view);
1654 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1655 strncpy(buf, "tree", sizeof(buf));
1656 else strncpy(buf, "item", sizeof(buf));
1657 if (it->wd->compress)
1658 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1660 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1661 strncat(buf, "/", sizeof(buf) - strlen(buf));
1662 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1664 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1665 elm_widget_style_get(it->base.widget));
1666 edje_object_mirrored_set(it->base.view,
1667 elm_widget_mirrored_get(it->base.widget));
1669 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1670 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1671 elm_widget_sub_object_add(it->base.widget, it->spacer);
1673 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1675 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1677 it->expanded_depth = depth;
1678 treesize = edje_object_data_get(it->base.view, "treesize");
1679 if (treesize) tsize = atoi(treesize);
1680 evas_object_size_hint_min_set(it->spacer,
1681 (depth * tsize) * _elm_config->scale, 1);
1682 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1685 edje_object_signal_callback_add(it->base.view,
1686 "elm,action,expand,toggle",
1687 "elm", _signal_expand_toggle, it);
1688 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1689 "elm", _signal_expand, it);
1690 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1691 "elm", _signal_contract, it);
1692 stacking = edje_object_data_get(it->base.view, "stacking");
1695 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1696 else if (!strcmp(stacking, "above"))
1697 evas_object_raise(it->base.view);
1699 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1701 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1703 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1705 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1707 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1709 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1713 if (it->selected != itc->selected)
1716 edje_object_signal_emit(it->base.view,
1717 "elm,state,selected", "elm");
1719 if (it->disabled != itc->disabled)
1722 edje_object_signal_emit(it->base.view,
1723 "elm,state,disabled", "elm");
1725 if (it->expanded != itc->expanded)
1728 edje_object_signal_emit(it->base.view,
1729 "elm,state,expanded", "elm");
1735 edje_object_signal_emit(it->base.view,
1736 "elm,state,selected", "elm");
1738 edje_object_signal_emit(it->base.view,
1739 "elm,state,disabled", "elm");
1741 edje_object_signal_emit(it->base.view,
1742 "elm,state,expanded", "elm");
1746 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1748 /* homogenous genlist shortcut */
1751 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1753 it->w = it->minw = it->wd->group_item_width;
1754 it->h = it->minh = it->wd->group_item_height;
1758 it->w = it->minw = it->wd->item_width;
1759 it->h = it->minh = it->wd->item_height;
1761 it->mincalcd = EINA_TRUE;
1766 if (it->itc->func.label_get)
1772 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1774 EINA_LIST_FOREACH(it->labels, l, key)
1776 char *s = it->itc->func.label_get
1777 ((void *)it->base.data, it->base.widget, l->data);
1781 edje_object_part_text_set(it->base.view, l->data, s);
1785 edje_object_part_text_set(it->base.view, l->data, "");
1788 if (it->itc->func.icon_get)
1794 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1796 EINA_LIST_FOREACH(it->icons, l, key)
1798 Evas_Object *ic = it->itc->func.icon_get
1799 ((void *)it->base.data, it->base.widget, l->data);
1803 it->icon_objs = eina_list_append(it->icon_objs, ic);
1804 edje_object_part_swallow(it->base.view, key, ic);
1805 evas_object_show(ic);
1806 elm_widget_sub_object_add(it->base.widget, ic);
1810 if (it->itc->func.state_get)
1816 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1818 EINA_LIST_FOREACH(it->states, l, key)
1820 Eina_Bool on = it->itc->func.state_get
1821 ((void *)it->base.data, it->base.widget, l->data);
1825 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1826 edje_object_signal_emit(it->base.view, buf, "elm");
1830 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1831 edje_object_signal_emit(it->base.view, buf, "elm");
1837 Evas_Coord mw = -1, mh = -1;
1839 if (it->wd->height_for_width) mw = it->wd->w;
1841 if (!it->display_only)
1842 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1843 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1844 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1846 if (!it->display_only)
1847 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1848 it->w = it->minw = mw;
1849 it->h = it->minh = mh;
1850 it->mincalcd = EINA_TRUE;
1852 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1854 it->wd->group_item_width = mw;
1855 it->wd->group_item_height = mh;
1857 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1859 it->wd->item_width = mw;
1860 it->wd->item_height = mh;
1863 if (!calc) evas_object_show(it->base.view);
1866 if (it->tooltip.content_cb)
1868 elm_widget_item_tooltip_content_cb_set(it,
1869 it->tooltip.content_cb,
1870 it->tooltip.data, NULL);
1871 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1874 if (it->mouse_cursor)
1875 elm_widget_item_cursor_set(it, it->mouse_cursor);
1877 it->realized = EINA_TRUE;
1878 it->want_unrealize = EINA_FALSE;
1880 if (itc) _item_cache_free(itc);
1881 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1885 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1889 if (!it->realized) return;
1890 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1893 ecore_timer_del(it->long_timer);
1894 it->long_timer = NULL;
1898 evas_object_del(it->base.view);
1899 it->base.view = NULL;
1900 evas_object_del(it->spacer);
1905 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1906 _item_cache_add(it);
1908 elm_widget_stringlist_free(it->labels);
1910 elm_widget_stringlist_free(it->icons);
1912 elm_widget_stringlist_free(it->states);
1914 EINA_LIST_FREE(it->icon_objs, icon)
1915 evas_object_del(icon);
1918 it->realized = EINA_FALSE;
1919 it->want_unrealize = EINA_FALSE;
1923 _item_block_recalc(Item_Block *itb,
1929 Elm_Genlist_Item *it;
1930 Evas_Coord minw = 0, minh = 0;
1931 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1935 EINA_LIST_FOREACH(itb->items, l, it)
1937 if (it->delete_me) continue;
1938 showme |= it->showme;
1943 if (!it->mincalcd) changed = EINA_TRUE;
1946 _item_realize(it, in, EINA_TRUE);
1947 _item_unrealize(it, EINA_TRUE);
1952 _item_realize(it, in, EINA_TRUE);
1953 _item_unrealize(it, EINA_TRUE);
1957 _item_realize(it, in, EINA_FALSE);
1959 if (minw < it->minw) minw = it->minw;
1967 itb->changed = EINA_FALSE;
1968 /* force an evas norender to garbage collect deleted objects */
1969 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1974 _item_block_realize(Item_Block *itb,
1979 Elm_Genlist_Item *it;
1981 if (itb->realized) return;
1982 EINA_LIST_FOREACH(itb->items, l, it)
1984 if (it->delete_me) continue;
1985 if (full) _item_realize(it, in, EINA_FALSE);
1988 itb->realized = EINA_TRUE;
1989 itb->want_unrealize = EINA_FALSE;
1993 _item_block_unrealize(Item_Block *itb)
1996 Elm_Genlist_Item *it;
1997 Eina_Bool dragging = EINA_FALSE;
1999 if (!itb->realized) return;
2000 EINA_LIST_FOREACH(itb->items, l, it)
2002 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2006 dragging = EINA_TRUE;
2007 it->want_unrealize = EINA_TRUE;
2010 _item_unrealize(it, EINA_FALSE);
2015 itb->realized = EINA_FALSE;
2016 itb->want_unrealize = EINA_TRUE;
2019 itb->want_unrealize = EINA_FALSE;
2023 _item_block_position(Item_Block *itb,
2027 Elm_Genlist_Item *it;
2028 Elm_Genlist_Item *git;
2029 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2032 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2033 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2035 EINA_LIST_FOREACH(itb->items, l, it)
2037 if (it->delete_me) continue;
2041 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2042 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2044 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2045 cvx, cvy, cvw, cvh));
2046 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2048 if ((itb->realized) && (!it->realized))
2050 if (vis) _item_realize(it, in, EINA_FALSE);
2056 git = it->group_item;
2059 if (git->scrl_y < oy)
2061 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2062 git->scrl_y = (it->scrl_y + it->h) - git->h;
2063 git->want_realize = EINA_TRUE;
2065 evas_object_resize(it->base.view, it->w, it->h);
2066 evas_object_move(it->base.view,
2067 it->scrl_x, it->scrl_y);
2068 evas_object_show(it->base.view);
2072 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2079 if (vis) it->want_realize = EINA_TRUE;
2086 _group_items_recalc(void *data)
2088 Widget_Data *wd = data;
2090 Elm_Genlist_Item *git;
2092 EINA_LIST_FOREACH(wd->group_items, l, git)
2094 if (git->want_realize)
2097 _item_realize(git, 0, EINA_FALSE);
2098 evas_object_resize(git->base.view, wd->minw, git->h);
2099 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2100 evas_object_show(git->base.view);
2101 evas_object_raise(git->base.view);
2103 else if (!git->want_realize && git->realized)
2106 _item_unrealize(git, EINA_FALSE);
2112 _must_recalc_idler(void *data)
2114 Widget_Data *wd = data;
2115 if (wd->calc_job) ecore_job_del(wd->calc_job);
2116 wd->calc_job = ecore_job_add(_calc_job, wd);
2117 wd->must_recalc_idler = NULL;
2118 return ECORE_CALLBACK_CANCEL;
2122 _calc_job(void *data)
2124 Widget_Data *wd = data;
2126 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2127 Item_Block *chb = NULL;
2128 int in = 0, minw_change = 0;
2129 Eina_Bool changed = EINA_FALSE;
2131 Eina_Bool did_must_recalc = EINA_FALSE;
2134 t0 = ecore_time_get();
2135 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2139 // if (wd->height_for_width) changed = EINA_TRUE;
2142 EINA_INLIST_FOREACH(wd->blocks, itb)
2144 Eina_Bool showme = EINA_FALSE;
2147 showme = itb->showme;
2148 itb->showme = EINA_FALSE;
2151 if (itb->realized) _item_block_unrealize(itb);
2153 if ((itb->changed) || (changed) ||
2154 ((itb->must_recalc) && (!did_must_recalc)))
2156 if ((changed) || (itb->must_recalc))
2159 Elm_Genlist_Item *it;
2160 EINA_LIST_FOREACH(itb->items, l, it)
2161 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2162 itb->changed = EINA_TRUE;
2163 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2164 itb->must_recalc = EINA_FALSE;
2166 if (itb->realized) _item_block_unrealize(itb);
2167 showme = _item_block_recalc(itb, in, 0, 1);
2173 if (minw == -1) minw = itb->minw;
2174 else if ((!itb->must_recalc) && (minw < itb->minw))
2183 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2185 wd->show_item->showme = EINA_FALSE;
2187 elm_smart_scroller_region_bring_in(wd->scr,
2189 wd->show_item->block->x,
2191 wd->show_item->block->y,
2192 wd->show_item->block->w,
2195 elm_smart_scroller_child_region_show(wd->scr,
2197 wd->show_item->block->x,
2199 wd->show_item->block->y,
2200 wd->show_item->block->w,
2202 wd->show_item = NULL;
2207 EINA_INLIST_FOREACH(wd->blocks, itb)
2213 if ((chb) && (EINA_INLIST_GET(chb)->next))
2215 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2217 if (itb->realized) _item_block_unrealize(itb);
2220 wd->realminw = minw;
2221 if (minw < wd->w) minw = wd->w;
2222 if ((minw != wd->minw) || (minh != wd->minh))
2226 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2227 _sizing_eval(wd->obj);
2228 if ((wd->anchor_item) && (wd->anchor_item->block))
2230 Elm_Genlist_Item *it;
2233 it = wd->anchor_item;
2234 it_y = wd->anchor_y;
2235 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2236 it->block->y + it->y + it_y);
2237 wd->anchor_item = it;
2238 wd->anchor_y = it_y;
2241 t = ecore_time_get();
2242 if (did_must_recalc)
2244 if (!wd->must_recalc_idler)
2245 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2247 wd->calc_job = NULL;
2248 evas_object_smart_changed(wd->pan_smart);
2252 _update_job(void *data)
2254 Widget_Data *wd = data;
2257 int num, num0, position = 0, recalc = 0;
2259 wd->update_job = NULL;
2261 EINA_INLIST_FOREACH(wd->blocks, itb)
2263 Evas_Coord itminw, itminh;
2264 Elm_Genlist_Item *it;
2270 _item_block_position(itb, num);
2275 EINA_LIST_FOREACH(itb->items, l2, it)
2282 it->updateme = EINA_FALSE;
2285 _item_unrealize(it, EINA_FALSE);
2286 _item_realize(it, num, EINA_FALSE);
2291 _item_realize(it, num, EINA_TRUE);
2292 _item_unrealize(it, EINA_TRUE);
2294 if ((it->minw != itminw) || (it->minh != itminh))
2299 itb->updateme = EINA_FALSE;
2303 itb->changed = EINA_TRUE;
2304 _item_block_recalc(itb, num0, 0, 1);
2305 _item_block_position(itb, num0);
2310 if (wd->calc_job) ecore_job_del(wd->calc_job);
2311 wd->calc_job = ecore_job_add(_calc_job, wd);
2316 _pan_set(Evas_Object *obj,
2320 Pan *sd = evas_object_smart_data_get(obj);
2323 // Evas_Coord ow, oh;
2324 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2325 // ow = sd->wd->minw - ow;
2326 // if (ow < 0) ow = 0;
2327 // oh = sd->wd->minh - oh;
2328 // if (oh < 0) oh = 0;
2329 // if (x < 0) x = 0;
2330 // if (y < 0) y = 0;
2331 // if (x > ow) x = ow;
2332 // if (y > oh) y = oh;
2333 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2337 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2339 if ((itb->y + itb->h) > y)
2341 Elm_Genlist_Item *it;
2344 EINA_LIST_FOREACH(itb->items, l2, it)
2346 if ((itb->y + it->y) >= y)
2348 sd->wd->anchor_item = it;
2349 sd->wd->anchor_y = -(itb->y + it->y - y);
2356 evas_object_smart_changed(obj);
2360 _pan_get(Evas_Object *obj,
2364 Pan *sd = evas_object_smart_data_get(obj);
2366 if (x) *x = sd->wd->pan_x;
2367 if (y) *y = sd->wd->pan_y;
2371 _pan_max_get(Evas_Object *obj,
2375 Pan *sd = evas_object_smart_data_get(obj);
2378 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2379 ow = sd->wd->minw - ow;
2381 oh = sd->wd->minh - oh;
2388 _pan_min_get(Evas_Object *obj __UNUSED__,
2397 _pan_child_size_get(Evas_Object *obj,
2401 Pan *sd = evas_object_smart_data_get(obj);
2403 if (w) *w = sd->wd->minw;
2404 if (h) *h = sd->wd->minh;
2408 _pan_add(Evas_Object *obj)
2411 Evas_Object_Smart_Clipped_Data *cd;
2414 cd = evas_object_smart_data_get(obj);
2417 sd->__clipped_data = *cd;
2419 evas_object_smart_data_set(obj, sd);
2423 _pan_del(Evas_Object *obj)
2425 Pan *sd = evas_object_smart_data_get(obj);
2430 ecore_job_del(sd->resize_job);
2431 sd->resize_job = NULL;
2437 _pan_resize_job(void *data)
2440 _sizing_eval(sd->wd->obj);
2441 sd->resize_job = NULL;
2445 _pan_resize(Evas_Object *obj,
2449 Pan *sd = evas_object_smart_data_get(obj);
2452 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2453 if ((ow == w) && (oh == h)) return;
2454 if ((sd->wd->height_for_width) && (ow != w))
2456 if (sd->resize_job) ecore_job_del(sd->resize_job);
2457 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2459 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2460 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2464 _pan_calculate(Evas_Object *obj)
2466 Pan *sd = evas_object_smart_data_get(obj);
2468 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2470 Elm_Genlist_Item *git;
2473 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2474 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2475 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2477 git->want_realize = EINA_FALSE;
2479 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2481 itb->w = sd->wd->minw;
2482 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2483 itb->y - sd->wd->pan_y + oy,
2485 cvx, cvy, cvw, cvh))
2487 if ((!itb->realized) || (itb->changed))
2488 _item_block_realize(itb, in, 0);
2489 _item_block_position(itb, in);
2493 if (itb->realized) _item_block_unrealize(itb);
2497 _group_items_recalc(sd->wd);
2501 _pan_move(Evas_Object *obj,
2502 Evas_Coord x __UNUSED__,
2503 Evas_Coord y __UNUSED__)
2505 Pan *sd = evas_object_smart_data_get(obj);
2507 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2508 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2512 _hold_on(void *data __UNUSED__,
2514 void *event_info __UNUSED__)
2516 Widget_Data *wd = elm_widget_data_get(obj);
2518 elm_smart_scroller_hold_set(wd->scr, 1);
2522 _hold_off(void *data __UNUSED__,
2524 void *event_info __UNUSED__)
2526 Widget_Data *wd = elm_widget_data_get(obj);
2528 elm_smart_scroller_hold_set(wd->scr, 0);
2532 _freeze_on(void *data __UNUSED__,
2534 void *event_info __UNUSED__)
2536 Widget_Data *wd = elm_widget_data_get(obj);
2538 elm_smart_scroller_freeze_set(wd->scr, 1);
2542 _freeze_off(void *data __UNUSED__,
2544 void *event_info __UNUSED__)
2546 Widget_Data *wd = elm_widget_data_get(obj);
2548 elm_smart_scroller_freeze_set(wd->scr, 0);
2552 _scroll_edge_left(void *data,
2553 Evas_Object *scr __UNUSED__,
2554 void *event_info __UNUSED__)
2556 Evas_Object *obj = data;
2557 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2561 _scroll_edge_right(void *data,
2562 Evas_Object *scr __UNUSED__,
2563 void *event_info __UNUSED__)
2565 Evas_Object *obj = data;
2566 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2570 _scroll_edge_top(void *data,
2571 Evas_Object *scr __UNUSED__,
2572 void *event_info __UNUSED__)
2574 Evas_Object *obj = data;
2575 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2579 _scroll_edge_bottom(void *data,
2580 Evas_Object *scr __UNUSED__,
2581 void *event_info __UNUSED__)
2583 Evas_Object *obj = data;
2584 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2588 * Add a new Genlist object
2590 * @param parent The parent object
2591 * @return The new object or NULL if it cannot be created
2596 elm_genlist_add(Evas_Object *parent)
2601 Evas_Coord minw, minh;
2602 static Evas_Smart *smart = NULL;
2606 static Evas_Smart_Class sc;
2608 evas_object_smart_clipped_smart_set(&_pan_sc);
2610 sc.name = "elm_genlist_pan";
2611 sc.version = EVAS_SMART_CLASS_VERSION;
2614 sc.resize = _pan_resize;
2615 sc.move = _pan_move;
2616 sc.calculate = _pan_calculate;
2617 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2620 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2622 ELM_SET_WIDTYPE(widtype, "genlist");
2623 elm_widget_type_set(obj, "genlist");
2624 elm_widget_sub_object_add(parent, obj);
2625 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2626 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2627 elm_widget_data_set(obj, wd);
2628 elm_widget_del_hook_set(obj, _del_hook);
2629 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2630 elm_widget_theme_hook_set(obj, _theme_hook);
2631 elm_widget_can_focus_set(obj, EINA_TRUE);
2632 elm_widget_event_hook_set(obj, _event_hook);
2633 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2635 wd->scr = elm_smart_scroller_add(e);
2636 elm_smart_scroller_widget_set(wd->scr, obj);
2637 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2638 elm_widget_style_get(obj));
2639 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2640 _elm_config->thumbscroll_bounce_enable);
2641 elm_widget_resize_object_set(obj, wd->scr);
2643 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2644 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2646 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2647 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2651 wd->mode = ELM_LIST_SCROLL;
2652 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2653 wd->item_cache_max = wd->max_items_per_block * 2;
2654 wd->longpress_timeout = _elm_config->longpress_timeout;
2656 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2657 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2658 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2659 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2661 wd->pan_smart = evas_object_smart_add(e, smart);
2662 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2665 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2666 _pan_set, _pan_get, _pan_max_get,
2667 _pan_min_get, _pan_child_size_get);
2669 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2671 evas_object_size_hint_min_set(obj, minw, minh);
2673 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2678 static Elm_Genlist_Item *
2679 _item_new(Widget_Data *wd,
2680 const Elm_Genlist_Item_Class *itc,
2682 Elm_Genlist_Item *parent,
2683 Elm_Genlist_Item_Flags flags,
2685 const void *func_data)
2687 Elm_Genlist_Item *it;
2689 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2690 if (!it) return NULL;
2693 it->base.data = data;
2694 it->parent = parent;
2696 it->func.func = func;
2697 it->func.data = func_data;
2698 it->mouse_cursor = NULL;
2699 it->expanded_depth = 0;
2704 _item_block_add(Widget_Data *wd,
2705 Elm_Genlist_Item *it)
2707 Item_Block *itb = NULL;
2714 itb = calloc(1, sizeof(Item_Block));
2717 if (!it->rel->block)
2720 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2721 itb->items = eina_list_append(itb->items, it);
2727 wd->blocks = eina_inlist_prepend_relative
2728 (wd->blocks, EINA_INLIST_GET(itb),
2729 EINA_INLIST_GET(it->rel->block));
2731 eina_list_prepend_relative(itb->items, it, it->rel);
2735 wd->blocks = eina_inlist_append_relative
2736 (wd->blocks, EINA_INLIST_GET(itb),
2737 EINA_INLIST_GET(it->rel->block));
2739 eina_list_append_relative(itb->items, it, it->rel);
2749 itb = (Item_Block *)(wd->blocks);
2750 if (itb->count >= wd->max_items_per_block)
2752 itb = calloc(1, sizeof(Item_Block));
2756 eina_inlist_prepend(wd->blocks,
2757 EINA_INLIST_GET(itb));
2762 itb = calloc(1, sizeof(Item_Block));
2766 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2768 itb->items = eina_list_prepend(itb->items, it);
2774 itb = (Item_Block *)(wd->blocks->last);
2775 if (itb->count >= wd->max_items_per_block)
2777 itb = calloc(1, sizeof(Item_Block));
2781 eina_inlist_append(wd->blocks,
2782 EINA_INLIST_GET(itb));
2787 itb = calloc(1, sizeof(Item_Block));
2791 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2793 itb->items = eina_list_append(itb->items, it);
2799 itb = it->rel->block;
2800 if (!itb) goto newblock;
2802 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2804 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2807 itb->changed = EINA_TRUE;
2809 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2810 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2813 it->rel->relcount--;
2814 if ((it->rel->delete_me) && (!it->rel->relcount))
2818 if (itb->count > itb->wd->max_items_per_block)
2822 Elm_Genlist_Item *it2;
2824 newc = itb->count / 2;
2825 itb2 = calloc(1, sizeof(Item_Block));
2829 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2830 EINA_INLIST_GET(itb));
2831 itb2->changed = EINA_TRUE;
2832 while ((itb->count > newc) && (itb->items))
2836 l = eina_list_last(itb->items);
2838 itb->items = eina_list_remove_list(itb->items, l);
2841 itb2->items = eina_list_prepend(itb2->items, it2);
2849 _queue_process(Widget_Data *wd,
2853 Eina_Bool showme = EINA_FALSE;
2856 t0 = ecore_time_get();
2857 for (n = 0; (wd->queue) && (n < 128); n++)
2859 Elm_Genlist_Item *it;
2861 it = wd->queue->data;
2862 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2863 it->queued = EINA_FALSE;
2864 _item_block_add(wd, it);
2865 t = ecore_time_get();
2866 if (it->block->changed)
2868 showme = _item_block_recalc(it->block, it->block->num, 1,
2870 it->block->changed = 0;
2872 if (showme) it->block->showme = EINA_TRUE;
2873 if (eina_inlist_count(wd->blocks) > 1)
2875 if ((t - t0) > (ecore_animator_frametime_get())) break;
2882 _item_idler(void *data)
2884 Widget_Data *wd = data;
2887 //static double q_start = 0.0;
2888 //if (q_start == 0.0) q_start = ecore_time_get();
2891 if (_queue_process(wd, 1) > 0)
2893 if (wd->calc_job) ecore_job_del(wd->calc_job);
2894 wd->calc_job = ecore_job_add(_calc_job, wd);
2899 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2901 wd->queue_idler = NULL;
2902 return ECORE_CALLBACK_CANCEL;
2904 return ECORE_CALLBACK_RENEW;
2908 _item_queue(Widget_Data *wd,
2909 Elm_Genlist_Item *it)
2911 if (it->queued) return;
2912 it->queued = EINA_TRUE;
2913 wd->queue = eina_list_append(wd->queue, it);
2914 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2916 if (wd->queue_idler)
2918 ecore_idler_del(wd->queue_idler);
2919 wd->queue_idler = NULL;
2921 _queue_process(wd, 0);
2923 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2927 * Append item to the end of the genlist
2929 * This appends the given item to the end of the list or the end of
2930 * the children if the parent is given.
2932 * @param obj The genlist object
2933 * @param itc The item class for the item
2934 * @param data The item data
2935 * @param parent The parent item, or NULL if none
2936 * @param flags Item flags
2937 * @param func Convenience function called when item selected
2938 * @param func_data Data passed to @p func above.
2939 * @return A handle to the item added or NULL if not possible
2943 EAPI Elm_Genlist_Item *
2944 elm_genlist_item_append(Evas_Object *obj,
2945 const Elm_Genlist_Item_Class *itc,
2947 Elm_Genlist_Item *parent,
2948 Elm_Genlist_Item_Flags flags,
2950 const void *func_data)
2952 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2953 Widget_Data *wd = elm_widget_data_get(obj);
2954 if (!wd) return NULL;
2955 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2957 if (!it) return NULL;
2960 if (flags & ELM_GENLIST_ITEM_GROUP)
2961 wd->group_items = eina_list_append(wd->group_items, it);
2962 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2967 Elm_Genlist_Item *it2 = NULL;
2968 Eina_List *ll = eina_list_last(it->parent->items);
2969 if (ll) it2 = ll->data;
2970 it->parent->items = eina_list_append(it->parent->items, it);
2971 if (!it2) it2 = it->parent;
2973 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2974 EINA_INLIST_GET(it2));
2976 it->rel->relcount++;
2978 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2979 it->group_item = parent;
2980 else if (it->parent->group_item)
2981 it->group_item = it->parent->group_item;
2983 it->before = EINA_FALSE;
2984 _item_queue(wd, it);
2989 * Prepend item at start of the genlist
2991 * This adds an item to the beginning of the list or beginning of the
2992 * children of the parent if given.
2994 * @param obj The genlist object
2995 * @param itc The item class for the item
2996 * @param data The item data
2997 * @param parent The parent item, or NULL if none
2998 * @param flags Item flags
2999 * @param func Convenience function called when item selected
3000 * @param func_data Data passed to @p func above.
3001 * @return A handle to the item added or NULL if not possible
3005 EAPI Elm_Genlist_Item *
3006 elm_genlist_item_prepend(Evas_Object *obj,
3007 const Elm_Genlist_Item_Class *itc,
3009 Elm_Genlist_Item *parent,
3010 Elm_Genlist_Item_Flags flags,
3012 const void *func_data)
3014 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3015 Widget_Data *wd = elm_widget_data_get(obj);
3016 if (!wd) return NULL;
3017 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3019 if (!it) return NULL;
3022 if (flags & ELM_GENLIST_ITEM_GROUP)
3023 wd->group_items = eina_list_prepend(wd->group_items, it);
3024 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3029 Elm_Genlist_Item *it2 = NULL;
3030 Eina_List *ll = it->parent->items;
3031 if (ll) it2 = ll->data;
3032 it->parent->items = eina_list_prepend(it->parent->items, it);
3033 if (!it2) it2 = it->parent;
3035 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3036 EINA_INLIST_GET(it2));
3038 it->rel->relcount++;
3040 it->before = EINA_TRUE;
3041 _item_queue(wd, it);
3046 * Insert item before another in the genlist
3048 * This inserts an item before another in the list. It will be in the
3049 * same tree level or group as the item it is inseted before.
3051 * @param obj The genlist object
3052 * @param itc The item class for the item
3053 * @param data The item data
3054 * @param before The item to insert before
3055 * @param flags Item flags
3056 * @param func Convenience function called when item selected
3057 * @param func_data Data passed to @p func above.
3058 * @return A handle to the item added or NULL if not possible
3062 EAPI Elm_Genlist_Item *
3063 elm_genlist_item_insert_before(Evas_Object *obj,
3064 const Elm_Genlist_Item_Class *itc,
3066 Elm_Genlist_Item *parent,
3067 Elm_Genlist_Item *before,
3068 Elm_Genlist_Item_Flags flags,
3070 const void *func_data)
3072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3073 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3074 Widget_Data *wd = elm_widget_data_get(obj);
3075 if (!wd) return NULL;
3076 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3078 if (!it) return NULL;
3081 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3084 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3085 EINA_INLIST_GET(before));
3087 it->rel->relcount++;
3088 it->before = EINA_TRUE;
3089 _item_queue(wd, it);
3094 * Insert an item after another in the genlst
3096 * This inserts an item after another in the list. It will be in the
3097 * same tree level or group as the item it is inseted after.
3099 * @param obj The genlist object
3100 * @param itc The item class for the item
3101 * @param data The item data
3102 * @param after The item to insert after
3103 * @param flags Item flags
3104 * @param func Convenience function called when item selected
3105 * @param func_data Data passed to @p func above.
3106 * @return A handle to the item added or NULL if not possible
3110 EAPI Elm_Genlist_Item *
3111 elm_genlist_item_insert_after(Evas_Object *obj,
3112 const Elm_Genlist_Item_Class *itc,
3114 Elm_Genlist_Item *parent,
3115 Elm_Genlist_Item *after,
3116 Elm_Genlist_Item_Flags flags,
3118 const void *func_data)
3120 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3121 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3122 Widget_Data *wd = elm_widget_data_get(obj);
3123 if (!wd) return NULL;
3124 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3126 if (!it) return NULL;
3127 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3128 EINA_INLIST_GET(after));
3131 it->parent->items = eina_list_append_relative(it->parent->items, it,
3135 it->rel->relcount++;
3136 it->before = EINA_FALSE;
3137 _item_queue(wd, it);
3144 * This clears all items in the list, leaving it empty.
3146 * @param obj The genlist object
3151 elm_genlist_clear(Evas_Object *obj)
3153 ELM_CHECK_WIDTYPE(obj, widtype);
3154 Widget_Data *wd = elm_widget_data_get(obj);
3156 if (wd->walking > 0)
3158 Elm_Genlist_Item *it;
3160 wd->clear_me = EINA_TRUE;
3161 EINA_INLIST_FOREACH(wd->items, it)
3163 it->delete_me = EINA_TRUE;
3169 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3171 if (wd->anchor_item == it)
3173 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3174 if (!wd->anchor_item)
3176 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3178 wd->items = eina_inlist_remove(wd->items, wd->items);
3179 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3180 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3181 elm_widget_item_pre_notify_del(it);
3182 if (it->realized) _item_unrealize(it, EINA_FALSE);
3183 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3184 it->itc->func.del((void *)it->base.data, it->base.widget);
3185 if (it->long_timer) ecore_timer_del(it->long_timer);
3186 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3187 elm_widget_item_del(it);
3189 wd->clear_me = EINA_FALSE;
3190 wd->anchor_item = NULL;
3193 Item_Block *itb = (Item_Block *)(wd->blocks);
3195 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3196 if (itb->items) eina_list_free(itb->items);
3201 ecore_job_del(wd->calc_job);
3202 wd->calc_job = NULL;
3204 if (wd->queue_idler)
3206 ecore_idler_del(wd->queue_idler);
3207 wd->queue_idler = NULL;
3209 if (wd->must_recalc_idler)
3211 ecore_idler_del(wd->must_recalc_idler);
3212 wd->must_recalc_idler = NULL;
3216 eina_list_free(wd->queue);
3221 eina_list_free(wd->selected);
3222 wd->selected = NULL;
3224 wd->show_item = NULL;
3231 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3232 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3238 * Enable or disable multi-select in the genlist
3240 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3241 * the list. This allows more than 1 item to be selected.
3243 * @param obj The genlist object
3244 * @param multi Multi-select enable/disable
3249 elm_genlist_multi_select_set(Evas_Object *obj,
3252 ELM_CHECK_WIDTYPE(obj, widtype);
3253 Widget_Data *wd = elm_widget_data_get(obj);
3259 * Gets if multi-select in genlist is enable or disable
3261 * @param obj The genlist object
3262 * @return Multi-select enable/disable
3263 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3268 elm_genlist_multi_select_get(const Evas_Object *obj)
3270 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3271 Widget_Data *wd = elm_widget_data_get(obj);
3272 if (!wd) return EINA_FALSE;
3277 * Get the selectd item in the genlist
3279 * This gets the selected item in the list (if multi-select is enabled
3280 * only the first item in the list is selected - which is not very
3281 * useful, so see elm_genlist_selected_items_get() for when
3282 * multi-select is used).
3284 * If no item is selected, NULL is returned.
3286 * @param obj The genlist object
3287 * @return The selected item, or NULL if none.
3291 EAPI Elm_Genlist_Item *
3292 elm_genlist_selected_item_get(const Evas_Object *obj)
3294 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3295 Widget_Data *wd = elm_widget_data_get(obj);
3296 if (!wd) return NULL;
3297 if (wd->selected) return wd->selected->data;
3302 * Get a list of selected items in the genlist
3304 * This returns a list of the selected items. This list pointer is
3305 * only valid so long as no items are selected or unselected (or
3306 * unselected implicitly by deletion). The list contains
3307 * Elm_Genlist_Item pointers.
3309 * @param obj The genlist object
3310 * @return The list of selected items, nor NULL if none are selected.
3314 EAPI const Eina_List *
3315 elm_genlist_selected_items_get(const Evas_Object *obj)
3317 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3318 Widget_Data *wd = elm_widget_data_get(obj);
3319 if (!wd) return NULL;
3320 return wd->selected;
3324 * Get a list of realized items in genlist
3326 * This returns a list of the realized items in the genlist. The list
3327 * contains Elm_Genlist_Item pointers. The list must be freed by the
3328 * caller when done with eina_list_free(). The item pointers in the
3329 * list are only valid so long as those items are not deleted or the
3330 * genlist is not deleted.
3332 * @param obj The genlist object
3333 * @return The list of realized items, nor NULL if none are realized.
3338 elm_genlist_realized_items_get(const Evas_Object *obj)
3340 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3341 Widget_Data *wd = elm_widget_data_get(obj);
3342 Eina_List *list = NULL;
3344 Eina_Bool done = EINA_FALSE;
3345 if (!wd) return NULL;
3346 EINA_INLIST_FOREACH(wd->blocks, itb)
3351 Elm_Genlist_Item *it;
3354 EINA_LIST_FOREACH(itb->items, l, it)
3356 if (it->realized) list = eina_list_append(list, it);
3368 * Get the item that is at the x, y canvas coords
3370 * This returns the item at the given coordinates (which are canvas
3371 * relative not object-relative). If an item is at that coordinate,
3372 * that item handle is returned, and if @p posret is not NULL, the
3373 * integer pointed to is set to a value of -1, 0 or 1, depending if
3374 * the coordinate is on the upper portion of that item (-1), on the
3375 * middle section (0) or on the lower part (1). If NULL is returned as
3376 * an item (no item found there), then posret may indicate -1 or 1
3377 * based if the coordinate is above or below all items respectively in
3380 * @param it The item
3381 * @param x The input x coordinate
3382 * @param y The input y coordinate
3383 * @param posret The position relative to the item returned here
3384 * @return The item at the coordinates or NULL if none
3388 EAPI Elm_Genlist_Item *
3389 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3395 Widget_Data *wd = elm_widget_data_get(obj);
3396 Evas_Coord ox, oy, ow, oh;
3399 if (!wd) return NULL;
3400 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3402 EINA_INLIST_FOREACH(wd->blocks, itb)
3405 Elm_Genlist_Item *it;
3407 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3408 oy + itb->y - itb->wd->pan_y,
3409 itb->w, itb->h, x, y, 1, 1))
3411 EINA_LIST_FOREACH(itb->items, l, it)
3413 Evas_Coord itx, ity;
3415 itx = ox + itb->x + it->x - itb->wd->pan_x;
3416 ity = oy + itb->y + it->y - itb->wd->pan_y;
3417 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3421 if (y <= (ity + (it->h / 4))) *posret = -1;
3422 else if (y >= (ity + it->h - (it->h / 4)))
3428 lasty = ity + it->h;
3433 if (y > lasty) *posret = 1;
3440 * Get the first item in the genlist
3442 * This returns the first item in the list.
3444 * @param obj The genlist object
3445 * @return The first item, or NULL if none
3449 EAPI Elm_Genlist_Item *
3450 elm_genlist_first_item_get(const Evas_Object *obj)
3452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3453 Widget_Data *wd = elm_widget_data_get(obj);
3454 if (!wd) return NULL;
3455 if (!wd->items) return NULL;
3456 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3457 while ((it) && (it->delete_me))
3458 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3463 * Get the last item in the genlist
3465 * This returns the last item in the list.
3467 * @return The last item, or NULL if none
3471 EAPI Elm_Genlist_Item *
3472 elm_genlist_last_item_get(const Evas_Object *obj)
3474 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3475 Widget_Data *wd = elm_widget_data_get(obj);
3476 if (!wd) return NULL;
3477 if (!wd->items) return NULL;
3478 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3479 while ((it) && (it->delete_me))
3480 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3485 * Get the next item in the genlist
3487 * This returns the item after the item @p it.
3489 * @param it The item
3490 * @return The item after @p it, or NULL if none
3494 EAPI Elm_Genlist_Item *
3495 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3497 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3500 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3501 if ((it) && (!it->delete_me)) break;
3503 return (Elm_Genlist_Item *)it;
3507 * Get the previous item in the genlist
3509 * This returns the item before the item @p it.
3511 * @param it The item
3512 * @return The item before @p it, or NULL if none
3516 EAPI Elm_Genlist_Item *
3517 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3519 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3522 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3523 if ((it) && (!it->delete_me)) break;
3525 return (Elm_Genlist_Item *)it;
3529 * Get the genlist object from an item
3531 * This returns the genlist object itself that an item belongs to.
3533 * @param it The item
3534 * @return The genlist object
3539 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3541 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3542 return it->base.widget;
3546 * Get the parent item of the given item
3548 * This returns the parent item of the item @p it given.
3550 * @param it The item
3551 * @return The parent of the item or NULL if none
3555 EAPI Elm_Genlist_Item *
3556 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3558 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3563 * Clear all sub-items (children) of the given item
3565 * This clears all items that are children (or their descendants) of the
3568 * @param it The item
3573 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3575 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3576 Eina_List *tl = NULL, *l;
3577 Elm_Genlist_Item *it2;
3579 EINA_LIST_FOREACH(it->items, l, it2)
3580 tl = eina_list_append(tl, it2);
3581 EINA_LIST_FREE(tl, it2)
3582 elm_genlist_item_del(it2);
3586 * Set the selected state of an item
3588 * This sets the selected state (1 selected, 0 not selected) of the given
3591 * @param it The item
3592 * @param selected The selected state
3597 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3600 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3601 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3603 if (it->delete_me) return;
3604 selected = !!selected;
3605 if (it->selected == selected) return;
3611 while (wd->selected)
3612 _item_unselect(wd->selected->data);
3614 _item_highlight(it);
3622 * Get the selected state of an item
3624 * This gets the selected state of an item (1 selected, 0 not selected).
3626 * @param it The item
3627 * @return The selected state
3632 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3634 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3635 return it->selected;
3639 * Sets the expanded state of an item (if it's a parent)
3641 * This expands or contracts a parent item (thus showing or hiding the
3644 * @param it The item
3645 * @param expanded The expanded state (1 expanded, 0 not expanded).
3650 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3653 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3654 if (it->expanded == expanded) return;
3655 it->expanded = expanded;
3659 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3660 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3665 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3666 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3671 * Get the expanded state of an item
3673 * This gets the expanded state of an item
3675 * @param it The item
3676 * @return Thre expanded state
3681 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3683 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3684 return it->expanded;
3688 * Get the depth of expanded item
3690 * @param it The genlist item object
3691 * @return The depth of expanded item
3696 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3698 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3699 return it->expanded_depth;
3703 * Sets the disabled state of an item.
3705 * A disabled item cannot be selected or unselected. It will also
3706 * change appearance to appear disabled. This sets the disabled state
3707 * (1 disabled, 0 not disabled).
3709 * @param it The item
3710 * @param disabled The disabled state
3715 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3718 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3719 if (it->disabled == disabled) return;
3720 if (it->delete_me) return;
3721 it->disabled = disabled;
3725 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3727 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3732 * Get the disabled state of an item
3734 * This gets the disabled state of the given item.
3736 * @param it The item
3737 * @return The disabled state
3742 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3744 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3745 if (it->delete_me) return EINA_FALSE;
3746 return it->disabled;
3750 * Sets the display only state of an item.
3752 * A display only item cannot be selected or unselected. It is for
3753 * display only and not selecting or otherwise clicking, dragging
3754 * etc. by the user, thus finger size rules will not be applied to
3757 * @param it The item
3758 * @param display_only The display only state
3763 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3764 Eina_Bool display_only)
3766 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3767 if (it->display_only == display_only) return;
3768 if (it->delete_me) return;
3769 it->display_only = display_only;
3770 it->mincalcd = EINA_FALSE;
3771 it->updateme = EINA_TRUE;
3772 if (it->block) it->block->updateme = EINA_TRUE;
3773 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3774 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3778 * Get the display only state of an item
3780 * This gets the display only state of the given item.
3782 * @param it The item
3783 * @return The display only state
3788 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3790 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3791 if (it->delete_me) return EINA_FALSE;
3792 return it->display_only;
3796 * Show the given item
3798 * This causes genlist to jump to the given item @p it and show it (by
3799 * scrolling), if it is not fully visible.
3801 * @param it The item
3806 elm_genlist_item_show(Elm_Genlist_Item *it)
3808 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3809 Evas_Coord gith = 0;
3810 if (it->delete_me) return;
3811 if ((it->queued) || (!it->mincalcd))
3813 it->wd->show_item = it;
3814 it->wd->bring_in = EINA_TRUE;
3815 it->showme = EINA_TRUE;
3818 if (it->wd->show_item)
3820 it->wd->show_item->showme = EINA_FALSE;
3821 it->wd->show_item = NULL;
3823 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3824 gith = it->group_item->h;
3825 elm_smart_scroller_child_region_show(it->wd->scr,
3826 it->x + it->block->x,
3827 it->y + it->block->y - gith,
3828 it->block->w, it->h);
3832 * Bring in the given item
3834 * This causes genlist to jump to the given item @p it and show it (by
3835 * scrolling), if it is not fully visible. This may use animation to
3836 * do so and take a period of time
3838 * @param it The item
3843 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3845 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3846 Evas_Coord gith = 0;
3847 if (it->delete_me) return;
3848 if ((it->queued) || (!it->mincalcd))
3850 it->wd->show_item = it;
3851 it->wd->bring_in = EINA_TRUE;
3852 it->showme = EINA_TRUE;
3855 if (it->wd->show_item)
3857 it->wd->show_item->showme = EINA_FALSE;
3858 it->wd->show_item = NULL;
3860 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3861 gith = it->group_item->h;
3862 elm_smart_scroller_region_bring_in(it->wd->scr,
3863 it->x + it->block->x,
3864 it->y + it->block->y - gith,
3865 it->block->w, it->h);
3869 * Show the given item at the top
3871 * This causes genlist to jump to the given item @p it and show it (by
3872 * scrolling), if it is not fully visible.
3874 * @param it The item
3879 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3881 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3883 Evas_Coord gith = 0;
3885 if (it->delete_me) return;
3886 if ((it->queued) || (!it->mincalcd))
3888 it->wd->show_item = it;
3889 it->wd->bring_in = EINA_TRUE;
3890 it->showme = EINA_TRUE;
3893 if (it->wd->show_item)
3895 it->wd->show_item->showme = EINA_FALSE;
3896 it->wd->show_item = NULL;
3898 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3899 if (it->group_item) gith = it->group_item->h;
3900 elm_smart_scroller_child_region_show(it->wd->scr,
3901 it->x + it->block->x,
3902 it->y + it->block->y - gith,
3907 * Bring in the given item at the top
3909 * This causes genlist to jump to the given item @p it and show it (by
3910 * scrolling), if it is not fully visible. This may use animation to
3911 * do so and take a period of time
3913 * @param it The item
3918 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3920 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3922 Evas_Coord gith = 0;
3924 if (it->delete_me) return;
3925 if ((it->queued) || (!it->mincalcd))
3927 it->wd->show_item = it;
3928 it->wd->bring_in = EINA_TRUE;
3929 it->showme = EINA_TRUE;
3932 if (it->wd->show_item)
3934 it->wd->show_item->showme = EINA_FALSE;
3935 it->wd->show_item = NULL;
3937 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3938 if (it->group_item) gith = it->group_item->h;
3939 elm_smart_scroller_region_bring_in(it->wd->scr,
3940 it->x + it->block->x,
3941 it->y + it->block->y - gith,
3946 * Show the given item at the middle
3948 * This causes genlist to jump to the given item @p it and show it (by
3949 * scrolling), if it is not fully visible.
3951 * @param it The item
3956 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3958 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3961 if (it->delete_me) return;
3962 if ((it->queued) || (!it->mincalcd))
3964 it->wd->show_item = it;
3965 it->wd->bring_in = EINA_TRUE;
3966 it->showme = EINA_TRUE;
3969 if (it->wd->show_item)
3971 it->wd->show_item->showme = EINA_FALSE;
3972 it->wd->show_item = NULL;
3974 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3975 elm_smart_scroller_child_region_show(it->wd->scr,
3976 it->x + it->block->x,
3977 it->y + it->block->y - oh / 2 +
3978 it->h / 2, it->block->w, oh);
3982 * Bring in the given item at the middle
3984 * This causes genlist to jump to the given item @p it and show it (by
3985 * scrolling), if it is not fully visible. This may use animation to
3986 * do so and take a period of time
3988 * @param it The item
3993 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3995 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3998 if (it->delete_me) return;
3999 if ((it->queued) || (!it->mincalcd))
4001 it->wd->show_item = it;
4002 it->wd->bring_in = EINA_TRUE;
4003 it->showme = EINA_TRUE;
4006 if (it->wd->show_item)
4008 it->wd->show_item->showme = EINA_FALSE;
4009 it->wd->show_item = NULL;
4011 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4012 elm_smart_scroller_region_bring_in(it->wd->scr,
4013 it->x + it->block->x,
4014 it->y + it->block->y - oh / 2 + it->h / 2,
4019 * Delete a given item
4021 * This deletes the item from genlist and calls the genlist item del
4022 * class callback defined in the item class, if it is set. This clears all
4023 * subitems if it is a tree.
4025 * @param it The item
4030 elm_genlist_item_del(Elm_Genlist_Item *it)
4032 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4033 if ((it->relcount > 0) || (it->walking > 0))
4035 elm_widget_item_pre_notify_del(it);
4036 elm_genlist_item_subitems_clear(it);
4037 it->delete_me = EINA_TRUE;
4038 if (it->wd->show_item == it) it->wd->show_item = NULL;
4040 it->wd->selected = eina_list_remove(it->wd->selected,
4044 if (it->realized) _item_unrealize(it, EINA_FALSE);
4045 it->block->changed = EINA_TRUE;
4046 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4047 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4049 if (it->itc->func.del)
4050 it->itc->func.del((void *)it->base.data, it->base.widget);
4057 * Set the data item from the genlist item
4059 * This set the data value passed on the elm_genlist_item_append() and
4060 * related item addition calls. This function will also call
4061 * elm_genlist_item_update() so the item will be updated to reflect the
4064 * @param it The item
4065 * @param data The new data pointer to set
4070 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4073 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4074 elm_widget_item_data_set(it, data);
4075 elm_genlist_item_update(it);
4079 * Get the data item from the genlist item
4081 * This returns the data value passed on the elm_genlist_item_append()
4082 * and related item addition calls and elm_genlist_item_data_set().
4084 * @param it The item
4085 * @return The data pointer provided when created
4090 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4092 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4093 return elm_widget_item_data_get(it);
4097 * Tells genlist to "orphan" icons fetchs by the item class
4099 * This instructs genlist to release references to icons in the item,
4100 * meaning that they will no longer be managed by genlist and are
4101 * floating "orphans" that can be re-used elsewhere if the user wants
4104 * @param it The item
4109 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4112 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4113 EINA_LIST_FREE(it->icon_objs, icon)
4115 elm_widget_sub_object_del(it->base.widget, icon);
4116 evas_object_smart_member_del(icon);
4117 evas_object_hide(icon);
4122 * Get the real evas object of the genlist item
4124 * This returns the actual evas object used for the specified genlist
4125 * item. This may be NULL as it may not be created, and may be deleted
4126 * at any time by genlist. Do not modify this object (move, resize,
4127 * show, hide etc.) as genlist is controlling it. This function is for
4128 * querying, emitting custom signals or hooking lower level callbacks
4129 * for events. Do not delete this object under any circumstances.
4131 * @param it The item
4132 * @return The object pointer
4136 EAPI const Evas_Object *
4137 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4139 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4140 return it->base.view;
4144 * Update the contents of an item
4146 * This updates an item by calling all the item class functions again
4147 * to get the icons, labels and states. Use this when the original
4148 * item data has changed and the changes are desired to be reflected.
4150 * @param it The item
4155 elm_genlist_item_update(Elm_Genlist_Item *it)
4157 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4158 if (!it->block) return;
4159 if (it->delete_me) return;
4160 it->mincalcd = EINA_FALSE;
4161 it->updateme = EINA_TRUE;
4162 it->block->updateme = EINA_TRUE;
4163 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4164 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4168 * Update the item class of an item
4170 * @param it The item
4171 * @parem itc The item class for the item
4176 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4177 const Elm_Genlist_Item_Class *itc)
4179 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4180 if (!it->block) return;
4181 EINA_SAFETY_ON_NULL_RETURN(itc);
4182 if (it->delete_me) return;
4184 it->nocache = EINA_TRUE;
4185 elm_genlist_item_update(it);
4188 static Evas_Object *
4189 _elm_genlist_item_label_create(void *data,
4191 void *item __UNUSED__)
4193 Evas_Object *label = elm_label_add(obj);
4196 elm_object_style_set(label, "tooltip");
4197 elm_label_label_set(label, data);
4202 _elm_genlist_item_label_del_cb(void *data,
4203 Evas_Object *obj __UNUSED__,
4204 void *event_info __UNUSED__)
4206 eina_stringshare_del(data);
4210 * Set the text to be shown in the genlist item.
4212 * @param item Target item
4213 * @param text The text to set in the content
4215 * Setup the text as tooltip to object. The item can have only one
4216 * tooltip, so any previous tooltip data is removed.
4221 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4224 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4225 text = eina_stringshare_add(text);
4226 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4228 _elm_genlist_item_label_del_cb);
4232 * Set the content to be shown in the tooltip item
4234 * Setup the tooltip to item. The item can have only one tooltip, so
4235 * any previous tooltip data is removed. @p func(with @p data) will be
4236 * called every time that need to show the tooltip and it should return a
4237 * valid Evas_Object. This object is then managed fully by tooltip
4238 * system and is deleted when the tooltip is gone.
4240 * @param item the genlist item being attached by a tooltip.
4241 * @param func the function used to create the tooltip contents.
4242 * @param data what to provide to @a func as callback data/context.
4243 * @param del_cb called when data is not needed anymore, either when
4244 * another callback replaces @func, the tooltip is unset with
4245 * elm_genlist_item_tooltip_unset() or the owner @a item
4246 * dies. This callback receives as the first parameter the
4247 * given @a data, and @c event_info is the item.
4252 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4253 Elm_Tooltip_Item_Content_Cb func,
4255 Evas_Smart_Cb del_cb)
4257 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4259 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4262 if (item->tooltip.del_cb)
4263 item->tooltip.del_cb((void *)item->tooltip.data,
4264 item->base.widget, item);
4266 item->tooltip.content_cb = func;
4267 item->tooltip.data = data;
4268 item->tooltip.del_cb = del_cb;
4270 if (item->base.view)
4272 elm_widget_item_tooltip_content_cb_set(item,
4273 item->tooltip.content_cb,
4274 item->tooltip.data, NULL);
4275 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4281 if (del_cb) del_cb((void *)data, NULL, NULL);
4285 * Unset tooltip from item
4287 * @param item genlist item to remove previously set tooltip.
4289 * Remove tooltip from item. The callback provided as del_cb to
4290 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4291 * it is not used anymore.
4293 * @see elm_genlist_item_tooltip_content_cb_set()
4298 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4301 if ((item->base.view) && (item->tooltip.content_cb))
4302 elm_widget_item_tooltip_unset(item);
4304 if (item->tooltip.del_cb)
4305 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4306 item->tooltip.del_cb = NULL;
4307 item->tooltip.content_cb = NULL;
4308 item->tooltip.data = NULL;
4309 if (item->tooltip.style)
4310 elm_genlist_item_tooltip_style_set(item, NULL);
4314 * Sets a different style for this item tooltip.
4316 * @note before you set a style you should define a tooltip with
4317 * elm_genlist_item_tooltip_content_cb_set() or
4318 * elm_genlist_item_tooltip_text_set()
4320 * @param item genlist item with tooltip already set.
4321 * @param style the theme style to use (default, transparent, ...)
4326 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4329 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4330 eina_stringshare_replace(&item->tooltip.style, style);
4331 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4335 * Get the style for this item tooltip.
4337 * @param item genlist item with tooltip already set.
4338 * @return style the theme style in use, defaults to "default". If the
4339 * object does not have a tooltip set, then NULL is returned.
4344 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4346 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4347 return item->tooltip.style;
4351 * Set the cursor to be shown when mouse is over the genlist item
4353 * @param item Target item
4354 * @param cursor the cursor name to be used.
4356 * @see elm_object_cursor_set()
4360 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4363 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4364 eina_stringshare_replace(&item->mouse_cursor, cursor);
4365 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4369 * Get the cursor to be shown when mouse is over the genlist item
4371 * @param item genlist item with cursor already set.
4372 * @return the cursor name.
4377 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4379 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4380 return elm_widget_item_cursor_get(item);
4384 * Unset the cursor to be shown when mouse is over the genlist item
4386 * @param item Target item
4388 * @see elm_object_cursor_unset()
4392 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4394 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4395 if (!item->mouse_cursor)
4398 if (item->base.view)
4399 elm_widget_item_cursor_unset(item);
4401 eina_stringshare_del(item->mouse_cursor);
4402 item->mouse_cursor = NULL;
4406 * Sets a different style for this item cursor.
4408 * @note before you set a style you should define a cursor with
4409 * elm_genlist_item_cursor_set()
4411 * @param item genlist item with cursor already set.
4412 * @param style the theme style to use (default, transparent, ...)
4417 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4420 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4421 elm_widget_item_cursor_style_set(item, style);
4425 * Get the style for this item cursor.
4427 * @param item genlist item with cursor already set.
4428 * @return style the theme style in use, defaults to "default". If the
4429 * object does not have a cursor set, then NULL is returned.
4434 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4436 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4437 return elm_widget_item_cursor_style_get(item);
4441 * Set if the cursor set should be searched on the theme or should use
4442 * the provided by the engine, only.
4444 * @note before you set if should look on theme you should define a
4445 * cursor with elm_object_cursor_set(). By default it will only look
4446 * for cursors provided by the engine.
4448 * @param item widget item with cursor already set.
4449 * @param engine_only boolean to define it cursors should be looked
4450 * only between the provided by the engine or searched on widget's
4456 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4457 Eina_Bool engine_only)
4459 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4460 elm_widget_item_cursor_engine_only_set(item, engine_only);
4464 * Get the cursor engine only usage for this item cursor.
4466 * @param item widget item with cursor already set.
4467 * @return engine_only boolean to define it cursors should be looked
4468 * only between the provided by the engine or searched on widget's
4469 * theme as well. If the object does not have a cursor set, then
4470 * EINA_FALSE is returned.
4475 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4477 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4478 return elm_widget_item_cursor_engine_only_get(item);
4482 * This sets the horizontal stretching mode
4484 * This sets the mode used for sizing items horizontally. Valid modes
4485 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4486 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4487 * the scroller will scroll horizontally. Otherwise items are expanded
4488 * to fill the width of the viewport of the scroller. If it is
4489 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4490 * limited to that size.
4492 * @param obj The genlist object
4493 * @param mode The mode to use
4498 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4501 ELM_CHECK_WIDTYPE(obj, widtype);
4502 Widget_Data *wd = elm_widget_data_get(obj);
4504 if (wd->mode == mode) return;
4510 * Gets the horizontal stretching mode
4512 * @param obj The genlist object
4513 * @return The mode to use
4514 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4519 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4521 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4522 Widget_Data *wd = elm_widget_data_get(obj);
4523 if (!wd) return ELM_LIST_LAST;
4528 * Set the always select mode.
4530 * Items will only call their selection func and callback when first
4531 * becoming selected. Any further clicks will do nothing, unless you
4532 * enable always select with elm_genlist_always_select_mode_set().
4533 * This means even if selected, every click will make the selected
4534 * callbacks be called.
4536 * @param obj The genlist object
4537 * @param always_select The always select mode
4538 * (EINA_TRUE = on, EINA_FALSE = off)
4543 elm_genlist_always_select_mode_set(Evas_Object *obj,
4544 Eina_Bool always_select)
4546 ELM_CHECK_WIDTYPE(obj, widtype);
4547 Widget_Data *wd = elm_widget_data_get(obj);
4549 wd->always_select = always_select;
4553 * Get the always select mode.
4555 * @param obj The genlist object
4556 * @return The always select mode
4557 * (EINA_TRUE = on, EINA_FALSE = off)
4562 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4564 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4565 Widget_Data *wd = elm_widget_data_get(obj);
4566 if (!wd) return EINA_FALSE;
4567 return wd->always_select;
4571 * Set no select mode
4573 * This will turn off the ability to select items entirely and they
4574 * will neither appear selected nor call selected callback functions.
4576 * @param obj The genlist object
4577 * @param no_select The no select mode
4578 * (EINA_TRUE = on, EINA_FALSE = off)
4583 elm_genlist_no_select_mode_set(Evas_Object *obj,
4584 Eina_Bool no_select)
4586 ELM_CHECK_WIDTYPE(obj, widtype);
4587 Widget_Data *wd = elm_widget_data_get(obj);
4589 wd->no_select = no_select;
4593 * Gets no select mode
4595 * @param obj The genlist object
4596 * @return The no select mode
4597 * (EINA_TRUE = on, EINA_FALSE = off)
4602 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4604 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4605 Widget_Data *wd = elm_widget_data_get(obj);
4606 if (!wd) return EINA_FALSE;
4607 return wd->no_select;
4613 * This will enable the compress mode where items are "compressed"
4614 * horizontally to fit the genlist scrollable viewport width. This is
4615 * special for genlist. Do not rely on
4616 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4617 * work as genlist needs to handle it specially.
4619 * @param obj The genlist object
4620 * @param compress The compress mode
4621 * (EINA_TRUE = on, EINA_FALSE = off)
4626 elm_genlist_compress_mode_set(Evas_Object *obj,
4629 ELM_CHECK_WIDTYPE(obj, widtype);
4630 Widget_Data *wd = elm_widget_data_get(obj);
4632 wd->compress = compress;
4636 * Get the compress mode
4638 * @param obj The genlist object
4639 * @return The compress mode
4640 * (EINA_TRUE = on, EINA_FALSE = off)
4645 elm_genlist_compress_mode_get(const Evas_Object *obj)
4647 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4648 Widget_Data *wd = elm_widget_data_get(obj);
4649 if (!wd) return EINA_FALSE;
4650 return wd->compress;
4654 * Set height-for-width mode
4656 * With height-for-width mode the item width will be fixed (restricted
4657 * to a minimum of) to the list width when calculating its size in
4658 * order to allow the height to be calculated based on it. This allows,
4659 * for instance, text block to wrap lines if the Edje part is
4660 * configured with "text.min: 0 1".
4662 * @note This mode will make list resize slower as it will have to
4663 * recalculate every item height again whenever the list width
4666 * @note When height-for-width mode is enabled, it also enables
4667 * compress mode (see elm_genlist_compress_mode_set()) and
4668 * disables homogeneous (see elm_genlist_homogeneous_set()).
4670 * @param obj The genlist object
4671 * @param setting The height-for-width mode (EINA_TRUE = on,
4677 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4678 Eina_Bool height_for_width)
4680 ELM_CHECK_WIDTYPE(obj, widtype);
4681 Widget_Data *wd = elm_widget_data_get(obj);
4683 wd->height_for_width = !!height_for_width;
4684 if (wd->height_for_width)
4686 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4687 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4692 * Get the height-for-width mode
4694 * @param obj The genlist object
4695 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4701 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4703 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4704 Widget_Data *wd = elm_widget_data_get(obj);
4705 if (!wd) return EINA_FALSE;
4706 return wd->height_for_width;
4712 * This will enable or disable the scroller bounce mode for the
4713 * genlist. See elm_scroller_bounce_set() for details
4715 * @param obj The genlist object
4716 * @param h_bounce Allow bounce horizontally
4717 * @param v_bounce Allow bounce vertically
4722 elm_genlist_bounce_set(Evas_Object *obj,
4726 ELM_CHECK_WIDTYPE(obj, widtype);
4727 Widget_Data *wd = elm_widget_data_get(obj);
4729 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4733 * Get the bounce mode
4735 * @param obj The genlist object
4736 * @param h_bounce Allow bounce horizontally
4737 * @param v_bounce Allow bounce vertically
4742 elm_genlist_bounce_get(const Evas_Object *obj,
4743 Eina_Bool *h_bounce,
4744 Eina_Bool *v_bounce)
4746 ELM_CHECK_WIDTYPE(obj, widtype);
4747 Widget_Data *wd = elm_widget_data_get(obj);
4749 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4753 * Set homogenous mode
4755 * This will enable the homogeneous mode where items are of the same
4756 * height and width so that genlist may do the lazy-loading at its
4757 * maximum. This implies 'compressed' mode.
4759 * @param obj The genlist object
4760 * @param homogeneous Assume the items within the genlist are of the
4761 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4766 elm_genlist_homogeneous_set(Evas_Object *obj,
4767 Eina_Bool homogeneous)
4769 ELM_CHECK_WIDTYPE(obj, widtype);
4770 Widget_Data *wd = elm_widget_data_get(obj);
4772 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4773 wd->homogeneous = homogeneous;
4777 * Get the homogenous mode
4779 * @param obj The genlist object
4780 * @return Assume the items within the genlist are of the same height
4781 * and width (EINA_TRUE = on, EINA_FALSE = off)
4786 elm_genlist_homogeneous_get(const Evas_Object *obj)
4788 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4789 Widget_Data *wd = elm_widget_data_get(obj);
4790 if (!wd) return EINA_FALSE;
4791 return wd->homogeneous;
4795 * Set the maximum number of items within an item block
4797 * This will configure the block count to tune to the target with
4798 * particular performance matrix.
4800 * @param obj The genlist object
4801 * @param n Maximum number of items within an item block
4806 elm_genlist_block_count_set(Evas_Object *obj,
4809 ELM_CHECK_WIDTYPE(obj, widtype);
4810 Widget_Data *wd = elm_widget_data_get(obj);
4812 wd->max_items_per_block = n;
4813 wd->item_cache_max = wd->max_items_per_block * 2;
4814 _item_cache_clean(wd);
4818 * Get the maximum number of items within an item block
4820 * @param obj The genlist object
4821 * @return Maximum number of items within an item block
4826 elm_genlist_block_count_get(const Evas_Object *obj)
4828 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4829 Widget_Data *wd = elm_widget_data_get(obj);
4831 return wd->max_items_per_block;
4835 * Set the timeout in seconds for the longpress event
4837 * @param obj The genlist object
4838 * @param timeout timeout in seconds
4843 elm_genlist_longpress_timeout_set(Evas_Object *obj,
4846 ELM_CHECK_WIDTYPE(obj, widtype);
4847 Widget_Data *wd = elm_widget_data_get(obj);
4849 wd->longpress_timeout = timeout;
4853 * Get the timeout in seconds for the longpress event
4855 * @param obj The genlist object
4856 * @return timeout in seconds
4861 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4863 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4864 Widget_Data *wd = elm_widget_data_get(obj);
4866 return wd->longpress_timeout;
4870 * Set the scrollbar policy
4872 * This sets the scrollbar visibility policy for the given genlist
4873 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
4874 * made visible if it is needed, and otherwise kept hidden.
4875 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
4876 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
4877 * respectively for the horizontal and vertical scrollbars.
4879 * @param obj The genlist object
4880 * @param policy_h Horizontal scrollbar policy
4881 * @param policy_v Vertical scrollbar policy
4886 elm_genlist_scroller_policy_set(Evas_Object *obj,
4887 Elm_Scroller_Policy policy_h,
4888 Elm_Scroller_Policy policy_v)
4890 ELM_CHECK_WIDTYPE(obj, widtype);
4891 Widget_Data *wd = elm_widget_data_get(obj);
4893 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4894 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4897 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4901 * Get the scrollbar policy
4903 * @param obj The genlist object
4904 * @param policy_h Horizontal scrollbar policy
4905 * @param policy_v Vertical scrollbar policy
4910 elm_genlist_scroller_policy_get(const Evas_Object *obj,
4911 Elm_Scroller_Policy *policy_h,
4912 Elm_Scroller_Policy *policy_v)
4914 ELM_CHECK_WIDTYPE(obj, widtype);
4915 Widget_Data *wd = elm_widget_data_get(obj);
4916 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4917 if ((!wd) || (!wd->scr)) return;
4918 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4919 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
4920 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
4924 * Update the contents of all realized items
4926 * This updates all realized items by calling all the item class functions again
4927 * to get the icons, labels and states. Use this when the original
4928 * item data has changed and the changes are desired to be reflected.
4930 * @param it The item
4935 elm_genlist_realized_items_update(Evas_Object *obj)
4937 ELM_CHECK_WIDTYPE(obj, widtype);
4939 Eina_List *list, *l;
4940 Elm_Genlist_Item *it;
4942 list = elm_genlist_realized_items_get(obj);
4943 EINA_LIST_FOREACH(list, l, it)
4944 elm_genlist_item_update(it);