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;
402 Evas_Object *base_view, *spacer;
404 const char *item_style; // it->itc->item_style
405 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
406 Eina_Bool compress : 1; // it->wd->compress
407 Eina_Bool odd : 1; // in & 0x1
409 Eina_Bool selected : 1; // it->selected
410 Eina_Bool disabled : 1; // it->disabled
411 Eina_Bool expanded : 1; // it->expanded
414 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
415 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
419 Evas_Object_Smart_Clipped_Data __clipped_data;
421 Ecore_Job *resize_job;
424 static const char *widtype = NULL;
425 static void _item_cache_zero(Widget_Data *wd);
426 static void _del_hook(Evas_Object *obj);
427 static void _mirrored_set(Evas_Object *obj,
429 static void _theme_hook(Evas_Object *obj);
430 static void _show_region_hook(void *data,
432 static void _sizing_eval(Evas_Object *obj);
433 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
434 static void _item_block_unrealize(Item_Block *itb);
435 static void _calc_job(void *data);
436 static void _on_focus_hook(void *data,
438 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
439 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
440 static Eina_Bool _item_single_select_up(Widget_Data *wd);
441 static Eina_Bool _item_single_select_down(Widget_Data *wd);
442 static Eina_Bool _event_hook(Evas_Object *obj,
444 Evas_Callback_Type type,
446 static void _signal_emit_hook(Evas_Object *obj,
447 const char *emission,
449 static Eina_Bool _deselect_all_items(Widget_Data *wd);
450 static void _pan_calculate(Evas_Object *obj);
451 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
452 static void _mode_item_realize(Elm_Genlist_Item *it);
453 static void _mode_item_unrealize(Elm_Genlist_Item *it);
454 static void _item_mode_set(Elm_Genlist_Item *it);
455 static void _item_mode_unset(Widget_Data *wd);
457 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
460 _event_hook(Evas_Object *obj,
461 Evas_Object *src __UNUSED__,
462 Evas_Callback_Type type,
465 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
466 Evas_Event_Key_Down *ev = event_info;
467 Widget_Data *wd = elm_widget_data_get(obj);
468 if (!wd) return EINA_FALSE;
469 if (!wd->items) return EINA_FALSE;
470 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
471 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
473 Elm_Genlist_Item *it = NULL;
476 Evas_Coord step_x = 0;
477 Evas_Coord step_y = 0;
480 Evas_Coord page_x = 0;
481 Evas_Coord page_y = 0;
483 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
484 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
485 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
486 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
488 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
492 else if ((!strcmp(ev->keyname, "Right")) ||
493 (!strcmp(ev->keyname, "KP_Right")))
497 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
499 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
500 (_item_multi_select_up(wd)))
501 || (_item_single_select_up(wd)))
503 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
509 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
511 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
512 (_item_multi_select_down(wd)))
513 || (_item_single_select_down(wd)))
515 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
521 else if ((!strcmp(ev->keyname, "Home")) ||
522 (!strcmp(ev->keyname, "KP_Home")))
524 it = elm_genlist_first_item_get(obj);
525 elm_genlist_item_bring_in(it);
526 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
529 else if ((!strcmp(ev->keyname, "End")) ||
530 (!strcmp(ev->keyname, "KP_End")))
532 it = elm_genlist_last_item_get(obj);
533 elm_genlist_item_bring_in(it);
534 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
537 else if ((!strcmp(ev->keyname, "Prior")) ||
538 (!strcmp(ev->keyname, "KP_Prior")))
541 y -= -(page_y * v_h) / 100;
545 else if ((!strcmp(ev->keyname, "Next")) ||
546 (!strcmp(ev->keyname, "KP_Next")))
549 y += -(page_y * v_h) / 100;
553 else if(((!strcmp(ev->keyname, "Return")) ||
554 (!strcmp(ev->keyname, "KP_Enter")) ||
555 (!strcmp(ev->keyname, "space")))
556 && (!wd->multi) && (wd->selected))
558 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
559 elm_genlist_item_expanded_set(it,
560 !elm_genlist_item_expanded_get(it));
562 else if (!strcmp(ev->keyname, "Escape"))
564 if (!_deselect_all_items(wd)) return EINA_FALSE;
565 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
568 else return EINA_FALSE;
570 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
571 elm_smart_scroller_child_pos_set(wd->scr, x, y);
576 _deselect_all_items(Widget_Data *wd)
578 if (!wd->selected) return EINA_FALSE;
580 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
586 _item_multi_select_up(Widget_Data *wd)
588 if (!wd->selected) return EINA_FALSE;
589 if (!wd->multi) return EINA_FALSE;
591 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
592 if (!prev) return EINA_TRUE;
594 if (elm_genlist_item_selected_get(prev))
596 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
597 wd->last_selected_item = prev;
598 elm_genlist_item_show(wd->last_selected_item);
602 elm_genlist_item_selected_set(prev, EINA_TRUE);
603 elm_genlist_item_show(prev);
609 _item_multi_select_down(Widget_Data *wd)
611 if (!wd->selected) return EINA_FALSE;
612 if (!wd->multi) return EINA_FALSE;
614 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
615 if (!next) return EINA_TRUE;
617 if (elm_genlist_item_selected_get(next))
619 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
620 wd->last_selected_item = next;
621 elm_genlist_item_show(wd->last_selected_item);
625 elm_genlist_item_selected_set(next, EINA_TRUE);
626 elm_genlist_item_show(next);
632 _item_single_select_up(Widget_Data *wd)
634 Elm_Genlist_Item *prev;
637 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
638 while ((prev) && (prev->delete_me))
639 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
641 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
643 if (!prev) return EINA_FALSE;
645 _deselect_all_items(wd);
647 elm_genlist_item_selected_set(prev, EINA_TRUE);
648 elm_genlist_item_show(prev);
653 _item_single_select_down(Widget_Data *wd)
655 Elm_Genlist_Item *next;
658 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
659 while ((next) && (next->delete_me))
660 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
662 else next = elm_genlist_item_next_get(wd->last_selected_item);
664 if (!next) return EINA_FALSE;
666 _deselect_all_items(wd);
668 elm_genlist_item_selected_set(next, EINA_TRUE);
669 elm_genlist_item_show(next);
674 _on_focus_hook(void *data __UNUSED__,
677 Widget_Data *wd = elm_widget_data_get(obj);
679 if (elm_widget_focus_get(obj))
681 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
682 evas_object_focus_set(wd->obj, EINA_TRUE);
683 if ((wd->selected) && (!wd->last_selected_item))
684 wd->last_selected_item = eina_list_data_get(wd->selected);
688 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
689 evas_object_focus_set(wd->obj, EINA_FALSE);
694 _del_hook(Evas_Object *obj)
696 Widget_Data *wd = elm_widget_data_get(obj);
698 _item_cache_zero(wd);
699 if (wd->calc_job) ecore_job_del(wd->calc_job);
700 if (wd->update_job) ecore_job_del(wd->update_job);
701 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
702 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
703 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
704 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
709 _del_pre_hook(Evas_Object *obj)
711 Widget_Data *wd = elm_widget_data_get(obj);
713 evas_object_del(wd->pan_smart);
714 wd->pan_smart = NULL;
715 elm_genlist_clear(obj);
719 _mirrored_set(Evas_Object *obj,
722 Widget_Data *wd = elm_widget_data_get(obj);
724 _item_cache_zero(wd);
725 elm_smart_scroller_mirrored_set(wd->scr, rtl);
729 _theme_hook(Evas_Object *obj)
731 Widget_Data *wd = elm_widget_data_get(obj);
734 _item_cache_zero(wd);
735 _elm_widget_mirrored_reload(obj);
736 _mirrored_set(obj, elm_widget_mirrored_get(obj));
737 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
738 elm_widget_style_get(obj));
739 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
740 wd->item_width = wd->item_height = 0;
741 wd->group_item_width = wd->group_item_height = 0;
742 wd->minw = wd->minh = wd->realminw = 0;
743 EINA_INLIST_FOREACH(wd->blocks, itb)
746 Elm_Genlist_Item *it;
748 if (itb->realized) _item_block_unrealize(itb);
749 EINA_LIST_FOREACH(itb->items, l, it)
750 it->mincalcd = EINA_FALSE;
752 itb->changed = EINA_TRUE;
754 if (wd->calc_job) ecore_job_del(wd->calc_job);
755 wd->calc_job = ecore_job_add(_calc_job, wd);
760 _show_region_hook(void *data,
763 Widget_Data *wd = elm_widget_data_get(data);
764 Evas_Coord x, y, w, h;
766 elm_widget_show_region_get(obj, &x, &y, &w, &h);
767 //x & y are screen coordinates, Add with pan coordinates
770 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
774 _sizing_eval(Evas_Object *obj)
776 Widget_Data *wd = elm_widget_data_get(obj);
777 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
779 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
780 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
782 if (wd->height_for_width)
786 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
787 if ((vw != 0) && (vw != wd->prev_viewport_w))
791 wd->prev_viewport_w = vw;
792 EINA_INLIST_FOREACH(wd->blocks, itb)
794 itb->must_recalc = EINA_TRUE;
796 if (wd->calc_job) ecore_job_del(wd->calc_job);
797 wd->calc_job = ecore_job_add(_calc_job, wd);
800 if (wd->mode == ELM_LIST_LIMIT)
802 Evas_Coord vmw, vmh, vw, vh;
806 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
807 if ((minw > 0) && (vw < minw)) vw = minw;
808 else if ((maxw > 0) && (vw > maxw))
810 edje_object_size_min_calc
811 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
818 edje_object_size_min_calc
819 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
823 evas_object_size_hint_min_set(obj, minw, minh);
824 evas_object_size_hint_max_set(obj, maxw, maxh);
828 _signal_emit_hook(Evas_Object *obj,
829 const char *emission,
832 Widget_Data *wd = elm_widget_data_get(obj);
833 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
838 _item_highlight(Elm_Genlist_Item *it)
840 const char *selectraise;
841 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
842 (it->disabled) || (it->display_only) || (it->mode_view))
844 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
845 selectraise = edje_object_data_get(it->base.view, "selectraise");
846 if ((selectraise) && (!strcmp(selectraise, "on")))
848 evas_object_raise(it->base.view);
849 if ((it->group_item) && (it->group_item->realized))
850 evas_object_raise(it->group_item->base.view);
852 it->highlighted = EINA_TRUE;
856 _item_block_del(Elm_Genlist_Item *it)
859 Item_Block *itb = it->block;
861 itb->items = eina_list_remove(itb->items, it);
863 itb->changed = EINA_TRUE;
864 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
865 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
868 il = EINA_INLIST_GET(itb);
869 Item_Block *itbn = (Item_Block *)(il->next);
871 it->parent->items = eina_list_remove(it->parent->items, it);
873 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
875 if (itbn) itbn->changed = EINA_TRUE;
881 il = EINA_INLIST_GET(itb);
882 Item_Block *itbp = (Item_Block *)(il->prev);
883 Item_Block *itbn = (Item_Block *)(il->next);
884 if ((itbp) && ((itbp->count + itb->count) < 48))
886 Elm_Genlist_Item *it2;
888 EINA_LIST_FREE(itb->items, it2)
891 itbp->items = eina_list_append(itbp->items, it2);
893 itbp->changed = EINA_TRUE;
895 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
896 EINA_INLIST_GET(itb));
899 else if ((itbn) && ((itbn->count + itb->count) < 48))
903 Eina_List *last = eina_list_last(itb->items);
904 Elm_Genlist_Item *it2 = last->data;
907 itb->items = eina_list_remove_list(itb->items, last);
908 itbn->items = eina_list_prepend(itbn->items, it2);
910 itbn->changed = EINA_TRUE;
913 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
921 _item_del(Elm_Genlist_Item *it)
923 elm_widget_item_pre_notify_del(it);
924 elm_genlist_item_subitems_clear(it);
925 it->wd->walking -= it->walking;
926 if (it->wd->show_item == it) it->wd->show_item = NULL;
927 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
928 if (it->realized) _item_unrealize(it, EINA_FALSE);
929 if (it->block) _item_block_del(it);
930 if ((!it->delete_me) && (it->itc->func.del))
931 it->itc->func.del((void *)it->base.data, it->base.widget);
932 it->delete_me = EINA_TRUE;
934 it->wd->queue = eina_list_remove(it->wd->queue, it);
935 if (it->wd->anchor_item == it)
937 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
938 if (!it->wd->anchor_item)
939 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
941 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
943 it->parent->items = eina_list_remove(it->parent->items, it);
944 if (it->flags & ELM_GENLIST_ITEM_GROUP)
945 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
946 if (it->long_timer) ecore_timer_del(it->long_timer);
947 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
949 if (it->tooltip.del_cb)
950 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
952 elm_widget_item_del(it);
956 _item_select(Elm_Genlist_Item *it)
958 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
961 if (it->wd->always_select) goto call;
964 it->selected = EINA_TRUE;
965 it->wd->selected = eina_list_append(it->wd->selected, it);
969 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
971 evas_object_smart_callback_call(it->base.widget, "selected", it);
974 if ((it->wd->clear_me) && (!it->wd->walking))
975 elm_genlist_clear(it->base.widget);
978 if ((!it->walking) && (it->delete_me))
980 if (!it->relcount) _item_del(it);
983 it->wd->last_selected_item = it;
987 _item_unselect(Elm_Genlist_Item *it)
989 const char *stacking, *selectraise;
991 if ((it->delete_me) || (!it->highlighted)) return;
992 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
993 stacking = edje_object_data_get(it->base.view, "stacking");
994 selectraise = edje_object_data_get(it->base.view, "selectraise");
995 if ((selectraise) && (!strcmp(selectraise, "on")))
997 if ((stacking) && (!strcmp(stacking, "below")))
998 evas_object_lower(it->base.view);
1000 it->highlighted = EINA_FALSE;
1003 it->selected = EINA_FALSE;
1004 it->wd->selected = eina_list_remove(it->wd->selected, it);
1005 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1010 _mouse_move(void *data,
1011 Evas *evas __UNUSED__,
1015 Elm_Genlist_Item *it = data;
1016 Evas_Event_Mouse_Move *ev = event_info;
1017 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1019 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1021 if (!it->wd->on_hold)
1023 it->wd->on_hold = EINA_TRUE;
1024 if (!it->wd->wasselected)
1028 if (it->wd->multitouched)
1030 it->wd->cur_x = ev->cur.canvas.x;
1031 it->wd->cur_y = ev->cur.canvas.y;
1034 if ((it->dragging) && (it->down))
1036 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1039 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1040 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1041 if (abs((it->wd->history[it->wd->movements].x -
1042 it->wd->history[0].x)) > 40)
1043 it->wd->swipe = EINA_TRUE;
1045 it->wd->movements++;
1049 ecore_timer_del(it->long_timer);
1050 it->long_timer = NULL;
1052 evas_object_smart_callback_call(it->base.widget, "drag", it);
1055 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1059 ecore_timer_del(it->long_timer);
1060 it->long_timer = NULL;
1064 if (!it->display_only)
1065 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1066 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1067 x = ev->cur.canvas.x - x;
1068 y = ev->cur.canvas.y - y;
1071 if (adx < 0) adx = -dx;
1074 if (ady < 0) ady = -dy;
1077 if ((adx > minw) || (ady > minh))
1079 it->dragging = EINA_TRUE;
1082 ecore_timer_del(it->long_timer);
1083 it->long_timer = NULL;
1085 if (!it->wd->wasselected)
1090 evas_object_smart_callback_call(it->base.widget,
1091 "drag,start,up", it);
1095 evas_object_smart_callback_call(it->base.widget,
1096 "drag,start,left", it);
1098 evas_object_smart_callback_call(it->base.widget,
1099 "drag,start,right", it);
1105 evas_object_smart_callback_call(it->base.widget,
1106 "drag,start,down", it);
1110 evas_object_smart_callback_call(it->base.widget,
1111 "drag,start,left", it);
1113 evas_object_smart_callback_call(it->base.widget,
1114 "drag,start,right", it);
1121 _long_press(void *data)
1123 Elm_Genlist_Item *it = data;
1125 it->long_timer = NULL;
1126 if ((it->disabled) || (it->dragging) || (it->display_only))
1127 return ECORE_CALLBACK_CANCEL;
1128 it->wd->longpressed = EINA_TRUE;
1129 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1130 return ECORE_CALLBACK_CANCEL;
1134 _swipe(Elm_Genlist_Item *it)
1139 if ((it->display_only) || (it->disabled)) return;
1140 it->wd->swipe = EINA_FALSE;
1141 for (i = 0; i < it->wd->movements; i++)
1143 sum += it->wd->history[i].x;
1144 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1147 sum /= it->wd->movements;
1148 if (abs(sum - it->wd->history[0].x) <= 10) return;
1149 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1153 _swipe_cancel(void *data)
1155 Elm_Genlist_Item *it = data;
1157 if (!it) return ECORE_CALLBACK_CANCEL;
1158 it->wd->swipe = EINA_FALSE;
1159 it->wd->movements = 0;
1160 return ECORE_CALLBACK_RENEW;
1164 _multi_cancel(void *data)
1166 Widget_Data *wd = data;
1168 if (!wd) return ECORE_CALLBACK_CANCEL;
1169 wd->multi_timeout = EINA_TRUE;
1170 return ECORE_CALLBACK_RENEW;
1174 _multi_touch_gesture_eval(void *data)
1176 Elm_Genlist_Item *it = data;
1178 it->wd->multitouched = EINA_FALSE;
1179 if (it->wd->multi_timer)
1181 ecore_timer_del(it->wd->multi_timer);
1182 it->wd->multi_timer = NULL;
1184 if (it->wd->multi_timeout)
1186 it->wd->multi_timeout = EINA_FALSE;
1190 Evas_Coord minw = 0, minh = 0;
1191 Evas_Coord off_x, off_y, off_mx, off_my;
1193 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1194 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1195 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1196 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1197 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1199 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1201 if ((off_x + off_mx) > (off_y + off_my))
1203 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1204 evas_object_smart_callback_call(it->base.widget,
1205 "multi,swipe,right", it);
1206 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1207 evas_object_smart_callback_call(it->base.widget,
1208 "multi,swipe,left", it);
1209 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1210 evas_object_smart_callback_call(it->base.widget,
1211 "multi,pinch,out", it);
1213 evas_object_smart_callback_call(it->base.widget,
1214 "multi,pinch,in", it);
1218 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1219 evas_object_smart_callback_call(it->base.widget,
1220 "multi,swipe,down", it);
1221 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1222 evas_object_smart_callback_call(it->base.widget,
1223 "multi,swipe,up", it);
1224 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1225 evas_object_smart_callback_call(it->base.widget,
1226 "multi,pinch,out", it);
1228 evas_object_smart_callback_call(it->base.widget,
1229 "multi,pinch,in", it);
1232 it->wd->multi_timeout = EINA_FALSE;
1236 _multi_down(void *data,
1237 Evas *evas __UNUSED__,
1238 Evas_Object *obj __UNUSED__,
1241 Elm_Genlist_Item *it = data;
1242 Evas_Event_Multi_Down *ev = event_info;
1244 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1245 it->wd->multi_device = ev->device;
1246 it->wd->multi_down = EINA_TRUE;
1247 it->wd->multitouched = EINA_TRUE;
1248 it->wd->prev_mx = ev->canvas.x;
1249 it->wd->prev_my = ev->canvas.y;
1250 if (!it->wd->wasselected) _item_unselect(it);
1251 it->wd->wasselected = EINA_FALSE;
1252 it->wd->longpressed = EINA_FALSE;
1255 ecore_timer_del(it->long_timer);
1256 it->long_timer = NULL;
1260 it->dragging = EINA_FALSE;
1261 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1263 if (it->swipe_timer)
1265 ecore_timer_del(it->swipe_timer);
1266 it->swipe_timer = NULL;
1268 if (it->wd->on_hold)
1270 it->wd->swipe = EINA_FALSE;
1271 it->wd->movements = 0;
1272 it->wd->on_hold = EINA_FALSE;
1277 _multi_up(void *data,
1278 Evas *evas __UNUSED__,
1279 Evas_Object *obj __UNUSED__,
1282 Elm_Genlist_Item *it = data;
1283 Evas_Event_Multi_Up *ev = event_info;
1285 if (it->wd->multi_device != ev->device) return;
1286 it->wd->multi_device = 0;
1287 it->wd->multi_down = EINA_FALSE;
1288 if (it->wd->mouse_down) return;
1289 _multi_touch_gesture_eval(data);
1293 _multi_move(void *data,
1294 Evas *evas __UNUSED__,
1295 Evas_Object *obj __UNUSED__,
1298 Elm_Genlist_Item *it = data;
1299 Evas_Event_Multi_Move *ev = event_info;
1301 if (it->wd->multi_device != ev->device) return;
1302 it->wd->cur_mx = ev->cur.canvas.x;
1303 it->wd->cur_my = ev->cur.canvas.y;
1307 _mouse_down(void *data,
1308 Evas *evas __UNUSED__,
1312 Elm_Genlist_Item *it = data;
1313 Evas_Event_Mouse_Down *ev = event_info;
1316 if (ev->button != 1) return;
1317 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1319 it->wd->on_hold = EINA_TRUE;
1322 it->down = EINA_TRUE;
1323 it->dragging = EINA_FALSE;
1324 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1325 it->dx = ev->canvas.x - x;
1326 it->dy = ev->canvas.y - y;
1327 it->wd->mouse_down = EINA_TRUE;
1328 if (!it->wd->multitouched)
1330 it->wd->prev_x = ev->canvas.x;
1331 it->wd->prev_y = ev->canvas.y;
1332 it->wd->multi_timeout = EINA_FALSE;
1333 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1334 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1336 it->wd->longpressed = EINA_FALSE;
1337 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1338 else it->wd->on_hold = EINA_FALSE;
1339 if (it->wd->on_hold) return;
1340 it->wd->wasselected = it->selected;
1341 _item_highlight(it);
1342 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1343 if ((!it->disabled) && (!it->display_only))
1345 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1346 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1348 if (it->long_timer) ecore_timer_del(it->long_timer);
1349 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1350 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1352 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1355 it->long_timer = NULL;
1356 it->wd->swipe = EINA_FALSE;
1357 it->wd->movements = 0;
1361 _mouse_up(void *data,
1362 Evas *evas __UNUSED__,
1363 Evas_Object *obj __UNUSED__,
1366 Elm_Genlist_Item *it = data;
1367 Evas_Event_Mouse_Up *ev = event_info;
1368 Eina_Bool dragged = EINA_FALSE;
1370 if (ev->button != 1) return;
1371 it->down = EINA_FALSE;
1372 it->wd->mouse_down = EINA_FALSE;
1373 if (it->wd->multitouched)
1375 if (it->wd->multi_down) return;
1376 _multi_touch_gesture_eval(data);
1379 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1380 else it->wd->on_hold = EINA_FALSE;
1383 ecore_timer_del(it->long_timer);
1384 it->long_timer = NULL;
1388 it->dragging = EINA_FALSE;
1389 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1392 if (it->swipe_timer)
1394 ecore_timer_del(it->swipe_timer);
1395 it->swipe_timer = NULL;
1397 if (it->wd->multi_timer)
1399 ecore_timer_del(it->wd->multi_timer);
1400 it->wd->multi_timer = NULL;
1401 it->wd->multi_timeout = EINA_FALSE;
1403 if (it->wd->on_hold)
1405 if (it->wd->swipe) _swipe(data);
1406 it->wd->longpressed = EINA_FALSE;
1407 it->wd->on_hold = EINA_FALSE;
1410 if (it->wd->longpressed)
1412 it->wd->longpressed = EINA_FALSE;
1413 if (!it->wd->wasselected)
1415 it->wd->wasselected = EINA_FALSE;
1420 if (it->want_unrealize)
1422 _item_unrealize(it, EINA_FALSE);
1423 if (it->block->want_unrealize)
1424 _item_block_unrealize(it->block);
1427 if ((it->disabled) || (dragged) || (it->display_only)) return;
1428 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1433 _item_highlight(it);
1436 else _item_unselect(it);
1442 Widget_Data *wd = it->wd;
1445 while (wd->selected) _item_unselect(wd->selected->data);
1450 const Eina_List *l, *l_next;
1451 Elm_Genlist_Item *it2;
1453 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1454 if (it2 != it) _item_unselect(it2);
1455 //_item_highlight(it);
1458 _item_highlight(it);
1464 _signal_expand_toggle(void *data,
1465 Evas_Object *obj __UNUSED__,
1466 const char *emission __UNUSED__,
1467 const char *source __UNUSED__)
1469 Elm_Genlist_Item *it = data;
1472 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1474 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1478 _signal_expand(void *data,
1479 Evas_Object *obj __UNUSED__,
1480 const char *emission __UNUSED__,
1481 const char *source __UNUSED__)
1483 Elm_Genlist_Item *it = data;
1486 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1490 _signal_contract(void *data,
1491 Evas_Object *obj __UNUSED__,
1492 const char *emission __UNUSED__,
1493 const char *source __UNUSED__)
1495 Elm_Genlist_Item *it = data;
1498 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1502 _scr_hold_timer_cb(void *data)
1504 if (!data) return ECORE_CALLBACK_CANCEL;
1505 Widget_Data *wd = data;
1506 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1507 wd->scr_hold_timer = NULL;
1508 return ECORE_CALLBACK_CANCEL;
1512 _mode_finished_signal_cb(void *data,
1514 const char *emission __UNUSED__,
1515 const char *source __UNUSED__)
1519 Elm_Genlist_Item *it = data;
1520 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1523 it->nocache = EINA_FALSE;
1524 _mode_item_unrealize(it);
1525 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1526 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1530 _item_cache_clean(Widget_Data *wd)
1532 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1536 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1537 wd->item_cache = eina_inlist_remove(wd->item_cache,
1538 wd->item_cache->last);
1539 wd->item_cache_count--;
1540 if (itc->spacer) evas_object_del(itc->spacer);
1541 if (itc->base_view) evas_object_del(itc->base_view);
1542 if (itc->item_style) eina_stringshare_del(itc->item_style);
1548 _item_cache_zero(Widget_Data *wd)
1550 int pmax = wd->item_cache_max;
1551 wd->item_cache_max = 0;
1552 _item_cache_clean(wd);
1553 wd->item_cache_max = pmax;
1557 _item_cache_add(Elm_Genlist_Item *it)
1561 if (it->wd->item_cache_max <= 0)
1563 evas_object_del(it->base.view);
1564 it->base.view = NULL;
1565 evas_object_del(it->spacer);
1570 it->wd->item_cache_count++;
1571 itc = calloc(1, sizeof(Item_Cache));
1572 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1573 EINA_INLIST_GET(itc));
1574 itc->spacer = it->spacer;
1576 itc->base_view = it->base.view;
1577 it->base.view = NULL;
1578 evas_object_hide(itc->base_view);
1579 evas_object_move(itc->base_view, -9999, -9999);
1580 itc->item_style = eina_stringshare_add(it->itc->item_style);
1581 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1582 itc->compress = (it->wd->compress);
1583 itc->odd = (it->order_num_in & 0x1);
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)
1625 Eina_Bool tree = 0, odd;
1627 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1628 odd = (it->order_num_in & 0x1);
1629 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1631 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1633 if ((itc->tree == tree) &&
1634 (itc->odd == odd) &&
1635 (itc->compress == it->wd->compress) &&
1636 (!strcmp(it->itc->item_style, itc->item_style)))
1638 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1639 EINA_INLIST_GET(itc));
1640 it->wd->item_cache_count--;
1648 _item_cache_free(Item_Cache *itc)
1650 if (itc->spacer) evas_object_del(itc->spacer);
1651 if (itc->base_view) evas_object_del(itc->base_view);
1652 if (itc->item_style) eina_stringshare_del(itc->item_style);
1657 _item_realize(Elm_Genlist_Item *it,
1661 Elm_Genlist_Item *it2;
1662 const char *stacking;
1663 const char *treesize;
1665 int depth, tsize = 20;
1666 Item_Cache *itc = NULL;
1668 if ((it->realized) || (it->delete_me)) return;
1669 it->order_num_in = in;
1672 it->nocache = EINA_FALSE;
1674 itc = _item_cache_find(it);
1677 it->base.view = itc->base_view;
1678 itc->base_view = NULL;
1679 it->spacer = itc->spacer;
1684 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1685 edje_object_scale_set(it->base.view,
1686 elm_widget_scale_get(it->base.widget) *
1687 _elm_config->scale);
1688 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1689 elm_widget_sub_object_add(it->base.widget, it->base.view);
1691 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1692 strncpy(buf, "tree", sizeof(buf));
1693 else strncpy(buf, "item", sizeof(buf));
1694 if (it->wd->compress)
1695 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1697 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1698 strncat(buf, "/", sizeof(buf) - strlen(buf));
1699 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1701 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1702 elm_widget_style_get(it->base.widget));
1703 edje_object_mirrored_set(it->base.view,
1704 elm_widget_mirrored_get(it->base.widget));
1706 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1707 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1708 elm_widget_sub_object_add(it->base.widget, it->spacer);
1710 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1712 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1714 it->expanded_depth = depth;
1715 treesize = edje_object_data_get(it->base.view, "treesize");
1716 if (treesize) tsize = atoi(treesize);
1717 evas_object_size_hint_min_set(it->spacer,
1718 (depth * tsize) * _elm_config->scale, 1);
1719 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1722 edje_object_signal_callback_add(it->base.view,
1723 "elm,action,expand,toggle",
1724 "elm", _signal_expand_toggle, it);
1725 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1726 "elm", _signal_expand, it);
1727 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1728 "elm", _signal_contract, it);
1729 stacking = edje_object_data_get(it->base.view, "stacking");
1732 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1733 else if (!strcmp(stacking, "above"))
1734 evas_object_raise(it->base.view);
1736 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1738 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1740 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1742 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1744 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1746 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1750 if (it->selected != itc->selected)
1753 edje_object_signal_emit(it->base.view,
1754 "elm,state,selected", "elm");
1756 if (it->disabled != itc->disabled)
1759 edje_object_signal_emit(it->base.view,
1760 "elm,state,disabled", "elm");
1762 if (it->expanded != itc->expanded)
1765 edje_object_signal_emit(it->base.view,
1766 "elm,state,expanded", "elm");
1772 edje_object_signal_emit(it->base.view,
1773 "elm,state,selected", "elm");
1775 edje_object_signal_emit(it->base.view,
1776 "elm,state,disabled", "elm");
1778 edje_object_signal_emit(it->base.view,
1779 "elm,state,expanded", "elm");
1783 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1785 /* homogenous genlist shortcut */
1788 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1790 it->w = it->minw = it->wd->group_item_width;
1791 it->h = it->minh = it->wd->group_item_height;
1795 it->w = it->minw = it->wd->item_width;
1796 it->h = it->minh = it->wd->item_height;
1798 it->mincalcd = EINA_TRUE;
1803 if (it->itc->func.label_get)
1809 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1811 EINA_LIST_FOREACH(it->labels, l, key)
1813 char *s = it->itc->func.label_get
1814 ((void *)it->base.data, it->base.widget, l->data);
1818 edje_object_part_text_set(it->base.view, l->data, s);
1822 edje_object_part_text_set(it->base.view, l->data, "");
1825 if (it->itc->func.icon_get)
1831 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1833 EINA_LIST_FOREACH(it->icons, l, key)
1835 Evas_Object *ic = it->itc->func.icon_get
1836 ((void *)it->base.data, it->base.widget, l->data);
1840 it->icon_objs = eina_list_append(it->icon_objs, ic);
1841 edje_object_part_swallow(it->base.view, key, ic);
1842 evas_object_show(ic);
1843 elm_widget_sub_object_add(it->base.widget, ic);
1847 if (it->itc->func.state_get)
1853 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1855 EINA_LIST_FOREACH(it->states, l, key)
1857 Eina_Bool on = it->itc->func.state_get
1858 ((void *)it->base.data, it->base.widget, l->data);
1862 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1863 edje_object_signal_emit(it->base.view, buf, "elm");
1867 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1868 edje_object_signal_emit(it->base.view, buf, "elm");
1874 Evas_Coord mw = -1, mh = -1;
1876 if (it->wd->height_for_width) mw = it->wd->w;
1878 if (!it->display_only)
1879 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1880 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1881 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1883 if (!it->display_only)
1884 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1885 it->w = it->minw = mw;
1886 it->h = it->minh = mh;
1887 it->mincalcd = EINA_TRUE;
1889 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1891 it->wd->group_item_width = mw;
1892 it->wd->group_item_height = mh;
1894 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1896 it->wd->item_width = mw;
1897 it->wd->item_height = mh;
1900 if (!calc) evas_object_show(it->base.view);
1903 if (it->tooltip.content_cb)
1905 elm_widget_item_tooltip_content_cb_set(it,
1906 it->tooltip.content_cb,
1907 it->tooltip.data, NULL);
1908 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1911 if (it->mouse_cursor)
1912 elm_widget_item_cursor_set(it, it->mouse_cursor);
1914 it->realized = EINA_TRUE;
1915 it->want_unrealize = EINA_FALSE;
1917 if (itc) _item_cache_free(itc);
1918 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1922 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1926 if (!it->realized) return;
1927 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1930 ecore_timer_del(it->long_timer);
1931 it->long_timer = NULL;
1935 evas_object_del(it->base.view);
1936 it->base.view = NULL;
1937 evas_object_del(it->spacer);
1942 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1943 _item_cache_add(it);
1945 elm_widget_stringlist_free(it->labels);
1947 elm_widget_stringlist_free(it->icons);
1949 elm_widget_stringlist_free(it->states);
1951 EINA_LIST_FREE(it->icon_objs, icon)
1952 evas_object_del(icon);
1954 _mode_item_unrealize(it);
1956 it->realized = EINA_FALSE;
1957 it->want_unrealize = EINA_FALSE;
1961 _item_block_recalc(Item_Block *itb,
1967 Elm_Genlist_Item *it;
1968 Evas_Coord minw = 0, minh = 0;
1969 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1973 EINA_LIST_FOREACH(itb->items, l, it)
1975 if (it->delete_me) continue;
1976 showme |= it->showme;
1981 if (!it->mincalcd) changed = EINA_TRUE;
1984 _item_realize(it, in, EINA_TRUE);
1985 _item_unrealize(it, EINA_TRUE);
1990 _item_realize(it, in, EINA_TRUE);
1991 _item_unrealize(it, EINA_TRUE);
1995 _item_realize(it, in, EINA_FALSE);
1997 if (minw < it->minw) minw = it->minw;
2005 itb->changed = EINA_FALSE;
2006 /* force an evas norender to garbage collect deleted objects */
2007 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2012 _item_block_realize(Item_Block *itb,
2017 Elm_Genlist_Item *it;
2019 if (itb->realized) return;
2020 EINA_LIST_FOREACH(itb->items, l, it)
2022 if (it->delete_me) continue;
2023 if (full) _item_realize(it, in, EINA_FALSE);
2026 itb->realized = EINA_TRUE;
2027 itb->want_unrealize = EINA_FALSE;
2031 _item_block_unrealize(Item_Block *itb)
2034 Elm_Genlist_Item *it;
2035 Eina_Bool dragging = EINA_FALSE;
2037 if (!itb->realized) return;
2038 EINA_LIST_FOREACH(itb->items, l, it)
2040 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2044 dragging = EINA_TRUE;
2045 it->want_unrealize = EINA_TRUE;
2048 _item_unrealize(it, EINA_FALSE);
2053 itb->realized = EINA_FALSE;
2054 itb->want_unrealize = EINA_TRUE;
2057 itb->want_unrealize = EINA_FALSE;
2061 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2066 evas_object_resize(view, it->w, it->h);
2067 evas_object_move(view, it->scrl_x, it->scrl_y);
2068 evas_object_show(view);
2072 _item_block_position(Item_Block *itb,
2076 Elm_Genlist_Item *it;
2077 Elm_Genlist_Item *git;
2078 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2081 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2082 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2084 EINA_LIST_FOREACH(itb->items, l, it)
2086 if (it->delete_me) continue;
2090 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2091 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2093 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2094 cvx, cvy, cvw, cvh));
2095 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2097 if ((itb->realized) && (!it->realized))
2099 if (vis) _item_realize(it, in, EINA_FALSE);
2105 git = it->group_item;
2108 if (git->scrl_y < oy)
2110 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2111 git->scrl_y = (it->scrl_y + it->h) - git->h;
2112 git->want_realize = EINA_TRUE;
2115 _item_position(it, it->mode_view);
2117 _item_position(it, it->base.view);
2121 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2128 if (vis) it->want_realize = EINA_TRUE;
2135 _group_items_recalc(void *data)
2137 Widget_Data *wd = data;
2139 Elm_Genlist_Item *git;
2141 EINA_LIST_FOREACH(wd->group_items, l, git)
2143 if (git->want_realize)
2146 _item_realize(git, 0, EINA_FALSE);
2147 evas_object_resize(git->base.view, wd->minw, git->h);
2148 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2149 evas_object_show(git->base.view);
2150 evas_object_raise(git->base.view);
2152 else if (!git->want_realize && git->realized)
2155 _item_unrealize(git, EINA_FALSE);
2161 _must_recalc_idler(void *data)
2163 Widget_Data *wd = data;
2164 if (wd->calc_job) ecore_job_del(wd->calc_job);
2165 wd->calc_job = ecore_job_add(_calc_job, wd);
2166 wd->must_recalc_idler = NULL;
2167 return ECORE_CALLBACK_CANCEL;
2171 _calc_job(void *data)
2173 Widget_Data *wd = data;
2175 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2176 Item_Block *chb = NULL;
2177 int in = 0, minw_change = 0;
2178 Eina_Bool changed = EINA_FALSE;
2180 Eina_Bool did_must_recalc = EINA_FALSE;
2183 t0 = ecore_time_get();
2184 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2188 // if (wd->height_for_width) changed = EINA_TRUE;
2191 EINA_INLIST_FOREACH(wd->blocks, itb)
2193 Eina_Bool showme = EINA_FALSE;
2196 showme = itb->showme;
2197 itb->showme = EINA_FALSE;
2200 if (itb->realized) _item_block_unrealize(itb);
2202 if ((itb->changed) || (changed) ||
2203 ((itb->must_recalc) && (!did_must_recalc)))
2205 if ((changed) || (itb->must_recalc))
2208 Elm_Genlist_Item *it;
2209 EINA_LIST_FOREACH(itb->items, l, it)
2210 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2211 itb->changed = EINA_TRUE;
2212 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2213 itb->must_recalc = EINA_FALSE;
2215 if (itb->realized) _item_block_unrealize(itb);
2216 showme = _item_block_recalc(itb, in, 0, 1);
2222 if (minw == -1) minw = itb->minw;
2223 else if ((!itb->must_recalc) && (minw < itb->minw))
2232 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2234 wd->show_item->showme = EINA_FALSE;
2236 elm_smart_scroller_region_bring_in(wd->scr,
2238 wd->show_item->block->x,
2240 wd->show_item->block->y,
2241 wd->show_item->block->w,
2244 elm_smart_scroller_child_region_show(wd->scr,
2246 wd->show_item->block->x,
2248 wd->show_item->block->y,
2249 wd->show_item->block->w,
2251 wd->show_item = NULL;
2256 EINA_INLIST_FOREACH(wd->blocks, itb)
2262 if ((chb) && (EINA_INLIST_GET(chb)->next))
2264 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2266 if (itb->realized) _item_block_unrealize(itb);
2269 wd->realminw = minw;
2270 if (minw < wd->w) minw = wd->w;
2271 if ((minw != wd->minw) || (minh != wd->minh))
2275 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2276 _sizing_eval(wd->obj);
2277 if ((wd->anchor_item) && (wd->anchor_item->block))
2279 Elm_Genlist_Item *it;
2282 it = wd->anchor_item;
2283 it_y = wd->anchor_y;
2284 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2285 it->block->y + it->y + it_y);
2286 wd->anchor_item = it;
2287 wd->anchor_y = it_y;
2290 t = ecore_time_get();
2291 if (did_must_recalc)
2293 if (!wd->must_recalc_idler)
2294 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2296 wd->calc_job = NULL;
2297 evas_object_smart_changed(wd->pan_smart);
2301 _update_job(void *data)
2303 Widget_Data *wd = data;
2306 int num, num0, position = 0, recalc = 0;
2308 wd->update_job = NULL;
2310 EINA_INLIST_FOREACH(wd->blocks, itb)
2312 Evas_Coord itminw, itminh;
2313 Elm_Genlist_Item *it;
2319 _item_block_position(itb, num);
2324 EINA_LIST_FOREACH(itb->items, l2, it)
2331 it->updateme = EINA_FALSE;
2334 _item_unrealize(it, EINA_FALSE);
2335 _item_realize(it, num, EINA_FALSE);
2340 _item_realize(it, num, EINA_TRUE);
2341 _item_unrealize(it, EINA_TRUE);
2343 if ((it->minw != itminw) || (it->minh != itminh))
2348 itb->updateme = EINA_FALSE;
2352 itb->changed = EINA_TRUE;
2353 _item_block_recalc(itb, num0, 0, 1);
2354 _item_block_position(itb, num0);
2359 if (wd->calc_job) ecore_job_del(wd->calc_job);
2360 wd->calc_job = ecore_job_add(_calc_job, wd);
2365 _pan_set(Evas_Object *obj,
2369 Pan *sd = evas_object_smart_data_get(obj);
2372 // Evas_Coord ow, oh;
2373 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2374 // ow = sd->wd->minw - ow;
2375 // if (ow < 0) ow = 0;
2376 // oh = sd->wd->minh - oh;
2377 // if (oh < 0) oh = 0;
2378 // if (x < 0) x = 0;
2379 // if (y < 0) y = 0;
2380 // if (x > ow) x = ow;
2381 // if (y > oh) y = oh;
2382 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2386 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2388 if ((itb->y + itb->h) > y)
2390 Elm_Genlist_Item *it;
2393 EINA_LIST_FOREACH(itb->items, l2, it)
2395 if ((itb->y + it->y) >= y)
2397 sd->wd->anchor_item = it;
2398 sd->wd->anchor_y = -(itb->y + it->y - y);
2405 evas_object_smart_changed(obj);
2409 _pan_get(Evas_Object *obj,
2413 Pan *sd = evas_object_smart_data_get(obj);
2415 if (x) *x = sd->wd->pan_x;
2416 if (y) *y = sd->wd->pan_y;
2420 _pan_max_get(Evas_Object *obj,
2424 Pan *sd = evas_object_smart_data_get(obj);
2427 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2428 ow = sd->wd->minw - ow;
2430 oh = sd->wd->minh - oh;
2437 _pan_min_get(Evas_Object *obj __UNUSED__,
2446 _pan_child_size_get(Evas_Object *obj,
2450 Pan *sd = evas_object_smart_data_get(obj);
2452 if (w) *w = sd->wd->minw;
2453 if (h) *h = sd->wd->minh;
2457 _pan_add(Evas_Object *obj)
2460 Evas_Object_Smart_Clipped_Data *cd;
2463 cd = evas_object_smart_data_get(obj);
2466 sd->__clipped_data = *cd;
2468 evas_object_smart_data_set(obj, sd);
2472 _pan_del(Evas_Object *obj)
2474 Pan *sd = evas_object_smart_data_get(obj);
2479 ecore_job_del(sd->resize_job);
2480 sd->resize_job = NULL;
2486 _pan_resize_job(void *data)
2489 _sizing_eval(sd->wd->obj);
2490 sd->resize_job = NULL;
2494 _pan_resize(Evas_Object *obj,
2498 Pan *sd = evas_object_smart_data_get(obj);
2501 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2502 if ((ow == w) && (oh == h)) return;
2503 if ((sd->wd->height_for_width) && (ow != w))
2505 if (sd->resize_job) ecore_job_del(sd->resize_job);
2506 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2508 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2509 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2513 _pan_calculate(Evas_Object *obj)
2515 Pan *sd = evas_object_smart_data_get(obj);
2517 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2519 Elm_Genlist_Item *git;
2522 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2523 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2524 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2526 git->want_realize = EINA_FALSE;
2528 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2530 itb->w = sd->wd->minw;
2531 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2532 itb->y - sd->wd->pan_y + oy,
2534 cvx, cvy, cvw, cvh))
2536 if ((!itb->realized) || (itb->changed))
2537 _item_block_realize(itb, in, 0);
2538 _item_block_position(itb, in);
2542 if (itb->realized) _item_block_unrealize(itb);
2546 _group_items_recalc(sd->wd);
2550 _pan_move(Evas_Object *obj,
2551 Evas_Coord x __UNUSED__,
2552 Evas_Coord y __UNUSED__)
2554 Pan *sd = evas_object_smart_data_get(obj);
2556 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2557 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2561 _hold_on(void *data __UNUSED__,
2563 void *event_info __UNUSED__)
2565 Widget_Data *wd = elm_widget_data_get(obj);
2567 elm_smart_scroller_hold_set(wd->scr, 1);
2571 _hold_off(void *data __UNUSED__,
2573 void *event_info __UNUSED__)
2575 Widget_Data *wd = elm_widget_data_get(obj);
2577 elm_smart_scroller_hold_set(wd->scr, 0);
2581 _freeze_on(void *data __UNUSED__,
2583 void *event_info __UNUSED__)
2585 Widget_Data *wd = elm_widget_data_get(obj);
2587 elm_smart_scroller_freeze_set(wd->scr, 1);
2591 _freeze_off(void *data __UNUSED__,
2593 void *event_info __UNUSED__)
2595 Widget_Data *wd = elm_widget_data_get(obj);
2597 elm_smart_scroller_freeze_set(wd->scr, 0);
2601 _scroll_edge_left(void *data,
2602 Evas_Object *scr __UNUSED__,
2603 void *event_info __UNUSED__)
2605 Evas_Object *obj = data;
2606 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2610 _scroll_edge_right(void *data,
2611 Evas_Object *scr __UNUSED__,
2612 void *event_info __UNUSED__)
2614 Evas_Object *obj = data;
2615 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2619 _scroll_edge_top(void *data,
2620 Evas_Object *scr __UNUSED__,
2621 void *event_info __UNUSED__)
2623 Evas_Object *obj = data;
2624 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2628 _scroll_edge_bottom(void *data,
2629 Evas_Object *scr __UNUSED__,
2630 void *event_info __UNUSED__)
2632 Evas_Object *obj = data;
2633 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2637 _mode_item_realize(Elm_Genlist_Item *it)
2641 if ((it->mode_view) || (it->delete_me)) return;
2643 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2644 edje_object_scale_set(it->mode_view,
2645 elm_widget_scale_get(it->base.widget) *
2646 _elm_config->scale);
2647 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2648 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2650 strncpy(buf, "item", sizeof(buf));
2651 if (it->wd->compress)
2652 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2654 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2655 strncat(buf, "/", sizeof(buf) - strlen(buf));
2656 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2658 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2659 elm_widget_style_get(it->base.widget));
2660 edje_object_mirrored_set(it->mode_view,
2661 elm_widget_mirrored_get(it->base.widget));
2662 elm_widget_sub_object_add(it->base.widget, it->spacer);
2664 /* signal callback add */
2665 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2667 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2669 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2672 /* label_get, icon_get, state_get */
2673 if (it->itc->func.label_get)
2679 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2681 EINA_LIST_FOREACH(it->mode_labels, l, key)
2683 char *s = it->itc->func.label_get
2684 ((void *)it->base.data, it->base.widget, l->data);
2688 edje_object_part_text_set(it->mode_view, l->data, s);
2693 if (it->itc->func.icon_get)
2699 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2701 EINA_LIST_FOREACH(it->mode_icons, l, key)
2703 Evas_Object *ic = it->itc->func.icon_get
2704 ((void *)it->base.data, it->base.widget, l->data);
2708 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
2709 edje_object_part_swallow(it->mode_view, key, ic);
2710 evas_object_show(ic);
2711 elm_widget_sub_object_add(it->base.widget, ic);
2715 if (it->itc->func.state_get)
2721 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2723 EINA_LIST_FOREACH(it->mode_states, l, key)
2725 Eina_Bool on = it->itc->func.state_get
2726 ((void *)it->base.data, it->base.widget, l->data);
2730 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2731 edje_object_signal_emit(it->mode_view, buf, "elm");
2736 edje_object_part_swallow(it->mode_view,
2737 edje_object_data_get(it->mode_view, "mode_part"),
2740 it->want_unrealize = EINA_FALSE;
2744 _mode_item_unrealize(Elm_Genlist_Item *it)
2746 Widget_Data *wd = it->wd;
2748 if (!it->mode_view) return;
2750 elm_widget_stringlist_free(it->mode_labels);
2751 it->mode_labels = NULL;
2752 elm_widget_stringlist_free(it->mode_icons);
2753 it->mode_icons = NULL;
2754 elm_widget_stringlist_free(it->mode_states);
2756 EINA_LIST_FREE(it->mode_icon_objs, icon)
2757 evas_object_del(icon);
2759 edje_object_part_unswallow(it->mode_view, it->base.view);
2760 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2761 evas_object_del(it->mode_view);
2762 it->mode_view = NULL;
2764 if (wd->mode_item == it)
2765 wd->mode_item = NULL;
2769 _item_mode_set(Elm_Genlist_Item *it)
2772 Widget_Data *wd = it->wd;
2777 it->nocache = EINA_TRUE;
2779 if (wd->scr_hold_timer)
2781 ecore_timer_del(wd->scr_hold_timer);
2782 wd->scr_hold_timer = NULL;
2784 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2785 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2787 _mode_item_realize(it);
2788 _item_position(it, it->mode_view);
2790 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2791 edje_object_signal_emit(it->mode_view, buf, "elm");
2795 _item_mode_unset(Widget_Data *wd)
2798 if (!wd->mode_item) return;
2799 char buf[1024], buf2[1024];
2800 Elm_Genlist_Item *it;
2803 it->nocache = EINA_TRUE;
2805 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2806 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2808 edje_object_signal_emit(it->mode_view, buf, "elm");
2809 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2811 wd->mode_item = NULL;
2815 * Add a new Genlist object
2817 * @param parent The parent object
2818 * @return The new object or NULL if it cannot be created
2823 elm_genlist_add(Evas_Object *parent)
2828 Evas_Coord minw, minh;
2829 static Evas_Smart *smart = NULL;
2833 static Evas_Smart_Class sc;
2835 evas_object_smart_clipped_smart_set(&_pan_sc);
2837 sc.name = "elm_genlist_pan";
2838 sc.version = EVAS_SMART_CLASS_VERSION;
2841 sc.resize = _pan_resize;
2842 sc.move = _pan_move;
2843 sc.calculate = _pan_calculate;
2844 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2847 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2849 ELM_SET_WIDTYPE(widtype, "genlist");
2850 elm_widget_type_set(obj, "genlist");
2851 elm_widget_sub_object_add(parent, obj);
2852 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2853 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2854 elm_widget_data_set(obj, wd);
2855 elm_widget_del_hook_set(obj, _del_hook);
2856 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2857 elm_widget_theme_hook_set(obj, _theme_hook);
2858 elm_widget_can_focus_set(obj, EINA_TRUE);
2859 elm_widget_event_hook_set(obj, _event_hook);
2860 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2862 wd->scr = elm_smart_scroller_add(e);
2863 elm_smart_scroller_widget_set(wd->scr, obj);
2864 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2865 elm_widget_style_get(obj));
2866 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2867 _elm_config->thumbscroll_bounce_enable);
2868 elm_widget_resize_object_set(obj, wd->scr);
2870 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2871 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2873 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2874 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2878 wd->mode = ELM_LIST_SCROLL;
2879 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2880 wd->item_cache_max = wd->max_items_per_block * 2;
2881 wd->longpress_timeout = _elm_config->longpress_timeout;
2883 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2884 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2885 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2886 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2888 wd->pan_smart = evas_object_smart_add(e, smart);
2889 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2892 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2893 _pan_set, _pan_get, _pan_max_get,
2894 _pan_min_get, _pan_child_size_get);
2896 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2898 evas_object_size_hint_min_set(obj, minw, minh);
2900 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2905 static Elm_Genlist_Item *
2906 _item_new(Widget_Data *wd,
2907 const Elm_Genlist_Item_Class *itc,
2909 Elm_Genlist_Item *parent,
2910 Elm_Genlist_Item_Flags flags,
2912 const void *func_data)
2914 Elm_Genlist_Item *it;
2916 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2917 if (!it) return NULL;
2920 it->base.data = data;
2921 it->parent = parent;
2923 it->func.func = func;
2924 it->func.data = func_data;
2925 it->mouse_cursor = NULL;
2926 it->expanded_depth = 0;
2931 _item_block_add(Widget_Data *wd,
2932 Elm_Genlist_Item *it)
2934 Item_Block *itb = NULL;
2941 itb = calloc(1, sizeof(Item_Block));
2944 if (!it->rel->block)
2947 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2948 itb->items = eina_list_append(itb->items, it);
2954 wd->blocks = eina_inlist_prepend_relative
2955 (wd->blocks, EINA_INLIST_GET(itb),
2956 EINA_INLIST_GET(it->rel->block));
2958 eina_list_prepend_relative(itb->items, it, it->rel);
2962 wd->blocks = eina_inlist_append_relative
2963 (wd->blocks, EINA_INLIST_GET(itb),
2964 EINA_INLIST_GET(it->rel->block));
2966 eina_list_append_relative(itb->items, it, it->rel);
2976 itb = (Item_Block *)(wd->blocks);
2977 if (itb->count >= wd->max_items_per_block)
2979 itb = calloc(1, sizeof(Item_Block));
2983 eina_inlist_prepend(wd->blocks,
2984 EINA_INLIST_GET(itb));
2989 itb = calloc(1, sizeof(Item_Block));
2993 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2995 itb->items = eina_list_prepend(itb->items, it);
3001 itb = (Item_Block *)(wd->blocks->last);
3002 if (itb->count >= wd->max_items_per_block)
3004 itb = calloc(1, sizeof(Item_Block));
3008 eina_inlist_append(wd->blocks,
3009 EINA_INLIST_GET(itb));
3014 itb = calloc(1, sizeof(Item_Block));
3018 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3020 itb->items = eina_list_append(itb->items, it);
3026 itb = it->rel->block;
3027 if (!itb) goto newblock;
3029 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3031 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3034 itb->changed = EINA_TRUE;
3036 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3037 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3040 it->rel->relcount--;
3041 if ((it->rel->delete_me) && (!it->rel->relcount))
3045 if (itb->count > itb->wd->max_items_per_block)
3049 Elm_Genlist_Item *it2;
3051 newc = itb->count / 2;
3052 itb2 = calloc(1, sizeof(Item_Block));
3056 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3057 EINA_INLIST_GET(itb));
3058 itb2->changed = EINA_TRUE;
3059 while ((itb->count > newc) && (itb->items))
3063 l = eina_list_last(itb->items);
3065 itb->items = eina_list_remove_list(itb->items, l);
3068 itb2->items = eina_list_prepend(itb2->items, it2);
3076 _queue_process(Widget_Data *wd,
3080 Eina_Bool showme = EINA_FALSE;
3083 t0 = ecore_time_get();
3084 for (n = 0; (wd->queue) && (n < 128); n++)
3086 Elm_Genlist_Item *it;
3088 it = wd->queue->data;
3089 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3090 it->queued = EINA_FALSE;
3091 _item_block_add(wd, it);
3092 t = ecore_time_get();
3093 if (it->block->changed)
3095 showme = _item_block_recalc(it->block, it->block->num, 1,
3097 it->block->changed = 0;
3099 if (showme) it->block->showme = EINA_TRUE;
3100 if (eina_inlist_count(wd->blocks) > 1)
3102 if ((t - t0) > (ecore_animator_frametime_get())) break;
3109 _item_idler(void *data)
3111 Widget_Data *wd = data;
3114 //static double q_start = 0.0;
3115 //if (q_start == 0.0) q_start = ecore_time_get();
3118 if (_queue_process(wd, 1) > 0)
3120 if (wd->calc_job) ecore_job_del(wd->calc_job);
3121 wd->calc_job = ecore_job_add(_calc_job, wd);
3126 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3128 wd->queue_idler = NULL;
3129 return ECORE_CALLBACK_CANCEL;
3131 return ECORE_CALLBACK_RENEW;
3135 _item_queue(Widget_Data *wd,
3136 Elm_Genlist_Item *it)
3138 if (it->queued) return;
3139 it->queued = EINA_TRUE;
3140 wd->queue = eina_list_append(wd->queue, it);
3141 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3143 if (wd->queue_idler)
3145 ecore_idler_del(wd->queue_idler);
3146 wd->queue_idler = NULL;
3148 _queue_process(wd, 0);
3150 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3154 * Append item to the end of the genlist
3156 * This appends the given item to the end of the list or the end of
3157 * the children if the parent is given.
3159 * @param obj The genlist object
3160 * @param itc The item class for the item
3161 * @param data The item data
3162 * @param parent The parent item, or NULL if none
3163 * @param flags Item flags
3164 * @param func Convenience function called when item selected
3165 * @param func_data Data passed to @p func above.
3166 * @return A handle to the item added or NULL if not possible
3170 EAPI Elm_Genlist_Item *
3171 elm_genlist_item_append(Evas_Object *obj,
3172 const Elm_Genlist_Item_Class *itc,
3174 Elm_Genlist_Item *parent,
3175 Elm_Genlist_Item_Flags flags,
3177 const void *func_data)
3179 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3180 Widget_Data *wd = elm_widget_data_get(obj);
3181 if (!wd) return NULL;
3182 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3184 if (!it) return NULL;
3187 if (flags & ELM_GENLIST_ITEM_GROUP)
3188 wd->group_items = eina_list_append(wd->group_items, it);
3189 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3194 Elm_Genlist_Item *it2 = NULL;
3195 Eina_List *ll = eina_list_last(it->parent->items);
3196 if (ll) it2 = ll->data;
3197 it->parent->items = eina_list_append(it->parent->items, it);
3198 if (!it2) it2 = it->parent;
3200 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3201 EINA_INLIST_GET(it2));
3203 it->rel->relcount++;
3205 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3206 it->group_item = parent;
3207 else if (it->parent->group_item)
3208 it->group_item = it->parent->group_item;
3210 it->before = EINA_FALSE;
3211 _item_queue(wd, it);
3216 * Prepend item at start of the genlist
3218 * This adds an item to the beginning of the list or beginning of the
3219 * children of the parent if given.
3221 * @param obj The genlist object
3222 * @param itc The item class for the item
3223 * @param data The item data
3224 * @param parent The parent item, or NULL if none
3225 * @param flags Item flags
3226 * @param func Convenience function called when item selected
3227 * @param func_data Data passed to @p func above.
3228 * @return A handle to the item added or NULL if not possible
3232 EAPI Elm_Genlist_Item *
3233 elm_genlist_item_prepend(Evas_Object *obj,
3234 const Elm_Genlist_Item_Class *itc,
3236 Elm_Genlist_Item *parent,
3237 Elm_Genlist_Item_Flags flags,
3239 const void *func_data)
3241 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3242 Widget_Data *wd = elm_widget_data_get(obj);
3243 if (!wd) return NULL;
3244 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3246 if (!it) return NULL;
3249 if (flags & ELM_GENLIST_ITEM_GROUP)
3250 wd->group_items = eina_list_prepend(wd->group_items, it);
3251 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3256 Elm_Genlist_Item *it2 = NULL;
3257 Eina_List *ll = it->parent->items;
3258 if (ll) it2 = ll->data;
3259 it->parent->items = eina_list_prepend(it->parent->items, it);
3260 if (!it2) it2 = it->parent;
3262 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3263 EINA_INLIST_GET(it2));
3265 it->rel->relcount++;
3267 it->before = EINA_TRUE;
3268 _item_queue(wd, it);
3273 * Insert item before another in the genlist
3275 * This inserts an item before another in the list. It will be in the
3276 * same tree level or group as the item it is inseted before.
3278 * @param obj The genlist object
3279 * @param itc The item class for the item
3280 * @param data The item data
3281 * @param before The item to insert before
3282 * @param flags Item flags
3283 * @param func Convenience function called when item selected
3284 * @param func_data Data passed to @p func above.
3285 * @return A handle to the item added or NULL if not possible
3289 EAPI Elm_Genlist_Item *
3290 elm_genlist_item_insert_before(Evas_Object *obj,
3291 const Elm_Genlist_Item_Class *itc,
3293 Elm_Genlist_Item *parent,
3294 Elm_Genlist_Item *before,
3295 Elm_Genlist_Item_Flags flags,
3297 const void *func_data)
3299 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3300 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3301 Widget_Data *wd = elm_widget_data_get(obj);
3302 if (!wd) return NULL;
3303 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3305 if (!it) return NULL;
3308 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3311 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3312 EINA_INLIST_GET(before));
3314 it->rel->relcount++;
3315 it->before = EINA_TRUE;
3316 _item_queue(wd, it);
3321 * Insert an item after another in the genlst
3323 * This inserts an item after another in the list. It will be in the
3324 * same tree level or group as the item it is inseted after.
3326 * @param obj The genlist object
3327 * @param itc The item class for the item
3328 * @param data The item data
3329 * @param after The item to insert after
3330 * @param flags Item flags
3331 * @param func Convenience function called when item selected
3332 * @param func_data Data passed to @p func above.
3333 * @return A handle to the item added or NULL if not possible
3337 EAPI Elm_Genlist_Item *
3338 elm_genlist_item_insert_after(Evas_Object *obj,
3339 const Elm_Genlist_Item_Class *itc,
3341 Elm_Genlist_Item *parent,
3342 Elm_Genlist_Item *after,
3343 Elm_Genlist_Item_Flags flags,
3345 const void *func_data)
3347 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3348 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3349 Widget_Data *wd = elm_widget_data_get(obj);
3350 if (!wd) return NULL;
3351 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3353 if (!it) return NULL;
3354 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3355 EINA_INLIST_GET(after));
3358 it->parent->items = eina_list_append_relative(it->parent->items, it,
3362 it->rel->relcount++;
3363 it->before = EINA_FALSE;
3364 _item_queue(wd, it);
3371 * This clears all items in the list, leaving it empty.
3373 * @param obj The genlist object
3378 elm_genlist_clear(Evas_Object *obj)
3380 ELM_CHECK_WIDTYPE(obj, widtype);
3381 Widget_Data *wd = elm_widget_data_get(obj);
3383 if (wd->walking > 0)
3385 Elm_Genlist_Item *it;
3387 wd->clear_me = EINA_TRUE;
3388 EINA_INLIST_FOREACH(wd->items, it)
3390 it->delete_me = EINA_TRUE;
3396 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3398 if (wd->anchor_item == it)
3400 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3401 if (!wd->anchor_item)
3403 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3405 wd->items = eina_inlist_remove(wd->items, wd->items);
3406 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3407 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3408 elm_widget_item_pre_notify_del(it);
3409 if (it->realized) _item_unrealize(it, EINA_FALSE);
3410 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3411 it->itc->func.del((void *)it->base.data, it->base.widget);
3412 if (it->long_timer) ecore_timer_del(it->long_timer);
3413 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3414 elm_widget_item_del(it);
3416 wd->clear_me = EINA_FALSE;
3417 wd->anchor_item = NULL;
3420 Item_Block *itb = (Item_Block *)(wd->blocks);
3422 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3423 if (itb->items) eina_list_free(itb->items);
3428 ecore_job_del(wd->calc_job);
3429 wd->calc_job = NULL;
3431 if (wd->queue_idler)
3433 ecore_idler_del(wd->queue_idler);
3434 wd->queue_idler = NULL;
3436 if (wd->must_recalc_idler)
3438 ecore_idler_del(wd->must_recalc_idler);
3439 wd->must_recalc_idler = NULL;
3443 eina_list_free(wd->queue);
3448 eina_list_free(wd->selected);
3449 wd->selected = NULL;
3451 wd->show_item = NULL;
3458 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3459 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3465 * Enable or disable multi-select in the genlist
3467 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3468 * the list. This allows more than 1 item to be selected.
3470 * @param obj The genlist object
3471 * @param multi Multi-select enable/disable
3476 elm_genlist_multi_select_set(Evas_Object *obj,
3479 ELM_CHECK_WIDTYPE(obj, widtype);
3480 Widget_Data *wd = elm_widget_data_get(obj);
3486 * Gets if multi-select in genlist is enable or disable
3488 * @param obj The genlist object
3489 * @return Multi-select enable/disable
3490 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3495 elm_genlist_multi_select_get(const Evas_Object *obj)
3497 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3498 Widget_Data *wd = elm_widget_data_get(obj);
3499 if (!wd) return EINA_FALSE;
3504 * Get the selectd item in the genlist
3506 * This gets the selected item in the list (if multi-select is enabled
3507 * only the first item in the list is selected - which is not very
3508 * useful, so see elm_genlist_selected_items_get() for when
3509 * multi-select is used).
3511 * If no item is selected, NULL is returned.
3513 * @param obj The genlist object
3514 * @return The selected item, or NULL if none.
3518 EAPI Elm_Genlist_Item *
3519 elm_genlist_selected_item_get(const Evas_Object *obj)
3521 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3522 Widget_Data *wd = elm_widget_data_get(obj);
3523 if (!wd) return NULL;
3524 if (wd->selected) return wd->selected->data;
3529 * Get a list of selected items in the genlist
3531 * This returns a list of the selected items. This list pointer is
3532 * only valid so long as no items are selected or unselected (or
3533 * unselected implicitly by deletion). The list contains
3534 * Elm_Genlist_Item pointers.
3536 * @param obj The genlist object
3537 * @return The list of selected items, nor NULL if none are selected.
3541 EAPI const Eina_List *
3542 elm_genlist_selected_items_get(const Evas_Object *obj)
3544 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3545 Widget_Data *wd = elm_widget_data_get(obj);
3546 if (!wd) return NULL;
3547 return wd->selected;
3551 * Get a list of realized items in genlist
3553 * This returns a list of the realized items in the genlist. The list
3554 * contains Elm_Genlist_Item pointers. The list must be freed by the
3555 * caller when done with eina_list_free(). The item pointers in the
3556 * list are only valid so long as those items are not deleted or the
3557 * genlist is not deleted.
3559 * @param obj The genlist object
3560 * @return The list of realized items, nor NULL if none are realized.
3565 elm_genlist_realized_items_get(const Evas_Object *obj)
3567 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3568 Widget_Data *wd = elm_widget_data_get(obj);
3569 Eina_List *list = NULL;
3571 Eina_Bool done = EINA_FALSE;
3572 if (!wd) return NULL;
3573 EINA_INLIST_FOREACH(wd->blocks, itb)
3578 Elm_Genlist_Item *it;
3581 EINA_LIST_FOREACH(itb->items, l, it)
3583 if (it->realized) list = eina_list_append(list, it);
3595 * Get the item that is at the x, y canvas coords
3597 * This returns the item at the given coordinates (which are canvas
3598 * relative not object-relative). If an item is at that coordinate,
3599 * that item handle is returned, and if @p posret is not NULL, the
3600 * integer pointed to is set to a value of -1, 0 or 1, depending if
3601 * the coordinate is on the upper portion of that item (-1), on the
3602 * middle section (0) or on the lower part (1). If NULL is returned as
3603 * an item (no item found there), then posret may indicate -1 or 1
3604 * based if the coordinate is above or below all items respectively in
3607 * @param it The item
3608 * @param x The input x coordinate
3609 * @param y The input y coordinate
3610 * @param posret The position relative to the item returned here
3611 * @return The item at the coordinates or NULL if none
3615 EAPI Elm_Genlist_Item *
3616 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3621 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3622 Widget_Data *wd = elm_widget_data_get(obj);
3623 Evas_Coord ox, oy, ow, oh;
3626 if (!wd) return NULL;
3627 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3629 EINA_INLIST_FOREACH(wd->blocks, itb)
3632 Elm_Genlist_Item *it;
3634 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3635 oy + itb->y - itb->wd->pan_y,
3636 itb->w, itb->h, x, y, 1, 1))
3638 EINA_LIST_FOREACH(itb->items, l, it)
3640 Evas_Coord itx, ity;
3642 itx = ox + itb->x + it->x - itb->wd->pan_x;
3643 ity = oy + itb->y + it->y - itb->wd->pan_y;
3644 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3648 if (y <= (ity + (it->h / 4))) *posret = -1;
3649 else if (y >= (ity + it->h - (it->h / 4)))
3655 lasty = ity + it->h;
3660 if (y > lasty) *posret = 1;
3667 * Get the first item in the genlist
3669 * This returns the first item in the list.
3671 * @param obj The genlist object
3672 * @return The first item, or NULL if none
3676 EAPI Elm_Genlist_Item *
3677 elm_genlist_first_item_get(const Evas_Object *obj)
3679 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3680 Widget_Data *wd = elm_widget_data_get(obj);
3681 if (!wd) return NULL;
3682 if (!wd->items) return NULL;
3683 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3684 while ((it) && (it->delete_me))
3685 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3690 * Get the last item in the genlist
3692 * This returns the last item in the list.
3694 * @return The last item, or NULL if none
3698 EAPI Elm_Genlist_Item *
3699 elm_genlist_last_item_get(const Evas_Object *obj)
3701 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3702 Widget_Data *wd = elm_widget_data_get(obj);
3703 if (!wd) return NULL;
3704 if (!wd->items) return NULL;
3705 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3706 while ((it) && (it->delete_me))
3707 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3712 * Get the next item in the genlist
3714 * This returns the item after the item @p it.
3716 * @param it The item
3717 * @return The item after @p it, or NULL if none
3721 EAPI Elm_Genlist_Item *
3722 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3724 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3727 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3728 if ((it) && (!it->delete_me)) break;
3730 return (Elm_Genlist_Item *)it;
3734 * Get the previous item in the genlist
3736 * This returns the item before the item @p it.
3738 * @param it The item
3739 * @return The item before @p it, or NULL if none
3743 EAPI Elm_Genlist_Item *
3744 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3746 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3749 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3750 if ((it) && (!it->delete_me)) break;
3752 return (Elm_Genlist_Item *)it;
3756 * Get the genlist object from an item
3758 * This returns the genlist object itself that an item belongs to.
3760 * @param it The item
3761 * @return The genlist object
3766 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3768 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3769 return it->base.widget;
3773 * Get the parent item of the given item
3775 * This returns the parent item of the item @p it given.
3777 * @param it The item
3778 * @return The parent of the item or NULL if none
3782 EAPI Elm_Genlist_Item *
3783 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3785 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3790 * Clear all sub-items (children) of the given item
3792 * This clears all items that are children (or their descendants) of the
3795 * @param it The item
3800 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3802 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3803 Eina_List *tl = NULL, *l;
3804 Elm_Genlist_Item *it2;
3806 EINA_LIST_FOREACH(it->items, l, it2)
3807 tl = eina_list_append(tl, it2);
3808 EINA_LIST_FREE(tl, it2)
3809 elm_genlist_item_del(it2);
3813 * Set the selected state of an item
3815 * This sets the selected state (1 selected, 0 not selected) of the given
3818 * @param it The item
3819 * @param selected The selected state
3824 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3827 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3828 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3830 if (it->delete_me) return;
3831 selected = !!selected;
3832 if (it->selected == selected) return;
3838 while (wd->selected)
3839 _item_unselect(wd->selected->data);
3841 _item_highlight(it);
3849 * Get the selected state of an item
3851 * This gets the selected state of an item (1 selected, 0 not selected).
3853 * @param it The item
3854 * @return The selected state
3859 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3861 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3862 return it->selected;
3866 * Sets the expanded state of an item (if it's a parent)
3868 * This expands or contracts a parent item (thus showing or hiding the
3871 * @param it The item
3872 * @param expanded The expanded state (1 expanded, 0 not expanded).
3877 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3880 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3881 if (it->expanded == expanded) return;
3882 it->expanded = expanded;
3886 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3887 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3892 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3893 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3898 * Get the expanded state of an item
3900 * This gets the expanded state of an item
3902 * @param it The item
3903 * @return Thre expanded state
3908 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3910 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3911 return it->expanded;
3915 * Get the depth of expanded item
3917 * @param it The genlist item object
3918 * @return The depth of expanded item
3923 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3926 return it->expanded_depth;
3930 * Sets the disabled state of an item.
3932 * A disabled item cannot be selected or unselected. It will also
3933 * change appearance to appear disabled. This sets the disabled state
3934 * (1 disabled, 0 not disabled).
3936 * @param it The item
3937 * @param disabled The disabled state
3942 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3945 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3946 if (it->disabled == disabled) return;
3947 if (it->delete_me) return;
3948 it->disabled = disabled;
3952 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3954 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3959 * Get the disabled state of an item
3961 * This gets the disabled state of the given item.
3963 * @param it The item
3964 * @return The disabled state
3969 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3971 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3972 if (it->delete_me) return EINA_FALSE;
3973 return it->disabled;
3977 * Sets the display only state of an item.
3979 * A display only item cannot be selected or unselected. It is for
3980 * display only and not selecting or otherwise clicking, dragging
3981 * etc. by the user, thus finger size rules will not be applied to
3984 * @param it The item
3985 * @param display_only The display only state
3990 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3991 Eina_Bool display_only)
3993 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3994 if (it->display_only == display_only) return;
3995 if (it->delete_me) return;
3996 it->display_only = display_only;
3997 it->mincalcd = EINA_FALSE;
3998 it->updateme = EINA_TRUE;
3999 if (it->block) it->block->updateme = EINA_TRUE;
4000 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4001 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4005 * Get the display only state of an item
4007 * This gets the display only state of the given item.
4009 * @param it The item
4010 * @return The display only state
4015 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4017 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4018 if (it->delete_me) return EINA_FALSE;
4019 return it->display_only;
4023 * Show the given item
4025 * This causes genlist to jump to the given item @p it and show it (by
4026 * scrolling), if it is not fully visible.
4028 * @param it The item
4033 elm_genlist_item_show(Elm_Genlist_Item *it)
4035 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4036 Evas_Coord gith = 0;
4037 if (it->delete_me) return;
4038 if ((it->queued) || (!it->mincalcd))
4040 it->wd->show_item = it;
4041 it->wd->bring_in = EINA_TRUE;
4042 it->showme = EINA_TRUE;
4045 if (it->wd->show_item)
4047 it->wd->show_item->showme = EINA_FALSE;
4048 it->wd->show_item = NULL;
4050 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4051 gith = it->group_item->h;
4052 elm_smart_scroller_child_region_show(it->wd->scr,
4053 it->x + it->block->x,
4054 it->y + it->block->y - gith,
4055 it->block->w, it->h);
4059 * Bring in the given item
4061 * This causes genlist to jump to the given item @p it and show it (by
4062 * scrolling), if it is not fully visible. This may use animation to
4063 * do so and take a period of time
4065 * @param it The item
4070 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4072 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4073 Evas_Coord gith = 0;
4074 if (it->delete_me) return;
4075 if ((it->queued) || (!it->mincalcd))
4077 it->wd->show_item = it;
4078 it->wd->bring_in = EINA_TRUE;
4079 it->showme = EINA_TRUE;
4082 if (it->wd->show_item)
4084 it->wd->show_item->showme = EINA_FALSE;
4085 it->wd->show_item = NULL;
4087 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4088 gith = it->group_item->h;
4089 elm_smart_scroller_region_bring_in(it->wd->scr,
4090 it->x + it->block->x,
4091 it->y + it->block->y - gith,
4092 it->block->w, it->h);
4096 * Show the given item at the top
4098 * This causes genlist to jump to the given item @p it and show it (by
4099 * scrolling), if it is not fully visible.
4101 * @param it The item
4106 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4108 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4110 Evas_Coord gith = 0;
4112 if (it->delete_me) return;
4113 if ((it->queued) || (!it->mincalcd))
4115 it->wd->show_item = it;
4116 it->wd->bring_in = EINA_TRUE;
4117 it->showme = EINA_TRUE;
4120 if (it->wd->show_item)
4122 it->wd->show_item->showme = EINA_FALSE;
4123 it->wd->show_item = NULL;
4125 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4126 if (it->group_item) gith = it->group_item->h;
4127 elm_smart_scroller_child_region_show(it->wd->scr,
4128 it->x + it->block->x,
4129 it->y + it->block->y - gith,
4134 * Bring in the given item at the top
4136 * This causes genlist to jump to the given item @p it and show it (by
4137 * scrolling), if it is not fully visible. This may use animation to
4138 * do so and take a period of time
4140 * @param it The item
4145 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4147 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4149 Evas_Coord gith = 0;
4151 if (it->delete_me) return;
4152 if ((it->queued) || (!it->mincalcd))
4154 it->wd->show_item = it;
4155 it->wd->bring_in = EINA_TRUE;
4156 it->showme = EINA_TRUE;
4159 if (it->wd->show_item)
4161 it->wd->show_item->showme = EINA_FALSE;
4162 it->wd->show_item = NULL;
4164 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4165 if (it->group_item) gith = it->group_item->h;
4166 elm_smart_scroller_region_bring_in(it->wd->scr,
4167 it->x + it->block->x,
4168 it->y + it->block->y - gith,
4173 * Show the given item at the middle
4175 * This causes genlist to jump to the given item @p it and show it (by
4176 * scrolling), if it is not fully visible.
4178 * @param it The item
4183 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4185 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4188 if (it->delete_me) return;
4189 if ((it->queued) || (!it->mincalcd))
4191 it->wd->show_item = it;
4192 it->wd->bring_in = EINA_TRUE;
4193 it->showme = EINA_TRUE;
4196 if (it->wd->show_item)
4198 it->wd->show_item->showme = EINA_FALSE;
4199 it->wd->show_item = NULL;
4201 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4202 elm_smart_scroller_child_region_show(it->wd->scr,
4203 it->x + it->block->x,
4204 it->y + it->block->y - oh / 2 +
4205 it->h / 2, it->block->w, oh);
4209 * Bring in the given item at the middle
4211 * This causes genlist to jump to the given item @p it and show it (by
4212 * scrolling), if it is not fully visible. This may use animation to
4213 * do so and take a period of time
4215 * @param it The item
4220 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4222 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4225 if (it->delete_me) return;
4226 if ((it->queued) || (!it->mincalcd))
4228 it->wd->show_item = it;
4229 it->wd->bring_in = EINA_TRUE;
4230 it->showme = EINA_TRUE;
4233 if (it->wd->show_item)
4235 it->wd->show_item->showme = EINA_FALSE;
4236 it->wd->show_item = NULL;
4238 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4239 elm_smart_scroller_region_bring_in(it->wd->scr,
4240 it->x + it->block->x,
4241 it->y + it->block->y - oh / 2 + it->h / 2,
4246 * Delete a given item
4248 * This deletes the item from genlist and calls the genlist item del
4249 * class callback defined in the item class, if it is set. This clears all
4250 * subitems if it is a tree.
4252 * @param it The item
4257 elm_genlist_item_del(Elm_Genlist_Item *it)
4259 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4260 if ((it->relcount > 0) || (it->walking > 0))
4262 elm_widget_item_pre_notify_del(it);
4263 elm_genlist_item_subitems_clear(it);
4264 it->delete_me = EINA_TRUE;
4265 if (it->wd->show_item == it) it->wd->show_item = NULL;
4267 it->wd->selected = eina_list_remove(it->wd->selected,
4271 if (it->realized) _item_unrealize(it, EINA_FALSE);
4272 it->block->changed = EINA_TRUE;
4273 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4274 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4276 if (it->itc->func.del)
4277 it->itc->func.del((void *)it->base.data, it->base.widget);
4284 * Set the data item from the genlist item
4286 * This set the data value passed on the elm_genlist_item_append() and
4287 * related item addition calls. This function will also call
4288 * elm_genlist_item_update() so the item will be updated to reflect the
4291 * @param it The item
4292 * @param data The new data pointer to set
4297 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4301 elm_widget_item_data_set(it, data);
4302 elm_genlist_item_update(it);
4306 * Get the data item from the genlist item
4308 * This returns the data value passed on the elm_genlist_item_append()
4309 * and related item addition calls and elm_genlist_item_data_set().
4311 * @param it The item
4312 * @return The data pointer provided when created
4317 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4319 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4320 return elm_widget_item_data_get(it);
4324 * Tells genlist to "orphan" icons fetchs by the item class
4326 * This instructs genlist to release references to icons in the item,
4327 * meaning that they will no longer be managed by genlist and are
4328 * floating "orphans" that can be re-used elsewhere if the user wants
4331 * @param it The item
4336 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4340 EINA_LIST_FREE(it->icon_objs, icon)
4342 elm_widget_sub_object_del(it->base.widget, icon);
4343 evas_object_smart_member_del(icon);
4344 evas_object_hide(icon);
4349 * Get the real evas object of the genlist item
4351 * This returns the actual evas object used for the specified genlist
4352 * item. This may be NULL as it may not be created, and may be deleted
4353 * at any time by genlist. Do not modify this object (move, resize,
4354 * show, hide etc.) as genlist is controlling it. This function is for
4355 * querying, emitting custom signals or hooking lower level callbacks
4356 * for events. Do not delete this object under any circumstances.
4358 * @param it The item
4359 * @return The object pointer
4363 EAPI const Evas_Object *
4364 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4366 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4367 return it->base.view;
4371 * Update the contents of an item
4373 * This updates an item by calling all the item class functions again
4374 * to get the icons, labels and states. Use this when the original
4375 * item data has changed and the changes are desired to be reflected.
4377 * @param it The item
4382 elm_genlist_item_update(Elm_Genlist_Item *it)
4384 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4385 if (!it->block) return;
4386 if (it->delete_me) return;
4387 it->mincalcd = EINA_FALSE;
4388 it->updateme = EINA_TRUE;
4389 it->block->updateme = EINA_TRUE;
4390 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4391 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4395 * Update the item class of an item
4397 * @param it The item
4398 * @parem itc The item class for the item
4403 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4404 const Elm_Genlist_Item_Class *itc)
4406 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4407 if (!it->block) return;
4408 EINA_SAFETY_ON_NULL_RETURN(itc);
4409 if (it->delete_me) return;
4411 it->nocache = EINA_TRUE;
4412 elm_genlist_item_update(it);
4415 static Evas_Object *
4416 _elm_genlist_item_label_create(void *data,
4418 void *item __UNUSED__)
4420 Evas_Object *label = elm_label_add(obj);
4423 elm_object_style_set(label, "tooltip");
4424 elm_label_label_set(label, data);
4429 _elm_genlist_item_label_del_cb(void *data,
4430 Evas_Object *obj __UNUSED__,
4431 void *event_info __UNUSED__)
4433 eina_stringshare_del(data);
4437 * Set the text to be shown in the genlist item.
4439 * @param item Target item
4440 * @param text The text to set in the content
4442 * Setup the text as tooltip to object. The item can have only one
4443 * tooltip, so any previous tooltip data is removed.
4448 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4451 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4452 text = eina_stringshare_add(text);
4453 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4455 _elm_genlist_item_label_del_cb);
4459 * Set the content to be shown in the tooltip item
4461 * Setup the tooltip to item. The item can have only one tooltip, so
4462 * any previous tooltip data is removed. @p func(with @p data) will be
4463 * called every time that need to show the tooltip and it should return a
4464 * valid Evas_Object. This object is then managed fully by tooltip
4465 * system and is deleted when the tooltip is gone.
4467 * @param item the genlist item being attached by a tooltip.
4468 * @param func the function used to create the tooltip contents.
4469 * @param data what to provide to @a func as callback data/context.
4470 * @param del_cb called when data is not needed anymore, either when
4471 * another callback replaces @func, the tooltip is unset with
4472 * elm_genlist_item_tooltip_unset() or the owner @a item
4473 * dies. This callback receives as the first parameter the
4474 * given @a data, and @c event_info is the item.
4479 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4480 Elm_Tooltip_Item_Content_Cb func,
4482 Evas_Smart_Cb del_cb)
4484 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4486 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4489 if (item->tooltip.del_cb)
4490 item->tooltip.del_cb((void *)item->tooltip.data,
4491 item->base.widget, item);
4493 item->tooltip.content_cb = func;
4494 item->tooltip.data = data;
4495 item->tooltip.del_cb = del_cb;
4497 if (item->base.view)
4499 elm_widget_item_tooltip_content_cb_set(item,
4500 item->tooltip.content_cb,
4501 item->tooltip.data, NULL);
4502 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4508 if (del_cb) del_cb((void *)data, NULL, NULL);
4512 * Unset tooltip from item
4514 * @param item genlist item to remove previously set tooltip.
4516 * Remove tooltip from item. The callback provided as del_cb to
4517 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4518 * it is not used anymore.
4520 * @see elm_genlist_item_tooltip_content_cb_set()
4525 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4528 if ((item->base.view) && (item->tooltip.content_cb))
4529 elm_widget_item_tooltip_unset(item);
4531 if (item->tooltip.del_cb)
4532 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4533 item->tooltip.del_cb = NULL;
4534 item->tooltip.content_cb = NULL;
4535 item->tooltip.data = NULL;
4536 if (item->tooltip.style)
4537 elm_genlist_item_tooltip_style_set(item, NULL);
4541 * Sets a different style for this item tooltip.
4543 * @note before you set a style you should define a tooltip with
4544 * elm_genlist_item_tooltip_content_cb_set() or
4545 * elm_genlist_item_tooltip_text_set()
4547 * @param item genlist item with tooltip already set.
4548 * @param style the theme style to use (default, transparent, ...)
4553 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4556 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4557 eina_stringshare_replace(&item->tooltip.style, style);
4558 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4562 * Get the style for this item tooltip.
4564 * @param item genlist item with tooltip already set.
4565 * @return style the theme style in use, defaults to "default". If the
4566 * object does not have a tooltip set, then NULL is returned.
4571 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4573 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4574 return item->tooltip.style;
4578 * Set the cursor to be shown when mouse is over the genlist item
4580 * @param item Target item
4581 * @param cursor the cursor name to be used.
4583 * @see elm_object_cursor_set()
4587 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4590 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4591 eina_stringshare_replace(&item->mouse_cursor, cursor);
4592 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4596 * Get the cursor to be shown when mouse is over the genlist item
4598 * @param item genlist item with cursor already set.
4599 * @return the cursor name.
4604 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4606 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4607 return elm_widget_item_cursor_get(item);
4611 * Unset the cursor to be shown when mouse is over the genlist item
4613 * @param item Target item
4615 * @see elm_object_cursor_unset()
4619 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4621 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4622 if (!item->mouse_cursor)
4625 if (item->base.view)
4626 elm_widget_item_cursor_unset(item);
4628 eina_stringshare_del(item->mouse_cursor);
4629 item->mouse_cursor = NULL;
4633 * Sets a different style for this item cursor.
4635 * @note before you set a style you should define a cursor with
4636 * elm_genlist_item_cursor_set()
4638 * @param item genlist item with cursor already set.
4639 * @param style the theme style to use (default, transparent, ...)
4644 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4647 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4648 elm_widget_item_cursor_style_set(item, style);
4652 * Get the style for this item cursor.
4654 * @param item genlist item with cursor already set.
4655 * @return style the theme style in use, defaults to "default". If the
4656 * object does not have a cursor set, then NULL is returned.
4661 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4663 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4664 return elm_widget_item_cursor_style_get(item);
4668 * Set if the cursor set should be searched on the theme or should use
4669 * the provided by the engine, only.
4671 * @note before you set if should look on theme you should define a
4672 * cursor with elm_object_cursor_set(). By default it will only look
4673 * for cursors provided by the engine.
4675 * @param item widget item with cursor already set.
4676 * @param engine_only boolean to define it cursors should be looked
4677 * only between the provided by the engine or searched on widget's
4683 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4684 Eina_Bool engine_only)
4686 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4687 elm_widget_item_cursor_engine_only_set(item, engine_only);
4691 * Get the cursor engine only usage for this item cursor.
4693 * @param item widget item with cursor already set.
4694 * @return engine_only boolean to define it cursors should be looked
4695 * only between the provided by the engine or searched on widget's
4696 * theme as well. If the object does not have a cursor set, then
4697 * EINA_FALSE is returned.
4702 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4704 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4705 return elm_widget_item_cursor_engine_only_get(item);
4709 * This sets the horizontal stretching mode
4711 * This sets the mode used for sizing items horizontally. Valid modes
4712 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4713 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4714 * the scroller will scroll horizontally. Otherwise items are expanded
4715 * to fill the width of the viewport of the scroller. If it is
4716 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4717 * limited to that size.
4719 * @param obj The genlist object
4720 * @param mode The mode to use
4725 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4728 ELM_CHECK_WIDTYPE(obj, widtype);
4729 Widget_Data *wd = elm_widget_data_get(obj);
4731 if (wd->mode == mode) return;
4737 * Gets the horizontal stretching mode
4739 * @param obj The genlist object
4740 * @return The mode to use
4741 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4746 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4748 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4749 Widget_Data *wd = elm_widget_data_get(obj);
4750 if (!wd) return ELM_LIST_LAST;
4755 * Set the always select mode.
4757 * Items will only call their selection func and callback when first
4758 * becoming selected. Any further clicks will do nothing, unless you
4759 * enable always select with elm_genlist_always_select_mode_set().
4760 * This means even if selected, every click will make the selected
4761 * callbacks be called.
4763 * @param obj The genlist object
4764 * @param always_select The always select mode
4765 * (EINA_TRUE = on, EINA_FALSE = off)
4770 elm_genlist_always_select_mode_set(Evas_Object *obj,
4771 Eina_Bool always_select)
4773 ELM_CHECK_WIDTYPE(obj, widtype);
4774 Widget_Data *wd = elm_widget_data_get(obj);
4776 wd->always_select = always_select;
4780 * Get the always select mode.
4782 * @param obj The genlist object
4783 * @return The always select mode
4784 * (EINA_TRUE = on, EINA_FALSE = off)
4789 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4791 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4792 Widget_Data *wd = elm_widget_data_get(obj);
4793 if (!wd) return EINA_FALSE;
4794 return wd->always_select;
4798 * Set no select mode
4800 * This will turn off the ability to select items entirely and they
4801 * will neither appear selected nor call selected callback functions.
4803 * @param obj The genlist object
4804 * @param no_select The no select mode
4805 * (EINA_TRUE = on, EINA_FALSE = off)
4810 elm_genlist_no_select_mode_set(Evas_Object *obj,
4811 Eina_Bool no_select)
4813 ELM_CHECK_WIDTYPE(obj, widtype);
4814 Widget_Data *wd = elm_widget_data_get(obj);
4816 wd->no_select = no_select;
4820 * Gets no select mode
4822 * @param obj The genlist object
4823 * @return The no select mode
4824 * (EINA_TRUE = on, EINA_FALSE = off)
4829 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4831 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4832 Widget_Data *wd = elm_widget_data_get(obj);
4833 if (!wd) return EINA_FALSE;
4834 return wd->no_select;
4840 * This will enable the compress mode where items are "compressed"
4841 * horizontally to fit the genlist scrollable viewport width. This is
4842 * special for genlist. Do not rely on
4843 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4844 * work as genlist needs to handle it specially.
4846 * @param obj The genlist object
4847 * @param compress The compress mode
4848 * (EINA_TRUE = on, EINA_FALSE = off)
4853 elm_genlist_compress_mode_set(Evas_Object *obj,
4856 ELM_CHECK_WIDTYPE(obj, widtype);
4857 Widget_Data *wd = elm_widget_data_get(obj);
4859 wd->compress = compress;
4863 * Get the compress mode
4865 * @param obj The genlist object
4866 * @return The compress mode
4867 * (EINA_TRUE = on, EINA_FALSE = off)
4872 elm_genlist_compress_mode_get(const Evas_Object *obj)
4874 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4875 Widget_Data *wd = elm_widget_data_get(obj);
4876 if (!wd) return EINA_FALSE;
4877 return wd->compress;
4881 * Set height-for-width mode
4883 * With height-for-width mode the item width will be fixed (restricted
4884 * to a minimum of) to the list width when calculating its size in
4885 * order to allow the height to be calculated based on it. This allows,
4886 * for instance, text block to wrap lines if the Edje part is
4887 * configured with "text.min: 0 1".
4889 * @note This mode will make list resize slower as it will have to
4890 * recalculate every item height again whenever the list width
4893 * @note When height-for-width mode is enabled, it also enables
4894 * compress mode (see elm_genlist_compress_mode_set()) and
4895 * disables homogeneous (see elm_genlist_homogeneous_set()).
4897 * @param obj The genlist object
4898 * @param setting The height-for-width mode (EINA_TRUE = on,
4904 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4905 Eina_Bool height_for_width)
4907 ELM_CHECK_WIDTYPE(obj, widtype);
4908 Widget_Data *wd = elm_widget_data_get(obj);
4910 wd->height_for_width = !!height_for_width;
4911 if (wd->height_for_width)
4913 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4914 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4919 * Get the height-for-width mode
4921 * @param obj The genlist object
4922 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4928 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4930 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4931 Widget_Data *wd = elm_widget_data_get(obj);
4932 if (!wd) return EINA_FALSE;
4933 return wd->height_for_width;
4939 * This will enable or disable the scroller bounce mode for the
4940 * genlist. See elm_scroller_bounce_set() for details
4942 * @param obj The genlist object
4943 * @param h_bounce Allow bounce horizontally
4944 * @param v_bounce Allow bounce vertically
4949 elm_genlist_bounce_set(Evas_Object *obj,
4953 ELM_CHECK_WIDTYPE(obj, widtype);
4954 Widget_Data *wd = elm_widget_data_get(obj);
4956 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4960 * Get the bounce mode
4962 * @param obj The genlist object
4963 * @param h_bounce Allow bounce horizontally
4964 * @param v_bounce Allow bounce vertically
4969 elm_genlist_bounce_get(const Evas_Object *obj,
4970 Eina_Bool *h_bounce,
4971 Eina_Bool *v_bounce)
4973 ELM_CHECK_WIDTYPE(obj, widtype);
4974 Widget_Data *wd = elm_widget_data_get(obj);
4976 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4980 * Set homogenous mode
4982 * This will enable the homogeneous mode where items are of the same
4983 * height and width so that genlist may do the lazy-loading at its
4984 * maximum. This implies 'compressed' mode.
4986 * @param obj The genlist object
4987 * @param homogeneous Assume the items within the genlist are of the
4988 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4993 elm_genlist_homogeneous_set(Evas_Object *obj,
4994 Eina_Bool homogeneous)
4996 ELM_CHECK_WIDTYPE(obj, widtype);
4997 Widget_Data *wd = elm_widget_data_get(obj);
4999 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5000 wd->homogeneous = homogeneous;
5004 * Get the homogenous mode
5006 * @param obj The genlist object
5007 * @return Assume the items within the genlist are of the same height
5008 * and width (EINA_TRUE = on, EINA_FALSE = off)
5013 elm_genlist_homogeneous_get(const Evas_Object *obj)
5015 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5016 Widget_Data *wd = elm_widget_data_get(obj);
5017 if (!wd) return EINA_FALSE;
5018 return wd->homogeneous;
5022 * Set the maximum number of items within an item block
5024 * This will configure the block count to tune to the target with
5025 * particular performance matrix.
5027 * @param obj The genlist object
5028 * @param n Maximum number of items within an item block
5033 elm_genlist_block_count_set(Evas_Object *obj,
5036 ELM_CHECK_WIDTYPE(obj, widtype);
5037 Widget_Data *wd = elm_widget_data_get(obj);
5039 wd->max_items_per_block = n;
5040 wd->item_cache_max = wd->max_items_per_block * 2;
5041 _item_cache_clean(wd);
5045 * Get the maximum number of items within an item block
5047 * @param obj The genlist object
5048 * @return Maximum number of items within an item block
5053 elm_genlist_block_count_get(const Evas_Object *obj)
5055 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5056 Widget_Data *wd = elm_widget_data_get(obj);
5058 return wd->max_items_per_block;
5062 * Set the timeout in seconds for the longpress event
5064 * @param obj The genlist object
5065 * @param timeout timeout in seconds
5070 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5073 ELM_CHECK_WIDTYPE(obj, widtype);
5074 Widget_Data *wd = elm_widget_data_get(obj);
5076 wd->longpress_timeout = timeout;
5080 * Get the timeout in seconds for the longpress event
5082 * @param obj The genlist object
5083 * @return timeout in seconds
5088 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5090 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5091 Widget_Data *wd = elm_widget_data_get(obj);
5093 return wd->longpress_timeout;
5097 * Set the scrollbar policy
5099 * This sets the scrollbar visibility policy for the given genlist
5100 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5101 * made visible if it is needed, and otherwise kept hidden.
5102 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5103 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5104 * respectively for the horizontal and vertical scrollbars.
5106 * @param obj The genlist object
5107 * @param policy_h Horizontal scrollbar policy
5108 * @param policy_v Vertical scrollbar policy
5113 elm_genlist_scroller_policy_set(Evas_Object *obj,
5114 Elm_Scroller_Policy policy_h,
5115 Elm_Scroller_Policy policy_v)
5117 ELM_CHECK_WIDTYPE(obj, widtype);
5118 Widget_Data *wd = elm_widget_data_get(obj);
5120 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5121 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5124 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5128 * Get the scrollbar policy
5130 * @param obj The genlist object
5131 * @param policy_h Horizontal scrollbar policy
5132 * @param policy_v Vertical scrollbar policy
5137 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5138 Elm_Scroller_Policy *policy_h,
5139 Elm_Scroller_Policy *policy_v)
5141 ELM_CHECK_WIDTYPE(obj, widtype);
5142 Widget_Data *wd = elm_widget_data_get(obj);
5143 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5144 if ((!wd) || (!wd->scr)) return;
5145 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5146 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5147 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5151 * Update the contents of all realized items
5153 * This updates all realized items by calling all the item class functions again
5154 * to get the icons, labels and states. Use this when the original
5155 * item data has changed and the changes are desired to be reflected.
5157 * @param it The item
5162 elm_genlist_realized_items_update(Evas_Object *obj)
5164 ELM_CHECK_WIDTYPE(obj, widtype);
5166 Eina_List *list, *l;
5167 Elm_Genlist_Item *it;
5169 list = elm_genlist_realized_items_get(obj);
5170 EINA_LIST_FOREACH(list, l, it)
5171 elm_genlist_item_update(it);
5175 * Set genlist item mode
5177 * @param item The genlist item
5178 * @param mode Mode name
5179 * @param mode_set Boolean to define set or unset mode.
5184 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5185 const char *mode_type,
5188 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5189 Widget_Data *wd = it->wd;
5191 Elm_Genlist_Item *it2;
5194 if (!mode_type) return;
5196 if ((wd->mode_item == it) &&
5197 (!strcmp(mode_type, wd->mode_type)) &&
5200 if (!it->itc->mode_item_style) return;
5204 EINA_LIST_FOREACH(wd->selected, l, it2)
5206 elm_genlist_item_selected_set(it2, EINA_FALSE);
5210 it2 = elm_genlist_selected_item_get(wd->obj);
5211 if ((it2) && (it2->realized))
5212 elm_genlist_item_selected_set(it2, EINA_FALSE);
5215 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5217 ((it == wd->mode_item) && (!mode_set)))
5218 _item_mode_unset(wd);
5220 eina_stringshare_replace(&wd->mode_type, mode_type);
5221 if (mode_set) _item_mode_set(it);
5225 * Get active genlist mode type
5227 * @param obj The genlist object
5232 elm_genlist_mode_get(const Evas_Object *obj)
5234 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5235 Widget_Data *wd = elm_widget_data_get(obj);
5236 if (!wd) return NULL;
5237 return wd->mode_type;
5241 * Get active genlist mode item
5243 * @param obj The genlist object
5247 EAPI const Elm_Genlist_Item *
5248 elm_genlist_mode_item_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_item;