3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
11 * @defgroup Genlist Genlist
13 * The aim was to have more expansive list than the simple list in
14 * Elementary that could have more flexible items and allow many more entries
15 * while still being fast and low on memory usage. At the same time it was
16 * also made to be able to do tree structures. But the price to pay is more
17 * complex when it comes to usage. If all you want is a simple list with
18 * icons and a single label, use the normal List object.
20 * Genlist has a fairly large API, mostly because it's relatively complex,
21 * trying to be both expansive, powerful and efficient. First we will begin
22 * an overview on the theory behind genlist.
24 * Evas tracks every object you create. Every time it processes an event
25 * (mouse move, down, up etc.) it needs to walk through objects and find out
26 * what event that affects. Even worse every time it renders display updates,
27 * in order to just calculate what to re-draw, it needs to walk through many
28 * many many objects. Thus, the more objects you keep active, the more
29 * overhead Evas has in just doing its work. It is advisable to keep your
30 * active objects to the minimum working set you need. Also remember that
31 * object creation and deletion carries an overhead, so there is a
32 * middle-ground, which is not easily determined. But don't keep massive lists
33 * of objects you can't see or use. Genlist does this with list objects. It
34 * creates and destroys them dynamically as you scroll around. It groups them
35 * into blocks so it can determine the visibility etc. of a whole block at
36 * once as opposed to having to walk the whole list. This 2-level list allows
37 * for very large numbers of items to be in the list (tests have used up to
38 * 2,000,000 items). Also genlist employs a queue for adding items. As items
39 * may be different sizes, every item added needs to be calculated as to its
40 * size and thus this presents a lot of overhead on populating the list, this
41 * genlist employs a queue. Any item added is queued and spooled off over
42 * time, actually appearing some time later, so if your list has many members
43 * you may find it takes a while for them to all appear, with your process
44 * consuming a lot of CPU while it is busy spooling.
46 * Genlist also implements a tree structure, but it does so with callbacks to
47 * the application, with the application filling in tree structures when
48 * requested (allowing for efficient building of a very deep tree that could
49 * even be used for file-management). See the above smart signal callbacks for
52 * An item in the genlist world can have 0 or more text labels (they can be
53 * regular text or textblock - that's up to the style to determine), 0 or
54 * more icons (which are simply objects swallowed into the genlist item) and
55 * 0 or more boolean states that can be used for check, radio or other
56 * indicators by the edje theme style. An item may be one of several styles
57 * (Elementary provides 4 by default - "default", "double_label", "group_index"
58 * and "icon_top_text_bottom", but this can be extended by system or
59 * application custom themes/overlays/extensions).
61 * In order to implement the ability to add and delete items on the fly,
62 * Genlist implements a class/callback system where the application provides
63 * a structure with information about that type of item (genlist may contain
64 * multiple different items with different classes, states and styles).
65 * Genlist will call the functions in this struct (methods) when an item is
66 * "realized" (that is created dynamically while scrolling). All objects will
67 * simply be deleted when no longer needed with evas_object_del(). The
68 * Elm_Genlist_Item_Class structure contains the following members:
70 * item_style - This is a constant string and simply defines the name of the
71 * item style. It must be specified and the default should be "default".
73 * func.label_get - This function is called when an actual item object is
74 * created. The data parameter is the data parameter passed to
75 * elm_genlist_item_append() and related item creation functions. The obj
76 * parameter is the genlist object and the part parameter is the string name
77 * of the text part in the edje design that is listed as one of the possible
78 * labels that can be set. This function must return a strudup()'ed string as
79 * the caller will free() it when done.
81 * func.icon_get - This function is called when an actual item object is
82 * created. The data parameter is the data parameter passed to
83 * elm_genlist_item_append() and related item creation functions. The obj
84 * parameter is the genlist object and the part parameter is the string name
85 * of the icon part in the edje design that is listed as one of the possible
86 * icons that can be set. This must return NULL for no object or a valid
87 * object. The object will be deleted by genlist on shutdown or when the item
90 * func.state_get - This function is called when an actual item object is
91 * created. The data parameter is the data parameter passed to
92 * elm_genlist_item_append() and related item creation functions. The obj
93 * parameter is the genlist object and the part parameter is the string name
94 * of the state part in the edje design that is listed as one of the possible
95 * states that can be set. Return 0 for false or 1 for true. Genlist will
96 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
97 * true (the default is false), where XXX is the name of the part.
99 * func.del - This is called when elm_genlist_item_del() is called on an
100 * item, elm_genlist_clear() is called on the genlist, or
101 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
102 * intended for use when actual genlist items are deleted, so any backing
103 * data attached to the item (e.g. its data parameter on creation) can be
106 * Items can be added by several calls. All of them return a Elm_Genlist_Item
107 * handle that is an internal member inside the genlist. They all take a data
108 * parameter that is meant to be used for a handle to the applications
109 * internal data (eg the struct with the original item data). The parent
110 * parameter is the parent genlist item this belongs to if it is a tree or
111 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
112 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
113 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
114 * is displayed as an item that is able to expand and have child items.
115 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
116 * displayed at the top until the next group comes. The func parameter is a
117 * convenience callback that is called when the item is selected and the data
118 * parameter will be the func_data parameter, obj be the genlist object and
119 * event_info will be the genlist item.
121 * elm_genlist_item_append() appends an item to the end of the list, or if
122 * there is a parent, to the end of all the child items of the parent.
123 * elm_genlist_item_prepend() is the same but prepends to the beginning of
124 * the list or children list. elm_genlist_item_insert_before() inserts at
125 * item before another item and elm_genlist_item_insert_after() inserts after
126 * the indicated item.
128 * The application can clear the list with elm_genlist_clear() which deletes
129 * all the items in the list and elm_genlist_item_del() will delete a specific
130 * item. elm_genlist_item_subitems_clear() will clear all items that are
131 * children of the indicated parent item.
133 * If the application wants multiple items to be able to be selected,
134 * elm_genlist_multi_select_set() can enable this. If the list is
135 * single-selection only (the default), then elm_genlist_selected_item_get()
136 * will return the selected item, if any, or NULL I none is selected. If the
137 * list is multi-select then elm_genlist_selected_items_get() will return a
138 * list (that is only valid as long as no items are modified (added, deleted,
139 * selected or unselected)).
141 * To help inspect list items you can jump to the item at the top of the list
142 * with elm_genlist_first_item_get() which will return the item pointer, and
143 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
144 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
145 * and previous items respectively relative to the indicated item. Using
146 * these calls you can walk the entire item list/tree. Note that as a tree
147 * the items are flattened in the list, so elm_genlist_item_parent_get() will
148 * let you know which item is the parent (and thus know how to skip them if
151 * There are also convenience functions. elm_genlist_item_genlist_get() will
152 * return the genlist object the item belongs to. elm_genlist_item_show()
153 * will make the scroller scroll to show that specific item so its visible.
154 * elm_genlist_item_data_get() returns the data pointer set by the item
155 * creation functions.
157 * If an item changes (state of boolean changes, label or icons change),
158 * then use elm_genlist_item_update() to have genlist update the item with
159 * the new state. Genlist will re-realize the item thus call the functions
160 * in the _Elm_Genlist_Item_Class for that item.
162 * To programmatically (un)select an item use elm_genlist_item_selected_set().
163 * To get its selected state use elm_genlist_item_selected_get(). Similarly
164 * to expand/contract an item and get its expanded state, use
165 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
166 * again to make an item disabled (unable to be selected and appear
167 * differently) use elm_genlist_item_disabled_set() to set this and
168 * elm_genlist_item_disabled_get() to get the disabled state.
170 * In general to indicate how the genlist should expand items horizontally to
171 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
172 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
173 * mode means that if items are too wide to fit, the scroller will scroll
174 * horizontally. Otherwise items are expanded to fill the width of the
175 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
176 * to the viewport width and limited to that size. This can be combined with
177 * a different style that uses edjes' ellipsis feature (cutting text off like
180 * Items will only call their selection func and callback when first becoming
181 * selected. Any further clicks will do nothing, unless you enable always
182 * select with elm_genlist_always_select_mode_set(). This means even if
183 * selected, every click will make the selected callbacks be called.
184 * elm_genlist_no_select_mode_set() will turn off the ability to select
185 * items entirely and they will neither appear selected nor call selected
186 * callback functions.
188 * Remember that you can create new styles and add your own theme augmentation
189 * per application with elm_theme_extension_add(). If you absolutely must
190 * have a specific style that overrides any theme the user or system sets up
191 * you can use elm_theme_overlay_add() to add such a file.
195 typedef struct _Widget_Data Widget_Data;
196 typedef struct _Item_Block Item_Block;
197 typedef struct _Pan Pan;
198 typedef struct _Item_Cache Item_Cache;
202 Evas_Object *obj, *scr, *pan_smart;
203 Eina_Inlist *items, *blocks;
204 Eina_List *group_items;
206 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
207 Ecore_Job *calc_job, *update_job;
208 Ecore_Idle_Enterer *queue_idle_enterer;
209 Ecore_Idler *must_recalc_idler;
210 Eina_List *queue, *selected;
211 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
212 Eina_Inlist *item_cache;
215 Ecore_Timer *multi_timer, *scr_hold_timer;
216 const char *mode_type;
217 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
218 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
219 Eina_Bool mouse_down : 1;
220 Eina_Bool multi_down : 1;
221 Eina_Bool multi_timeout : 1;
222 Eina_Bool multitouched : 1;
223 Eina_Bool on_hold : 1;
225 Eina_Bool always_select : 1;
226 Eina_Bool longpressed : 1;
227 Eina_Bool wasselected : 1;
228 Eina_Bool no_select : 1;
229 Eina_Bool bring_in : 1;
230 Eina_Bool compress : 1;
231 Eina_Bool height_for_width : 1;
232 Eina_Bool homogeneous : 1;
233 Eina_Bool clear_me : 1;
238 } history[SWIPE_MOVES];
240 int item_cache_count;
246 int group_item_width;
247 int group_item_height;
248 int max_items_per_block;
249 double longpress_timeout;
259 Evas_Coord x, y, w, h, minw, minh;
260 Eina_Bool want_unrealize : 1;
261 Eina_Bool realized : 1;
262 Eina_Bool changed : 1;
263 Eina_Bool updateme : 1;
264 Eina_Bool showme : 1;
265 Eina_Bool must_recalc : 1;
268 struct _Elm_Genlist_Item
270 Elm_Widget_Item base;
275 Evas_Coord x, y, w, h, minw, minh;
276 const Elm_Genlist_Item_Class *itc;
277 Elm_Genlist_Item *parent;
278 Elm_Genlist_Item *group_item;
279 Elm_Genlist_Item_Flags flags;
287 Eina_List *labels, *icons, *states, *icon_objs;
288 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
289 Ecore_Timer *long_timer;
290 Ecore_Timer *swipe_timer;
292 Evas_Coord scrl_x, scrl_y;
294 Elm_Genlist_Item *rel;
295 Evas_Object *mode_view;
300 Elm_Tooltip_Item_Content_Cb content_cb;
301 Evas_Smart_Cb del_cb;
305 const char *mouse_cursor;
312 Eina_Bool before : 1;
314 Eina_Bool want_unrealize : 1;
315 Eina_Bool want_realize : 1;
316 Eina_Bool realized : 1;
317 Eina_Bool selected : 1;
318 Eina_Bool highlighted : 1;
319 Eina_Bool expanded : 1;
320 Eina_Bool disabled : 1;
321 Eina_Bool display_only : 1;
322 Eina_Bool mincalcd : 1;
323 Eina_Bool queued : 1;
324 Eina_Bool showme : 1;
325 Eina_Bool delete_me : 1;
327 Eina_Bool dragging : 1;
328 Eina_Bool updateme : 1;
329 Eina_Bool nocache : 1;
330 Eina_Bool stacking_even : 1;
331 Eina_Bool nostacking : 1;
338 Evas_Object *base_view, *spacer;
340 const char *item_style; // it->itc->item_style
341 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
342 Eina_Bool compress : 1; // it->wd->compress
344 Eina_Bool selected : 1; // it->selected
345 Eina_Bool disabled : 1; // it->disabled
346 Eina_Bool expanded : 1; // it->expanded
349 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
350 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
354 Evas_Object_Smart_Clipped_Data __clipped_data;
356 Ecore_Job *resize_job;
359 static const char *widtype = NULL;
360 static void _item_cache_zero(Widget_Data *wd);
361 static void _del_hook(Evas_Object *obj);
362 static void _mirrored_set(Evas_Object *obj,
364 static void _theme_hook(Evas_Object *obj);
365 static void _show_region_hook(void *data,
367 static void _sizing_eval(Evas_Object *obj);
368 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
369 static void _item_block_unrealize(Item_Block *itb);
370 static void _calc_job(void *data);
371 static void _on_focus_hook(void *data,
373 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
374 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
375 static Eina_Bool _item_single_select_up(Widget_Data *wd);
376 static Eina_Bool _item_single_select_down(Widget_Data *wd);
377 static Eina_Bool _event_hook(Evas_Object *obj,
379 Evas_Callback_Type type,
381 static void _signal_emit_hook(Evas_Object *obj,
382 const char *emission,
384 static Eina_Bool _deselect_all_items(Widget_Data *wd);
385 static void _pan_calculate(Evas_Object *obj);
386 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
387 static void _mode_item_realize(Elm_Genlist_Item *it);
388 static void _mode_item_unrealize(Elm_Genlist_Item *it);
389 static void _item_mode_set(Elm_Genlist_Item *it);
390 static void _item_mode_unset(Widget_Data *wd);
392 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
395 _event_hook(Evas_Object *obj,
396 Evas_Object *src __UNUSED__,
397 Evas_Callback_Type type,
400 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
401 Evas_Event_Key_Down *ev = event_info;
402 Widget_Data *wd = elm_widget_data_get(obj);
403 if (!wd) return EINA_FALSE;
404 if (!wd->items) return EINA_FALSE;
405 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
406 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
408 Elm_Genlist_Item *it = NULL;
411 Evas_Coord step_x = 0;
412 Evas_Coord step_y = 0;
415 Evas_Coord page_x = 0;
416 Evas_Coord page_y = 0;
418 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
419 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
420 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
421 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
423 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
427 else if ((!strcmp(ev->keyname, "Right")) ||
428 (!strcmp(ev->keyname, "KP_Right")))
432 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
434 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
435 (_item_multi_select_up(wd)))
436 || (_item_single_select_up(wd)))
438 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
444 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
446 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
447 (_item_multi_select_down(wd)))
448 || (_item_single_select_down(wd)))
450 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
456 else if ((!strcmp(ev->keyname, "Home")) ||
457 (!strcmp(ev->keyname, "KP_Home")))
459 it = elm_genlist_first_item_get(obj);
460 elm_genlist_item_bring_in(it);
461 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
464 else if ((!strcmp(ev->keyname, "End")) ||
465 (!strcmp(ev->keyname, "KP_End")))
467 it = elm_genlist_last_item_get(obj);
468 elm_genlist_item_bring_in(it);
469 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
472 else if ((!strcmp(ev->keyname, "Prior")) ||
473 (!strcmp(ev->keyname, "KP_Prior")))
476 y -= -(page_y * v_h) / 100;
480 else if ((!strcmp(ev->keyname, "Next")) ||
481 (!strcmp(ev->keyname, "KP_Next")))
484 y += -(page_y * v_h) / 100;
488 else if(((!strcmp(ev->keyname, "Return")) ||
489 (!strcmp(ev->keyname, "KP_Enter")) ||
490 (!strcmp(ev->keyname, "space")))
491 && (!wd->multi) && (wd->selected))
493 it = elm_genlist_selected_item_get(obj);
494 elm_genlist_item_expanded_set(it,
495 !elm_genlist_item_expanded_get(it));
497 else if (!strcmp(ev->keyname, "Escape"))
499 if (!_deselect_all_items(wd)) return EINA_FALSE;
500 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
503 else return EINA_FALSE;
505 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
506 elm_smart_scroller_child_pos_set(wd->scr, x, y);
511 _deselect_all_items(Widget_Data *wd)
513 if (!wd->selected) return EINA_FALSE;
515 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
521 _item_multi_select_up(Widget_Data *wd)
523 if (!wd->selected) return EINA_FALSE;
524 if (!wd->multi) return EINA_FALSE;
526 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
527 if (!prev) return EINA_TRUE;
529 if (elm_genlist_item_selected_get(prev))
531 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
532 wd->last_selected_item = prev;
533 elm_genlist_item_show(wd->last_selected_item);
537 elm_genlist_item_selected_set(prev, EINA_TRUE);
538 elm_genlist_item_show(prev);
544 _item_multi_select_down(Widget_Data *wd)
546 if (!wd->selected) return EINA_FALSE;
547 if (!wd->multi) return EINA_FALSE;
549 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
550 if (!next) return EINA_TRUE;
552 if (elm_genlist_item_selected_get(next))
554 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
555 wd->last_selected_item = next;
556 elm_genlist_item_show(wd->last_selected_item);
560 elm_genlist_item_selected_set(next, EINA_TRUE);
561 elm_genlist_item_show(next);
567 _item_single_select_up(Widget_Data *wd)
569 Elm_Genlist_Item *prev;
572 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
573 while ((prev) && (prev->delete_me))
574 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
576 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
578 if (!prev) return EINA_FALSE;
580 _deselect_all_items(wd);
582 elm_genlist_item_selected_set(prev, EINA_TRUE);
583 elm_genlist_item_show(prev);
588 _item_single_select_down(Widget_Data *wd)
590 Elm_Genlist_Item *next;
593 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
594 while ((next) && (next->delete_me))
595 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
597 else next = elm_genlist_item_next_get(wd->last_selected_item);
599 if (!next) return EINA_FALSE;
601 _deselect_all_items(wd);
603 elm_genlist_item_selected_set(next, EINA_TRUE);
604 elm_genlist_item_show(next);
609 _on_focus_hook(void *data __UNUSED__,
612 Widget_Data *wd = elm_widget_data_get(obj);
614 if (elm_widget_focus_get(obj))
616 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
617 evas_object_focus_set(wd->obj, EINA_TRUE);
618 if ((wd->selected) && (!wd->last_selected_item))
619 wd->last_selected_item = eina_list_data_get(wd->selected);
623 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
624 evas_object_focus_set(wd->obj, EINA_FALSE);
629 _del_hook(Evas_Object *obj)
631 Widget_Data *wd = elm_widget_data_get(obj);
633 _item_cache_zero(wd);
634 if (wd->calc_job) ecore_job_del(wd->calc_job);
635 if (wd->update_job) ecore_job_del(wd->update_job);
636 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
637 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
638 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
639 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
640 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
645 _del_pre_hook(Evas_Object *obj)
647 Widget_Data *wd = elm_widget_data_get(obj);
649 evas_object_del(wd->pan_smart);
650 wd->pan_smart = NULL;
651 elm_genlist_clear(obj);
655 _mirrored_set(Evas_Object *obj,
658 Widget_Data *wd = elm_widget_data_get(obj);
660 _item_cache_zero(wd);
661 elm_smart_scroller_mirrored_set(wd->scr, rtl);
665 _theme_hook(Evas_Object *obj)
667 Widget_Data *wd = elm_widget_data_get(obj);
670 _item_cache_zero(wd);
671 _elm_widget_mirrored_reload(obj);
672 _mirrored_set(obj, elm_widget_mirrored_get(obj));
673 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
674 elm_widget_style_get(obj));
675 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
676 wd->item_width = wd->item_height = 0;
677 wd->group_item_width = wd->group_item_height = 0;
678 wd->minw = wd->minh = wd->realminw = 0;
679 EINA_INLIST_FOREACH(wd->blocks, itb)
682 Elm_Genlist_Item *it;
684 if (itb->realized) _item_block_unrealize(itb);
685 EINA_LIST_FOREACH(itb->items, l, it)
686 it->mincalcd = EINA_FALSE;
688 itb->changed = EINA_TRUE;
690 if (wd->calc_job) ecore_job_del(wd->calc_job);
691 wd->calc_job = ecore_job_add(_calc_job, wd);
696 _show_region_hook(void *data,
699 Widget_Data *wd = elm_widget_data_get(data);
700 Evas_Coord x, y, w, h;
702 elm_widget_show_region_get(obj, &x, &y, &w, &h);
703 //x & y are screen coordinates, Add with pan coordinates
706 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
710 _sizing_eval(Evas_Object *obj)
712 Widget_Data *wd = elm_widget_data_get(obj);
713 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
715 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
716 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
718 if (wd->height_for_width)
722 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
723 if ((vw != 0) && (vw != wd->prev_viewport_w))
727 wd->prev_viewport_w = vw;
728 EINA_INLIST_FOREACH(wd->blocks, itb)
730 itb->must_recalc = EINA_TRUE;
732 if (wd->calc_job) ecore_job_del(wd->calc_job);
733 wd->calc_job = ecore_job_add(_calc_job, wd);
736 if (wd->mode == ELM_LIST_LIMIT)
738 Evas_Coord vmw, vmh, vw, vh;
742 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
743 if ((minw > 0) && (vw < minw)) vw = minw;
744 else if ((maxw > 0) && (vw > maxw))
746 edje_object_size_min_calc
747 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
754 edje_object_size_min_calc
755 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
759 evas_object_size_hint_min_set(obj, minw, minh);
760 evas_object_size_hint_max_set(obj, maxw, maxh);
764 _signal_emit_hook(Evas_Object *obj,
765 const char *emission,
768 Widget_Data *wd = elm_widget_data_get(obj);
769 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
774 _item_highlight(Elm_Genlist_Item *it)
776 const char *selectraise;
777 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
778 (it->disabled) || (it->display_only) || (it->mode_view))
780 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
781 selectraise = edje_object_data_get(it->base.view, "selectraise");
782 if ((selectraise) && (!strcmp(selectraise, "on")))
784 evas_object_raise(it->base.view);
785 if ((it->group_item) && (it->group_item->realized))
786 evas_object_raise(it->group_item->base.view);
788 it->highlighted = EINA_TRUE;
792 _item_block_del(Elm_Genlist_Item *it)
795 Item_Block *itb = it->block;
797 itb->items = eina_list_remove(itb->items, it);
799 itb->changed = EINA_TRUE;
800 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
801 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
804 il = EINA_INLIST_GET(itb);
805 Item_Block *itbn = (Item_Block *)(il->next);
807 it->parent->items = eina_list_remove(it->parent->items, it);
809 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
811 if (itbn) itbn->changed = EINA_TRUE;
817 il = EINA_INLIST_GET(itb);
818 Item_Block *itbp = (Item_Block *)(il->prev);
819 Item_Block *itbn = (Item_Block *)(il->next);
820 if ((itbp) && ((itbp->count + itb->count) < 48))
822 Elm_Genlist_Item *it2;
824 EINA_LIST_FREE(itb->items, it2)
827 itbp->items = eina_list_append(itbp->items, it2);
829 itbp->changed = EINA_TRUE;
831 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
832 EINA_INLIST_GET(itb));
835 else if ((itbn) && ((itbn->count + itb->count) < 48))
839 Eina_List *last = eina_list_last(itb->items);
840 Elm_Genlist_Item *it2 = last->data;
843 itb->items = eina_list_remove_list(itb->items, last);
844 itbn->items = eina_list_prepend(itbn->items, it2);
846 itbn->changed = EINA_TRUE;
849 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
857 _item_del(Elm_Genlist_Item *it)
859 elm_widget_item_pre_notify_del(it);
860 elm_genlist_item_subitems_clear(it);
861 it->wd->walking -= it->walking;
862 if (it->wd->show_item == it) it->wd->show_item = NULL;
863 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
864 if (it->realized) _item_unrealize(it, EINA_FALSE);
865 if (it->block) _item_block_del(it);
866 if ((!it->delete_me) && (it->itc->func.del))
867 it->itc->func.del((void *)it->base.data, it->base.widget);
868 it->delete_me = EINA_TRUE;
870 it->wd->queue = eina_list_remove(it->wd->queue, it);
871 if (it->wd->anchor_item == it)
873 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
874 if (!it->wd->anchor_item)
875 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
877 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
879 it->parent->items = eina_list_remove(it->parent->items, it);
880 if (it->flags & ELM_GENLIST_ITEM_GROUP)
881 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
882 if (it->long_timer) ecore_timer_del(it->long_timer);
883 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
885 if (it->tooltip.del_cb)
886 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
888 elm_widget_item_del(it);
892 _item_select(Elm_Genlist_Item *it)
894 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
897 if (it->wd->always_select) goto call;
900 it->selected = EINA_TRUE;
901 it->wd->selected = eina_list_append(it->wd->selected, it);
905 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
907 evas_object_smart_callback_call(it->base.widget, "selected", it);
910 if ((it->wd->clear_me) && (!it->wd->walking))
911 elm_genlist_clear(it->base.widget);
914 if ((!it->walking) && (it->delete_me))
916 if (!it->relcount) _item_del(it);
919 it->wd->last_selected_item = it;
923 _item_unselect(Elm_Genlist_Item *it)
925 const char *stacking, *selectraise;
927 if ((it->delete_me) || (!it->highlighted)) return;
928 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
929 stacking = edje_object_data_get(it->base.view, "stacking");
930 selectraise = edje_object_data_get(it->base.view, "selectraise");
933 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
934 else evas_object_raise(it->base.view);
936 it->highlighted = EINA_FALSE;
939 it->selected = EINA_FALSE;
940 it->wd->selected = eina_list_remove(it->wd->selected, it);
941 evas_object_smart_callback_call(it->base.widget, "unselected", it);
946 _mouse_move(void *data,
947 Evas *evas __UNUSED__,
951 Elm_Genlist_Item *it = data;
952 Evas_Event_Mouse_Move *ev = event_info;
953 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
955 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
957 if (!it->wd->on_hold)
959 it->wd->on_hold = EINA_TRUE;
960 if (!it->wd->wasselected)
964 if (it->wd->multitouched)
966 it->wd->cur_x = ev->cur.canvas.x;
967 it->wd->cur_y = ev->cur.canvas.y;
970 if ((it->dragging) && (it->down))
972 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
975 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
976 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
977 if (abs((it->wd->history[it->wd->movements].x -
978 it->wd->history[0].x)) > 40)
979 it->wd->swipe = EINA_TRUE;
985 ecore_timer_del(it->long_timer);
986 it->long_timer = NULL;
988 evas_object_smart_callback_call(it->base.widget, "drag", it);
991 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
995 ecore_timer_del(it->long_timer);
996 it->long_timer = NULL;
1000 if (!it->display_only)
1001 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1002 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1003 x = ev->cur.canvas.x - x;
1004 y = ev->cur.canvas.y - y;
1007 if (adx < 0) adx = -dx;
1010 if (ady < 0) ady = -dy;
1013 if ((adx > minw) || (ady > minh))
1015 it->dragging = EINA_TRUE;
1018 ecore_timer_del(it->long_timer);
1019 it->long_timer = NULL;
1021 if (!it->wd->wasselected)
1026 evas_object_smart_callback_call(it->base.widget,
1027 "drag,start,up", it);
1031 evas_object_smart_callback_call(it->base.widget,
1032 "drag,start,left", it);
1034 evas_object_smart_callback_call(it->base.widget,
1035 "drag,start,right", it);
1041 evas_object_smart_callback_call(it->base.widget,
1042 "drag,start,down", it);
1046 evas_object_smart_callback_call(it->base.widget,
1047 "drag,start,left", it);
1049 evas_object_smart_callback_call(it->base.widget,
1050 "drag,start,right", it);
1057 _long_press(void *data)
1059 Elm_Genlist_Item *it = data;
1061 it->long_timer = NULL;
1062 if ((it->disabled) || (it->dragging) || (it->display_only))
1063 return ECORE_CALLBACK_CANCEL;
1064 it->wd->longpressed = EINA_TRUE;
1065 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1066 return ECORE_CALLBACK_CANCEL;
1070 _swipe(Elm_Genlist_Item *it)
1075 if ((it->display_only) || (it->disabled)) return;
1076 it->wd->swipe = EINA_FALSE;
1077 for (i = 0; i < it->wd->movements; i++)
1079 sum += it->wd->history[i].x;
1080 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1083 sum /= it->wd->movements;
1084 if (abs(sum - it->wd->history[0].x) <= 10) return;
1085 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1089 _swipe_cancel(void *data)
1091 Elm_Genlist_Item *it = data;
1093 if (!it) return ECORE_CALLBACK_CANCEL;
1094 it->wd->swipe = EINA_FALSE;
1095 it->wd->movements = 0;
1096 return ECORE_CALLBACK_RENEW;
1100 _multi_cancel(void *data)
1102 Widget_Data *wd = data;
1104 if (!wd) return ECORE_CALLBACK_CANCEL;
1105 wd->multi_timeout = EINA_TRUE;
1106 return ECORE_CALLBACK_RENEW;
1110 _multi_touch_gesture_eval(void *data)
1112 Elm_Genlist_Item *it = data;
1114 it->wd->multitouched = EINA_FALSE;
1115 if (it->wd->multi_timer)
1117 ecore_timer_del(it->wd->multi_timer);
1118 it->wd->multi_timer = NULL;
1120 if (it->wd->multi_timeout)
1122 it->wd->multi_timeout = EINA_FALSE;
1126 Evas_Coord minw = 0, minh = 0;
1127 Evas_Coord off_x, off_y, off_mx, off_my;
1129 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1130 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1131 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1132 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1133 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1135 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1137 if ((off_x + off_mx) > (off_y + off_my))
1139 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1140 evas_object_smart_callback_call(it->base.widget,
1141 "multi,swipe,right", it);
1142 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1143 evas_object_smart_callback_call(it->base.widget,
1144 "multi,swipe,left", it);
1145 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1146 evas_object_smart_callback_call(it->base.widget,
1147 "multi,pinch,out", it);
1149 evas_object_smart_callback_call(it->base.widget,
1150 "multi,pinch,in", it);
1154 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1155 evas_object_smart_callback_call(it->base.widget,
1156 "multi,swipe,down", it);
1157 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1158 evas_object_smart_callback_call(it->base.widget,
1159 "multi,swipe,up", it);
1160 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1161 evas_object_smart_callback_call(it->base.widget,
1162 "multi,pinch,out", it);
1164 evas_object_smart_callback_call(it->base.widget,
1165 "multi,pinch,in", it);
1168 it->wd->multi_timeout = EINA_FALSE;
1172 _multi_down(void *data,
1173 Evas *evas __UNUSED__,
1174 Evas_Object *obj __UNUSED__,
1177 Elm_Genlist_Item *it = data;
1178 Evas_Event_Multi_Down *ev = event_info;
1180 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1181 it->wd->multi_device = ev->device;
1182 it->wd->multi_down = EINA_TRUE;
1183 it->wd->multitouched = EINA_TRUE;
1184 it->wd->prev_mx = ev->canvas.x;
1185 it->wd->prev_my = ev->canvas.y;
1186 if (!it->wd->wasselected) _item_unselect(it);
1187 it->wd->wasselected = EINA_FALSE;
1188 it->wd->longpressed = EINA_FALSE;
1191 ecore_timer_del(it->long_timer);
1192 it->long_timer = NULL;
1196 it->dragging = EINA_FALSE;
1197 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1199 if (it->swipe_timer)
1201 ecore_timer_del(it->swipe_timer);
1202 it->swipe_timer = NULL;
1204 if (it->wd->on_hold)
1206 it->wd->swipe = EINA_FALSE;
1207 it->wd->movements = 0;
1208 it->wd->on_hold = EINA_FALSE;
1213 _multi_up(void *data,
1214 Evas *evas __UNUSED__,
1215 Evas_Object *obj __UNUSED__,
1218 Elm_Genlist_Item *it = data;
1219 Evas_Event_Multi_Up *ev = event_info;
1221 if (it->wd->multi_device != ev->device) return;
1222 it->wd->multi_device = 0;
1223 it->wd->multi_down = EINA_FALSE;
1224 if (it->wd->mouse_down) return;
1225 _multi_touch_gesture_eval(data);
1229 _multi_move(void *data,
1230 Evas *evas __UNUSED__,
1231 Evas_Object *obj __UNUSED__,
1234 Elm_Genlist_Item *it = data;
1235 Evas_Event_Multi_Move *ev = event_info;
1237 if (it->wd->multi_device != ev->device) return;
1238 it->wd->cur_mx = ev->cur.canvas.x;
1239 it->wd->cur_my = ev->cur.canvas.y;
1243 _mouse_down(void *data,
1244 Evas *evas __UNUSED__,
1248 Elm_Genlist_Item *it = data;
1249 Evas_Event_Mouse_Down *ev = event_info;
1252 if (ev->button != 1) return;
1253 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1255 it->wd->on_hold = EINA_TRUE;
1258 it->down = EINA_TRUE;
1259 it->dragging = EINA_FALSE;
1260 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1261 it->dx = ev->canvas.x - x;
1262 it->dy = ev->canvas.y - y;
1263 it->wd->mouse_down = EINA_TRUE;
1264 if (!it->wd->multitouched)
1266 it->wd->prev_x = ev->canvas.x;
1267 it->wd->prev_y = ev->canvas.y;
1268 it->wd->multi_timeout = EINA_FALSE;
1269 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1270 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1272 it->wd->longpressed = EINA_FALSE;
1273 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1274 else it->wd->on_hold = EINA_FALSE;
1275 if (it->wd->on_hold) return;
1276 it->wd->wasselected = it->selected;
1277 _item_highlight(it);
1278 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1279 if ((!it->disabled) && (!it->display_only))
1281 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1282 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1284 if (it->long_timer) ecore_timer_del(it->long_timer);
1285 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1286 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1288 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1291 it->long_timer = NULL;
1292 it->wd->swipe = EINA_FALSE;
1293 it->wd->movements = 0;
1297 _mouse_up(void *data,
1298 Evas *evas __UNUSED__,
1299 Evas_Object *obj __UNUSED__,
1302 Elm_Genlist_Item *it = data;
1303 Evas_Event_Mouse_Up *ev = event_info;
1304 Eina_Bool dragged = EINA_FALSE;
1306 if (ev->button != 1) return;
1307 it->down = EINA_FALSE;
1308 it->wd->mouse_down = EINA_FALSE;
1309 if (it->wd->multitouched)
1311 if (it->wd->multi_down) return;
1312 _multi_touch_gesture_eval(data);
1315 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1316 else it->wd->on_hold = EINA_FALSE;
1319 ecore_timer_del(it->long_timer);
1320 it->long_timer = NULL;
1324 it->dragging = EINA_FALSE;
1325 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1328 if (it->swipe_timer)
1330 ecore_timer_del(it->swipe_timer);
1331 it->swipe_timer = NULL;
1333 if (it->wd->multi_timer)
1335 ecore_timer_del(it->wd->multi_timer);
1336 it->wd->multi_timer = NULL;
1337 it->wd->multi_timeout = EINA_FALSE;
1339 if (it->wd->on_hold)
1341 if (it->wd->swipe) _swipe(data);
1342 it->wd->longpressed = EINA_FALSE;
1343 it->wd->on_hold = EINA_FALSE;
1346 if (it->wd->longpressed)
1348 it->wd->longpressed = EINA_FALSE;
1349 if (!it->wd->wasselected)
1351 it->wd->wasselected = EINA_FALSE;
1356 if (it->want_unrealize)
1358 _item_unrealize(it, EINA_FALSE);
1359 if (it->block->want_unrealize)
1360 _item_block_unrealize(it->block);
1363 if ((it->disabled) || (dragged) || (it->display_only)) return;
1364 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1369 _item_highlight(it);
1372 else _item_unselect(it);
1378 Widget_Data *wd = it->wd;
1381 while (wd->selected) _item_unselect(wd->selected->data);
1386 const Eina_List *l, *l_next;
1387 Elm_Genlist_Item *it2;
1389 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1390 if (it2 != it) _item_unselect(it2);
1391 //_item_highlight(it);
1394 _item_highlight(it);
1400 _signal_expand_toggle(void *data,
1401 Evas_Object *obj __UNUSED__,
1402 const char *emission __UNUSED__,
1403 const char *source __UNUSED__)
1405 Elm_Genlist_Item *it = data;
1408 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1410 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1414 _signal_expand(void *data,
1415 Evas_Object *obj __UNUSED__,
1416 const char *emission __UNUSED__,
1417 const char *source __UNUSED__)
1419 Elm_Genlist_Item *it = data;
1422 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1426 _signal_contract(void *data,
1427 Evas_Object *obj __UNUSED__,
1428 const char *emission __UNUSED__,
1429 const char *source __UNUSED__)
1431 Elm_Genlist_Item *it = data;
1434 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1438 _scr_hold_timer_cb(void *data)
1440 if (!data) return ECORE_CALLBACK_CANCEL;
1441 Widget_Data *wd = data;
1442 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1443 wd->scr_hold_timer = NULL;
1444 return ECORE_CALLBACK_CANCEL;
1448 _mode_finished_signal_cb(void *data,
1450 const char *emission __UNUSED__,
1451 const char *source __UNUSED__)
1455 Elm_Genlist_Item *it = data;
1456 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1459 it->nocache = EINA_FALSE;
1460 _mode_item_unrealize(it);
1461 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1462 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1466 _item_cache_clean(Widget_Data *wd)
1468 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1472 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1473 wd->item_cache = eina_inlist_remove(wd->item_cache,
1474 wd->item_cache->last);
1475 wd->item_cache_count--;
1476 if (itc->spacer) evas_object_del(itc->spacer);
1477 if (itc->base_view) evas_object_del(itc->base_view);
1478 if (itc->item_style) eina_stringshare_del(itc->item_style);
1484 _item_cache_zero(Widget_Data *wd)
1486 int pmax = wd->item_cache_max;
1487 wd->item_cache_max = 0;
1488 _item_cache_clean(wd);
1489 wd->item_cache_max = pmax;
1493 _item_cache_add(Elm_Genlist_Item *it)
1497 if (it->wd->item_cache_max <= 0)
1499 evas_object_del(it->base.view);
1500 it->base.view = NULL;
1501 evas_object_del(it->spacer);
1506 it->wd->item_cache_count++;
1507 itc = calloc(1, sizeof(Item_Cache));
1508 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1509 EINA_INLIST_GET(itc));
1510 itc->spacer = it->spacer;
1512 itc->base_view = it->base.view;
1513 it->base.view = NULL;
1514 evas_object_hide(itc->base_view);
1515 evas_object_move(itc->base_view, -9999, -9999);
1516 itc->item_style = eina_stringshare_add(it->itc->item_style);
1517 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1518 itc->compress = (it->wd->compress);
1519 itc->selected = it->selected;
1520 itc->disabled = it->disabled;
1521 itc->expanded = it->expanded;
1524 ecore_timer_del(it->long_timer);
1525 it->long_timer = NULL;
1527 if (it->swipe_timer)
1529 ecore_timer_del(it->swipe_timer);
1530 it->swipe_timer = NULL;
1532 // FIXME: other callbacks?
1533 edje_object_signal_callback_del_full(itc->base_view,
1534 "elm,action,expand,toggle",
1535 "elm", _signal_expand_toggle, it);
1536 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1538 _signal_expand, it);
1539 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1540 "elm", _signal_contract, it);
1541 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1543 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1545 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1547 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1549 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1551 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1553 _item_cache_clean(it->wd);
1557 _item_cache_find(Elm_Genlist_Item *it)
1562 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1563 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1565 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1567 if ((itc->tree == tree) &&
1568 (itc->compress == it->wd->compress) &&
1569 (!strcmp(it->itc->item_style, itc->item_style)))
1571 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1572 EINA_INLIST_GET(itc));
1573 it->wd->item_cache_count--;
1581 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1583 if (!it->nostacking)
1585 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1586 evas_object_lower(it->base.view);
1588 evas_object_raise(it->base.view);
1591 if (it->order_num_in & 0x1)
1592 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1594 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1598 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1602 if (it->selected != itc->selected)
1605 edje_object_signal_emit(it->base.view,
1606 "elm,state,selected", "elm");
1608 if (it->disabled != itc->disabled)
1611 edje_object_signal_emit(it->base.view,
1612 "elm,state,disabled", "elm");
1614 if (it->expanded != itc->expanded)
1617 edje_object_signal_emit(it->base.view,
1618 "elm,state,expanded", "elm");
1624 edje_object_signal_emit(it->base.view,
1625 "elm,state,selected", "elm");
1627 edje_object_signal_emit(it->base.view,
1628 "elm,state,disabled", "elm");
1630 edje_object_signal_emit(it->base.view,
1631 "elm,state,expanded", "elm");
1636 _item_cache_free(Item_Cache *itc)
1638 if (itc->spacer) evas_object_del(itc->spacer);
1639 if (itc->base_view) evas_object_del(itc->base_view);
1640 if (itc->item_style) eina_stringshare_del(itc->item_style);
1645 _item_label_realize(Elm_Genlist_Item *it,
1646 Evas_Object *target,
1649 if (it->itc->func.label_get)
1654 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1655 EINA_LIST_FOREACH(*source, l, key)
1657 char *s = it->itc->func.label_get
1658 ((void *)it->base.data, it->base.widget, key);
1662 edje_object_part_text_set(target, key, s);
1667 edje_object_part_text_set(target, key, "");
1674 _item_icon_realize(Elm_Genlist_Item *it,
1675 Evas_Object *target,
1678 Eina_List *res = NULL;
1680 if (it->itc->func.icon_get)
1685 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1686 EINA_LIST_FOREACH(*source, l, key)
1688 Evas_Object *ic = it->itc->func.icon_get
1689 ((void *)it->base.data, it->base.widget, key);
1693 res = eina_list_append(res, ic);
1694 edje_object_part_swallow(target, key, ic);
1695 evas_object_show(ic);
1696 elm_widget_sub_object_add(it->base.widget, ic);
1698 elm_widget_disabled_set(ic, EINA_TRUE);
1707 _item_state_realize(Elm_Genlist_Item *it,
1708 Evas_Object *target,
1711 if (it->itc->func.state_get)
1717 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1718 EINA_LIST_FOREACH(*source, l, key)
1720 Eina_Bool on = it->itc->func.state_get
1721 ((void *)it->base.data, it->base.widget, key);
1725 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1726 edje_object_signal_emit(target, buf, "elm");
1730 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1731 edje_object_signal_emit(target, buf, "elm");
1738 _item_realize(Elm_Genlist_Item *it,
1742 Elm_Genlist_Item *it2;
1743 const char *treesize;
1745 int depth, tsize = 20;
1746 Item_Cache *itc = NULL;
1748 if (it->delete_me) return ;
1751 if (it->order_num_in != in)
1753 it->order_num_in = in;
1754 _elm_genlist_item_odd_even_update(it);
1755 _elm_genlist_item_state_update(it, NULL);
1759 it->order_num_in = in;
1762 it->nocache = EINA_FALSE;
1764 itc = _item_cache_find(it);
1767 it->base.view = itc->base_view;
1768 itc->base_view = NULL;
1769 it->spacer = itc->spacer;
1774 const char *stacking_even;
1775 const char *stacking;
1777 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1778 edje_object_scale_set(it->base.view,
1779 elm_widget_scale_get(it->base.widget) *
1780 _elm_config->scale);
1781 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1782 elm_widget_sub_object_add(it->base.widget, it->base.view);
1784 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1785 strncpy(buf, "tree", sizeof(buf));
1786 else strncpy(buf, "item", sizeof(buf));
1787 if (it->wd->compress)
1788 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1790 strncat(buf, "/", sizeof(buf) - strlen(buf));
1791 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1793 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1794 elm_widget_style_get(it->base.widget));
1796 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1797 if (!stacking_even) stacking_even = "above";
1798 it->stacking_even = !!strcmp("above", stacking_even);
1800 stacking = edje_object_data_get(it->base.view, "stacking");
1801 if (!stacking) stacking = "yes";
1802 it->nostacking = !!strcmp("yes", stacking);
1804 edje_object_mirrored_set(it->base.view,
1805 elm_widget_mirrored_get(it->base.widget));
1807 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1808 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1809 elm_widget_sub_object_add(it->base.widget, it->spacer);
1812 _elm_genlist_item_odd_even_update(it);
1814 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1816 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1818 it->expanded_depth = depth;
1819 treesize = edje_object_data_get(it->base.view, "treesize");
1820 if (treesize) tsize = atoi(treesize);
1821 evas_object_size_hint_min_set(it->spacer,
1822 (depth * tsize) * _elm_config->scale, 1);
1823 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1826 edje_object_signal_callback_add(it->base.view,
1827 "elm,action,expand,toggle",
1828 "elm", _signal_expand_toggle, it);
1829 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1830 "elm", _signal_expand, it);
1831 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1832 "elm", _signal_contract, it);
1833 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1835 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1837 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1839 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1841 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1843 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1846 _elm_genlist_item_state_update(it, itc);
1849 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1851 /* homogenous genlist shortcut */
1854 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1856 it->w = it->minw = it->wd->group_item_width;
1857 it->h = it->minh = it->wd->group_item_height;
1861 it->w = it->minw = it->wd->item_width;
1862 it->h = it->minh = it->wd->item_height;
1864 it->mincalcd = EINA_TRUE;
1869 /* FIXME: If you see that assert, please notify us and we
1870 will clean our mess */
1871 assert(eina_list_count(it->icon_objs) == 0);
1873 _item_label_realize(it, it->base.view, &it->labels);
1874 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1875 _item_state_realize(it, it->base.view, &it->states);
1879 Evas_Coord mw = -1, mh = -1;
1881 if (it->wd->height_for_width) mw = it->wd->w;
1883 if (!it->display_only)
1884 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1885 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1886 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1888 if (!it->display_only)
1889 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1890 it->w = it->minw = mw;
1891 it->h = it->minh = mh;
1892 it->mincalcd = EINA_TRUE;
1894 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1896 it->wd->group_item_width = mw;
1897 it->wd->group_item_height = mh;
1899 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1901 it->wd->item_width = mw;
1902 it->wd->item_height = mh;
1905 if (!calc) evas_object_show(it->base.view);
1908 if (it->tooltip.content_cb)
1910 elm_widget_item_tooltip_content_cb_set(it,
1911 it->tooltip.content_cb,
1912 it->tooltip.data, NULL);
1913 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1916 if (it->mouse_cursor)
1917 elm_widget_item_cursor_set(it, it->mouse_cursor);
1919 it->realized = EINA_TRUE;
1920 it->want_unrealize = EINA_FALSE;
1922 if (itc) _item_cache_free(itc);
1923 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1927 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1931 if (!it->realized) return;
1932 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1935 ecore_timer_del(it->long_timer);
1936 it->long_timer = NULL;
1940 evas_object_del(it->base.view);
1941 it->base.view = NULL;
1942 evas_object_del(it->spacer);
1947 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1948 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
1949 _item_cache_add(it);
1951 elm_widget_stringlist_free(it->labels);
1953 elm_widget_stringlist_free(it->icons);
1955 elm_widget_stringlist_free(it->states);
1957 EINA_LIST_FREE(it->icon_objs, icon)
1958 evas_object_del(icon);
1960 _mode_item_unrealize(it);
1962 it->realized = EINA_FALSE;
1963 it->want_unrealize = EINA_FALSE;
1967 _item_block_recalc(Item_Block *itb,
1970 int norender __UNUSED__)
1973 Elm_Genlist_Item *it;
1974 Evas_Coord minw = 0, minh = 0;
1975 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1979 EINA_LIST_FOREACH(itb->items, l, it)
1981 if (it->delete_me) continue;
1982 showme |= it->showme;
1987 if (!it->mincalcd) changed = EINA_TRUE;
1990 _item_realize(it, in, EINA_TRUE);
1991 _item_unrealize(it, EINA_TRUE);
1996 _item_realize(it, in, EINA_TRUE);
1997 _item_unrealize(it, EINA_TRUE);
2001 _item_realize(it, in, EINA_FALSE);
2003 if (minw < it->minw) minw = it->minw;
2011 itb->changed = EINA_FALSE;
2012 /* force an evas norender to garbage collect deleted objects */
2013 // if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2018 _item_block_realize(Item_Block *itb,
2023 Elm_Genlist_Item *it;
2025 if (itb->realized) return;
2026 EINA_LIST_FOREACH(itb->items, l, it)
2028 if (it->delete_me) continue;
2029 if (full) _item_realize(it, in, EINA_FALSE);
2032 itb->realized = EINA_TRUE;
2033 itb->want_unrealize = EINA_FALSE;
2037 _item_block_unrealize(Item_Block *itb)
2040 Elm_Genlist_Item *it;
2041 Eina_Bool dragging = EINA_FALSE;
2043 if (!itb->realized) return;
2044 EINA_LIST_FOREACH(itb->items, l, it)
2046 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2050 dragging = EINA_TRUE;
2051 it->want_unrealize = EINA_TRUE;
2054 _item_unrealize(it, EINA_FALSE);
2059 itb->realized = EINA_FALSE;
2060 itb->want_unrealize = EINA_TRUE;
2063 itb->want_unrealize = EINA_FALSE;
2067 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2072 evas_object_resize(view, it->w, it->h);
2073 evas_object_move(view, it->scrl_x, it->scrl_y);
2074 evas_object_show(view);
2078 _item_block_position(Item_Block *itb,
2082 Elm_Genlist_Item *it;
2083 Elm_Genlist_Item *git;
2084 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2087 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2088 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2090 EINA_LIST_FOREACH(itb->items, l, it)
2092 if (it->delete_me) continue;
2096 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2097 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2099 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2100 cvx, cvy, cvw, cvh));
2101 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2103 if ((itb->realized) && (!it->realized))
2105 if (vis) _item_realize(it, in, EINA_FALSE);
2111 git = it->group_item;
2114 if (git->scrl_y < oy)
2116 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2117 git->scrl_y = (it->scrl_y + it->h) - git->h;
2118 git->want_realize = EINA_TRUE;
2121 _item_position(it, it->mode_view);
2123 _item_position(it, it->base.view);
2127 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2134 if (vis) it->want_realize = EINA_TRUE;
2141 _group_items_recalc(void *data)
2143 Widget_Data *wd = data;
2145 Elm_Genlist_Item *git;
2147 EINA_LIST_FOREACH(wd->group_items, l, git)
2149 if (git->want_realize)
2152 _item_realize(git, 0, EINA_FALSE);
2153 evas_object_resize(git->base.view, wd->minw, git->h);
2154 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2155 evas_object_show(git->base.view);
2156 evas_object_raise(git->base.view);
2158 else if (!git->want_realize && git->realized)
2161 _item_unrealize(git, EINA_FALSE);
2167 _must_recalc_idler(void *data)
2169 Widget_Data *wd = data;
2170 if (wd->calc_job) ecore_job_del(wd->calc_job);
2171 wd->calc_job = ecore_job_add(_calc_job, wd);
2172 wd->must_recalc_idler = NULL;
2173 return ECORE_CALLBACK_CANCEL;
2177 _calc_job(void *data)
2179 Widget_Data *wd = data;
2181 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2182 Item_Block *chb = NULL;
2183 int in = 0, minw_change = 0;
2184 Eina_Bool changed = EINA_FALSE;
2186 Eina_Bool did_must_recalc = EINA_FALSE;
2189 t0 = ecore_time_get();
2190 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2194 // if (wd->height_for_width) changed = EINA_TRUE;
2197 EINA_INLIST_FOREACH(wd->blocks, itb)
2199 Eina_Bool showme = EINA_FALSE;
2202 showme = itb->showme;
2203 itb->showme = EINA_FALSE;
2206 if (itb->realized) _item_block_unrealize(itb);
2208 if ((itb->changed) || (changed) ||
2209 ((itb->must_recalc) && (!did_must_recalc)))
2211 if ((changed) || (itb->must_recalc))
2214 Elm_Genlist_Item *it;
2215 EINA_LIST_FOREACH(itb->items, l, it)
2216 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2217 itb->changed = EINA_TRUE;
2218 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2219 itb->must_recalc = EINA_FALSE;
2221 if (itb->realized) _item_block_unrealize(itb);
2222 showme = _item_block_recalc(itb, in, 0, 1);
2228 if (minw == -1) minw = itb->minw;
2229 else if ((!itb->must_recalc) && (minw < itb->minw))
2238 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2240 wd->show_item->showme = EINA_FALSE;
2242 elm_smart_scroller_region_bring_in(wd->scr,
2244 wd->show_item->block->x,
2246 wd->show_item->block->y,
2247 wd->show_item->block->w,
2250 elm_smart_scroller_child_region_show(wd->scr,
2252 wd->show_item->block->x,
2254 wd->show_item->block->y,
2255 wd->show_item->block->w,
2257 wd->show_item = NULL;
2262 EINA_INLIST_FOREACH(wd->blocks, itb)
2268 if ((chb) && (EINA_INLIST_GET(chb)->next))
2270 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2272 if (itb->realized) _item_block_unrealize(itb);
2275 wd->realminw = minw;
2276 if (minw < wd->w) minw = wd->w;
2277 if ((minw != wd->minw) || (minh != wd->minh))
2281 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2282 _sizing_eval(wd->obj);
2283 if ((wd->anchor_item) && (wd->anchor_item->block))
2285 Elm_Genlist_Item *it;
2288 it = wd->anchor_item;
2289 it_y = wd->anchor_y;
2290 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2291 it->block->y + it->y + it_y);
2292 wd->anchor_item = it;
2293 wd->anchor_y = it_y;
2296 t = ecore_time_get();
2297 if (did_must_recalc)
2299 if (!wd->must_recalc_idler)
2300 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2302 wd->calc_job = NULL;
2303 evas_object_smart_changed(wd->pan_smart);
2307 _update_job(void *data)
2309 Widget_Data *wd = data;
2312 int num, num0, position = 0, recalc = 0;
2314 wd->update_job = NULL;
2316 EINA_INLIST_FOREACH(wd->blocks, itb)
2318 Evas_Coord itminw, itminh;
2319 Elm_Genlist_Item *it;
2325 _item_block_position(itb, num);
2330 EINA_LIST_FOREACH(itb->items, l2, it)
2337 it->updateme = EINA_FALSE;
2340 _item_unrealize(it, EINA_FALSE);
2341 _item_realize(it, num, EINA_FALSE);
2346 _item_realize(it, num, EINA_TRUE);
2347 _item_unrealize(it, EINA_TRUE);
2349 if ((it->minw != itminw) || (it->minh != itminh))
2354 itb->updateme = EINA_FALSE;
2358 itb->changed = EINA_TRUE;
2359 _item_block_recalc(itb, num0, 0, 1);
2360 _item_block_position(itb, num0);
2365 if (wd->calc_job) ecore_job_del(wd->calc_job);
2366 wd->calc_job = ecore_job_add(_calc_job, wd);
2371 _pan_set(Evas_Object *obj,
2375 Pan *sd = evas_object_smart_data_get(obj);
2378 // Evas_Coord ow, oh;
2379 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2380 // ow = sd->wd->minw - ow;
2381 // if (ow < 0) ow = 0;
2382 // oh = sd->wd->minh - oh;
2383 // if (oh < 0) oh = 0;
2384 // if (x < 0) x = 0;
2385 // if (y < 0) y = 0;
2386 // if (x > ow) x = ow;
2387 // if (y > oh) y = oh;
2388 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2392 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2394 if ((itb->y + itb->h) > y)
2396 Elm_Genlist_Item *it;
2399 EINA_LIST_FOREACH(itb->items, l2, it)
2401 if ((itb->y + it->y) >= y)
2403 sd->wd->anchor_item = it;
2404 sd->wd->anchor_y = -(itb->y + it->y - y);
2411 evas_object_smart_changed(obj);
2415 _pan_get(Evas_Object *obj,
2419 Pan *sd = evas_object_smart_data_get(obj);
2421 if (x) *x = sd->wd->pan_x;
2422 if (y) *y = sd->wd->pan_y;
2426 _pan_max_get(Evas_Object *obj,
2430 Pan *sd = evas_object_smart_data_get(obj);
2433 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2434 ow = sd->wd->minw - ow;
2436 oh = sd->wd->minh - oh;
2443 _pan_min_get(Evas_Object *obj __UNUSED__,
2452 _pan_child_size_get(Evas_Object *obj,
2456 Pan *sd = evas_object_smart_data_get(obj);
2458 if (w) *w = sd->wd->minw;
2459 if (h) *h = sd->wd->minh;
2463 _pan_add(Evas_Object *obj)
2466 Evas_Object_Smart_Clipped_Data *cd;
2469 cd = evas_object_smart_data_get(obj);
2472 sd->__clipped_data = *cd;
2474 evas_object_smart_data_set(obj, sd);
2478 _pan_del(Evas_Object *obj)
2480 Pan *sd = evas_object_smart_data_get(obj);
2485 ecore_job_del(sd->resize_job);
2486 sd->resize_job = NULL;
2492 _pan_resize_job(void *data)
2495 _sizing_eval(sd->wd->obj);
2496 sd->resize_job = NULL;
2500 _pan_resize(Evas_Object *obj,
2504 Pan *sd = evas_object_smart_data_get(obj);
2507 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2508 if ((ow == w) && (oh == h)) return;
2509 if ((sd->wd->height_for_width) && (ow != w))
2511 if (sd->resize_job) ecore_job_del(sd->resize_job);
2512 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2514 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2515 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2519 _pan_calculate(Evas_Object *obj)
2521 Pan *sd = evas_object_smart_data_get(obj);
2523 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2525 Elm_Genlist_Item *git;
2528 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2529 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2530 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2532 git->want_realize = EINA_FALSE;
2534 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2536 itb->w = sd->wd->minw;
2537 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2538 itb->y - sd->wd->pan_y + oy,
2540 cvx, cvy, cvw, cvh))
2542 if ((!itb->realized) || (itb->changed))
2543 _item_block_realize(itb, in, 0);
2544 _item_block_position(itb, in);
2548 if (itb->realized) _item_block_unrealize(itb);
2552 _group_items_recalc(sd->wd);
2556 _pan_move(Evas_Object *obj,
2557 Evas_Coord x __UNUSED__,
2558 Evas_Coord y __UNUSED__)
2560 Pan *sd = evas_object_smart_data_get(obj);
2562 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2563 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2567 _hold_on(void *data __UNUSED__,
2569 void *event_info __UNUSED__)
2571 Widget_Data *wd = elm_widget_data_get(obj);
2573 elm_smart_scroller_hold_set(wd->scr, 1);
2577 _hold_off(void *data __UNUSED__,
2579 void *event_info __UNUSED__)
2581 Widget_Data *wd = elm_widget_data_get(obj);
2583 elm_smart_scroller_hold_set(wd->scr, 0);
2587 _freeze_on(void *data __UNUSED__,
2589 void *event_info __UNUSED__)
2591 Widget_Data *wd = elm_widget_data_get(obj);
2593 elm_smart_scroller_freeze_set(wd->scr, 1);
2597 _freeze_off(void *data __UNUSED__,
2599 void *event_info __UNUSED__)
2601 Widget_Data *wd = elm_widget_data_get(obj);
2603 elm_smart_scroller_freeze_set(wd->scr, 0);
2607 _scroll_edge_left(void *data,
2608 Evas_Object *scr __UNUSED__,
2609 void *event_info __UNUSED__)
2611 Evas_Object *obj = data;
2612 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2616 _scroll_edge_right(void *data,
2617 Evas_Object *scr __UNUSED__,
2618 void *event_info __UNUSED__)
2620 Evas_Object *obj = data;
2621 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2625 _scroll_edge_top(void *data,
2626 Evas_Object *scr __UNUSED__,
2627 void *event_info __UNUSED__)
2629 Evas_Object *obj = data;
2630 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2634 _scroll_edge_bottom(void *data,
2635 Evas_Object *scr __UNUSED__,
2636 void *event_info __UNUSED__)
2638 Evas_Object *obj = data;
2639 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2643 _mode_item_realize(Elm_Genlist_Item *it)
2647 if ((it->mode_view) || (it->delete_me)) return;
2649 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2650 edje_object_scale_set(it->mode_view,
2651 elm_widget_scale_get(it->base.widget) *
2652 _elm_config->scale);
2653 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2654 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2656 strncpy(buf, "item", sizeof(buf));
2657 if (it->wd->compress)
2658 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2660 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2661 strncat(buf, "/", sizeof(buf) - strlen(buf));
2662 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2664 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2665 elm_widget_style_get(it->base.widget));
2666 edje_object_mirrored_set(it->mode_view,
2667 elm_widget_mirrored_get(it->base.widget));
2669 /* signal callback add */
2670 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2672 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2674 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2677 /* label_get, icon_get, state_get */
2678 /* FIXME: If you see that assert, please notify us and we
2679 will clean our mess */
2680 assert(eina_list_count(it->mode_icon_objs) == 0);
2682 _item_label_realize(it, it->mode_view, &it->mode_labels);
2683 it->mode_icon_objs = _item_icon_realize(it,
2686 _item_state_realize(it, it->mode_view, &it->mode_states);
2688 edje_object_part_swallow(it->mode_view,
2689 edje_object_data_get(it->mode_view, "mode_part"),
2692 it->want_unrealize = EINA_FALSE;
2696 _mode_item_unrealize(Elm_Genlist_Item *it)
2698 Widget_Data *wd = it->wd;
2700 if (!it->mode_view) return;
2702 elm_widget_stringlist_free(it->mode_labels);
2703 it->mode_labels = NULL;
2704 elm_widget_stringlist_free(it->mode_icons);
2705 it->mode_icons = NULL;
2706 elm_widget_stringlist_free(it->mode_states);
2708 EINA_LIST_FREE(it->mode_icon_objs, icon)
2709 evas_object_del(icon);
2711 edje_object_part_unswallow(it->mode_view, it->base.view);
2712 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2713 evas_object_del(it->mode_view);
2714 it->mode_view = NULL;
2716 if (wd->mode_item == it)
2717 wd->mode_item = NULL;
2721 _item_mode_set(Elm_Genlist_Item *it)
2724 Widget_Data *wd = it->wd;
2729 it->nocache = EINA_TRUE;
2731 if (wd->scr_hold_timer)
2733 ecore_timer_del(wd->scr_hold_timer);
2734 wd->scr_hold_timer = NULL;
2736 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2737 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2739 _mode_item_realize(it);
2740 _item_position(it, it->mode_view);
2742 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2743 edje_object_signal_emit(it->mode_view, buf, "elm");
2747 _item_mode_unset(Widget_Data *wd)
2750 if (!wd->mode_item) return;
2751 char buf[1024], buf2[1024];
2752 Elm_Genlist_Item *it;
2755 it->nocache = EINA_TRUE;
2757 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2758 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2760 edje_object_signal_emit(it->mode_view, buf, "elm");
2761 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2763 wd->mode_item = NULL;
2767 * Add a new Genlist object
2769 * @param parent The parent object
2770 * @return The new object or NULL if it cannot be created
2775 elm_genlist_add(Evas_Object *parent)
2780 Evas_Coord minw, minh;
2781 static Evas_Smart *smart = NULL;
2785 static Evas_Smart_Class sc;
2787 evas_object_smart_clipped_smart_set(&_pan_sc);
2789 sc.name = "elm_genlist_pan";
2790 sc.version = EVAS_SMART_CLASS_VERSION;
2793 sc.resize = _pan_resize;
2794 sc.move = _pan_move;
2795 sc.calculate = _pan_calculate;
2796 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2799 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2801 ELM_SET_WIDTYPE(widtype, "genlist");
2802 elm_widget_type_set(obj, "genlist");
2803 elm_widget_sub_object_add(parent, obj);
2804 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2805 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2806 elm_widget_data_set(obj, wd);
2807 elm_widget_del_hook_set(obj, _del_hook);
2808 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2809 elm_widget_theme_hook_set(obj, _theme_hook);
2810 elm_widget_can_focus_set(obj, EINA_TRUE);
2811 elm_widget_event_hook_set(obj, _event_hook);
2812 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2814 wd->scr = elm_smart_scroller_add(e);
2815 elm_smart_scroller_widget_set(wd->scr, obj);
2816 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2817 elm_widget_style_get(obj));
2818 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2819 _elm_config->thumbscroll_bounce_enable);
2820 elm_widget_resize_object_set(obj, wd->scr);
2822 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2823 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2825 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2826 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2830 wd->mode = ELM_LIST_SCROLL;
2831 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2832 wd->item_cache_max = wd->max_items_per_block * 2;
2833 wd->longpress_timeout = _elm_config->longpress_timeout;
2835 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2836 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2837 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2838 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2840 wd->pan_smart = evas_object_smart_add(e, smart);
2841 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2844 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2845 _pan_set, _pan_get, _pan_max_get,
2846 _pan_min_get, _pan_child_size_get);
2848 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2850 evas_object_size_hint_min_set(obj, minw, minh);
2852 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2857 static Elm_Genlist_Item *
2858 _item_new(Widget_Data *wd,
2859 const Elm_Genlist_Item_Class *itc,
2861 Elm_Genlist_Item *parent,
2862 Elm_Genlist_Item_Flags flags,
2864 const void *func_data)
2866 Elm_Genlist_Item *it;
2868 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2869 if (!it) return NULL;
2872 it->base.data = data;
2873 it->parent = parent;
2875 it->func.func = func;
2876 it->func.data = func_data;
2877 it->mouse_cursor = NULL;
2878 it->expanded_depth = 0;
2883 _item_block_add(Widget_Data *wd,
2884 Elm_Genlist_Item *it)
2886 Item_Block *itb = NULL;
2893 itb = calloc(1, sizeof(Item_Block));
2896 if (!it->rel->block)
2899 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2900 itb->items = eina_list_append(itb->items, it);
2906 wd->blocks = eina_inlist_prepend_relative
2907 (wd->blocks, EINA_INLIST_GET(itb),
2908 EINA_INLIST_GET(it->rel->block));
2910 eina_list_prepend_relative(itb->items, it, it->rel);
2914 wd->blocks = eina_inlist_append_relative
2915 (wd->blocks, EINA_INLIST_GET(itb),
2916 EINA_INLIST_GET(it->rel->block));
2918 eina_list_append_relative(itb->items, it, it->rel);
2928 itb = (Item_Block *)(wd->blocks);
2929 if (itb->count >= wd->max_items_per_block)
2931 itb = calloc(1, sizeof(Item_Block));
2935 eina_inlist_prepend(wd->blocks,
2936 EINA_INLIST_GET(itb));
2941 itb = calloc(1, sizeof(Item_Block));
2945 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2947 itb->items = eina_list_prepend(itb->items, it);
2953 itb = (Item_Block *)(wd->blocks->last);
2954 if (itb->count >= wd->max_items_per_block)
2956 itb = calloc(1, sizeof(Item_Block));
2960 eina_inlist_append(wd->blocks,
2961 EINA_INLIST_GET(itb));
2966 itb = calloc(1, sizeof(Item_Block));
2970 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2972 itb->items = eina_list_append(itb->items, it);
2978 itb = it->rel->block;
2979 if (!itb) goto newblock;
2981 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2983 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2986 itb->changed = EINA_TRUE;
2988 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2989 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2992 it->rel->relcount--;
2993 if ((it->rel->delete_me) && (!it->rel->relcount))
2997 if (itb->count > itb->wd->max_items_per_block)
3001 Elm_Genlist_Item *it2;
3003 newc = itb->count / 2;
3004 itb2 = calloc(1, sizeof(Item_Block));
3008 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3009 EINA_INLIST_GET(itb));
3010 itb2->changed = EINA_TRUE;
3011 while ((itb->count > newc) && (itb->items))
3015 l = eina_list_last(itb->items);
3017 itb->items = eina_list_remove_list(itb->items, l);
3020 itb2->items = eina_list_prepend(itb2->items, it2);
3028 _queue_process(Widget_Data *wd,
3032 Eina_Bool showme = EINA_FALSE;
3035 t0 = ecore_time_get();
3036 for (n = 0; (wd->queue) && (n < 128); n++)
3038 Elm_Genlist_Item *it;
3040 it = wd->queue->data;
3041 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3042 it->queued = EINA_FALSE;
3043 _item_block_add(wd, it);
3044 t = ecore_time_get();
3045 if (it->block->changed)
3047 showme = _item_block_recalc(it->block, it->block->num, 1,
3049 it->block->changed = 0;
3051 if (showme) it->block->showme = EINA_TRUE;
3052 if (eina_inlist_count(wd->blocks) > 1)
3054 if ((t - t0) > (ecore_animator_frametime_get())) break;
3061 _idle_process(void *data, Eina_Bool *wakeup)
3063 Widget_Data *wd = data;
3066 //static double q_start = 0.0;
3067 //if (q_start == 0.0) q_start = ecore_time_get();
3069 if (_queue_process(wd, 1) > 0) *wakeup = EINA_TRUE;
3073 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3075 return ECORE_CALLBACK_CANCEL;
3077 return ECORE_CALLBACK_RENEW;
3081 _item_idle_enterer(void *data)
3083 Widget_Data *wd = data;
3084 Eina_Bool wakeup = EINA_FALSE;
3085 Eina_Bool ok = _idle_process(data, &wakeup);
3090 if (wd->calc_job) ecore_job_del(wd->calc_job);
3091 wd->calc_job = ecore_job_add(_calc_job, wd);
3093 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3098 _item_queue(Widget_Data *wd,
3099 Elm_Genlist_Item *it)
3101 if (it->queued) return;
3102 it->queued = EINA_TRUE;
3103 wd->queue = eina_list_append(wd->queue, it);
3104 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3106 if (wd->queue_idle_enterer)
3108 ecore_idle_enterer_del(wd->queue_idle_enterer);
3109 wd->queue_idle_enterer = NULL;
3111 _queue_process(wd, 0);
3113 if (!wd->queue_idle_enterer)
3114 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3118 * Append item to the end of the genlist
3120 * This appends the given item to the end of the list or the end of
3121 * the children if the parent is given.
3123 * @param obj The genlist object
3124 * @param itc The item class for the item
3125 * @param data The item data
3126 * @param parent The parent item, or NULL if none
3127 * @param flags Item flags
3128 * @param func Convenience function called when item selected
3129 * @param func_data Data passed to @p func above.
3130 * @return A handle to the item added or NULL if not possible
3134 EAPI Elm_Genlist_Item *
3135 elm_genlist_item_append(Evas_Object *obj,
3136 const Elm_Genlist_Item_Class *itc,
3138 Elm_Genlist_Item *parent,
3139 Elm_Genlist_Item_Flags flags,
3141 const void *func_data)
3143 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3144 Widget_Data *wd = elm_widget_data_get(obj);
3145 if (!wd) return NULL;
3146 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3148 if (!it) return NULL;
3151 if (flags & ELM_GENLIST_ITEM_GROUP)
3152 wd->group_items = eina_list_append(wd->group_items, it);
3153 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3158 Elm_Genlist_Item *it2 = NULL;
3159 Eina_List *ll = eina_list_last(it->parent->items);
3160 if (ll) it2 = ll->data;
3161 it->parent->items = eina_list_append(it->parent->items, it);
3162 if (!it2) it2 = it->parent;
3164 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3165 EINA_INLIST_GET(it2));
3167 it->rel->relcount++;
3169 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3170 it->group_item = parent;
3171 else if (it->parent->group_item)
3172 it->group_item = it->parent->group_item;
3174 it->before = EINA_FALSE;
3175 _item_queue(wd, it);
3180 * Prepend item at start of the genlist
3182 * This adds an item to the beginning of the list or beginning of the
3183 * children of the parent if given.
3185 * @param obj The genlist object
3186 * @param itc The item class for the item
3187 * @param data The item data
3188 * @param parent The parent item, or NULL if none
3189 * @param flags Item flags
3190 * @param func Convenience function called when item selected
3191 * @param func_data Data passed to @p func above.
3192 * @return A handle to the item added or NULL if not possible
3196 EAPI Elm_Genlist_Item *
3197 elm_genlist_item_prepend(Evas_Object *obj,
3198 const Elm_Genlist_Item_Class *itc,
3200 Elm_Genlist_Item *parent,
3201 Elm_Genlist_Item_Flags flags,
3203 const void *func_data)
3205 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3206 Widget_Data *wd = elm_widget_data_get(obj);
3207 if (!wd) return NULL;
3208 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3210 if (!it) return NULL;
3213 if (flags & ELM_GENLIST_ITEM_GROUP)
3214 wd->group_items = eina_list_prepend(wd->group_items, it);
3215 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3220 Elm_Genlist_Item *it2 = NULL;
3221 Eina_List *ll = it->parent->items;
3222 if (ll) it2 = ll->data;
3223 it->parent->items = eina_list_prepend(it->parent->items, it);
3224 if (!it2) it2 = it->parent;
3226 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3227 EINA_INLIST_GET(it2));
3229 it->rel->relcount++;
3231 it->before = EINA_TRUE;
3232 _item_queue(wd, it);
3237 * Insert item before another in the genlist
3239 * This inserts an item before another in the list. It will be in the
3240 * same tree level or group as the item it is inseted before.
3242 * @param obj The genlist object
3243 * @param itc The item class for the item
3244 * @param data The item data
3245 * @param before The item to insert before
3246 * @param flags Item flags
3247 * @param func Convenience function called when item selected
3248 * @param func_data Data passed to @p func above.
3249 * @return A handle to the item added or NULL if not possible
3253 EAPI Elm_Genlist_Item *
3254 elm_genlist_item_insert_before(Evas_Object *obj,
3255 const Elm_Genlist_Item_Class *itc,
3257 Elm_Genlist_Item *parent,
3258 Elm_Genlist_Item *before,
3259 Elm_Genlist_Item_Flags flags,
3261 const void *func_data)
3263 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3264 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3265 Widget_Data *wd = elm_widget_data_get(obj);
3266 if (!wd) return NULL;
3267 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3269 if (!it) return NULL;
3272 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3275 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3276 EINA_INLIST_GET(before));
3278 it->rel->relcount++;
3279 it->before = EINA_TRUE;
3280 _item_queue(wd, it);
3285 * Insert an item after another in the genlst
3287 * This inserts an item after another in the list. It will be in the
3288 * same tree level or group as the item it is inseted after.
3290 * @param obj The genlist object
3291 * @param itc The item class for the item
3292 * @param data The item data
3293 * @param after The item to insert after
3294 * @param flags Item flags
3295 * @param func Convenience function called when item selected
3296 * @param func_data Data passed to @p func above.
3297 * @return A handle to the item added or NULL if not possible
3301 EAPI Elm_Genlist_Item *
3302 elm_genlist_item_insert_after(Evas_Object *obj,
3303 const Elm_Genlist_Item_Class *itc,
3305 Elm_Genlist_Item *parent,
3306 Elm_Genlist_Item *after,
3307 Elm_Genlist_Item_Flags flags,
3309 const void *func_data)
3311 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3312 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3313 Widget_Data *wd = elm_widget_data_get(obj);
3314 if (!wd) return NULL;
3315 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3317 if (!it) return NULL;
3318 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3319 EINA_INLIST_GET(after));
3322 it->parent->items = eina_list_append_relative(it->parent->items, it,
3326 it->rel->relcount++;
3327 it->before = EINA_FALSE;
3328 _item_queue(wd, it);
3335 * This clears all items in the list, leaving it empty.
3337 * @param obj The genlist object
3342 elm_genlist_clear(Evas_Object *obj)
3344 ELM_CHECK_WIDTYPE(obj, widtype);
3345 Widget_Data *wd = elm_widget_data_get(obj);
3347 if (wd->walking > 0)
3349 Elm_Genlist_Item *it;
3351 wd->clear_me = EINA_TRUE;
3352 EINA_INLIST_FOREACH(wd->items, it)
3354 it->delete_me = EINA_TRUE;
3360 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3362 if (wd->anchor_item == it)
3364 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3365 if (!wd->anchor_item)
3367 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3369 wd->items = eina_inlist_remove(wd->items, wd->items);
3370 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3371 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3372 elm_widget_item_pre_notify_del(it);
3373 if (it->realized) _item_unrealize(it, EINA_FALSE);
3374 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3375 it->itc->func.del((void *)it->base.data, it->base.widget);
3376 if (it->long_timer) ecore_timer_del(it->long_timer);
3377 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3378 elm_widget_item_del(it);
3380 wd->clear_me = EINA_FALSE;
3381 wd->anchor_item = NULL;
3384 Item_Block *itb = (Item_Block *)(wd->blocks);
3386 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3387 if (itb->items) eina_list_free(itb->items);
3392 ecore_job_del(wd->calc_job);
3393 wd->calc_job = NULL;
3395 if (wd->queue_idle_enterer)
3397 ecore_idle_enterer_del(wd->queue_idle_enterer);
3398 wd->queue_idle_enterer = NULL;
3400 if (wd->must_recalc_idler)
3402 ecore_idler_del(wd->must_recalc_idler);
3403 wd->must_recalc_idler = NULL;
3407 eina_list_free(wd->queue);
3412 eina_list_free(wd->selected);
3413 wd->selected = NULL;
3415 wd->show_item = NULL;
3422 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3423 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3429 * Enable or disable multi-select in the genlist
3431 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3432 * the list. This allows more than 1 item to be selected.
3434 * @param obj The genlist object
3435 * @param multi Multi-select enable/disable
3440 elm_genlist_multi_select_set(Evas_Object *obj,
3443 ELM_CHECK_WIDTYPE(obj, widtype);
3444 Widget_Data *wd = elm_widget_data_get(obj);
3450 * Gets if multi-select in genlist is enable or disable
3452 * @param obj The genlist object
3453 * @return Multi-select enable/disable
3454 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3459 elm_genlist_multi_select_get(const Evas_Object *obj)
3461 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3462 Widget_Data *wd = elm_widget_data_get(obj);
3463 if (!wd) return EINA_FALSE;
3468 * Get the selectd item in the genlist
3470 * This gets the selected item in the list (if multi-select is enabled
3471 * only the first item in the list is selected - which is not very
3472 * useful, so see elm_genlist_selected_items_get() for when
3473 * multi-select is used).
3475 * If no item is selected, NULL is returned.
3477 * @param obj The genlist object
3478 * @return The selected item, or NULL if none.
3482 EAPI Elm_Genlist_Item *
3483 elm_genlist_selected_item_get(const Evas_Object *obj)
3485 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3486 Widget_Data *wd = elm_widget_data_get(obj);
3487 if (!wd) return NULL;
3488 if (wd->selected) return wd->selected->data;
3493 * Get a list of selected items in the genlist
3495 * This returns a list of the selected items. This list pointer is
3496 * only valid so long as no items are selected or unselected (or
3497 * unselected implicitly by deletion). The list contains
3498 * Elm_Genlist_Item pointers.
3500 * @param obj The genlist object
3501 * @return The list of selected items, nor NULL if none are selected.
3505 EAPI const Eina_List *
3506 elm_genlist_selected_items_get(const Evas_Object *obj)
3508 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3509 Widget_Data *wd = elm_widget_data_get(obj);
3510 if (!wd) return NULL;
3511 return wd->selected;
3515 * Get a list of realized items in genlist
3517 * This returns a list of the realized items in the genlist. The list
3518 * contains Elm_Genlist_Item pointers. The list must be freed by the
3519 * caller when done with eina_list_free(). The item pointers in the
3520 * list are only valid so long as those items are not deleted or the
3521 * genlist is not deleted.
3523 * @param obj The genlist object
3524 * @return The list of realized items, nor NULL if none are realized.
3529 elm_genlist_realized_items_get(const Evas_Object *obj)
3531 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3532 Widget_Data *wd = elm_widget_data_get(obj);
3533 Eina_List *list = NULL;
3535 Eina_Bool done = EINA_FALSE;
3536 if (!wd) return NULL;
3537 EINA_INLIST_FOREACH(wd->blocks, itb)
3542 Elm_Genlist_Item *it;
3545 EINA_LIST_FOREACH(itb->items, l, it)
3547 if (it->realized) list = eina_list_append(list, it);
3559 * Get the item that is at the x, y canvas coords
3561 * This returns the item at the given coordinates (which are canvas
3562 * relative not object-relative). If an item is at that coordinate,
3563 * that item handle is returned, and if @p posret is not NULL, the
3564 * integer pointed to is set to a value of -1, 0 or 1, depending if
3565 * the coordinate is on the upper portion of that item (-1), on the
3566 * middle section (0) or on the lower part (1). If NULL is returned as
3567 * an item (no item found there), then posret may indicate -1 or 1
3568 * based if the coordinate is above or below all items respectively in
3571 * @param it The item
3572 * @param x The input x coordinate
3573 * @param y The input y coordinate
3574 * @param posret The position relative to the item returned here
3575 * @return The item at the coordinates or NULL if none
3579 EAPI Elm_Genlist_Item *
3580 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3585 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3586 Widget_Data *wd = elm_widget_data_get(obj);
3587 Evas_Coord ox, oy, ow, oh;
3590 if (!wd) return NULL;
3591 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3593 EINA_INLIST_FOREACH(wd->blocks, itb)
3596 Elm_Genlist_Item *it;
3598 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3599 oy + itb->y - itb->wd->pan_y,
3600 itb->w, itb->h, x, y, 1, 1))
3602 EINA_LIST_FOREACH(itb->items, l, it)
3604 Evas_Coord itx, ity;
3606 itx = ox + itb->x + it->x - itb->wd->pan_x;
3607 ity = oy + itb->y + it->y - itb->wd->pan_y;
3608 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3612 if (y <= (ity + (it->h / 4))) *posret = -1;
3613 else if (y >= (ity + it->h - (it->h / 4)))
3619 lasty = ity + it->h;
3624 if (y > lasty) *posret = 1;
3631 * Get the first item in the genlist
3633 * This returns the first item in the list.
3635 * @param obj The genlist object
3636 * @return The first item, or NULL if none
3640 EAPI Elm_Genlist_Item *
3641 elm_genlist_first_item_get(const Evas_Object *obj)
3643 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3644 Widget_Data *wd = elm_widget_data_get(obj);
3645 if (!wd) return NULL;
3646 if (!wd->items) return NULL;
3647 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3648 while ((it) && (it->delete_me))
3649 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3654 * Get the last item in the genlist
3656 * This returns the last item in the list.
3658 * @return The last item, or NULL if none
3662 EAPI Elm_Genlist_Item *
3663 elm_genlist_last_item_get(const Evas_Object *obj)
3665 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3666 Widget_Data *wd = elm_widget_data_get(obj);
3667 if (!wd) return NULL;
3668 if (!wd->items) return NULL;
3669 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3670 while ((it) && (it->delete_me))
3671 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3676 * Get the next item in the genlist
3678 * This returns the item after the item @p it.
3680 * @param it The item
3681 * @return The item after @p it, or NULL if none
3685 EAPI Elm_Genlist_Item *
3686 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3688 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3691 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3692 if ((it) && (!it->delete_me)) break;
3694 return (Elm_Genlist_Item *)it;
3698 * Get the previous item in the genlist
3700 * This returns the item before the item @p it.
3702 * @param it The item
3703 * @return The item before @p it, or NULL if none
3707 EAPI Elm_Genlist_Item *
3708 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3710 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3713 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3714 if ((it) && (!it->delete_me)) break;
3716 return (Elm_Genlist_Item *)it;
3720 * Get the genlist object from an item
3722 * This returns the genlist object itself that an item belongs to.
3724 * @param it The item
3725 * @return The genlist object
3730 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3732 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3733 return it->base.widget;
3737 * Get the parent item of the given item
3739 * This returns the parent item of the item @p it given.
3741 * @param it The item
3742 * @return The parent of the item or NULL if none
3746 EAPI Elm_Genlist_Item *
3747 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3749 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3754 * Clear all sub-items (children) of the given item
3756 * This clears all items that are children (or their descendants) of the
3759 * @param it The item
3764 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3766 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3767 Eina_List *tl = NULL, *l;
3768 Elm_Genlist_Item *it2;
3770 EINA_LIST_FOREACH(it->items, l, it2)
3771 tl = eina_list_append(tl, it2);
3772 EINA_LIST_FREE(tl, it2)
3773 elm_genlist_item_del(it2);
3777 * Set the selected state of an item
3779 * This sets the selected state (1 selected, 0 not selected) of the given
3782 * @param it The item
3783 * @param selected The selected state
3788 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3791 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3792 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3794 if ((it->delete_me) && (it->disabled)) return;
3795 selected = !!selected;
3796 if (it->selected == selected) return;
3802 while (wd->selected)
3803 _item_unselect(wd->selected->data);
3805 _item_highlight(it);
3813 * Get the selected state of an item
3815 * This gets the selected state of an item (1 selected, 0 not selected).
3817 * @param it The item
3818 * @return The selected state
3823 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3825 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3826 return it->selected;
3830 * Sets the expanded state of an item (if it's a parent)
3832 * This expands or contracts a parent item (thus showing or hiding the
3835 * @param it The item
3836 * @param expanded The expanded state (1 expanded, 0 not expanded).
3841 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3844 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3845 if (it->expanded == expanded) return;
3846 it->expanded = expanded;
3850 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3851 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3856 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3857 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3862 * Get the expanded state of an item
3864 * This gets the expanded state of an item
3866 * @param it The item
3867 * @return Thre expanded state
3872 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3874 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3875 return it->expanded;
3879 * Get the depth of expanded item
3881 * @param it The genlist item object
3882 * @return The depth of expanded item
3887 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3889 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3890 return it->expanded_depth;
3894 * Sets the disabled state of an item.
3896 * A disabled item cannot be selected or unselected. It will also
3897 * change appearance to appear disabled. This sets the disabled state
3898 * (1 disabled, 0 not disabled).
3900 * @param it The item
3901 * @param disabled The disabled state
3906 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3909 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3912 if (it->disabled == disabled) return;
3913 if (it->delete_me) return;
3914 it->disabled = !!disabled;
3916 elm_genlist_item_selected_set(it, EINA_FALSE);
3920 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3922 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3923 EINA_LIST_FOREACH(it->icon_objs, l, obj)
3924 elm_widget_disabled_set(obj, disabled);
3929 * Get the disabled state of an item
3931 * This gets the disabled state of the given item.
3933 * @param it The item
3934 * @return The disabled state
3939 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3941 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3942 if (it->delete_me) return EINA_FALSE;
3943 return it->disabled;
3947 * Sets the display only state of an item.
3949 * A display only item cannot be selected or unselected. It is for
3950 * display only and not selecting or otherwise clicking, dragging
3951 * etc. by the user, thus finger size rules will not be applied to
3954 * @param it The item
3955 * @param display_only The display only state
3960 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3961 Eina_Bool display_only)
3963 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3964 if (it->display_only == display_only) return;
3965 if (it->delete_me) return;
3966 it->display_only = display_only;
3967 it->mincalcd = EINA_FALSE;
3968 it->updateme = EINA_TRUE;
3969 if (it->block) it->block->updateme = EINA_TRUE;
3970 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3971 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3975 * Get the display only state of an item
3977 * This gets the display only state of the given item.
3979 * @param it The item
3980 * @return The display only state
3985 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3987 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3988 if (it->delete_me) return EINA_FALSE;
3989 return it->display_only;
3993 * Show the given item
3995 * This causes genlist to jump to the given item @p it and show it (by
3996 * scrolling), if it is not fully visible.
3998 * @param it The item
4003 elm_genlist_item_show(Elm_Genlist_Item *it)
4005 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4006 Evas_Coord gith = 0;
4007 if (it->delete_me) return;
4008 if ((it->queued) || (!it->mincalcd))
4010 it->wd->show_item = it;
4011 it->wd->bring_in = EINA_TRUE;
4012 it->showme = EINA_TRUE;
4015 if (it->wd->show_item)
4017 it->wd->show_item->showme = EINA_FALSE;
4018 it->wd->show_item = NULL;
4020 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4021 gith = it->group_item->h;
4022 elm_smart_scroller_child_region_show(it->wd->scr,
4023 it->x + it->block->x,
4024 it->y + it->block->y - gith,
4025 it->block->w, it->h);
4029 * Bring in the given item
4031 * This causes genlist to jump to the given item @p it and show it (by
4032 * scrolling), if it is not fully visible. This may use animation to
4033 * do so and take a period of time
4035 * @param it The item
4040 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4042 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4043 Evas_Coord gith = 0;
4044 if (it->delete_me) return;
4045 if ((it->queued) || (!it->mincalcd))
4047 it->wd->show_item = it;
4048 it->wd->bring_in = EINA_TRUE;
4049 it->showme = EINA_TRUE;
4052 if (it->wd->show_item)
4054 it->wd->show_item->showme = EINA_FALSE;
4055 it->wd->show_item = NULL;
4057 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4058 gith = it->group_item->h;
4059 elm_smart_scroller_region_bring_in(it->wd->scr,
4060 it->x + it->block->x,
4061 it->y + it->block->y - gith,
4062 it->block->w, it->h);
4066 * Show the given item at the top
4068 * This causes genlist to jump to the given item @p it and show it (by
4069 * scrolling), if it is not fully visible.
4071 * @param it The item
4076 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4078 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4080 Evas_Coord gith = 0;
4082 if (it->delete_me) return;
4083 if ((it->queued) || (!it->mincalcd))
4085 it->wd->show_item = it;
4086 it->wd->bring_in = EINA_TRUE;
4087 it->showme = EINA_TRUE;
4090 if (it->wd->show_item)
4092 it->wd->show_item->showme = EINA_FALSE;
4093 it->wd->show_item = NULL;
4095 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4096 if (it->group_item) gith = it->group_item->h;
4097 elm_smart_scroller_child_region_show(it->wd->scr,
4098 it->x + it->block->x,
4099 it->y + it->block->y - gith,
4104 * Bring in the given item at the top
4106 * This causes genlist to jump to the given item @p it and show it (by
4107 * scrolling), if it is not fully visible. This may use animation to
4108 * do so and take a period of time
4110 * @param it The item
4115 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4117 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4119 Evas_Coord gith = 0;
4121 if (it->delete_me) return;
4122 if ((it->queued) || (!it->mincalcd))
4124 it->wd->show_item = it;
4125 it->wd->bring_in = EINA_TRUE;
4126 it->showme = EINA_TRUE;
4129 if (it->wd->show_item)
4131 it->wd->show_item->showme = EINA_FALSE;
4132 it->wd->show_item = NULL;
4134 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4135 if (it->group_item) gith = it->group_item->h;
4136 elm_smart_scroller_region_bring_in(it->wd->scr,
4137 it->x + it->block->x,
4138 it->y + it->block->y - gith,
4143 * Show the given item at the middle
4145 * This causes genlist to jump to the given item @p it and show it (by
4146 * scrolling), if it is not fully visible.
4148 * @param it The item
4153 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4155 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4158 if (it->delete_me) return;
4159 if ((it->queued) || (!it->mincalcd))
4161 it->wd->show_item = it;
4162 it->wd->bring_in = EINA_TRUE;
4163 it->showme = EINA_TRUE;
4166 if (it->wd->show_item)
4168 it->wd->show_item->showme = EINA_FALSE;
4169 it->wd->show_item = NULL;
4171 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4172 elm_smart_scroller_child_region_show(it->wd->scr,
4173 it->x + it->block->x,
4174 it->y + it->block->y - oh / 2 +
4175 it->h / 2, it->block->w, oh);
4179 * Bring in the given item at the middle
4181 * This causes genlist to jump to the given item @p it and show it (by
4182 * scrolling), if it is not fully visible. This may use animation to
4183 * do so and take a period of time
4185 * @param it The item
4190 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4192 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4195 if (it->delete_me) return;
4196 if ((it->queued) || (!it->mincalcd))
4198 it->wd->show_item = it;
4199 it->wd->bring_in = EINA_TRUE;
4200 it->showme = EINA_TRUE;
4203 if (it->wd->show_item)
4205 it->wd->show_item->showme = EINA_FALSE;
4206 it->wd->show_item = NULL;
4208 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4209 elm_smart_scroller_region_bring_in(it->wd->scr,
4210 it->x + it->block->x,
4211 it->y + it->block->y - oh / 2 + it->h / 2,
4216 * Delete a given item
4218 * This deletes the item from genlist and calls the genlist item del
4219 * class callback defined in the item class, if it is set. This clears all
4220 * subitems if it is a tree.
4222 * @param it The item
4227 elm_genlist_item_del(Elm_Genlist_Item *it)
4229 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4230 if ((it->relcount > 0) || (it->walking > 0))
4232 elm_widget_item_pre_notify_del(it);
4233 elm_genlist_item_subitems_clear(it);
4234 it->delete_me = EINA_TRUE;
4235 if (it->wd->show_item == it) it->wd->show_item = NULL;
4237 it->wd->selected = eina_list_remove(it->wd->selected,
4241 if (it->realized) _item_unrealize(it, EINA_FALSE);
4242 it->block->changed = EINA_TRUE;
4243 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4244 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4246 if (it->itc->func.del)
4247 it->itc->func.del((void *)it->base.data, it->base.widget);
4254 * Set the data item from the genlist item
4256 * This set the data value passed on the elm_genlist_item_append() and
4257 * related item addition calls. This function will also call
4258 * elm_genlist_item_update() so the item will be updated to reflect the
4261 * @param it The item
4262 * @param data The new data pointer to set
4267 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4271 elm_widget_item_data_set(it, data);
4272 elm_genlist_item_update(it);
4276 * Get the data item from the genlist item
4278 * This returns the data value passed on the elm_genlist_item_append()
4279 * and related item addition calls and elm_genlist_item_data_set().
4281 * @param it The item
4282 * @return The data pointer provided when created
4287 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4289 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4290 return elm_widget_item_data_get(it);
4294 * Tells genlist to "orphan" icons fetchs by the item class
4296 * This instructs genlist to release references to icons in the item,
4297 * meaning that they will no longer be managed by genlist and are
4298 * floating "orphans" that can be re-used elsewhere if the user wants
4301 * @param it The item
4306 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4310 EINA_LIST_FREE(it->icon_objs, icon)
4312 elm_widget_sub_object_del(it->base.widget, icon);
4313 evas_object_smart_member_del(icon);
4314 evas_object_hide(icon);
4319 * Get the real evas object of the genlist item
4321 * This returns the actual evas object used for the specified genlist
4322 * item. This may be NULL as it may not be created, and may be deleted
4323 * at any time by genlist. Do not modify this object (move, resize,
4324 * show, hide etc.) as genlist is controlling it. This function is for
4325 * querying, emitting custom signals or hooking lower level callbacks
4326 * for events. Do not delete this object under any circumstances.
4328 * @param it The item
4329 * @return The object pointer
4333 EAPI const Evas_Object *
4334 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4337 return it->base.view;
4341 * Update the contents of an item
4343 * This updates an item by calling all the item class functions again
4344 * to get the icons, labels and states. Use this when the original
4345 * item data has changed and the changes are desired to be reflected.
4347 * @param it The item
4352 elm_genlist_item_update(Elm_Genlist_Item *it)
4354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4355 if (!it->block) return;
4356 if (it->delete_me) return;
4357 it->mincalcd = EINA_FALSE;
4358 it->updateme = EINA_TRUE;
4359 it->block->updateme = EINA_TRUE;
4360 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4361 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4365 * Update the item class of an item
4367 * @param it The item
4368 * @parem itc The item class for the item
4373 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4374 const Elm_Genlist_Item_Class *itc)
4376 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4377 if (!it->block) return;
4378 EINA_SAFETY_ON_NULL_RETURN(itc);
4379 if (it->delete_me) return;
4381 it->nocache = EINA_TRUE;
4382 elm_genlist_item_update(it);
4385 static Evas_Object *
4386 _elm_genlist_item_label_create(void *data,
4388 void *item __UNUSED__)
4390 Evas_Object *label = elm_label_add(obj);
4393 elm_object_style_set(label, "tooltip");
4394 elm_label_label_set(label, data);
4399 _elm_genlist_item_label_del_cb(void *data,
4400 Evas_Object *obj __UNUSED__,
4401 void *event_info __UNUSED__)
4403 eina_stringshare_del(data);
4407 * Set the text to be shown in the genlist item.
4409 * @param item Target item
4410 * @param text The text to set in the content
4412 * Setup the text as tooltip to object. The item can have only one
4413 * tooltip, so any previous tooltip data is removed.
4418 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4421 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4422 text = eina_stringshare_add(text);
4423 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4425 _elm_genlist_item_label_del_cb);
4429 * Set the content to be shown in the tooltip item
4431 * Setup the tooltip to item. The item can have only one tooltip, so
4432 * any previous tooltip data is removed. @p func(with @p data) will be
4433 * called every time that need to show the tooltip and it should return a
4434 * valid Evas_Object. This object is then managed fully by tooltip
4435 * system and is deleted when the tooltip is gone.
4437 * @param item the genlist item being attached by a tooltip.
4438 * @param func the function used to create the tooltip contents.
4439 * @param data what to provide to @a func as callback data/context.
4440 * @param del_cb called when data is not needed anymore, either when
4441 * another callback replaces @func, the tooltip is unset with
4442 * elm_genlist_item_tooltip_unset() or the owner @a item
4443 * dies. This callback receives as the first parameter the
4444 * given @a data, and @c event_info is the item.
4449 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4450 Elm_Tooltip_Item_Content_Cb func,
4452 Evas_Smart_Cb del_cb)
4454 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4456 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4459 if (item->tooltip.del_cb)
4460 item->tooltip.del_cb((void *)item->tooltip.data,
4461 item->base.widget, item);
4463 item->tooltip.content_cb = func;
4464 item->tooltip.data = data;
4465 item->tooltip.del_cb = del_cb;
4467 if (item->base.view)
4469 elm_widget_item_tooltip_content_cb_set(item,
4470 item->tooltip.content_cb,
4471 item->tooltip.data, NULL);
4472 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4478 if (del_cb) del_cb((void *)data, NULL, NULL);
4482 * Unset tooltip from item
4484 * @param item genlist item to remove previously set tooltip.
4486 * Remove tooltip from item. The callback provided as del_cb to
4487 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4488 * it is not used anymore.
4490 * @see elm_genlist_item_tooltip_content_cb_set()
4495 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4497 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4498 if ((item->base.view) && (item->tooltip.content_cb))
4499 elm_widget_item_tooltip_unset(item);
4501 if (item->tooltip.del_cb)
4502 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4503 item->tooltip.del_cb = NULL;
4504 item->tooltip.content_cb = NULL;
4505 item->tooltip.data = NULL;
4506 if (item->tooltip.style)
4507 elm_genlist_item_tooltip_style_set(item, NULL);
4511 * Sets a different style for this item tooltip.
4513 * @note before you set a style you should define a tooltip with
4514 * elm_genlist_item_tooltip_content_cb_set() or
4515 * elm_genlist_item_tooltip_text_set()
4517 * @param item genlist item with tooltip already set.
4518 * @param style the theme style to use (default, transparent, ...)
4523 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4526 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4527 eina_stringshare_replace(&item->tooltip.style, style);
4528 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4532 * Get the style for this item tooltip.
4534 * @param item genlist item with tooltip already set.
4535 * @return style the theme style in use, defaults to "default". If the
4536 * object does not have a tooltip set, then NULL is returned.
4541 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4543 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4544 return item->tooltip.style;
4548 * Set the cursor to be shown when mouse is over the genlist item
4550 * @param item Target item
4551 * @param cursor the cursor name to be used.
4553 * @see elm_object_cursor_set()
4557 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4560 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4561 eina_stringshare_replace(&item->mouse_cursor, cursor);
4562 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4566 * Get the cursor to be shown when mouse is over the genlist item
4568 * @param item genlist item with cursor already set.
4569 * @return the cursor name.
4574 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4576 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4577 return elm_widget_item_cursor_get(item);
4581 * Unset the cursor to be shown when mouse is over the genlist item
4583 * @param item Target item
4585 * @see elm_object_cursor_unset()
4589 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4591 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4592 if (!item->mouse_cursor)
4595 if (item->base.view)
4596 elm_widget_item_cursor_unset(item);
4598 eina_stringshare_del(item->mouse_cursor);
4599 item->mouse_cursor = NULL;
4603 * Sets a different style for this item cursor.
4605 * @note before you set a style you should define a cursor with
4606 * elm_genlist_item_cursor_set()
4608 * @param item genlist item with cursor already set.
4609 * @param style the theme style to use (default, transparent, ...)
4614 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4617 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4618 elm_widget_item_cursor_style_set(item, style);
4622 * Get the style for this item cursor.
4624 * @param item genlist item with cursor already set.
4625 * @return style the theme style in use, defaults to "default". If the
4626 * object does not have a cursor set, then NULL is returned.
4631 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4633 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4634 return elm_widget_item_cursor_style_get(item);
4638 * Set if the cursor set should be searched on the theme or should use
4639 * the provided by the engine, only.
4641 * @note before you set if should look on theme you should define a
4642 * cursor with elm_object_cursor_set(). By default it will only look
4643 * for cursors provided by the engine.
4645 * @param item widget item with cursor already set.
4646 * @param engine_only boolean to define it cursors should be looked
4647 * only between the provided by the engine or searched on widget's
4653 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4654 Eina_Bool engine_only)
4656 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4657 elm_widget_item_cursor_engine_only_set(item, engine_only);
4661 * Get the cursor engine only usage for this item cursor.
4663 * @param item widget item with cursor already set.
4664 * @return engine_only boolean to define it cursors should be looked
4665 * only between the provided by the engine or searched on widget's
4666 * theme as well. If the object does not have a cursor set, then
4667 * EINA_FALSE is returned.
4672 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4674 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4675 return elm_widget_item_cursor_engine_only_get(item);
4679 * This sets the horizontal stretching mode
4681 * This sets the mode used for sizing items horizontally. Valid modes
4682 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4683 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4684 * the scroller will scroll horizontally. Otherwise items are expanded
4685 * to fill the width of the viewport of the scroller. If it is
4686 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4687 * limited to that size.
4689 * @param obj The genlist object
4690 * @param mode The mode to use
4695 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4698 ELM_CHECK_WIDTYPE(obj, widtype);
4699 Widget_Data *wd = elm_widget_data_get(obj);
4701 if (wd->mode == mode) return;
4707 * Gets the horizontal stretching mode
4709 * @param obj The genlist object
4710 * @return The mode to use
4711 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4716 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4718 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4719 Widget_Data *wd = elm_widget_data_get(obj);
4720 if (!wd) return ELM_LIST_LAST;
4725 * Set the always select mode.
4727 * Items will only call their selection func and callback when first
4728 * becoming selected. Any further clicks will do nothing, unless you
4729 * enable always select with elm_genlist_always_select_mode_set().
4730 * This means even if selected, every click will make the selected
4731 * callbacks be called.
4733 * @param obj The genlist object
4734 * @param always_select The always select mode
4735 * (EINA_TRUE = on, EINA_FALSE = off)
4740 elm_genlist_always_select_mode_set(Evas_Object *obj,
4741 Eina_Bool always_select)
4743 ELM_CHECK_WIDTYPE(obj, widtype);
4744 Widget_Data *wd = elm_widget_data_get(obj);
4746 wd->always_select = always_select;
4750 * Get the always select mode.
4752 * @param obj The genlist object
4753 * @return The always select mode
4754 * (EINA_TRUE = on, EINA_FALSE = off)
4759 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4761 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4762 Widget_Data *wd = elm_widget_data_get(obj);
4763 if (!wd) return EINA_FALSE;
4764 return wd->always_select;
4768 * Set no select mode
4770 * This will turn off the ability to select items entirely and they
4771 * will neither appear selected nor call selected callback functions.
4773 * @param obj The genlist object
4774 * @param no_select The no select mode
4775 * (EINA_TRUE = on, EINA_FALSE = off)
4780 elm_genlist_no_select_mode_set(Evas_Object *obj,
4781 Eina_Bool no_select)
4783 ELM_CHECK_WIDTYPE(obj, widtype);
4784 Widget_Data *wd = elm_widget_data_get(obj);
4786 wd->no_select = no_select;
4790 * Gets no select mode
4792 * @param obj The genlist object
4793 * @return The no select mode
4794 * (EINA_TRUE = on, EINA_FALSE = off)
4799 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4801 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4802 Widget_Data *wd = elm_widget_data_get(obj);
4803 if (!wd) return EINA_FALSE;
4804 return wd->no_select;
4810 * This will enable the compress mode where items are "compressed"
4811 * horizontally to fit the genlist scrollable viewport width. This is
4812 * special for genlist. Do not rely on
4813 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4814 * work as genlist needs to handle it specially.
4816 * @param obj The genlist object
4817 * @param compress The compress mode
4818 * (EINA_TRUE = on, EINA_FALSE = off)
4823 elm_genlist_compress_mode_set(Evas_Object *obj,
4826 ELM_CHECK_WIDTYPE(obj, widtype);
4827 Widget_Data *wd = elm_widget_data_get(obj);
4829 wd->compress = compress;
4833 * Get the compress mode
4835 * @param obj The genlist object
4836 * @return The compress mode
4837 * (EINA_TRUE = on, EINA_FALSE = off)
4842 elm_genlist_compress_mode_get(const Evas_Object *obj)
4844 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4845 Widget_Data *wd = elm_widget_data_get(obj);
4846 if (!wd) return EINA_FALSE;
4847 return wd->compress;
4851 * Set height-for-width mode
4853 * With height-for-width mode the item width will be fixed (restricted
4854 * to a minimum of) to the list width when calculating its size in
4855 * order to allow the height to be calculated based on it. This allows,
4856 * for instance, text block to wrap lines if the Edje part is
4857 * configured with "text.min: 0 1".
4859 * @note This mode will make list resize slower as it will have to
4860 * recalculate every item height again whenever the list width
4863 * @note When height-for-width mode is enabled, it also enables
4864 * compress mode (see elm_genlist_compress_mode_set()) and
4865 * disables homogeneous (see elm_genlist_homogeneous_set()).
4867 * @param obj The genlist object
4868 * @param setting The height-for-width mode (EINA_TRUE = on,
4874 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4875 Eina_Bool height_for_width)
4877 ELM_CHECK_WIDTYPE(obj, widtype);
4878 Widget_Data *wd = elm_widget_data_get(obj);
4880 wd->height_for_width = !!height_for_width;
4881 if (wd->height_for_width)
4883 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4884 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4889 * Get the height-for-width mode
4891 * @param obj The genlist object
4892 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4898 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4900 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4901 Widget_Data *wd = elm_widget_data_get(obj);
4902 if (!wd) return EINA_FALSE;
4903 return wd->height_for_width;
4909 * This will enable or disable the scroller bounce mode for the
4910 * genlist. See elm_scroller_bounce_set() for details
4912 * @param obj The genlist object
4913 * @param h_bounce Allow bounce horizontally
4914 * @param v_bounce Allow bounce vertically
4919 elm_genlist_bounce_set(Evas_Object *obj,
4923 ELM_CHECK_WIDTYPE(obj, widtype);
4924 Widget_Data *wd = elm_widget_data_get(obj);
4926 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4930 * Get the bounce mode
4932 * @param obj The genlist object
4933 * @param h_bounce Allow bounce horizontally
4934 * @param v_bounce Allow bounce vertically
4939 elm_genlist_bounce_get(const Evas_Object *obj,
4940 Eina_Bool *h_bounce,
4941 Eina_Bool *v_bounce)
4943 ELM_CHECK_WIDTYPE(obj, widtype);
4944 Widget_Data *wd = elm_widget_data_get(obj);
4946 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4950 * Set homogenous mode
4952 * This will enable the homogeneous mode where items are of the same
4953 * height and width so that genlist may do the lazy-loading at its
4954 * maximum. This implies 'compressed' mode.
4956 * @param obj The genlist object
4957 * @param homogeneous Assume the items within the genlist are of the
4958 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4963 elm_genlist_homogeneous_set(Evas_Object *obj,
4964 Eina_Bool homogeneous)
4966 ELM_CHECK_WIDTYPE(obj, widtype);
4967 Widget_Data *wd = elm_widget_data_get(obj);
4969 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4970 wd->homogeneous = homogeneous;
4974 * Get the homogenous mode
4976 * @param obj The genlist object
4977 * @return Assume the items within the genlist are of the same height
4978 * and width (EINA_TRUE = on, EINA_FALSE = off)
4983 elm_genlist_homogeneous_get(const Evas_Object *obj)
4985 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4986 Widget_Data *wd = elm_widget_data_get(obj);
4987 if (!wd) return EINA_FALSE;
4988 return wd->homogeneous;
4992 * Set the maximum number of items within an item block
4994 * This will configure the block count to tune to the target with
4995 * particular performance matrix.
4997 * @param obj The genlist object
4998 * @param n Maximum number of items within an item block
5003 elm_genlist_block_count_set(Evas_Object *obj,
5006 ELM_CHECK_WIDTYPE(obj, widtype);
5007 Widget_Data *wd = elm_widget_data_get(obj);
5009 wd->max_items_per_block = n;
5010 wd->item_cache_max = wd->max_items_per_block * 2;
5011 _item_cache_clean(wd);
5015 * Get the maximum number of items within an item block
5017 * @param obj The genlist object
5018 * @return Maximum number of items within an item block
5023 elm_genlist_block_count_get(const Evas_Object *obj)
5025 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5026 Widget_Data *wd = elm_widget_data_get(obj);
5028 return wd->max_items_per_block;
5032 * Set the timeout in seconds for the longpress event
5034 * @param obj The genlist object
5035 * @param timeout timeout in seconds
5040 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5043 ELM_CHECK_WIDTYPE(obj, widtype);
5044 Widget_Data *wd = elm_widget_data_get(obj);
5046 wd->longpress_timeout = timeout;
5050 * Get the timeout in seconds for the longpress event
5052 * @param obj The genlist object
5053 * @return timeout in seconds
5058 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5060 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5061 Widget_Data *wd = elm_widget_data_get(obj);
5063 return wd->longpress_timeout;
5067 * Set the scrollbar policy
5069 * This sets the scrollbar visibility policy for the given genlist
5070 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5071 * made visible if it is needed, and otherwise kept hidden.
5072 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5073 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5074 * respectively for the horizontal and vertical scrollbars.
5076 * @param obj The genlist object
5077 * @param policy_h Horizontal scrollbar policy
5078 * @param policy_v Vertical scrollbar policy
5083 elm_genlist_scroller_policy_set(Evas_Object *obj,
5084 Elm_Scroller_Policy policy_h,
5085 Elm_Scroller_Policy policy_v)
5087 ELM_CHECK_WIDTYPE(obj, widtype);
5088 Widget_Data *wd = elm_widget_data_get(obj);
5090 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5091 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5094 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5098 * Get the scrollbar policy
5100 * @param obj The genlist object
5101 * @param policy_h Horizontal scrollbar policy
5102 * @param policy_v Vertical scrollbar policy
5107 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5108 Elm_Scroller_Policy *policy_h,
5109 Elm_Scroller_Policy *policy_v)
5111 ELM_CHECK_WIDTYPE(obj, widtype);
5112 Widget_Data *wd = elm_widget_data_get(obj);
5113 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5114 if ((!wd) || (!wd->scr)) return;
5115 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5116 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5117 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5121 * Update the contents of all realized items
5123 * This updates all realized items by calling all the item class functions again
5124 * to get the icons, labels and states. Use this when the original
5125 * item data has changed and the changes are desired to be reflected.
5127 * @param it The item
5132 elm_genlist_realized_items_update(Evas_Object *obj)
5134 ELM_CHECK_WIDTYPE(obj, widtype);
5136 Eina_List *list, *l;
5137 Elm_Genlist_Item *it;
5139 list = elm_genlist_realized_items_get(obj);
5140 EINA_LIST_FOREACH(list, l, it)
5141 elm_genlist_item_update(it);
5145 * Set genlist item mode
5147 * @param item The genlist item
5148 * @param mode Mode name
5149 * @param mode_set Boolean to define set or unset mode.
5154 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5155 const char *mode_type,
5158 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5159 Widget_Data *wd = it->wd;
5161 Elm_Genlist_Item *it2;
5164 if (!mode_type) return;
5166 if ((wd->mode_item == it) &&
5167 (!strcmp(mode_type, wd->mode_type)) &&
5170 if (!it->itc->mode_item_style) return;
5174 EINA_LIST_FOREACH(wd->selected, l, it2)
5176 elm_genlist_item_selected_set(it2, EINA_FALSE);
5180 it2 = elm_genlist_selected_item_get(wd->obj);
5181 if ((it2) && (it2->realized))
5182 elm_genlist_item_selected_set(it2, EINA_FALSE);
5185 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5187 ((it == wd->mode_item) && (!mode_set)))
5188 _item_mode_unset(wd);
5190 eina_stringshare_replace(&wd->mode_type, mode_type);
5191 if (mode_set) _item_mode_set(it);
5195 * Get active genlist mode type
5197 * @param obj The genlist object
5202 elm_genlist_mode_get(const Evas_Object *obj)
5204 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5205 Widget_Data *wd = elm_widget_data_get(obj);
5206 if (!wd) return NULL;
5207 return wd->mode_type;
5211 * Get active genlist mode item
5213 * @param obj The genlist object
5217 EAPI const Elm_Genlist_Item *
5218 elm_genlist_mode_item_get(const Evas_Object *obj)
5220 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5221 Widget_Data *wd = elm_widget_data_get(obj);
5222 if (!wd) return NULL;
5223 return wd->mode_item;