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, *must_recalc_idler;
276 Eina_List *queue, *selected;
277 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
278 Eina_Inlist *item_cache;
281 Ecore_Timer *multi_timer, *scr_hold_timer;
282 const char *mode_type;
283 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
284 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
285 Eina_Bool mouse_down : 1;
286 Eina_Bool multi_down : 1;
287 Eina_Bool multi_timeout : 1;
288 Eina_Bool multitouched : 1;
289 Eina_Bool on_hold : 1;
291 Eina_Bool always_select : 1;
292 Eina_Bool longpressed : 1;
293 Eina_Bool wasselected : 1;
294 Eina_Bool no_select : 1;
295 Eina_Bool bring_in : 1;
296 Eina_Bool compress : 1;
297 Eina_Bool height_for_width : 1;
298 Eina_Bool homogeneous : 1;
299 Eina_Bool clear_me : 1;
304 } history[SWIPE_MOVES];
306 int item_cache_count;
312 int group_item_width;
313 int group_item_height;
314 int max_items_per_block;
315 double longpress_timeout;
325 Evas_Coord x, y, w, h, minw, minh;
326 Eina_Bool want_unrealize : 1;
327 Eina_Bool realized : 1;
328 Eina_Bool changed : 1;
329 Eina_Bool updateme : 1;
330 Eina_Bool showme : 1;
331 Eina_Bool must_recalc : 1;
334 struct _Elm_Genlist_Item
336 Elm_Widget_Item base;
341 Evas_Coord x, y, w, h, minw, minh;
342 const Elm_Genlist_Item_Class *itc;
343 Elm_Genlist_Item *parent;
344 Elm_Genlist_Item *group_item;
345 Elm_Genlist_Item_Flags flags;
353 Eina_List *labels, *icons, *states, *icon_objs;
354 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
355 Ecore_Timer *long_timer;
356 Ecore_Timer *swipe_timer;
358 Evas_Coord scrl_x, scrl_y;
360 Elm_Genlist_Item *rel;
361 Evas_Object *mode_view;
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;
396 Eina_Bool stacking_even : 1;
397 Eina_Bool nostacking : 1;
404 Evas_Object *base_view, *spacer;
406 const char *item_style; // it->itc->item_style
407 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
408 Eina_Bool compress : 1; // it->wd->compress
410 Eina_Bool selected : 1; // it->selected
411 Eina_Bool disabled : 1; // it->disabled
412 Eina_Bool expanded : 1; // it->expanded
415 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
416 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
420 Evas_Object_Smart_Clipped_Data __clipped_data;
422 Ecore_Job *resize_job;
425 static const char *widtype = NULL;
426 static void _item_cache_zero(Widget_Data *wd);
427 static void _del_hook(Evas_Object *obj);
428 static void _mirrored_set(Evas_Object *obj,
430 static void _theme_hook(Evas_Object *obj);
431 static void _show_region_hook(void *data,
433 static void _sizing_eval(Evas_Object *obj);
434 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
435 static void _item_block_unrealize(Item_Block *itb);
436 static void _calc_job(void *data);
437 static void _on_focus_hook(void *data,
439 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
440 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
441 static Eina_Bool _item_single_select_up(Widget_Data *wd);
442 static Eina_Bool _item_single_select_down(Widget_Data *wd);
443 static Eina_Bool _event_hook(Evas_Object *obj,
445 Evas_Callback_Type type,
447 static void _signal_emit_hook(Evas_Object *obj,
448 const char *emission,
450 static Eina_Bool _deselect_all_items(Widget_Data *wd);
451 static void _pan_calculate(Evas_Object *obj);
452 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
453 static void _mode_item_realize(Elm_Genlist_Item *it);
454 static void _mode_item_unrealize(Elm_Genlist_Item *it);
455 static void _item_mode_set(Elm_Genlist_Item *it);
456 static void _item_mode_unset(Widget_Data *wd);
458 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
461 _event_hook(Evas_Object *obj,
462 Evas_Object *src __UNUSED__,
463 Evas_Callback_Type type,
466 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
467 Evas_Event_Key_Down *ev = event_info;
468 Widget_Data *wd = elm_widget_data_get(obj);
469 if (!wd) return EINA_FALSE;
470 if (!wd->items) return EINA_FALSE;
471 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
472 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
474 Elm_Genlist_Item *it = NULL;
477 Evas_Coord step_x = 0;
478 Evas_Coord step_y = 0;
481 Evas_Coord page_x = 0;
482 Evas_Coord page_y = 0;
484 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
485 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
486 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
487 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
489 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
493 else if ((!strcmp(ev->keyname, "Right")) ||
494 (!strcmp(ev->keyname, "KP_Right")))
498 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
500 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
501 (_item_multi_select_up(wd)))
502 || (_item_single_select_up(wd)))
504 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
510 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
512 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
513 (_item_multi_select_down(wd)))
514 || (_item_single_select_down(wd)))
516 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
522 else if ((!strcmp(ev->keyname, "Home")) ||
523 (!strcmp(ev->keyname, "KP_Home")))
525 it = elm_genlist_first_item_get(obj);
526 elm_genlist_item_bring_in(it);
527 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
530 else if ((!strcmp(ev->keyname, "End")) ||
531 (!strcmp(ev->keyname, "KP_End")))
533 it = elm_genlist_last_item_get(obj);
534 elm_genlist_item_bring_in(it);
535 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
538 else if ((!strcmp(ev->keyname, "Prior")) ||
539 (!strcmp(ev->keyname, "KP_Prior")))
542 y -= -(page_y * v_h) / 100;
546 else if ((!strcmp(ev->keyname, "Next")) ||
547 (!strcmp(ev->keyname, "KP_Next")))
550 y += -(page_y * v_h) / 100;
554 else if(((!strcmp(ev->keyname, "Return")) ||
555 (!strcmp(ev->keyname, "KP_Enter")) ||
556 (!strcmp(ev->keyname, "space")))
557 && (!wd->multi) && (wd->selected))
559 it = elm_genlist_selected_item_get(obj);
560 elm_genlist_item_expanded_set(it,
561 !elm_genlist_item_expanded_get(it));
563 else if (!strcmp(ev->keyname, "Escape"))
565 if (!_deselect_all_items(wd)) return EINA_FALSE;
566 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
569 else return EINA_FALSE;
571 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
572 elm_smart_scroller_child_pos_set(wd->scr, x, y);
577 _deselect_all_items(Widget_Data *wd)
579 if (!wd->selected) return EINA_FALSE;
581 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
587 _item_multi_select_up(Widget_Data *wd)
589 if (!wd->selected) return EINA_FALSE;
590 if (!wd->multi) return EINA_FALSE;
592 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
593 if (!prev) return EINA_TRUE;
595 if (elm_genlist_item_selected_get(prev))
597 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
598 wd->last_selected_item = prev;
599 elm_genlist_item_show(wd->last_selected_item);
603 elm_genlist_item_selected_set(prev, EINA_TRUE);
604 elm_genlist_item_show(prev);
610 _item_multi_select_down(Widget_Data *wd)
612 if (!wd->selected) return EINA_FALSE;
613 if (!wd->multi) return EINA_FALSE;
615 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
616 if (!next) return EINA_TRUE;
618 if (elm_genlist_item_selected_get(next))
620 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
621 wd->last_selected_item = next;
622 elm_genlist_item_show(wd->last_selected_item);
626 elm_genlist_item_selected_set(next, EINA_TRUE);
627 elm_genlist_item_show(next);
633 _item_single_select_up(Widget_Data *wd)
635 Elm_Genlist_Item *prev;
638 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
639 while ((prev) && (prev->delete_me))
640 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
642 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
644 if (!prev) return EINA_FALSE;
646 _deselect_all_items(wd);
648 elm_genlist_item_selected_set(prev, EINA_TRUE);
649 elm_genlist_item_show(prev);
654 _item_single_select_down(Widget_Data *wd)
656 Elm_Genlist_Item *next;
659 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
660 while ((next) && (next->delete_me))
661 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
663 else next = elm_genlist_item_next_get(wd->last_selected_item);
665 if (!next) return EINA_FALSE;
667 _deselect_all_items(wd);
669 elm_genlist_item_selected_set(next, EINA_TRUE);
670 elm_genlist_item_show(next);
675 _on_focus_hook(void *data __UNUSED__,
678 Widget_Data *wd = elm_widget_data_get(obj);
680 if (elm_widget_focus_get(obj))
682 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
683 evas_object_focus_set(wd->obj, EINA_TRUE);
684 if ((wd->selected) && (!wd->last_selected_item))
685 wd->last_selected_item = eina_list_data_get(wd->selected);
689 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
690 evas_object_focus_set(wd->obj, EINA_FALSE);
695 _del_hook(Evas_Object *obj)
697 Widget_Data *wd = elm_widget_data_get(obj);
699 _item_cache_zero(wd);
700 if (wd->calc_job) ecore_job_del(wd->calc_job);
701 if (wd->update_job) ecore_job_del(wd->update_job);
702 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
703 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
704 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
705 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
710 _del_pre_hook(Evas_Object *obj)
712 Widget_Data *wd = elm_widget_data_get(obj);
714 evas_object_del(wd->pan_smart);
715 wd->pan_smart = NULL;
716 elm_genlist_clear(obj);
720 _mirrored_set(Evas_Object *obj,
723 Widget_Data *wd = elm_widget_data_get(obj);
725 _item_cache_zero(wd);
726 elm_smart_scroller_mirrored_set(wd->scr, rtl);
730 _theme_hook(Evas_Object *obj)
732 Widget_Data *wd = elm_widget_data_get(obj);
735 _item_cache_zero(wd);
736 _elm_widget_mirrored_reload(obj);
737 _mirrored_set(obj, elm_widget_mirrored_get(obj));
738 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
739 elm_widget_style_get(obj));
740 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
741 wd->item_width = wd->item_height = 0;
742 wd->group_item_width = wd->group_item_height = 0;
743 wd->minw = wd->minh = wd->realminw = 0;
744 EINA_INLIST_FOREACH(wd->blocks, itb)
747 Elm_Genlist_Item *it;
749 if (itb->realized) _item_block_unrealize(itb);
750 EINA_LIST_FOREACH(itb->items, l, it)
751 it->mincalcd = EINA_FALSE;
753 itb->changed = EINA_TRUE;
755 if (wd->calc_job) ecore_job_del(wd->calc_job);
756 wd->calc_job = ecore_job_add(_calc_job, wd);
761 _show_region_hook(void *data,
764 Widget_Data *wd = elm_widget_data_get(data);
765 Evas_Coord x, y, w, h;
767 elm_widget_show_region_get(obj, &x, &y, &w, &h);
768 //x & y are screen coordinates, Add with pan coordinates
771 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
775 _sizing_eval(Evas_Object *obj)
777 Widget_Data *wd = elm_widget_data_get(obj);
778 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
780 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
781 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
783 if (wd->height_for_width)
787 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
788 if ((vw != 0) && (vw != wd->prev_viewport_w))
792 wd->prev_viewport_w = vw;
793 EINA_INLIST_FOREACH(wd->blocks, itb)
795 itb->must_recalc = EINA_TRUE;
797 if (wd->calc_job) ecore_job_del(wd->calc_job);
798 wd->calc_job = ecore_job_add(_calc_job, wd);
801 if (wd->mode == ELM_LIST_LIMIT)
803 Evas_Coord vmw, vmh, vw, vh;
807 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
808 if ((minw > 0) && (vw < minw)) vw = minw;
809 else if ((maxw > 0) && (vw > maxw))
811 edje_object_size_min_calc
812 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
819 edje_object_size_min_calc
820 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
824 evas_object_size_hint_min_set(obj, minw, minh);
825 evas_object_size_hint_max_set(obj, maxw, maxh);
829 _signal_emit_hook(Evas_Object *obj,
830 const char *emission,
833 Widget_Data *wd = elm_widget_data_get(obj);
834 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
839 _item_highlight(Elm_Genlist_Item *it)
841 const char *selectraise;
842 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
843 (it->disabled) || (it->display_only) || (it->mode_view))
845 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
846 selectraise = edje_object_data_get(it->base.view, "selectraise");
847 if ((selectraise) && (!strcmp(selectraise, "on")))
849 evas_object_raise(it->base.view);
850 if ((it->group_item) && (it->group_item->realized))
851 evas_object_raise(it->group_item->base.view);
853 it->highlighted = EINA_TRUE;
857 _item_block_del(Elm_Genlist_Item *it)
860 Item_Block *itb = it->block;
862 itb->items = eina_list_remove(itb->items, it);
864 itb->changed = EINA_TRUE;
865 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
866 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
869 il = EINA_INLIST_GET(itb);
870 Item_Block *itbn = (Item_Block *)(il->next);
872 it->parent->items = eina_list_remove(it->parent->items, it);
874 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
876 if (itbn) itbn->changed = EINA_TRUE;
882 il = EINA_INLIST_GET(itb);
883 Item_Block *itbp = (Item_Block *)(il->prev);
884 Item_Block *itbn = (Item_Block *)(il->next);
885 if ((itbp) && ((itbp->count + itb->count) < 48))
887 Elm_Genlist_Item *it2;
889 EINA_LIST_FREE(itb->items, it2)
892 itbp->items = eina_list_append(itbp->items, it2);
894 itbp->changed = EINA_TRUE;
896 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
897 EINA_INLIST_GET(itb));
900 else if ((itbn) && ((itbn->count + itb->count) < 48))
904 Eina_List *last = eina_list_last(itb->items);
905 Elm_Genlist_Item *it2 = last->data;
908 itb->items = eina_list_remove_list(itb->items, last);
909 itbn->items = eina_list_prepend(itbn->items, it2);
911 itbn->changed = EINA_TRUE;
914 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
922 _item_del(Elm_Genlist_Item *it)
924 elm_widget_item_pre_notify_del(it);
925 elm_genlist_item_subitems_clear(it);
926 it->wd->walking -= it->walking;
927 if (it->wd->show_item == it) it->wd->show_item = NULL;
928 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
929 if (it->realized) _item_unrealize(it, EINA_FALSE);
930 if (it->block) _item_block_del(it);
931 if ((!it->delete_me) && (it->itc->func.del))
932 it->itc->func.del((void *)it->base.data, it->base.widget);
933 it->delete_me = EINA_TRUE;
935 it->wd->queue = eina_list_remove(it->wd->queue, it);
936 if (it->wd->anchor_item == it)
938 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
939 if (!it->wd->anchor_item)
940 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
942 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
944 it->parent->items = eina_list_remove(it->parent->items, it);
945 if (it->flags & ELM_GENLIST_ITEM_GROUP)
946 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
947 if (it->long_timer) ecore_timer_del(it->long_timer);
948 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
950 if (it->tooltip.del_cb)
951 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
953 elm_widget_item_del(it);
957 _item_select(Elm_Genlist_Item *it)
959 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
962 if (it->wd->always_select) goto call;
965 it->selected = EINA_TRUE;
966 it->wd->selected = eina_list_append(it->wd->selected, it);
970 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
972 evas_object_smart_callback_call(it->base.widget, "selected", it);
975 if ((it->wd->clear_me) && (!it->wd->walking))
976 elm_genlist_clear(it->base.widget);
979 if ((!it->walking) && (it->delete_me))
981 if (!it->relcount) _item_del(it);
984 it->wd->last_selected_item = it;
988 _item_unselect(Elm_Genlist_Item *it)
990 const char *stacking, *selectraise;
992 if ((it->delete_me) || (!it->highlighted)) return;
993 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
994 stacking = edje_object_data_get(it->base.view, "stacking");
995 selectraise = edje_object_data_get(it->base.view, "selectraise");
998 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
999 else evas_object_raise(it->base.view);
1001 it->highlighted = EINA_FALSE;
1004 it->selected = EINA_FALSE;
1005 it->wd->selected = eina_list_remove(it->wd->selected, it);
1006 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1011 _mouse_move(void *data,
1012 Evas *evas __UNUSED__,
1016 Elm_Genlist_Item *it = data;
1017 Evas_Event_Mouse_Move *ev = event_info;
1018 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1020 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1022 if (!it->wd->on_hold)
1024 it->wd->on_hold = EINA_TRUE;
1025 if (!it->wd->wasselected)
1029 if (it->wd->multitouched)
1031 it->wd->cur_x = ev->cur.canvas.x;
1032 it->wd->cur_y = ev->cur.canvas.y;
1035 if ((it->dragging) && (it->down))
1037 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1040 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1041 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1042 if (abs((it->wd->history[it->wd->movements].x -
1043 it->wd->history[0].x)) > 40)
1044 it->wd->swipe = EINA_TRUE;
1046 it->wd->movements++;
1050 ecore_timer_del(it->long_timer);
1051 it->long_timer = NULL;
1053 evas_object_smart_callback_call(it->base.widget, "drag", it);
1056 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1060 ecore_timer_del(it->long_timer);
1061 it->long_timer = NULL;
1065 if (!it->display_only)
1066 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1067 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1068 x = ev->cur.canvas.x - x;
1069 y = ev->cur.canvas.y - y;
1072 if (adx < 0) adx = -dx;
1075 if (ady < 0) ady = -dy;
1078 if ((adx > minw) || (ady > minh))
1080 it->dragging = EINA_TRUE;
1083 ecore_timer_del(it->long_timer);
1084 it->long_timer = NULL;
1086 if (!it->wd->wasselected)
1091 evas_object_smart_callback_call(it->base.widget,
1092 "drag,start,up", it);
1096 evas_object_smart_callback_call(it->base.widget,
1097 "drag,start,left", it);
1099 evas_object_smart_callback_call(it->base.widget,
1100 "drag,start,right", it);
1106 evas_object_smart_callback_call(it->base.widget,
1107 "drag,start,down", it);
1111 evas_object_smart_callback_call(it->base.widget,
1112 "drag,start,left", it);
1114 evas_object_smart_callback_call(it->base.widget,
1115 "drag,start,right", it);
1122 _long_press(void *data)
1124 Elm_Genlist_Item *it = data;
1126 it->long_timer = NULL;
1127 if ((it->disabled) || (it->dragging) || (it->display_only))
1128 return ECORE_CALLBACK_CANCEL;
1129 it->wd->longpressed = EINA_TRUE;
1130 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1131 return ECORE_CALLBACK_CANCEL;
1135 _swipe(Elm_Genlist_Item *it)
1140 if ((it->display_only) || (it->disabled)) return;
1141 it->wd->swipe = EINA_FALSE;
1142 for (i = 0; i < it->wd->movements; i++)
1144 sum += it->wd->history[i].x;
1145 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1148 sum /= it->wd->movements;
1149 if (abs(sum - it->wd->history[0].x) <= 10) return;
1150 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1154 _swipe_cancel(void *data)
1156 Elm_Genlist_Item *it = data;
1158 if (!it) return ECORE_CALLBACK_CANCEL;
1159 it->wd->swipe = EINA_FALSE;
1160 it->wd->movements = 0;
1161 return ECORE_CALLBACK_RENEW;
1165 _multi_cancel(void *data)
1167 Widget_Data *wd = data;
1169 if (!wd) return ECORE_CALLBACK_CANCEL;
1170 wd->multi_timeout = EINA_TRUE;
1171 return ECORE_CALLBACK_RENEW;
1175 _multi_touch_gesture_eval(void *data)
1177 Elm_Genlist_Item *it = data;
1179 it->wd->multitouched = EINA_FALSE;
1180 if (it->wd->multi_timer)
1182 ecore_timer_del(it->wd->multi_timer);
1183 it->wd->multi_timer = NULL;
1185 if (it->wd->multi_timeout)
1187 it->wd->multi_timeout = EINA_FALSE;
1191 Evas_Coord minw = 0, minh = 0;
1192 Evas_Coord off_x, off_y, off_mx, off_my;
1194 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1195 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1196 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1197 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1198 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1200 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1202 if ((off_x + off_mx) > (off_y + off_my))
1204 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1205 evas_object_smart_callback_call(it->base.widget,
1206 "multi,swipe,right", it);
1207 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1208 evas_object_smart_callback_call(it->base.widget,
1209 "multi,swipe,left", it);
1210 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1211 evas_object_smart_callback_call(it->base.widget,
1212 "multi,pinch,out", it);
1214 evas_object_smart_callback_call(it->base.widget,
1215 "multi,pinch,in", it);
1219 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1220 evas_object_smart_callback_call(it->base.widget,
1221 "multi,swipe,down", it);
1222 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1223 evas_object_smart_callback_call(it->base.widget,
1224 "multi,swipe,up", it);
1225 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1226 evas_object_smart_callback_call(it->base.widget,
1227 "multi,pinch,out", it);
1229 evas_object_smart_callback_call(it->base.widget,
1230 "multi,pinch,in", it);
1233 it->wd->multi_timeout = EINA_FALSE;
1237 _multi_down(void *data,
1238 Evas *evas __UNUSED__,
1239 Evas_Object *obj __UNUSED__,
1242 Elm_Genlist_Item *it = data;
1243 Evas_Event_Multi_Down *ev = event_info;
1245 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1246 it->wd->multi_device = ev->device;
1247 it->wd->multi_down = EINA_TRUE;
1248 it->wd->multitouched = EINA_TRUE;
1249 it->wd->prev_mx = ev->canvas.x;
1250 it->wd->prev_my = ev->canvas.y;
1251 if (!it->wd->wasselected) _item_unselect(it);
1252 it->wd->wasselected = EINA_FALSE;
1253 it->wd->longpressed = EINA_FALSE;
1256 ecore_timer_del(it->long_timer);
1257 it->long_timer = NULL;
1261 it->dragging = EINA_FALSE;
1262 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1264 if (it->swipe_timer)
1266 ecore_timer_del(it->swipe_timer);
1267 it->swipe_timer = NULL;
1269 if (it->wd->on_hold)
1271 it->wd->swipe = EINA_FALSE;
1272 it->wd->movements = 0;
1273 it->wd->on_hold = EINA_FALSE;
1278 _multi_up(void *data,
1279 Evas *evas __UNUSED__,
1280 Evas_Object *obj __UNUSED__,
1283 Elm_Genlist_Item *it = data;
1284 Evas_Event_Multi_Up *ev = event_info;
1286 if (it->wd->multi_device != ev->device) return;
1287 it->wd->multi_device = 0;
1288 it->wd->multi_down = EINA_FALSE;
1289 if (it->wd->mouse_down) return;
1290 _multi_touch_gesture_eval(data);
1294 _multi_move(void *data,
1295 Evas *evas __UNUSED__,
1296 Evas_Object *obj __UNUSED__,
1299 Elm_Genlist_Item *it = data;
1300 Evas_Event_Multi_Move *ev = event_info;
1302 if (it->wd->multi_device != ev->device) return;
1303 it->wd->cur_mx = ev->cur.canvas.x;
1304 it->wd->cur_my = ev->cur.canvas.y;
1308 _mouse_down(void *data,
1309 Evas *evas __UNUSED__,
1313 Elm_Genlist_Item *it = data;
1314 Evas_Event_Mouse_Down *ev = event_info;
1317 if (ev->button != 1) return;
1318 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1320 it->wd->on_hold = EINA_TRUE;
1323 it->down = EINA_TRUE;
1324 it->dragging = EINA_FALSE;
1325 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1326 it->dx = ev->canvas.x - x;
1327 it->dy = ev->canvas.y - y;
1328 it->wd->mouse_down = EINA_TRUE;
1329 if (!it->wd->multitouched)
1331 it->wd->prev_x = ev->canvas.x;
1332 it->wd->prev_y = ev->canvas.y;
1333 it->wd->multi_timeout = EINA_FALSE;
1334 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1335 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1337 it->wd->longpressed = EINA_FALSE;
1338 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1339 else it->wd->on_hold = EINA_FALSE;
1340 if (it->wd->on_hold) return;
1341 it->wd->wasselected = it->selected;
1342 _item_highlight(it);
1343 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1344 if ((!it->disabled) && (!it->display_only))
1346 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1347 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1349 if (it->long_timer) ecore_timer_del(it->long_timer);
1350 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1351 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1353 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1356 it->long_timer = NULL;
1357 it->wd->swipe = EINA_FALSE;
1358 it->wd->movements = 0;
1362 _mouse_up(void *data,
1363 Evas *evas __UNUSED__,
1364 Evas_Object *obj __UNUSED__,
1367 Elm_Genlist_Item *it = data;
1368 Evas_Event_Mouse_Up *ev = event_info;
1369 Eina_Bool dragged = EINA_FALSE;
1371 if (ev->button != 1) return;
1372 it->down = EINA_FALSE;
1373 it->wd->mouse_down = EINA_FALSE;
1374 if (it->wd->multitouched)
1376 if (it->wd->multi_down) return;
1377 _multi_touch_gesture_eval(data);
1380 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1381 else it->wd->on_hold = EINA_FALSE;
1384 ecore_timer_del(it->long_timer);
1385 it->long_timer = NULL;
1389 it->dragging = EINA_FALSE;
1390 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1393 if (it->swipe_timer)
1395 ecore_timer_del(it->swipe_timer);
1396 it->swipe_timer = NULL;
1398 if (it->wd->multi_timer)
1400 ecore_timer_del(it->wd->multi_timer);
1401 it->wd->multi_timer = NULL;
1402 it->wd->multi_timeout = EINA_FALSE;
1404 if (it->wd->on_hold)
1406 if (it->wd->swipe) _swipe(data);
1407 it->wd->longpressed = EINA_FALSE;
1408 it->wd->on_hold = EINA_FALSE;
1411 if (it->wd->longpressed)
1413 it->wd->longpressed = EINA_FALSE;
1414 if (!it->wd->wasselected)
1416 it->wd->wasselected = EINA_FALSE;
1421 if (it->want_unrealize)
1423 _item_unrealize(it, EINA_FALSE);
1424 if (it->block->want_unrealize)
1425 _item_block_unrealize(it->block);
1428 if ((it->disabled) || (dragged) || (it->display_only)) return;
1429 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1434 _item_highlight(it);
1437 else _item_unselect(it);
1443 Widget_Data *wd = it->wd;
1446 while (wd->selected) _item_unselect(wd->selected->data);
1451 const Eina_List *l, *l_next;
1452 Elm_Genlist_Item *it2;
1454 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1455 if (it2 != it) _item_unselect(it2);
1456 //_item_highlight(it);
1459 _item_highlight(it);
1465 _signal_expand_toggle(void *data,
1466 Evas_Object *obj __UNUSED__,
1467 const char *emission __UNUSED__,
1468 const char *source __UNUSED__)
1470 Elm_Genlist_Item *it = data;
1473 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1475 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1479 _signal_expand(void *data,
1480 Evas_Object *obj __UNUSED__,
1481 const char *emission __UNUSED__,
1482 const char *source __UNUSED__)
1484 Elm_Genlist_Item *it = data;
1487 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1491 _signal_contract(void *data,
1492 Evas_Object *obj __UNUSED__,
1493 const char *emission __UNUSED__,
1494 const char *source __UNUSED__)
1496 Elm_Genlist_Item *it = data;
1499 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1503 _scr_hold_timer_cb(void *data)
1505 if (!data) return ECORE_CALLBACK_CANCEL;
1506 Widget_Data *wd = data;
1507 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1508 wd->scr_hold_timer = NULL;
1509 return ECORE_CALLBACK_CANCEL;
1513 _mode_finished_signal_cb(void *data,
1515 const char *emission __UNUSED__,
1516 const char *source __UNUSED__)
1520 Elm_Genlist_Item *it = data;
1521 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1524 it->nocache = EINA_FALSE;
1525 _mode_item_unrealize(it);
1526 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1527 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1531 _item_cache_clean(Widget_Data *wd)
1533 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1537 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1538 wd->item_cache = eina_inlist_remove(wd->item_cache,
1539 wd->item_cache->last);
1540 wd->item_cache_count--;
1541 if (itc->spacer) evas_object_del(itc->spacer);
1542 if (itc->base_view) evas_object_del(itc->base_view);
1543 if (itc->item_style) eina_stringshare_del(itc->item_style);
1549 _item_cache_zero(Widget_Data *wd)
1551 int pmax = wd->item_cache_max;
1552 wd->item_cache_max = 0;
1553 _item_cache_clean(wd);
1554 wd->item_cache_max = pmax;
1558 _item_cache_add(Elm_Genlist_Item *it)
1562 if (it->wd->item_cache_max <= 0)
1564 evas_object_del(it->base.view);
1565 it->base.view = NULL;
1566 evas_object_del(it->spacer);
1571 it->wd->item_cache_count++;
1572 itc = calloc(1, sizeof(Item_Cache));
1573 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1574 EINA_INLIST_GET(itc));
1575 itc->spacer = it->spacer;
1577 itc->base_view = it->base.view;
1578 it->base.view = NULL;
1579 evas_object_hide(itc->base_view);
1580 evas_object_move(itc->base_view, -9999, -9999);
1581 itc->item_style = eina_stringshare_add(it->itc->item_style);
1582 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1583 itc->compress = (it->wd->compress);
1584 itc->selected = it->selected;
1585 itc->disabled = it->disabled;
1586 itc->expanded = it->expanded;
1589 ecore_timer_del(it->long_timer);
1590 it->long_timer = NULL;
1592 if (it->swipe_timer)
1594 ecore_timer_del(it->swipe_timer);
1595 it->swipe_timer = NULL;
1597 // FIXME: other callbacks?
1598 edje_object_signal_callback_del_full(itc->base_view,
1599 "elm,action,expand,toggle",
1600 "elm", _signal_expand_toggle, it);
1601 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1603 _signal_expand, it);
1604 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1605 "elm", _signal_contract, it);
1606 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1608 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1610 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1612 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1614 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1616 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1618 _item_cache_clean(it->wd);
1622 _item_cache_find(Elm_Genlist_Item *it)
1627 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1628 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1630 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1632 if ((itc->tree == tree) &&
1633 (itc->compress == it->wd->compress) &&
1634 (!strcmp(it->itc->item_style, itc->item_style)))
1636 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1637 EINA_INLIST_GET(itc));
1638 it->wd->item_cache_count--;
1646 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1648 if (!it->nostacking)
1650 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1651 evas_object_lower(it->base.view);
1653 evas_object_raise(it->base.view);
1656 if (it->order_num_in & 0x1)
1657 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1659 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1663 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1667 if (it->selected != itc->selected)
1670 edje_object_signal_emit(it->base.view,
1671 "elm,state,selected", "elm");
1673 if (it->disabled != itc->disabled)
1676 edje_object_signal_emit(it->base.view,
1677 "elm,state,disabled", "elm");
1679 if (it->expanded != itc->expanded)
1682 edje_object_signal_emit(it->base.view,
1683 "elm,state,expanded", "elm");
1689 edje_object_signal_emit(it->base.view,
1690 "elm,state,selected", "elm");
1692 edje_object_signal_emit(it->base.view,
1693 "elm,state,disabled", "elm");
1695 edje_object_signal_emit(it->base.view,
1696 "elm,state,expanded", "elm");
1701 _item_cache_free(Item_Cache *itc)
1703 if (itc->spacer) evas_object_del(itc->spacer);
1704 if (itc->base_view) evas_object_del(itc->base_view);
1705 if (itc->item_style) eina_stringshare_del(itc->item_style);
1710 _item_label_realize(Elm_Genlist_Item *it,
1711 Evas_Object *target,
1712 const Eina_List *source)
1714 if (it->itc->func.label_get)
1720 elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1721 EINA_LIST_FOREACH(source, l, key)
1723 char *s = it->itc->func.label_get
1724 ((void *)it->base.data, it->base.widget, key);
1728 edje_object_part_text_set(target, key, s);
1733 edje_object_part_text_set(target, key, "");
1740 _item_icon_realize(Elm_Genlist_Item *it,
1741 Evas_Object *target,
1744 Eina_List *res = NULL;
1746 if (it->itc->func.icon_get)
1752 elm_widget_stringlist_get(edje_object_data_get(target,
1754 EINA_LIST_FOREACH(source, l, key)
1756 Evas_Object *ic = it->itc->func.icon_get
1757 ((void *)it->base.data, it->base.widget, key);
1761 res = eina_list_append(res, ic);
1762 edje_object_part_swallow(it->mode_view, key, ic);
1763 evas_object_show(ic);
1764 elm_widget_sub_object_add(it->base.widget, ic);
1773 _item_state_realize(Elm_Genlist_Item *it,
1774 Evas_Object *target,
1777 if (it->itc->func.state_get)
1784 elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1785 EINA_LIST_FOREACH(source, l, key)
1787 Eina_Bool on = it->itc->func.state_get
1788 ((void *)it->base.data, it->base.widget, key);
1792 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1793 edje_object_signal_emit(target, buf, "elm");
1797 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1798 edje_object_signal_emit(target, buf, "elm");
1805 _item_realize(Elm_Genlist_Item *it,
1809 Elm_Genlist_Item *it2;
1810 const char *treesize;
1812 int depth, tsize = 20;
1813 Item_Cache *itc = NULL;
1815 if (it->delete_me) return ;
1818 if (it->order_num_in != in)
1820 it->order_num_in = in;
1821 _elm_genlist_item_odd_even_update(it);
1822 _elm_genlist_item_state_update(it, NULL);
1826 it->order_num_in = in;
1829 it->nocache = EINA_FALSE;
1831 itc = _item_cache_find(it);
1834 it->base.view = itc->base_view;
1835 itc->base_view = NULL;
1836 it->spacer = itc->spacer;
1841 const char *stacking_even;
1842 const char *stacking;
1844 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1845 edje_object_scale_set(it->base.view,
1846 elm_widget_scale_get(it->base.widget) *
1847 _elm_config->scale);
1848 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1849 elm_widget_sub_object_add(it->base.widget, it->base.view);
1851 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1852 strncpy(buf, "tree", sizeof(buf));
1853 else strncpy(buf, "item", sizeof(buf));
1854 if (it->wd->compress)
1855 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1857 strncat(buf, "/", sizeof(buf) - strlen(buf));
1858 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1860 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1861 elm_widget_style_get(it->base.widget));
1863 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1864 if (!stacking_even) stacking_even = "above";
1865 it->stacking_even = !!strcmp("above", stacking_even);
1867 stacking = edje_object_data_get(it->base.view, "stacking");
1868 if (!stacking) stacking = "yes";
1869 it->nostacking = !!strcmp("yes", stacking);
1871 edje_object_mirrored_set(it->base.view,
1872 elm_widget_mirrored_get(it->base.widget));
1874 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1875 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1876 elm_widget_sub_object_add(it->base.widget, it->spacer);
1879 _elm_genlist_item_odd_even_update(it);
1881 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1883 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1885 it->expanded_depth = depth;
1886 treesize = edje_object_data_get(it->base.view, "treesize");
1887 if (treesize) tsize = atoi(treesize);
1888 evas_object_size_hint_min_set(it->spacer,
1889 (depth * tsize) * _elm_config->scale, 1);
1890 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1893 edje_object_signal_callback_add(it->base.view,
1894 "elm,action,expand,toggle",
1895 "elm", _signal_expand_toggle, it);
1896 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1897 "elm", _signal_expand, it);
1898 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1899 "elm", _signal_contract, it);
1900 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1902 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1904 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1906 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1908 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1910 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1913 _elm_genlist_item_state_update(it, itc);
1916 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1918 /* homogenous genlist shortcut */
1921 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1923 it->w = it->minw = it->wd->group_item_width;
1924 it->h = it->minh = it->wd->group_item_height;
1928 it->w = it->minw = it->wd->item_width;
1929 it->h = it->minh = it->wd->item_height;
1931 it->mincalcd = EINA_TRUE;
1936 /* FIXME: If you see that assert, please notify us and we
1937 will clean our mess */
1938 assert(eina_list_count(it->icon_objs) != 0);
1940 _item_label_realize(it, it->base.view, it->labels);
1941 it->icon_objs = _item_icon_realize(it, it->base.view, it->icons);
1942 _item_state_realize(it, it->base.view, it->states);
1946 Evas_Coord mw = -1, mh = -1;
1948 if (it->wd->height_for_width) mw = it->wd->w;
1950 if (!it->display_only)
1951 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1952 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1953 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1955 if (!it->display_only)
1956 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1957 it->w = it->minw = mw;
1958 it->h = it->minh = mh;
1959 it->mincalcd = EINA_TRUE;
1961 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1963 it->wd->group_item_width = mw;
1964 it->wd->group_item_height = mh;
1966 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1968 it->wd->item_width = mw;
1969 it->wd->item_height = mh;
1972 if (!calc) evas_object_show(it->base.view);
1975 if (it->tooltip.content_cb)
1977 elm_widget_item_tooltip_content_cb_set(it,
1978 it->tooltip.content_cb,
1979 it->tooltip.data, NULL);
1980 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1983 if (it->mouse_cursor)
1984 elm_widget_item_cursor_set(it, it->mouse_cursor);
1986 it->realized = EINA_TRUE;
1987 it->want_unrealize = EINA_FALSE;
1989 if (itc) _item_cache_free(itc);
1990 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1994 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1998 if (!it->realized) return;
1999 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2002 ecore_timer_del(it->long_timer);
2003 it->long_timer = NULL;
2007 evas_object_del(it->base.view);
2008 it->base.view = NULL;
2009 evas_object_del(it->spacer);
2014 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2015 _item_cache_add(it);
2017 elm_widget_stringlist_free(it->labels);
2019 elm_widget_stringlist_free(it->icons);
2021 elm_widget_stringlist_free(it->states);
2023 EINA_LIST_FREE(it->icon_objs, icon)
2024 evas_object_del(icon);
2026 _mode_item_unrealize(it);
2028 it->realized = EINA_FALSE;
2029 it->want_unrealize = EINA_FALSE;
2033 _item_block_recalc(Item_Block *itb,
2039 Elm_Genlist_Item *it;
2040 Evas_Coord minw = 0, minh = 0;
2041 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2045 EINA_LIST_FOREACH(itb->items, l, it)
2047 if (it->delete_me) continue;
2048 showme |= it->showme;
2053 if (!it->mincalcd) changed = EINA_TRUE;
2056 _item_realize(it, in, EINA_TRUE);
2057 _item_unrealize(it, EINA_TRUE);
2062 _item_realize(it, in, EINA_TRUE);
2063 _item_unrealize(it, EINA_TRUE);
2067 _item_realize(it, in, EINA_FALSE);
2069 if (minw < it->minw) minw = it->minw;
2077 itb->changed = EINA_FALSE;
2078 /* force an evas norender to garbage collect deleted objects */
2079 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2084 _item_block_realize(Item_Block *itb,
2089 Elm_Genlist_Item *it;
2091 if (itb->realized) return;
2092 EINA_LIST_FOREACH(itb->items, l, it)
2094 if (it->delete_me) continue;
2095 if (full) _item_realize(it, in, EINA_FALSE);
2098 itb->realized = EINA_TRUE;
2099 itb->want_unrealize = EINA_FALSE;
2103 _item_block_unrealize(Item_Block *itb)
2106 Elm_Genlist_Item *it;
2107 Eina_Bool dragging = EINA_FALSE;
2109 if (!itb->realized) return;
2110 EINA_LIST_FOREACH(itb->items, l, it)
2112 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2116 dragging = EINA_TRUE;
2117 it->want_unrealize = EINA_TRUE;
2120 _item_unrealize(it, EINA_FALSE);
2125 itb->realized = EINA_FALSE;
2126 itb->want_unrealize = EINA_TRUE;
2129 itb->want_unrealize = EINA_FALSE;
2133 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2138 evas_object_resize(view, it->w, it->h);
2139 evas_object_move(view, it->scrl_x, it->scrl_y);
2140 evas_object_show(view);
2144 _item_block_position(Item_Block *itb,
2148 Elm_Genlist_Item *it;
2149 Elm_Genlist_Item *git;
2150 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2153 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2154 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2156 EINA_LIST_FOREACH(itb->items, l, it)
2158 if (it->delete_me) continue;
2162 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2163 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2165 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2166 cvx, cvy, cvw, cvh));
2167 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2169 if ((itb->realized) && (!it->realized))
2171 if (vis) _item_realize(it, in, EINA_FALSE);
2177 git = it->group_item;
2180 if (git->scrl_y < oy)
2182 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2183 git->scrl_y = (it->scrl_y + it->h) - git->h;
2184 git->want_realize = EINA_TRUE;
2187 _item_position(it, it->mode_view);
2189 _item_position(it, it->base.view);
2193 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2200 if (vis) it->want_realize = EINA_TRUE;
2207 _group_items_recalc(void *data)
2209 Widget_Data *wd = data;
2211 Elm_Genlist_Item *git;
2213 EINA_LIST_FOREACH(wd->group_items, l, git)
2215 if (git->want_realize)
2218 _item_realize(git, 0, EINA_FALSE);
2219 evas_object_resize(git->base.view, wd->minw, git->h);
2220 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2221 evas_object_show(git->base.view);
2222 evas_object_raise(git->base.view);
2224 else if (!git->want_realize && git->realized)
2227 _item_unrealize(git, EINA_FALSE);
2233 _must_recalc_idler(void *data)
2235 Widget_Data *wd = data;
2236 if (wd->calc_job) ecore_job_del(wd->calc_job);
2237 wd->calc_job = ecore_job_add(_calc_job, wd);
2238 wd->must_recalc_idler = NULL;
2239 return ECORE_CALLBACK_CANCEL;
2243 _calc_job(void *data)
2245 Widget_Data *wd = data;
2247 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2248 Item_Block *chb = NULL;
2249 int in = 0, minw_change = 0;
2250 Eina_Bool changed = EINA_FALSE;
2252 Eina_Bool did_must_recalc = EINA_FALSE;
2255 t0 = ecore_time_get();
2256 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2260 // if (wd->height_for_width) changed = EINA_TRUE;
2263 EINA_INLIST_FOREACH(wd->blocks, itb)
2265 Eina_Bool showme = EINA_FALSE;
2268 showme = itb->showme;
2269 itb->showme = EINA_FALSE;
2272 if (itb->realized) _item_block_unrealize(itb);
2274 if ((itb->changed) || (changed) ||
2275 ((itb->must_recalc) && (!did_must_recalc)))
2277 if ((changed) || (itb->must_recalc))
2280 Elm_Genlist_Item *it;
2281 EINA_LIST_FOREACH(itb->items, l, it)
2282 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2283 itb->changed = EINA_TRUE;
2284 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2285 itb->must_recalc = EINA_FALSE;
2287 if (itb->realized) _item_block_unrealize(itb);
2288 showme = _item_block_recalc(itb, in, 0, 1);
2294 if (minw == -1) minw = itb->minw;
2295 else if ((!itb->must_recalc) && (minw < itb->minw))
2304 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2306 wd->show_item->showme = EINA_FALSE;
2308 elm_smart_scroller_region_bring_in(wd->scr,
2310 wd->show_item->block->x,
2312 wd->show_item->block->y,
2313 wd->show_item->block->w,
2316 elm_smart_scroller_child_region_show(wd->scr,
2318 wd->show_item->block->x,
2320 wd->show_item->block->y,
2321 wd->show_item->block->w,
2323 wd->show_item = NULL;
2328 EINA_INLIST_FOREACH(wd->blocks, itb)
2334 if ((chb) && (EINA_INLIST_GET(chb)->next))
2336 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2338 if (itb->realized) _item_block_unrealize(itb);
2341 wd->realminw = minw;
2342 if (minw < wd->w) minw = wd->w;
2343 if ((minw != wd->minw) || (minh != wd->minh))
2347 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2348 _sizing_eval(wd->obj);
2349 if ((wd->anchor_item) && (wd->anchor_item->block))
2351 Elm_Genlist_Item *it;
2354 it = wd->anchor_item;
2355 it_y = wd->anchor_y;
2356 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2357 it->block->y + it->y + it_y);
2358 wd->anchor_item = it;
2359 wd->anchor_y = it_y;
2362 t = ecore_time_get();
2363 if (did_must_recalc)
2365 if (!wd->must_recalc_idler)
2366 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2368 wd->calc_job = NULL;
2369 evas_object_smart_changed(wd->pan_smart);
2373 _update_job(void *data)
2375 Widget_Data *wd = data;
2378 int num, num0, position = 0, recalc = 0;
2380 wd->update_job = NULL;
2382 EINA_INLIST_FOREACH(wd->blocks, itb)
2384 Evas_Coord itminw, itminh;
2385 Elm_Genlist_Item *it;
2391 _item_block_position(itb, num);
2396 EINA_LIST_FOREACH(itb->items, l2, it)
2403 it->updateme = EINA_FALSE;
2406 _item_unrealize(it, EINA_FALSE);
2407 _item_realize(it, num, EINA_FALSE);
2412 _item_realize(it, num, EINA_TRUE);
2413 _item_unrealize(it, EINA_TRUE);
2415 if ((it->minw != itminw) || (it->minh != itminh))
2420 itb->updateme = EINA_FALSE;
2424 itb->changed = EINA_TRUE;
2425 _item_block_recalc(itb, num0, 0, 1);
2426 _item_block_position(itb, num0);
2431 if (wd->calc_job) ecore_job_del(wd->calc_job);
2432 wd->calc_job = ecore_job_add(_calc_job, wd);
2437 _pan_set(Evas_Object *obj,
2441 Pan *sd = evas_object_smart_data_get(obj);
2444 // Evas_Coord ow, oh;
2445 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2446 // ow = sd->wd->minw - ow;
2447 // if (ow < 0) ow = 0;
2448 // oh = sd->wd->minh - oh;
2449 // if (oh < 0) oh = 0;
2450 // if (x < 0) x = 0;
2451 // if (y < 0) y = 0;
2452 // if (x > ow) x = ow;
2453 // if (y > oh) y = oh;
2454 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2458 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2460 if ((itb->y + itb->h) > y)
2462 Elm_Genlist_Item *it;
2465 EINA_LIST_FOREACH(itb->items, l2, it)
2467 if ((itb->y + it->y) >= y)
2469 sd->wd->anchor_item = it;
2470 sd->wd->anchor_y = -(itb->y + it->y - y);
2477 evas_object_smart_changed(obj);
2481 _pan_get(Evas_Object *obj,
2485 Pan *sd = evas_object_smart_data_get(obj);
2487 if (x) *x = sd->wd->pan_x;
2488 if (y) *y = sd->wd->pan_y;
2492 _pan_max_get(Evas_Object *obj,
2496 Pan *sd = evas_object_smart_data_get(obj);
2499 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2500 ow = sd->wd->minw - ow;
2502 oh = sd->wd->minh - oh;
2509 _pan_min_get(Evas_Object *obj __UNUSED__,
2518 _pan_child_size_get(Evas_Object *obj,
2522 Pan *sd = evas_object_smart_data_get(obj);
2524 if (w) *w = sd->wd->minw;
2525 if (h) *h = sd->wd->minh;
2529 _pan_add(Evas_Object *obj)
2532 Evas_Object_Smart_Clipped_Data *cd;
2535 cd = evas_object_smart_data_get(obj);
2538 sd->__clipped_data = *cd;
2540 evas_object_smart_data_set(obj, sd);
2544 _pan_del(Evas_Object *obj)
2546 Pan *sd = evas_object_smart_data_get(obj);
2551 ecore_job_del(sd->resize_job);
2552 sd->resize_job = NULL;
2558 _pan_resize_job(void *data)
2561 _sizing_eval(sd->wd->obj);
2562 sd->resize_job = NULL;
2566 _pan_resize(Evas_Object *obj,
2570 Pan *sd = evas_object_smart_data_get(obj);
2573 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2574 if ((ow == w) && (oh == h)) return;
2575 if ((sd->wd->height_for_width) && (ow != w))
2577 if (sd->resize_job) ecore_job_del(sd->resize_job);
2578 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2580 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2581 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2585 _pan_calculate(Evas_Object *obj)
2587 Pan *sd = evas_object_smart_data_get(obj);
2589 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2591 Elm_Genlist_Item *git;
2594 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2595 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2596 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2598 git->want_realize = EINA_FALSE;
2600 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2602 itb->w = sd->wd->minw;
2603 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2604 itb->y - sd->wd->pan_y + oy,
2606 cvx, cvy, cvw, cvh))
2608 if ((!itb->realized) || (itb->changed))
2609 _item_block_realize(itb, in, 0);
2610 _item_block_position(itb, in);
2614 if (itb->realized) _item_block_unrealize(itb);
2618 _group_items_recalc(sd->wd);
2622 _pan_move(Evas_Object *obj,
2623 Evas_Coord x __UNUSED__,
2624 Evas_Coord y __UNUSED__)
2626 Pan *sd = evas_object_smart_data_get(obj);
2628 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2629 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2633 _hold_on(void *data __UNUSED__,
2635 void *event_info __UNUSED__)
2637 Widget_Data *wd = elm_widget_data_get(obj);
2639 elm_smart_scroller_hold_set(wd->scr, 1);
2643 _hold_off(void *data __UNUSED__,
2645 void *event_info __UNUSED__)
2647 Widget_Data *wd = elm_widget_data_get(obj);
2649 elm_smart_scroller_hold_set(wd->scr, 0);
2653 _freeze_on(void *data __UNUSED__,
2655 void *event_info __UNUSED__)
2657 Widget_Data *wd = elm_widget_data_get(obj);
2659 elm_smart_scroller_freeze_set(wd->scr, 1);
2663 _freeze_off(void *data __UNUSED__,
2665 void *event_info __UNUSED__)
2667 Widget_Data *wd = elm_widget_data_get(obj);
2669 elm_smart_scroller_freeze_set(wd->scr, 0);
2673 _scroll_edge_left(void *data,
2674 Evas_Object *scr __UNUSED__,
2675 void *event_info __UNUSED__)
2677 Evas_Object *obj = data;
2678 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2682 _scroll_edge_right(void *data,
2683 Evas_Object *scr __UNUSED__,
2684 void *event_info __UNUSED__)
2686 Evas_Object *obj = data;
2687 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2691 _scroll_edge_top(void *data,
2692 Evas_Object *scr __UNUSED__,
2693 void *event_info __UNUSED__)
2695 Evas_Object *obj = data;
2696 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2700 _scroll_edge_bottom(void *data,
2701 Evas_Object *scr __UNUSED__,
2702 void *event_info __UNUSED__)
2704 Evas_Object *obj = data;
2705 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2709 _mode_item_realize(Elm_Genlist_Item *it)
2713 if ((it->mode_view) || (it->delete_me)) return;
2715 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2716 edje_object_scale_set(it->mode_view,
2717 elm_widget_scale_get(it->base.widget) *
2718 _elm_config->scale);
2719 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2720 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2722 strncpy(buf, "item", sizeof(buf));
2723 if (it->wd->compress)
2724 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2726 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2727 strncat(buf, "/", sizeof(buf) - strlen(buf));
2728 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2730 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2731 elm_widget_style_get(it->base.widget));
2732 edje_object_mirrored_set(it->mode_view,
2733 elm_widget_mirrored_get(it->base.widget));
2735 /* signal callback add */
2736 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2738 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2740 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2743 /* label_get, icon_get, state_get */
2744 /* FIXME: If you see that assert, please notify us and we
2745 will clean our mess */
2746 assert(eina_list_count(it->mode_icon_objs) != 0);
2748 _item_label_realize(it, it->mode_view, it->mode_labels);
2749 it->mode_icon_objs = _item_icon_realize(it, it->mode_view, it->mode_icons);
2750 _item_state_realize(it, it->mode_view, it->mode_states);
2752 edje_object_part_swallow(it->mode_view,
2753 edje_object_data_get(it->mode_view, "mode_part"),
2756 it->want_unrealize = EINA_FALSE;
2760 _mode_item_unrealize(Elm_Genlist_Item *it)
2762 Widget_Data *wd = it->wd;
2764 if (!it->mode_view) return;
2766 elm_widget_stringlist_free(it->mode_labels);
2767 it->mode_labels = NULL;
2768 elm_widget_stringlist_free(it->mode_icons);
2769 it->mode_icons = NULL;
2770 elm_widget_stringlist_free(it->mode_states);
2772 EINA_LIST_FREE(it->mode_icon_objs, icon)
2773 evas_object_del(icon);
2775 edje_object_part_unswallow(it->mode_view, it->base.view);
2776 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2777 evas_object_del(it->mode_view);
2778 it->mode_view = NULL;
2780 if (wd->mode_item == it)
2781 wd->mode_item = NULL;
2785 _item_mode_set(Elm_Genlist_Item *it)
2788 Widget_Data *wd = it->wd;
2793 it->nocache = EINA_TRUE;
2795 if (wd->scr_hold_timer)
2797 ecore_timer_del(wd->scr_hold_timer);
2798 wd->scr_hold_timer = NULL;
2800 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2801 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2803 _mode_item_realize(it);
2804 _item_position(it, it->mode_view);
2806 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2807 edje_object_signal_emit(it->mode_view, buf, "elm");
2811 _item_mode_unset(Widget_Data *wd)
2814 if (!wd->mode_item) return;
2815 char buf[1024], buf2[1024];
2816 Elm_Genlist_Item *it;
2819 it->nocache = EINA_TRUE;
2821 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2822 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2824 edje_object_signal_emit(it->mode_view, buf, "elm");
2825 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2827 wd->mode_item = NULL;
2831 * Add a new Genlist object
2833 * @param parent The parent object
2834 * @return The new object or NULL if it cannot be created
2839 elm_genlist_add(Evas_Object *parent)
2844 Evas_Coord minw, minh;
2845 static Evas_Smart *smart = NULL;
2849 static Evas_Smart_Class sc;
2851 evas_object_smart_clipped_smart_set(&_pan_sc);
2853 sc.name = "elm_genlist_pan";
2854 sc.version = EVAS_SMART_CLASS_VERSION;
2857 sc.resize = _pan_resize;
2858 sc.move = _pan_move;
2859 sc.calculate = _pan_calculate;
2860 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2863 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2865 ELM_SET_WIDTYPE(widtype, "genlist");
2866 elm_widget_type_set(obj, "genlist");
2867 elm_widget_sub_object_add(parent, obj);
2868 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2869 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2870 elm_widget_data_set(obj, wd);
2871 elm_widget_del_hook_set(obj, _del_hook);
2872 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2873 elm_widget_theme_hook_set(obj, _theme_hook);
2874 elm_widget_can_focus_set(obj, EINA_TRUE);
2875 elm_widget_event_hook_set(obj, _event_hook);
2876 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2878 wd->scr = elm_smart_scroller_add(e);
2879 elm_smart_scroller_widget_set(wd->scr, obj);
2880 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2881 elm_widget_style_get(obj));
2882 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2883 _elm_config->thumbscroll_bounce_enable);
2884 elm_widget_resize_object_set(obj, wd->scr);
2886 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2887 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2889 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2890 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2894 wd->mode = ELM_LIST_SCROLL;
2895 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2896 wd->item_cache_max = wd->max_items_per_block * 2;
2897 wd->longpress_timeout = _elm_config->longpress_timeout;
2899 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2900 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2901 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2902 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2904 wd->pan_smart = evas_object_smart_add(e, smart);
2905 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2908 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2909 _pan_set, _pan_get, _pan_max_get,
2910 _pan_min_get, _pan_child_size_get);
2912 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2914 evas_object_size_hint_min_set(obj, minw, minh);
2916 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2921 static Elm_Genlist_Item *
2922 _item_new(Widget_Data *wd,
2923 const Elm_Genlist_Item_Class *itc,
2925 Elm_Genlist_Item *parent,
2926 Elm_Genlist_Item_Flags flags,
2928 const void *func_data)
2930 Elm_Genlist_Item *it;
2932 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2933 if (!it) return NULL;
2936 it->base.data = data;
2937 it->parent = parent;
2939 it->func.func = func;
2940 it->func.data = func_data;
2941 it->mouse_cursor = NULL;
2942 it->expanded_depth = 0;
2947 _item_block_add(Widget_Data *wd,
2948 Elm_Genlist_Item *it)
2950 Item_Block *itb = NULL;
2957 itb = calloc(1, sizeof(Item_Block));
2960 if (!it->rel->block)
2963 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2964 itb->items = eina_list_append(itb->items, it);
2970 wd->blocks = eina_inlist_prepend_relative
2971 (wd->blocks, EINA_INLIST_GET(itb),
2972 EINA_INLIST_GET(it->rel->block));
2974 eina_list_prepend_relative(itb->items, it, it->rel);
2978 wd->blocks = eina_inlist_append_relative
2979 (wd->blocks, EINA_INLIST_GET(itb),
2980 EINA_INLIST_GET(it->rel->block));
2982 eina_list_append_relative(itb->items, it, it->rel);
2992 itb = (Item_Block *)(wd->blocks);
2993 if (itb->count >= wd->max_items_per_block)
2995 itb = calloc(1, sizeof(Item_Block));
2999 eina_inlist_prepend(wd->blocks,
3000 EINA_INLIST_GET(itb));
3005 itb = calloc(1, sizeof(Item_Block));
3009 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3011 itb->items = eina_list_prepend(itb->items, it);
3017 itb = (Item_Block *)(wd->blocks->last);
3018 if (itb->count >= wd->max_items_per_block)
3020 itb = calloc(1, sizeof(Item_Block));
3024 eina_inlist_append(wd->blocks,
3025 EINA_INLIST_GET(itb));
3030 itb = calloc(1, sizeof(Item_Block));
3034 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3036 itb->items = eina_list_append(itb->items, it);
3042 itb = it->rel->block;
3043 if (!itb) goto newblock;
3045 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3047 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3050 itb->changed = EINA_TRUE;
3052 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3053 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3056 it->rel->relcount--;
3057 if ((it->rel->delete_me) && (!it->rel->relcount))
3061 if (itb->count > itb->wd->max_items_per_block)
3065 Elm_Genlist_Item *it2;
3067 newc = itb->count / 2;
3068 itb2 = calloc(1, sizeof(Item_Block));
3072 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3073 EINA_INLIST_GET(itb));
3074 itb2->changed = EINA_TRUE;
3075 while ((itb->count > newc) && (itb->items))
3079 l = eina_list_last(itb->items);
3081 itb->items = eina_list_remove_list(itb->items, l);
3084 itb2->items = eina_list_prepend(itb2->items, it2);
3092 _queue_process(Widget_Data *wd,
3096 Eina_Bool showme = EINA_FALSE;
3099 t0 = ecore_time_get();
3100 for (n = 0; (wd->queue) && (n < 128); n++)
3102 Elm_Genlist_Item *it;
3104 it = wd->queue->data;
3105 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3106 it->queued = EINA_FALSE;
3107 _item_block_add(wd, it);
3108 t = ecore_time_get();
3109 if (it->block->changed)
3111 showme = _item_block_recalc(it->block, it->block->num, 1,
3113 it->block->changed = 0;
3115 if (showme) it->block->showme = EINA_TRUE;
3116 if (eina_inlist_count(wd->blocks) > 1)
3118 if ((t - t0) > (ecore_animator_frametime_get())) break;
3125 _item_idler(void *data)
3127 Widget_Data *wd = data;
3130 //static double q_start = 0.0;
3131 //if (q_start == 0.0) q_start = ecore_time_get();
3134 if (_queue_process(wd, 1) > 0)
3136 if (wd->calc_job) ecore_job_del(wd->calc_job);
3137 wd->calc_job = ecore_job_add(_calc_job, wd);
3142 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3144 wd->queue_idler = NULL;
3145 return ECORE_CALLBACK_CANCEL;
3147 return ECORE_CALLBACK_RENEW;
3151 _item_queue(Widget_Data *wd,
3152 Elm_Genlist_Item *it)
3154 if (it->queued) return;
3155 it->queued = EINA_TRUE;
3156 wd->queue = eina_list_append(wd->queue, it);
3157 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3159 if (wd->queue_idler)
3161 ecore_idler_del(wd->queue_idler);
3162 wd->queue_idler = NULL;
3164 _queue_process(wd, 0);
3166 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3170 * Append item to the end of the genlist
3172 * This appends the given item to the end of the list or the end of
3173 * the children if the parent is given.
3175 * @param obj The genlist object
3176 * @param itc The item class for the item
3177 * @param data The item data
3178 * @param parent The parent item, or NULL if none
3179 * @param flags Item flags
3180 * @param func Convenience function called when item selected
3181 * @param func_data Data passed to @p func above.
3182 * @return A handle to the item added or NULL if not possible
3186 EAPI Elm_Genlist_Item *
3187 elm_genlist_item_append(Evas_Object *obj,
3188 const Elm_Genlist_Item_Class *itc,
3190 Elm_Genlist_Item *parent,
3191 Elm_Genlist_Item_Flags flags,
3193 const void *func_data)
3195 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3196 Widget_Data *wd = elm_widget_data_get(obj);
3197 if (!wd) return NULL;
3198 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3200 if (!it) return NULL;
3203 if (flags & ELM_GENLIST_ITEM_GROUP)
3204 wd->group_items = eina_list_append(wd->group_items, it);
3205 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3210 Elm_Genlist_Item *it2 = NULL;
3211 Eina_List *ll = eina_list_last(it->parent->items);
3212 if (ll) it2 = ll->data;
3213 it->parent->items = eina_list_append(it->parent->items, it);
3214 if (!it2) it2 = it->parent;
3216 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3217 EINA_INLIST_GET(it2));
3219 it->rel->relcount++;
3221 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3222 it->group_item = parent;
3223 else if (it->parent->group_item)
3224 it->group_item = it->parent->group_item;
3226 it->before = EINA_FALSE;
3227 _item_queue(wd, it);
3232 * Prepend item at start of the genlist
3234 * This adds an item to the beginning of the list or beginning of the
3235 * children of the parent if given.
3237 * @param obj The genlist object
3238 * @param itc The item class for the item
3239 * @param data The item data
3240 * @param parent The parent item, or NULL if none
3241 * @param flags Item flags
3242 * @param func Convenience function called when item selected
3243 * @param func_data Data passed to @p func above.
3244 * @return A handle to the item added or NULL if not possible
3248 EAPI Elm_Genlist_Item *
3249 elm_genlist_item_prepend(Evas_Object *obj,
3250 const Elm_Genlist_Item_Class *itc,
3252 Elm_Genlist_Item *parent,
3253 Elm_Genlist_Item_Flags flags,
3255 const void *func_data)
3257 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3258 Widget_Data *wd = elm_widget_data_get(obj);
3259 if (!wd) return NULL;
3260 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3262 if (!it) return NULL;
3265 if (flags & ELM_GENLIST_ITEM_GROUP)
3266 wd->group_items = eina_list_prepend(wd->group_items, it);
3267 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3272 Elm_Genlist_Item *it2 = NULL;
3273 Eina_List *ll = it->parent->items;
3274 if (ll) it2 = ll->data;
3275 it->parent->items = eina_list_prepend(it->parent->items, it);
3276 if (!it2) it2 = it->parent;
3278 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3279 EINA_INLIST_GET(it2));
3281 it->rel->relcount++;
3283 it->before = EINA_TRUE;
3284 _item_queue(wd, it);
3289 * Insert item before another in the genlist
3291 * This inserts an item before another in the list. It will be in the
3292 * same tree level or group as the item it is inseted before.
3294 * @param obj The genlist object
3295 * @param itc The item class for the item
3296 * @param data The item data
3297 * @param before The item to insert before
3298 * @param flags Item flags
3299 * @param func Convenience function called when item selected
3300 * @param func_data Data passed to @p func above.
3301 * @return A handle to the item added or NULL if not possible
3305 EAPI Elm_Genlist_Item *
3306 elm_genlist_item_insert_before(Evas_Object *obj,
3307 const Elm_Genlist_Item_Class *itc,
3309 Elm_Genlist_Item *parent,
3310 Elm_Genlist_Item *before,
3311 Elm_Genlist_Item_Flags flags,
3313 const void *func_data)
3315 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3316 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3317 Widget_Data *wd = elm_widget_data_get(obj);
3318 if (!wd) return NULL;
3319 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3321 if (!it) return NULL;
3324 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3327 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3328 EINA_INLIST_GET(before));
3330 it->rel->relcount++;
3331 it->before = EINA_TRUE;
3332 _item_queue(wd, it);
3337 * Insert an item after another in the genlst
3339 * This inserts an item after another in the list. It will be in the
3340 * same tree level or group as the item it is inseted after.
3342 * @param obj The genlist object
3343 * @param itc The item class for the item
3344 * @param data The item data
3345 * @param after The item to insert after
3346 * @param flags Item flags
3347 * @param func Convenience function called when item selected
3348 * @param func_data Data passed to @p func above.
3349 * @return A handle to the item added or NULL if not possible
3353 EAPI Elm_Genlist_Item *
3354 elm_genlist_item_insert_after(Evas_Object *obj,
3355 const Elm_Genlist_Item_Class *itc,
3357 Elm_Genlist_Item *parent,
3358 Elm_Genlist_Item *after,
3359 Elm_Genlist_Item_Flags flags,
3361 const void *func_data)
3363 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3364 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3365 Widget_Data *wd = elm_widget_data_get(obj);
3366 if (!wd) return NULL;
3367 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3369 if (!it) return NULL;
3370 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3371 EINA_INLIST_GET(after));
3374 it->parent->items = eina_list_append_relative(it->parent->items, it,
3378 it->rel->relcount++;
3379 it->before = EINA_FALSE;
3380 _item_queue(wd, it);
3387 * This clears all items in the list, leaving it empty.
3389 * @param obj The genlist object
3394 elm_genlist_clear(Evas_Object *obj)
3396 ELM_CHECK_WIDTYPE(obj, widtype);
3397 Widget_Data *wd = elm_widget_data_get(obj);
3399 if (wd->walking > 0)
3401 Elm_Genlist_Item *it;
3403 wd->clear_me = EINA_TRUE;
3404 EINA_INLIST_FOREACH(wd->items, it)
3406 it->delete_me = EINA_TRUE;
3412 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3414 if (wd->anchor_item == it)
3416 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3417 if (!wd->anchor_item)
3419 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3421 wd->items = eina_inlist_remove(wd->items, wd->items);
3422 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3423 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3424 elm_widget_item_pre_notify_del(it);
3425 if (it->realized) _item_unrealize(it, EINA_FALSE);
3426 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3427 it->itc->func.del((void *)it->base.data, it->base.widget);
3428 if (it->long_timer) ecore_timer_del(it->long_timer);
3429 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3430 elm_widget_item_del(it);
3432 wd->clear_me = EINA_FALSE;
3433 wd->anchor_item = NULL;
3436 Item_Block *itb = (Item_Block *)(wd->blocks);
3438 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3439 if (itb->items) eina_list_free(itb->items);
3444 ecore_job_del(wd->calc_job);
3445 wd->calc_job = NULL;
3447 if (wd->queue_idler)
3449 ecore_idler_del(wd->queue_idler);
3450 wd->queue_idler = NULL;
3452 if (wd->must_recalc_idler)
3454 ecore_idler_del(wd->must_recalc_idler);
3455 wd->must_recalc_idler = NULL;
3459 eina_list_free(wd->queue);
3464 eina_list_free(wd->selected);
3465 wd->selected = NULL;
3467 wd->show_item = NULL;
3474 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3475 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3481 * Enable or disable multi-select in the genlist
3483 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3484 * the list. This allows more than 1 item to be selected.
3486 * @param obj The genlist object
3487 * @param multi Multi-select enable/disable
3492 elm_genlist_multi_select_set(Evas_Object *obj,
3495 ELM_CHECK_WIDTYPE(obj, widtype);
3496 Widget_Data *wd = elm_widget_data_get(obj);
3502 * Gets if multi-select in genlist is enable or disable
3504 * @param obj The genlist object
3505 * @return Multi-select enable/disable
3506 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3511 elm_genlist_multi_select_get(const Evas_Object *obj)
3513 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3514 Widget_Data *wd = elm_widget_data_get(obj);
3515 if (!wd) return EINA_FALSE;
3520 * Get the selectd item in the genlist
3522 * This gets the selected item in the list (if multi-select is enabled
3523 * only the first item in the list is selected - which is not very
3524 * useful, so see elm_genlist_selected_items_get() for when
3525 * multi-select is used).
3527 * If no item is selected, NULL is returned.
3529 * @param obj The genlist object
3530 * @return The selected item, or NULL if none.
3534 EAPI Elm_Genlist_Item *
3535 elm_genlist_selected_item_get(const Evas_Object *obj)
3537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3538 Widget_Data *wd = elm_widget_data_get(obj);
3539 if (!wd) return NULL;
3540 if (wd->selected) return wd->selected->data;
3545 * Get a list of selected items in the genlist
3547 * This returns a list of the selected items. This list pointer is
3548 * only valid so long as no items are selected or unselected (or
3549 * unselected implicitly by deletion). The list contains
3550 * Elm_Genlist_Item pointers.
3552 * @param obj The genlist object
3553 * @return The list of selected items, nor NULL if none are selected.
3557 EAPI const Eina_List *
3558 elm_genlist_selected_items_get(const Evas_Object *obj)
3560 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3561 Widget_Data *wd = elm_widget_data_get(obj);
3562 if (!wd) return NULL;
3563 return wd->selected;
3567 * Get a list of realized items in genlist
3569 * This returns a list of the realized items in the genlist. The list
3570 * contains Elm_Genlist_Item pointers. The list must be freed by the
3571 * caller when done with eina_list_free(). The item pointers in the
3572 * list are only valid so long as those items are not deleted or the
3573 * genlist is not deleted.
3575 * @param obj The genlist object
3576 * @return The list of realized items, nor NULL if none are realized.
3581 elm_genlist_realized_items_get(const Evas_Object *obj)
3583 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3584 Widget_Data *wd = elm_widget_data_get(obj);
3585 Eina_List *list = NULL;
3587 Eina_Bool done = EINA_FALSE;
3588 if (!wd) return NULL;
3589 EINA_INLIST_FOREACH(wd->blocks, itb)
3594 Elm_Genlist_Item *it;
3597 EINA_LIST_FOREACH(itb->items, l, it)
3599 if (it->realized) list = eina_list_append(list, it);
3611 * Get the item that is at the x, y canvas coords
3613 * This returns the item at the given coordinates (which are canvas
3614 * relative not object-relative). If an item is at that coordinate,
3615 * that item handle is returned, and if @p posret is not NULL, the
3616 * integer pointed to is set to a value of -1, 0 or 1, depending if
3617 * the coordinate is on the upper portion of that item (-1), on the
3618 * middle section (0) or on the lower part (1). If NULL is returned as
3619 * an item (no item found there), then posret may indicate -1 or 1
3620 * based if the coordinate is above or below all items respectively in
3623 * @param it The item
3624 * @param x The input x coordinate
3625 * @param y The input y coordinate
3626 * @param posret The position relative to the item returned here
3627 * @return The item at the coordinates or NULL if none
3631 EAPI Elm_Genlist_Item *
3632 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3637 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3638 Widget_Data *wd = elm_widget_data_get(obj);
3639 Evas_Coord ox, oy, ow, oh;
3642 if (!wd) return NULL;
3643 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3645 EINA_INLIST_FOREACH(wd->blocks, itb)
3648 Elm_Genlist_Item *it;
3650 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3651 oy + itb->y - itb->wd->pan_y,
3652 itb->w, itb->h, x, y, 1, 1))
3654 EINA_LIST_FOREACH(itb->items, l, it)
3656 Evas_Coord itx, ity;
3658 itx = ox + itb->x + it->x - itb->wd->pan_x;
3659 ity = oy + itb->y + it->y - itb->wd->pan_y;
3660 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3664 if (y <= (ity + (it->h / 4))) *posret = -1;
3665 else if (y >= (ity + it->h - (it->h / 4)))
3671 lasty = ity + it->h;
3676 if (y > lasty) *posret = 1;
3683 * Get the first item in the genlist
3685 * This returns the first item in the list.
3687 * @param obj The genlist object
3688 * @return The first item, or NULL if none
3692 EAPI Elm_Genlist_Item *
3693 elm_genlist_first_item_get(const Evas_Object *obj)
3695 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3696 Widget_Data *wd = elm_widget_data_get(obj);
3697 if (!wd) return NULL;
3698 if (!wd->items) return NULL;
3699 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3700 while ((it) && (it->delete_me))
3701 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3706 * Get the last item in the genlist
3708 * This returns the last item in the list.
3710 * @return The last item, or NULL if none
3714 EAPI Elm_Genlist_Item *
3715 elm_genlist_last_item_get(const Evas_Object *obj)
3717 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3718 Widget_Data *wd = elm_widget_data_get(obj);
3719 if (!wd) return NULL;
3720 if (!wd->items) return NULL;
3721 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3722 while ((it) && (it->delete_me))
3723 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3728 * Get the next item in the genlist
3730 * This returns the item after the item @p it.
3732 * @param it The item
3733 * @return The item after @p it, or NULL if none
3737 EAPI Elm_Genlist_Item *
3738 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3740 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3743 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3744 if ((it) && (!it->delete_me)) break;
3746 return (Elm_Genlist_Item *)it;
3750 * Get the previous item in the genlist
3752 * This returns the item before the item @p it.
3754 * @param it The item
3755 * @return The item before @p it, or NULL if none
3759 EAPI Elm_Genlist_Item *
3760 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3762 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3765 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3766 if ((it) && (!it->delete_me)) break;
3768 return (Elm_Genlist_Item *)it;
3772 * Get the genlist object from an item
3774 * This returns the genlist object itself that an item belongs to.
3776 * @param it The item
3777 * @return The genlist object
3782 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3784 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3785 return it->base.widget;
3789 * Get the parent item of the given item
3791 * This returns the parent item of the item @p it given.
3793 * @param it The item
3794 * @return The parent of the item or NULL if none
3798 EAPI Elm_Genlist_Item *
3799 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3801 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3806 * Clear all sub-items (children) of the given item
3808 * This clears all items that are children (or their descendants) of the
3811 * @param it The item
3816 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3818 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3819 Eina_List *tl = NULL, *l;
3820 Elm_Genlist_Item *it2;
3822 EINA_LIST_FOREACH(it->items, l, it2)
3823 tl = eina_list_append(tl, it2);
3824 EINA_LIST_FREE(tl, it2)
3825 elm_genlist_item_del(it2);
3829 * Set the selected state of an item
3831 * This sets the selected state (1 selected, 0 not selected) of the given
3834 * @param it The item
3835 * @param selected The selected state
3840 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3843 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3844 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3846 if (it->delete_me) return;
3847 selected = !!selected;
3848 if (it->selected == selected) return;
3854 while (wd->selected)
3855 _item_unselect(wd->selected->data);
3857 _item_highlight(it);
3865 * Get the selected state of an item
3867 * This gets the selected state of an item (1 selected, 0 not selected).
3869 * @param it The item
3870 * @return The selected state
3875 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3877 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3878 return it->selected;
3882 * Sets the expanded state of an item (if it's a parent)
3884 * This expands or contracts a parent item (thus showing or hiding the
3887 * @param it The item
3888 * @param expanded The expanded state (1 expanded, 0 not expanded).
3893 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3896 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3897 if (it->expanded == expanded) return;
3898 it->expanded = expanded;
3902 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3903 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3908 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3909 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3914 * Get the expanded state of an item
3916 * This gets the expanded state of an item
3918 * @param it The item
3919 * @return Thre expanded state
3924 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3926 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3927 return it->expanded;
3931 * Get the depth of expanded item
3933 * @param it The genlist item object
3934 * @return The depth of expanded item
3939 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3941 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3942 return it->expanded_depth;
3946 * Sets the disabled state of an item.
3948 * A disabled item cannot be selected or unselected. It will also
3949 * change appearance to appear disabled. This sets the disabled state
3950 * (1 disabled, 0 not disabled).
3952 * @param it The item
3953 * @param disabled The disabled state
3958 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3961 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3962 if (it->disabled == disabled) return;
3963 if (it->delete_me) return;
3964 it->disabled = disabled;
3968 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3970 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3975 * Get the disabled state of an item
3977 * This gets the disabled state of the given item.
3979 * @param it The item
3980 * @return The disabled state
3985 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3988 if (it->delete_me) return EINA_FALSE;
3989 return it->disabled;
3993 * Sets the display only state of an item.
3995 * A display only item cannot be selected or unselected. It is for
3996 * display only and not selecting or otherwise clicking, dragging
3997 * etc. by the user, thus finger size rules will not be applied to
4000 * @param it The item
4001 * @param display_only The display only state
4006 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4007 Eina_Bool display_only)
4009 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4010 if (it->display_only == display_only) return;
4011 if (it->delete_me) return;
4012 it->display_only = display_only;
4013 it->mincalcd = EINA_FALSE;
4014 it->updateme = EINA_TRUE;
4015 if (it->block) it->block->updateme = EINA_TRUE;
4016 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4017 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4021 * Get the display only state of an item
4023 * This gets the display only state of the given item.
4025 * @param it The item
4026 * @return The display only state
4031 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4034 if (it->delete_me) return EINA_FALSE;
4035 return it->display_only;
4039 * Show the given item
4041 * This causes genlist to jump to the given item @p it and show it (by
4042 * scrolling), if it is not fully visible.
4044 * @param it The item
4049 elm_genlist_item_show(Elm_Genlist_Item *it)
4051 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4052 Evas_Coord gith = 0;
4053 if (it->delete_me) return;
4054 if ((it->queued) || (!it->mincalcd))
4056 it->wd->show_item = it;
4057 it->wd->bring_in = EINA_TRUE;
4058 it->showme = EINA_TRUE;
4061 if (it->wd->show_item)
4063 it->wd->show_item->showme = EINA_FALSE;
4064 it->wd->show_item = NULL;
4066 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4067 gith = it->group_item->h;
4068 elm_smart_scroller_child_region_show(it->wd->scr,
4069 it->x + it->block->x,
4070 it->y + it->block->y - gith,
4071 it->block->w, it->h);
4075 * Bring in the given item
4077 * This causes genlist to jump to the given item @p it and show it (by
4078 * scrolling), if it is not fully visible. This may use animation to
4079 * do so and take a period of time
4081 * @param it The item
4086 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4088 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4089 Evas_Coord gith = 0;
4090 if (it->delete_me) return;
4091 if ((it->queued) || (!it->mincalcd))
4093 it->wd->show_item = it;
4094 it->wd->bring_in = EINA_TRUE;
4095 it->showme = EINA_TRUE;
4098 if (it->wd->show_item)
4100 it->wd->show_item->showme = EINA_FALSE;
4101 it->wd->show_item = NULL;
4103 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4104 gith = it->group_item->h;
4105 elm_smart_scroller_region_bring_in(it->wd->scr,
4106 it->x + it->block->x,
4107 it->y + it->block->y - gith,
4108 it->block->w, it->h);
4112 * Show the given item at the top
4114 * This causes genlist to jump to the given item @p it and show it (by
4115 * scrolling), if it is not fully visible.
4117 * @param it The item
4122 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4124 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4126 Evas_Coord gith = 0;
4128 if (it->delete_me) return;
4129 if ((it->queued) || (!it->mincalcd))
4131 it->wd->show_item = it;
4132 it->wd->bring_in = EINA_TRUE;
4133 it->showme = EINA_TRUE;
4136 if (it->wd->show_item)
4138 it->wd->show_item->showme = EINA_FALSE;
4139 it->wd->show_item = NULL;
4141 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4142 if (it->group_item) gith = it->group_item->h;
4143 elm_smart_scroller_child_region_show(it->wd->scr,
4144 it->x + it->block->x,
4145 it->y + it->block->y - gith,
4150 * Bring in the given item at the top
4152 * This causes genlist to jump to the given item @p it and show it (by
4153 * scrolling), if it is not fully visible. This may use animation to
4154 * do so and take a period of time
4156 * @param it The item
4161 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4163 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4165 Evas_Coord gith = 0;
4167 if (it->delete_me) return;
4168 if ((it->queued) || (!it->mincalcd))
4170 it->wd->show_item = it;
4171 it->wd->bring_in = EINA_TRUE;
4172 it->showme = EINA_TRUE;
4175 if (it->wd->show_item)
4177 it->wd->show_item->showme = EINA_FALSE;
4178 it->wd->show_item = NULL;
4180 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4181 if (it->group_item) gith = it->group_item->h;
4182 elm_smart_scroller_region_bring_in(it->wd->scr,
4183 it->x + it->block->x,
4184 it->y + it->block->y - gith,
4189 * Show the given item at the middle
4191 * This causes genlist to jump to the given item @p it and show it (by
4192 * scrolling), if it is not fully visible.
4194 * @param it The item
4199 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4201 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4204 if (it->delete_me) return;
4205 if ((it->queued) || (!it->mincalcd))
4207 it->wd->show_item = it;
4208 it->wd->bring_in = EINA_TRUE;
4209 it->showme = EINA_TRUE;
4212 if (it->wd->show_item)
4214 it->wd->show_item->showme = EINA_FALSE;
4215 it->wd->show_item = NULL;
4217 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4218 elm_smart_scroller_child_region_show(it->wd->scr,
4219 it->x + it->block->x,
4220 it->y + it->block->y - oh / 2 +
4221 it->h / 2, it->block->w, oh);
4225 * Bring in the given item at the middle
4227 * This causes genlist to jump to the given item @p it and show it (by
4228 * scrolling), if it is not fully visible. This may use animation to
4229 * do so and take a period of time
4231 * @param it The item
4236 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4238 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4241 if (it->delete_me) return;
4242 if ((it->queued) || (!it->mincalcd))
4244 it->wd->show_item = it;
4245 it->wd->bring_in = EINA_TRUE;
4246 it->showme = EINA_TRUE;
4249 if (it->wd->show_item)
4251 it->wd->show_item->showme = EINA_FALSE;
4252 it->wd->show_item = NULL;
4254 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4255 elm_smart_scroller_region_bring_in(it->wd->scr,
4256 it->x + it->block->x,
4257 it->y + it->block->y - oh / 2 + it->h / 2,
4262 * Delete a given item
4264 * This deletes the item from genlist and calls the genlist item del
4265 * class callback defined in the item class, if it is set. This clears all
4266 * subitems if it is a tree.
4268 * @param it The item
4273 elm_genlist_item_del(Elm_Genlist_Item *it)
4275 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4276 if ((it->relcount > 0) || (it->walking > 0))
4278 elm_widget_item_pre_notify_del(it);
4279 elm_genlist_item_subitems_clear(it);
4280 it->delete_me = EINA_TRUE;
4281 if (it->wd->show_item == it) it->wd->show_item = NULL;
4283 it->wd->selected = eina_list_remove(it->wd->selected,
4287 if (it->realized) _item_unrealize(it, EINA_FALSE);
4288 it->block->changed = EINA_TRUE;
4289 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4290 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4292 if (it->itc->func.del)
4293 it->itc->func.del((void *)it->base.data, it->base.widget);
4300 * Set the data item from the genlist item
4302 * This set the data value passed on the elm_genlist_item_append() and
4303 * related item addition calls. This function will also call
4304 * elm_genlist_item_update() so the item will be updated to reflect the
4307 * @param it The item
4308 * @param data The new data pointer to set
4313 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4316 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4317 elm_widget_item_data_set(it, data);
4318 elm_genlist_item_update(it);
4322 * Get the data item from the genlist item
4324 * This returns the data value passed on the elm_genlist_item_append()
4325 * and related item addition calls and elm_genlist_item_data_set().
4327 * @param it The item
4328 * @return The data pointer provided when created
4333 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4336 return elm_widget_item_data_get(it);
4340 * Tells genlist to "orphan" icons fetchs by the item class
4342 * This instructs genlist to release references to icons in the item,
4343 * meaning that they will no longer be managed by genlist and are
4344 * floating "orphans" that can be re-used elsewhere if the user wants
4347 * @param it The item
4352 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4355 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4356 EINA_LIST_FREE(it->icon_objs, icon)
4358 elm_widget_sub_object_del(it->base.widget, icon);
4359 evas_object_smart_member_del(icon);
4360 evas_object_hide(icon);
4365 * Get the real evas object of the genlist item
4367 * This returns the actual evas object used for the specified genlist
4368 * item. This may be NULL as it may not be created, and may be deleted
4369 * at any time by genlist. Do not modify this object (move, resize,
4370 * show, hide etc.) as genlist is controlling it. This function is for
4371 * querying, emitting custom signals or hooking lower level callbacks
4372 * for events. Do not delete this object under any circumstances.
4374 * @param it The item
4375 * @return The object pointer
4379 EAPI const Evas_Object *
4380 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4382 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4383 return it->base.view;
4387 * Update the contents of an item
4389 * This updates an item by calling all the item class functions again
4390 * to get the icons, labels and states. Use this when the original
4391 * item data has changed and the changes are desired to be reflected.
4393 * @param it The item
4398 elm_genlist_item_update(Elm_Genlist_Item *it)
4400 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4401 if (!it->block) return;
4402 if (it->delete_me) return;
4403 it->mincalcd = EINA_FALSE;
4404 it->updateme = EINA_TRUE;
4405 it->block->updateme = EINA_TRUE;
4406 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4407 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4411 * Update the item class of an item
4413 * @param it The item
4414 * @parem itc The item class for the item
4419 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4420 const Elm_Genlist_Item_Class *itc)
4422 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4423 if (!it->block) return;
4424 EINA_SAFETY_ON_NULL_RETURN(itc);
4425 if (it->delete_me) return;
4427 it->nocache = EINA_TRUE;
4428 elm_genlist_item_update(it);
4431 static Evas_Object *
4432 _elm_genlist_item_label_create(void *data,
4434 void *item __UNUSED__)
4436 Evas_Object *label = elm_label_add(obj);
4439 elm_object_style_set(label, "tooltip");
4440 elm_label_label_set(label, data);
4445 _elm_genlist_item_label_del_cb(void *data,
4446 Evas_Object *obj __UNUSED__,
4447 void *event_info __UNUSED__)
4449 eina_stringshare_del(data);
4453 * Set the text to be shown in the genlist item.
4455 * @param item Target item
4456 * @param text The text to set in the content
4458 * Setup the text as tooltip to object. The item can have only one
4459 * tooltip, so any previous tooltip data is removed.
4464 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4467 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4468 text = eina_stringshare_add(text);
4469 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4471 _elm_genlist_item_label_del_cb);
4475 * Set the content to be shown in the tooltip item
4477 * Setup the tooltip to item. The item can have only one tooltip, so
4478 * any previous tooltip data is removed. @p func(with @p data) will be
4479 * called every time that need to show the tooltip and it should return a
4480 * valid Evas_Object. This object is then managed fully by tooltip
4481 * system and is deleted when the tooltip is gone.
4483 * @param item the genlist item being attached by a tooltip.
4484 * @param func the function used to create the tooltip contents.
4485 * @param data what to provide to @a func as callback data/context.
4486 * @param del_cb called when data is not needed anymore, either when
4487 * another callback replaces @func, the tooltip is unset with
4488 * elm_genlist_item_tooltip_unset() or the owner @a item
4489 * dies. This callback receives as the first parameter the
4490 * given @a data, and @c event_info is the item.
4495 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4496 Elm_Tooltip_Item_Content_Cb func,
4498 Evas_Smart_Cb del_cb)
4500 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4502 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4505 if (item->tooltip.del_cb)
4506 item->tooltip.del_cb((void *)item->tooltip.data,
4507 item->base.widget, item);
4509 item->tooltip.content_cb = func;
4510 item->tooltip.data = data;
4511 item->tooltip.del_cb = del_cb;
4513 if (item->base.view)
4515 elm_widget_item_tooltip_content_cb_set(item,
4516 item->tooltip.content_cb,
4517 item->tooltip.data, NULL);
4518 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4524 if (del_cb) del_cb((void *)data, NULL, NULL);
4528 * Unset tooltip from item
4530 * @param item genlist item to remove previously set tooltip.
4532 * Remove tooltip from item. The callback provided as del_cb to
4533 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4534 * it is not used anymore.
4536 * @see elm_genlist_item_tooltip_content_cb_set()
4541 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4543 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4544 if ((item->base.view) && (item->tooltip.content_cb))
4545 elm_widget_item_tooltip_unset(item);
4547 if (item->tooltip.del_cb)
4548 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4549 item->tooltip.del_cb = NULL;
4550 item->tooltip.content_cb = NULL;
4551 item->tooltip.data = NULL;
4552 if (item->tooltip.style)
4553 elm_genlist_item_tooltip_style_set(item, NULL);
4557 * Sets a different style for this item tooltip.
4559 * @note before you set a style you should define a tooltip with
4560 * elm_genlist_item_tooltip_content_cb_set() or
4561 * elm_genlist_item_tooltip_text_set()
4563 * @param item genlist item with tooltip already set.
4564 * @param style the theme style to use (default, transparent, ...)
4569 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4572 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4573 eina_stringshare_replace(&item->tooltip.style, style);
4574 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4578 * Get the style for this item tooltip.
4580 * @param item genlist item with tooltip already set.
4581 * @return style the theme style in use, defaults to "default". If the
4582 * object does not have a tooltip set, then NULL is returned.
4587 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4589 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4590 return item->tooltip.style;
4594 * Set the cursor to be shown when mouse is over the genlist item
4596 * @param item Target item
4597 * @param cursor the cursor name to be used.
4599 * @see elm_object_cursor_set()
4603 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4606 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4607 eina_stringshare_replace(&item->mouse_cursor, cursor);
4608 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4612 * Get the cursor to be shown when mouse is over the genlist item
4614 * @param item genlist item with cursor already set.
4615 * @return the cursor name.
4620 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4622 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4623 return elm_widget_item_cursor_get(item);
4627 * Unset the cursor to be shown when mouse is over the genlist item
4629 * @param item Target item
4631 * @see elm_object_cursor_unset()
4635 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4637 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4638 if (!item->mouse_cursor)
4641 if (item->base.view)
4642 elm_widget_item_cursor_unset(item);
4644 eina_stringshare_del(item->mouse_cursor);
4645 item->mouse_cursor = NULL;
4649 * Sets a different style for this item cursor.
4651 * @note before you set a style you should define a cursor with
4652 * elm_genlist_item_cursor_set()
4654 * @param item genlist item with cursor already set.
4655 * @param style the theme style to use (default, transparent, ...)
4660 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4663 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4664 elm_widget_item_cursor_style_set(item, style);
4668 * Get the style for this item cursor.
4670 * @param item genlist item with cursor already set.
4671 * @return style the theme style in use, defaults to "default". If the
4672 * object does not have a cursor set, then NULL is returned.
4677 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4679 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4680 return elm_widget_item_cursor_style_get(item);
4684 * Set if the cursor set should be searched on the theme or should use
4685 * the provided by the engine, only.
4687 * @note before you set if should look on theme you should define a
4688 * cursor with elm_object_cursor_set(). By default it will only look
4689 * for cursors provided by the engine.
4691 * @param item widget item with cursor already set.
4692 * @param engine_only boolean to define it cursors should be looked
4693 * only between the provided by the engine or searched on widget's
4699 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4700 Eina_Bool engine_only)
4702 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4703 elm_widget_item_cursor_engine_only_set(item, engine_only);
4707 * Get the cursor engine only usage for this item cursor.
4709 * @param item widget item with cursor already set.
4710 * @return engine_only boolean to define it cursors should be looked
4711 * only between the provided by the engine or searched on widget's
4712 * theme as well. If the object does not have a cursor set, then
4713 * EINA_FALSE is returned.
4718 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4720 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4721 return elm_widget_item_cursor_engine_only_get(item);
4725 * This sets the horizontal stretching mode
4727 * This sets the mode used for sizing items horizontally. Valid modes
4728 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4729 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4730 * the scroller will scroll horizontally. Otherwise items are expanded
4731 * to fill the width of the viewport of the scroller. If it is
4732 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4733 * limited to that size.
4735 * @param obj The genlist object
4736 * @param mode The mode to use
4741 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4744 ELM_CHECK_WIDTYPE(obj, widtype);
4745 Widget_Data *wd = elm_widget_data_get(obj);
4747 if (wd->mode == mode) return;
4753 * Gets the horizontal stretching mode
4755 * @param obj The genlist object
4756 * @return The mode to use
4757 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4762 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4764 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4765 Widget_Data *wd = elm_widget_data_get(obj);
4766 if (!wd) return ELM_LIST_LAST;
4771 * Set the always select mode.
4773 * Items will only call their selection func and callback when first
4774 * becoming selected. Any further clicks will do nothing, unless you
4775 * enable always select with elm_genlist_always_select_mode_set().
4776 * This means even if selected, every click will make the selected
4777 * callbacks be called.
4779 * @param obj The genlist object
4780 * @param always_select The always select mode
4781 * (EINA_TRUE = on, EINA_FALSE = off)
4786 elm_genlist_always_select_mode_set(Evas_Object *obj,
4787 Eina_Bool always_select)
4789 ELM_CHECK_WIDTYPE(obj, widtype);
4790 Widget_Data *wd = elm_widget_data_get(obj);
4792 wd->always_select = always_select;
4796 * Get the always select mode.
4798 * @param obj The genlist object
4799 * @return The always select mode
4800 * (EINA_TRUE = on, EINA_FALSE = off)
4805 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4807 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4808 Widget_Data *wd = elm_widget_data_get(obj);
4809 if (!wd) return EINA_FALSE;
4810 return wd->always_select;
4814 * Set no select mode
4816 * This will turn off the ability to select items entirely and they
4817 * will neither appear selected nor call selected callback functions.
4819 * @param obj The genlist object
4820 * @param no_select The no select mode
4821 * (EINA_TRUE = on, EINA_FALSE = off)
4826 elm_genlist_no_select_mode_set(Evas_Object *obj,
4827 Eina_Bool no_select)
4829 ELM_CHECK_WIDTYPE(obj, widtype);
4830 Widget_Data *wd = elm_widget_data_get(obj);
4832 wd->no_select = no_select;
4836 * Gets no select mode
4838 * @param obj The genlist object
4839 * @return The no select mode
4840 * (EINA_TRUE = on, EINA_FALSE = off)
4845 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4847 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4848 Widget_Data *wd = elm_widget_data_get(obj);
4849 if (!wd) return EINA_FALSE;
4850 return wd->no_select;
4856 * This will enable the compress mode where items are "compressed"
4857 * horizontally to fit the genlist scrollable viewport width. This is
4858 * special for genlist. Do not rely on
4859 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4860 * work as genlist needs to handle it specially.
4862 * @param obj The genlist object
4863 * @param compress The compress mode
4864 * (EINA_TRUE = on, EINA_FALSE = off)
4869 elm_genlist_compress_mode_set(Evas_Object *obj,
4872 ELM_CHECK_WIDTYPE(obj, widtype);
4873 Widget_Data *wd = elm_widget_data_get(obj);
4875 wd->compress = compress;
4879 * Get the compress mode
4881 * @param obj The genlist object
4882 * @return The compress mode
4883 * (EINA_TRUE = on, EINA_FALSE = off)
4888 elm_genlist_compress_mode_get(const Evas_Object *obj)
4890 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4891 Widget_Data *wd = elm_widget_data_get(obj);
4892 if (!wd) return EINA_FALSE;
4893 return wd->compress;
4897 * Set height-for-width mode
4899 * With height-for-width mode the item width will be fixed (restricted
4900 * to a minimum of) to the list width when calculating its size in
4901 * order to allow the height to be calculated based on it. This allows,
4902 * for instance, text block to wrap lines if the Edje part is
4903 * configured with "text.min: 0 1".
4905 * @note This mode will make list resize slower as it will have to
4906 * recalculate every item height again whenever the list width
4909 * @note When height-for-width mode is enabled, it also enables
4910 * compress mode (see elm_genlist_compress_mode_set()) and
4911 * disables homogeneous (see elm_genlist_homogeneous_set()).
4913 * @param obj The genlist object
4914 * @param setting The height-for-width mode (EINA_TRUE = on,
4920 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4921 Eina_Bool height_for_width)
4923 ELM_CHECK_WIDTYPE(obj, widtype);
4924 Widget_Data *wd = elm_widget_data_get(obj);
4926 wd->height_for_width = !!height_for_width;
4927 if (wd->height_for_width)
4929 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4930 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4935 * Get the height-for-width mode
4937 * @param obj The genlist object
4938 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4944 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4946 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4947 Widget_Data *wd = elm_widget_data_get(obj);
4948 if (!wd) return EINA_FALSE;
4949 return wd->height_for_width;
4955 * This will enable or disable the scroller bounce mode for the
4956 * genlist. See elm_scroller_bounce_set() for details
4958 * @param obj The genlist object
4959 * @param h_bounce Allow bounce horizontally
4960 * @param v_bounce Allow bounce vertically
4965 elm_genlist_bounce_set(Evas_Object *obj,
4969 ELM_CHECK_WIDTYPE(obj, widtype);
4970 Widget_Data *wd = elm_widget_data_get(obj);
4972 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4976 * Get the bounce mode
4978 * @param obj The genlist object
4979 * @param h_bounce Allow bounce horizontally
4980 * @param v_bounce Allow bounce vertically
4985 elm_genlist_bounce_get(const Evas_Object *obj,
4986 Eina_Bool *h_bounce,
4987 Eina_Bool *v_bounce)
4989 ELM_CHECK_WIDTYPE(obj, widtype);
4990 Widget_Data *wd = elm_widget_data_get(obj);
4992 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4996 * Set homogenous mode
4998 * This will enable the homogeneous mode where items are of the same
4999 * height and width so that genlist may do the lazy-loading at its
5000 * maximum. This implies 'compressed' mode.
5002 * @param obj The genlist object
5003 * @param homogeneous Assume the items within the genlist are of the
5004 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5009 elm_genlist_homogeneous_set(Evas_Object *obj,
5010 Eina_Bool homogeneous)
5012 ELM_CHECK_WIDTYPE(obj, widtype);
5013 Widget_Data *wd = elm_widget_data_get(obj);
5015 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5016 wd->homogeneous = homogeneous;
5020 * Get the homogenous mode
5022 * @param obj The genlist object
5023 * @return Assume the items within the genlist are of the same height
5024 * and width (EINA_TRUE = on, EINA_FALSE = off)
5029 elm_genlist_homogeneous_get(const Evas_Object *obj)
5031 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5032 Widget_Data *wd = elm_widget_data_get(obj);
5033 if (!wd) return EINA_FALSE;
5034 return wd->homogeneous;
5038 * Set the maximum number of items within an item block
5040 * This will configure the block count to tune to the target with
5041 * particular performance matrix.
5043 * @param obj The genlist object
5044 * @param n Maximum number of items within an item block
5049 elm_genlist_block_count_set(Evas_Object *obj,
5052 ELM_CHECK_WIDTYPE(obj, widtype);
5053 Widget_Data *wd = elm_widget_data_get(obj);
5055 wd->max_items_per_block = n;
5056 wd->item_cache_max = wd->max_items_per_block * 2;
5057 _item_cache_clean(wd);
5061 * Get the maximum number of items within an item block
5063 * @param obj The genlist object
5064 * @return Maximum number of items within an item block
5069 elm_genlist_block_count_get(const Evas_Object *obj)
5071 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5072 Widget_Data *wd = elm_widget_data_get(obj);
5074 return wd->max_items_per_block;
5078 * Set the timeout in seconds for the longpress event
5080 * @param obj The genlist object
5081 * @param timeout timeout in seconds
5086 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5089 ELM_CHECK_WIDTYPE(obj, widtype);
5090 Widget_Data *wd = elm_widget_data_get(obj);
5092 wd->longpress_timeout = timeout;
5096 * Get the timeout in seconds for the longpress event
5098 * @param obj The genlist object
5099 * @return timeout in seconds
5104 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5106 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5107 Widget_Data *wd = elm_widget_data_get(obj);
5109 return wd->longpress_timeout;
5113 * Set the scrollbar policy
5115 * This sets the scrollbar visibility policy for the given genlist
5116 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5117 * made visible if it is needed, and otherwise kept hidden.
5118 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5119 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5120 * respectively for the horizontal and vertical scrollbars.
5122 * @param obj The genlist object
5123 * @param policy_h Horizontal scrollbar policy
5124 * @param policy_v Vertical scrollbar policy
5129 elm_genlist_scroller_policy_set(Evas_Object *obj,
5130 Elm_Scroller_Policy policy_h,
5131 Elm_Scroller_Policy policy_v)
5133 ELM_CHECK_WIDTYPE(obj, widtype);
5134 Widget_Data *wd = elm_widget_data_get(obj);
5136 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5137 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5140 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5144 * Get the scrollbar policy
5146 * @param obj The genlist object
5147 * @param policy_h Horizontal scrollbar policy
5148 * @param policy_v Vertical scrollbar policy
5153 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5154 Elm_Scroller_Policy *policy_h,
5155 Elm_Scroller_Policy *policy_v)
5157 ELM_CHECK_WIDTYPE(obj, widtype);
5158 Widget_Data *wd = elm_widget_data_get(obj);
5159 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5160 if ((!wd) || (!wd->scr)) return;
5161 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5162 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5163 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5167 * Update the contents of all realized items
5169 * This updates all realized items by calling all the item class functions again
5170 * to get the icons, labels and states. Use this when the original
5171 * item data has changed and the changes are desired to be reflected.
5173 * @param it The item
5178 elm_genlist_realized_items_update(Evas_Object *obj)
5180 ELM_CHECK_WIDTYPE(obj, widtype);
5182 Eina_List *list, *l;
5183 Elm_Genlist_Item *it;
5185 list = elm_genlist_realized_items_get(obj);
5186 EINA_LIST_FOREACH(list, l, it)
5187 elm_genlist_item_update(it);
5191 * Set genlist item mode
5193 * @param item The genlist item
5194 * @param mode Mode name
5195 * @param mode_set Boolean to define set or unset mode.
5200 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5201 const char *mode_type,
5204 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5205 Widget_Data *wd = it->wd;
5207 Elm_Genlist_Item *it2;
5210 if (!mode_type) return;
5212 if ((wd->mode_item == it) &&
5213 (!strcmp(mode_type, wd->mode_type)) &&
5216 if (!it->itc->mode_item_style) return;
5220 EINA_LIST_FOREACH(wd->selected, l, it2)
5222 elm_genlist_item_selected_set(it2, EINA_FALSE);
5226 it2 = elm_genlist_selected_item_get(wd->obj);
5227 if ((it2) && (it2->realized))
5228 elm_genlist_item_selected_set(it2, EINA_FALSE);
5231 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5233 ((it == wd->mode_item) && (!mode_set)))
5234 _item_mode_unset(wd);
5236 eina_stringshare_replace(&wd->mode_type, mode_type);
5237 if (mode_set) _item_mode_set(it);
5241 * Get active genlist mode type
5243 * @param obj The genlist object
5248 elm_genlist_mode_get(const Evas_Object *obj)
5250 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5251 Widget_Data *wd = elm_widget_data_get(obj);
5252 if (!wd) return NULL;
5253 return wd->mode_type;
5257 * Get active genlist mode item
5259 * @param obj The genlist object
5263 EAPI const Elm_Genlist_Item *
5264 elm_genlist_mode_item_get(const Evas_Object *obj)
5266 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5267 Widget_Data *wd = elm_widget_data_get(obj);
5268 if (!wd) return NULL;
5269 return wd->mode_item;