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);
1705 _item_state_realize(Elm_Genlist_Item *it,
1706 Evas_Object *target,
1709 if (it->itc->func.state_get)
1715 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1716 EINA_LIST_FOREACH(*source, l, key)
1718 Eina_Bool on = it->itc->func.state_get
1719 ((void *)it->base.data, it->base.widget, key);
1723 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1724 edje_object_signal_emit(target, buf, "elm");
1728 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1729 edje_object_signal_emit(target, buf, "elm");
1736 _item_realize(Elm_Genlist_Item *it,
1740 Elm_Genlist_Item *it2;
1741 const char *treesize;
1743 int depth, tsize = 20;
1744 Item_Cache *itc = NULL;
1746 if (it->delete_me) return ;
1749 if (it->order_num_in != in)
1751 it->order_num_in = in;
1752 _elm_genlist_item_odd_even_update(it);
1753 _elm_genlist_item_state_update(it, NULL);
1757 it->order_num_in = in;
1760 it->nocache = EINA_FALSE;
1762 itc = _item_cache_find(it);
1765 it->base.view = itc->base_view;
1766 itc->base_view = NULL;
1767 it->spacer = itc->spacer;
1772 const char *stacking_even;
1773 const char *stacking;
1775 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1776 edje_object_scale_set(it->base.view,
1777 elm_widget_scale_get(it->base.widget) *
1778 _elm_config->scale);
1779 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1780 elm_widget_sub_object_add(it->base.widget, it->base.view);
1782 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1783 strncpy(buf, "tree", sizeof(buf));
1784 else strncpy(buf, "item", sizeof(buf));
1785 if (it->wd->compress)
1786 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1788 strncat(buf, "/", sizeof(buf) - strlen(buf));
1789 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1791 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1792 elm_widget_style_get(it->base.widget));
1794 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1795 if (!stacking_even) stacking_even = "above";
1796 it->stacking_even = !!strcmp("above", stacking_even);
1798 stacking = edje_object_data_get(it->base.view, "stacking");
1799 if (!stacking) stacking = "yes";
1800 it->nostacking = !!strcmp("yes", stacking);
1802 edje_object_mirrored_set(it->base.view,
1803 elm_widget_mirrored_get(it->base.widget));
1805 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1806 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1807 elm_widget_sub_object_add(it->base.widget, it->spacer);
1810 _elm_genlist_item_odd_even_update(it);
1812 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1814 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1816 it->expanded_depth = depth;
1817 treesize = edje_object_data_get(it->base.view, "treesize");
1818 if (treesize) tsize = atoi(treesize);
1819 evas_object_size_hint_min_set(it->spacer,
1820 (depth * tsize) * _elm_config->scale, 1);
1821 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1824 edje_object_signal_callback_add(it->base.view,
1825 "elm,action,expand,toggle",
1826 "elm", _signal_expand_toggle, it);
1827 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1828 "elm", _signal_expand, it);
1829 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1830 "elm", _signal_contract, it);
1831 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1833 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1835 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1837 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1839 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1841 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1844 _elm_genlist_item_state_update(it, itc);
1847 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1849 /* homogenous genlist shortcut */
1852 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1854 it->w = it->minw = it->wd->group_item_width;
1855 it->h = it->minh = it->wd->group_item_height;
1859 it->w = it->minw = it->wd->item_width;
1860 it->h = it->minh = it->wd->item_height;
1862 it->mincalcd = EINA_TRUE;
1867 /* FIXME: If you see that assert, please notify us and we
1868 will clean our mess */
1869 assert(eina_list_count(it->icon_objs) == 0);
1871 _item_label_realize(it, it->base.view, &it->labels);
1872 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1873 _item_state_realize(it, it->base.view, &it->states);
1877 Evas_Coord mw = -1, mh = -1;
1879 if (it->wd->height_for_width) mw = it->wd->w;
1881 if (!it->display_only)
1882 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1883 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1884 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1886 if (!it->display_only)
1887 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1888 it->w = it->minw = mw;
1889 it->h = it->minh = mh;
1890 it->mincalcd = EINA_TRUE;
1892 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1894 it->wd->group_item_width = mw;
1895 it->wd->group_item_height = mh;
1897 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1899 it->wd->item_width = mw;
1900 it->wd->item_height = mh;
1903 if (!calc) evas_object_show(it->base.view);
1906 if (it->tooltip.content_cb)
1908 elm_widget_item_tooltip_content_cb_set(it,
1909 it->tooltip.content_cb,
1910 it->tooltip.data, NULL);
1911 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1914 if (it->mouse_cursor)
1915 elm_widget_item_cursor_set(it, it->mouse_cursor);
1917 it->realized = EINA_TRUE;
1918 it->want_unrealize = EINA_FALSE;
1920 if (itc) _item_cache_free(itc);
1921 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1925 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1929 if (!it->realized) return;
1930 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1933 ecore_timer_del(it->long_timer);
1934 it->long_timer = NULL;
1938 evas_object_del(it->base.view);
1939 it->base.view = NULL;
1940 evas_object_del(it->spacer);
1945 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1946 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
1947 _item_cache_add(it);
1949 elm_widget_stringlist_free(it->labels);
1951 elm_widget_stringlist_free(it->icons);
1953 elm_widget_stringlist_free(it->states);
1955 EINA_LIST_FREE(it->icon_objs, icon)
1956 evas_object_del(icon);
1958 _mode_item_unrealize(it);
1960 it->realized = EINA_FALSE;
1961 it->want_unrealize = EINA_FALSE;
1965 _item_block_recalc(Item_Block *itb,
1971 Elm_Genlist_Item *it;
1972 Evas_Coord minw = 0, minh = 0;
1973 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1977 EINA_LIST_FOREACH(itb->items, l, it)
1979 if (it->delete_me) continue;
1980 showme |= it->showme;
1985 if (!it->mincalcd) changed = EINA_TRUE;
1988 _item_realize(it, in, EINA_TRUE);
1989 _item_unrealize(it, EINA_TRUE);
1994 _item_realize(it, in, EINA_TRUE);
1995 _item_unrealize(it, EINA_TRUE);
1999 _item_realize(it, in, EINA_FALSE);
2001 if (minw < it->minw) minw = it->minw;
2009 itb->changed = EINA_FALSE;
2010 /* force an evas norender to garbage collect deleted objects */
2011 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2016 _item_block_realize(Item_Block *itb,
2021 Elm_Genlist_Item *it;
2023 if (itb->realized) return;
2024 EINA_LIST_FOREACH(itb->items, l, it)
2026 if (it->delete_me) continue;
2027 if (full) _item_realize(it, in, EINA_FALSE);
2030 itb->realized = EINA_TRUE;
2031 itb->want_unrealize = EINA_FALSE;
2035 _item_block_unrealize(Item_Block *itb)
2038 Elm_Genlist_Item *it;
2039 Eina_Bool dragging = EINA_FALSE;
2041 if (!itb->realized) return;
2042 EINA_LIST_FOREACH(itb->items, l, it)
2044 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2048 dragging = EINA_TRUE;
2049 it->want_unrealize = EINA_TRUE;
2052 _item_unrealize(it, EINA_FALSE);
2057 itb->realized = EINA_FALSE;
2058 itb->want_unrealize = EINA_TRUE;
2061 itb->want_unrealize = EINA_FALSE;
2065 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2070 evas_object_resize(view, it->w, it->h);
2071 evas_object_move(view, it->scrl_x, it->scrl_y);
2072 evas_object_show(view);
2076 _item_block_position(Item_Block *itb,
2080 Elm_Genlist_Item *it;
2081 Elm_Genlist_Item *git;
2082 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2085 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2086 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2088 EINA_LIST_FOREACH(itb->items, l, it)
2090 if (it->delete_me) continue;
2094 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2095 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2097 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2098 cvx, cvy, cvw, cvh));
2099 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2101 if ((itb->realized) && (!it->realized))
2103 if (vis) _item_realize(it, in, EINA_FALSE);
2109 git = it->group_item;
2112 if (git->scrl_y < oy)
2114 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2115 git->scrl_y = (it->scrl_y + it->h) - git->h;
2116 git->want_realize = EINA_TRUE;
2119 _item_position(it, it->mode_view);
2121 _item_position(it, it->base.view);
2125 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2132 if (vis) it->want_realize = EINA_TRUE;
2139 _group_items_recalc(void *data)
2141 Widget_Data *wd = data;
2143 Elm_Genlist_Item *git;
2145 EINA_LIST_FOREACH(wd->group_items, l, git)
2147 if (git->want_realize)
2150 _item_realize(git, 0, EINA_FALSE);
2151 evas_object_resize(git->base.view, wd->minw, git->h);
2152 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2153 evas_object_show(git->base.view);
2154 evas_object_raise(git->base.view);
2156 else if (!git->want_realize && git->realized)
2159 _item_unrealize(git, EINA_FALSE);
2165 _must_recalc_idler(void *data)
2167 Widget_Data *wd = data;
2168 if (wd->calc_job) ecore_job_del(wd->calc_job);
2169 wd->calc_job = ecore_job_add(_calc_job, wd);
2170 wd->must_recalc_idler = NULL;
2171 return ECORE_CALLBACK_CANCEL;
2175 _calc_job(void *data)
2177 Widget_Data *wd = data;
2179 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2180 Item_Block *chb = NULL;
2181 int in = 0, minw_change = 0;
2182 Eina_Bool changed = EINA_FALSE;
2184 Eina_Bool did_must_recalc = EINA_FALSE;
2187 t0 = ecore_time_get();
2188 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2192 // if (wd->height_for_width) changed = EINA_TRUE;
2195 EINA_INLIST_FOREACH(wd->blocks, itb)
2197 Eina_Bool showme = EINA_FALSE;
2200 showme = itb->showme;
2201 itb->showme = EINA_FALSE;
2204 if (itb->realized) _item_block_unrealize(itb);
2206 if ((itb->changed) || (changed) ||
2207 ((itb->must_recalc) && (!did_must_recalc)))
2209 if ((changed) || (itb->must_recalc))
2212 Elm_Genlist_Item *it;
2213 EINA_LIST_FOREACH(itb->items, l, it)
2214 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2215 itb->changed = EINA_TRUE;
2216 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2217 itb->must_recalc = EINA_FALSE;
2219 if (itb->realized) _item_block_unrealize(itb);
2220 showme = _item_block_recalc(itb, in, 0, 1);
2226 if (minw == -1) minw = itb->minw;
2227 else if ((!itb->must_recalc) && (minw < itb->minw))
2236 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2238 wd->show_item->showme = EINA_FALSE;
2240 elm_smart_scroller_region_bring_in(wd->scr,
2242 wd->show_item->block->x,
2244 wd->show_item->block->y,
2245 wd->show_item->block->w,
2248 elm_smart_scroller_child_region_show(wd->scr,
2250 wd->show_item->block->x,
2252 wd->show_item->block->y,
2253 wd->show_item->block->w,
2255 wd->show_item = NULL;
2260 EINA_INLIST_FOREACH(wd->blocks, itb)
2266 if ((chb) && (EINA_INLIST_GET(chb)->next))
2268 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2270 if (itb->realized) _item_block_unrealize(itb);
2273 wd->realminw = minw;
2274 if (minw < wd->w) minw = wd->w;
2275 if ((minw != wd->minw) || (minh != wd->minh))
2279 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2280 _sizing_eval(wd->obj);
2281 if ((wd->anchor_item) && (wd->anchor_item->block))
2283 Elm_Genlist_Item *it;
2286 it = wd->anchor_item;
2287 it_y = wd->anchor_y;
2288 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2289 it->block->y + it->y + it_y);
2290 wd->anchor_item = it;
2291 wd->anchor_y = it_y;
2294 t = ecore_time_get();
2295 if (did_must_recalc)
2297 if (!wd->must_recalc_idler)
2298 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2300 wd->calc_job = NULL;
2301 evas_object_smart_changed(wd->pan_smart);
2305 _update_job(void *data)
2307 Widget_Data *wd = data;
2310 int num, num0, position = 0, recalc = 0;
2312 wd->update_job = NULL;
2314 EINA_INLIST_FOREACH(wd->blocks, itb)
2316 Evas_Coord itminw, itminh;
2317 Elm_Genlist_Item *it;
2323 _item_block_position(itb, num);
2328 EINA_LIST_FOREACH(itb->items, l2, it)
2335 it->updateme = EINA_FALSE;
2338 _item_unrealize(it, EINA_FALSE);
2339 _item_realize(it, num, EINA_FALSE);
2344 _item_realize(it, num, EINA_TRUE);
2345 _item_unrealize(it, EINA_TRUE);
2347 if ((it->minw != itminw) || (it->minh != itminh))
2352 itb->updateme = EINA_FALSE;
2356 itb->changed = EINA_TRUE;
2357 _item_block_recalc(itb, num0, 0, 1);
2358 _item_block_position(itb, num0);
2363 if (wd->calc_job) ecore_job_del(wd->calc_job);
2364 wd->calc_job = ecore_job_add(_calc_job, wd);
2369 _pan_set(Evas_Object *obj,
2373 Pan *sd = evas_object_smart_data_get(obj);
2376 // Evas_Coord ow, oh;
2377 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2378 // ow = sd->wd->minw - ow;
2379 // if (ow < 0) ow = 0;
2380 // oh = sd->wd->minh - oh;
2381 // if (oh < 0) oh = 0;
2382 // if (x < 0) x = 0;
2383 // if (y < 0) y = 0;
2384 // if (x > ow) x = ow;
2385 // if (y > oh) y = oh;
2386 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2390 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2392 if ((itb->y + itb->h) > y)
2394 Elm_Genlist_Item *it;
2397 EINA_LIST_FOREACH(itb->items, l2, it)
2399 if ((itb->y + it->y) >= y)
2401 sd->wd->anchor_item = it;
2402 sd->wd->anchor_y = -(itb->y + it->y - y);
2409 evas_object_smart_changed(obj);
2413 _pan_get(Evas_Object *obj,
2417 Pan *sd = evas_object_smart_data_get(obj);
2419 if (x) *x = sd->wd->pan_x;
2420 if (y) *y = sd->wd->pan_y;
2424 _pan_max_get(Evas_Object *obj,
2428 Pan *sd = evas_object_smart_data_get(obj);
2431 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2432 ow = sd->wd->minw - ow;
2434 oh = sd->wd->minh - oh;
2441 _pan_min_get(Evas_Object *obj __UNUSED__,
2450 _pan_child_size_get(Evas_Object *obj,
2454 Pan *sd = evas_object_smart_data_get(obj);
2456 if (w) *w = sd->wd->minw;
2457 if (h) *h = sd->wd->minh;
2461 _pan_add(Evas_Object *obj)
2464 Evas_Object_Smart_Clipped_Data *cd;
2467 cd = evas_object_smart_data_get(obj);
2470 sd->__clipped_data = *cd;
2472 evas_object_smart_data_set(obj, sd);
2476 _pan_del(Evas_Object *obj)
2478 Pan *sd = evas_object_smart_data_get(obj);
2483 ecore_job_del(sd->resize_job);
2484 sd->resize_job = NULL;
2490 _pan_resize_job(void *data)
2493 _sizing_eval(sd->wd->obj);
2494 sd->resize_job = NULL;
2498 _pan_resize(Evas_Object *obj,
2502 Pan *sd = evas_object_smart_data_get(obj);
2505 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2506 if ((ow == w) && (oh == h)) return;
2507 if ((sd->wd->height_for_width) && (ow != w))
2509 if (sd->resize_job) ecore_job_del(sd->resize_job);
2510 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2512 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2513 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2517 _pan_calculate(Evas_Object *obj)
2519 Pan *sd = evas_object_smart_data_get(obj);
2521 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2523 Elm_Genlist_Item *git;
2526 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2527 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2528 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2530 git->want_realize = EINA_FALSE;
2532 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2534 itb->w = sd->wd->minw;
2535 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2536 itb->y - sd->wd->pan_y + oy,
2538 cvx, cvy, cvw, cvh))
2540 if ((!itb->realized) || (itb->changed))
2541 _item_block_realize(itb, in, 0);
2542 _item_block_position(itb, in);
2546 if (itb->realized) _item_block_unrealize(itb);
2550 _group_items_recalc(sd->wd);
2554 _pan_move(Evas_Object *obj,
2555 Evas_Coord x __UNUSED__,
2556 Evas_Coord y __UNUSED__)
2558 Pan *sd = evas_object_smart_data_get(obj);
2560 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2561 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2565 _hold_on(void *data __UNUSED__,
2567 void *event_info __UNUSED__)
2569 Widget_Data *wd = elm_widget_data_get(obj);
2571 elm_smart_scroller_hold_set(wd->scr, 1);
2575 _hold_off(void *data __UNUSED__,
2577 void *event_info __UNUSED__)
2579 Widget_Data *wd = elm_widget_data_get(obj);
2581 elm_smart_scroller_hold_set(wd->scr, 0);
2585 _freeze_on(void *data __UNUSED__,
2587 void *event_info __UNUSED__)
2589 Widget_Data *wd = elm_widget_data_get(obj);
2591 elm_smart_scroller_freeze_set(wd->scr, 1);
2595 _freeze_off(void *data __UNUSED__,
2597 void *event_info __UNUSED__)
2599 Widget_Data *wd = elm_widget_data_get(obj);
2601 elm_smart_scroller_freeze_set(wd->scr, 0);
2605 _scroll_edge_left(void *data,
2606 Evas_Object *scr __UNUSED__,
2607 void *event_info __UNUSED__)
2609 Evas_Object *obj = data;
2610 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2614 _scroll_edge_right(void *data,
2615 Evas_Object *scr __UNUSED__,
2616 void *event_info __UNUSED__)
2618 Evas_Object *obj = data;
2619 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2623 _scroll_edge_top(void *data,
2624 Evas_Object *scr __UNUSED__,
2625 void *event_info __UNUSED__)
2627 Evas_Object *obj = data;
2628 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2632 _scroll_edge_bottom(void *data,
2633 Evas_Object *scr __UNUSED__,
2634 void *event_info __UNUSED__)
2636 Evas_Object *obj = data;
2637 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2641 _mode_item_realize(Elm_Genlist_Item *it)
2645 if ((it->mode_view) || (it->delete_me)) return;
2647 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2648 edje_object_scale_set(it->mode_view,
2649 elm_widget_scale_get(it->base.widget) *
2650 _elm_config->scale);
2651 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2652 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2654 strncpy(buf, "item", sizeof(buf));
2655 if (it->wd->compress)
2656 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2658 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2659 strncat(buf, "/", sizeof(buf) - strlen(buf));
2660 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2662 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2663 elm_widget_style_get(it->base.widget));
2664 edje_object_mirrored_set(it->mode_view,
2665 elm_widget_mirrored_get(it->base.widget));
2667 /* signal callback add */
2668 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2670 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2672 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2675 /* label_get, icon_get, state_get */
2676 /* FIXME: If you see that assert, please notify us and we
2677 will clean our mess */
2678 assert(eina_list_count(it->mode_icon_objs) == 0);
2680 _item_label_realize(it, it->mode_view, &it->mode_labels);
2681 it->mode_icon_objs = _item_icon_realize(it,
2684 _item_state_realize(it, it->mode_view, &it->mode_states);
2686 edje_object_part_swallow(it->mode_view,
2687 edje_object_data_get(it->mode_view, "mode_part"),
2690 it->want_unrealize = EINA_FALSE;
2694 _mode_item_unrealize(Elm_Genlist_Item *it)
2696 Widget_Data *wd = it->wd;
2698 if (!it->mode_view) return;
2700 elm_widget_stringlist_free(it->mode_labels);
2701 it->mode_labels = NULL;
2702 elm_widget_stringlist_free(it->mode_icons);
2703 it->mode_icons = NULL;
2704 elm_widget_stringlist_free(it->mode_states);
2706 EINA_LIST_FREE(it->mode_icon_objs, icon)
2707 evas_object_del(icon);
2709 edje_object_part_unswallow(it->mode_view, it->base.view);
2710 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2711 evas_object_del(it->mode_view);
2712 it->mode_view = NULL;
2714 if (wd->mode_item == it)
2715 wd->mode_item = NULL;
2719 _item_mode_set(Elm_Genlist_Item *it)
2722 Widget_Data *wd = it->wd;
2727 it->nocache = EINA_TRUE;
2729 if (wd->scr_hold_timer)
2731 ecore_timer_del(wd->scr_hold_timer);
2732 wd->scr_hold_timer = NULL;
2734 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2735 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2737 _mode_item_realize(it);
2738 _item_position(it, it->mode_view);
2740 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2741 edje_object_signal_emit(it->mode_view, buf, "elm");
2745 _item_mode_unset(Widget_Data *wd)
2748 if (!wd->mode_item) return;
2749 char buf[1024], buf2[1024];
2750 Elm_Genlist_Item *it;
2753 it->nocache = EINA_TRUE;
2755 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2756 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2758 edje_object_signal_emit(it->mode_view, buf, "elm");
2759 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2761 wd->mode_item = NULL;
2765 * Add a new Genlist object
2767 * @param parent The parent object
2768 * @return The new object or NULL if it cannot be created
2773 elm_genlist_add(Evas_Object *parent)
2778 Evas_Coord minw, minh;
2779 static Evas_Smart *smart = NULL;
2783 static Evas_Smart_Class sc;
2785 evas_object_smart_clipped_smart_set(&_pan_sc);
2787 sc.name = "elm_genlist_pan";
2788 sc.version = EVAS_SMART_CLASS_VERSION;
2791 sc.resize = _pan_resize;
2792 sc.move = _pan_move;
2793 sc.calculate = _pan_calculate;
2794 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2797 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2799 ELM_SET_WIDTYPE(widtype, "genlist");
2800 elm_widget_type_set(obj, "genlist");
2801 elm_widget_sub_object_add(parent, obj);
2802 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2803 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2804 elm_widget_data_set(obj, wd);
2805 elm_widget_del_hook_set(obj, _del_hook);
2806 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2807 elm_widget_theme_hook_set(obj, _theme_hook);
2808 elm_widget_can_focus_set(obj, EINA_TRUE);
2809 elm_widget_event_hook_set(obj, _event_hook);
2810 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2812 wd->scr = elm_smart_scroller_add(e);
2813 elm_smart_scroller_widget_set(wd->scr, obj);
2814 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2815 elm_widget_style_get(obj));
2816 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2817 _elm_config->thumbscroll_bounce_enable);
2818 elm_widget_resize_object_set(obj, wd->scr);
2820 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2821 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2823 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2824 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2828 wd->mode = ELM_LIST_SCROLL;
2829 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2830 wd->item_cache_max = wd->max_items_per_block * 2;
2831 wd->longpress_timeout = _elm_config->longpress_timeout;
2833 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2834 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2835 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2836 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2838 wd->pan_smart = evas_object_smart_add(e, smart);
2839 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2842 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2843 _pan_set, _pan_get, _pan_max_get,
2844 _pan_min_get, _pan_child_size_get);
2846 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2848 evas_object_size_hint_min_set(obj, minw, minh);
2850 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2855 static Elm_Genlist_Item *
2856 _item_new(Widget_Data *wd,
2857 const Elm_Genlist_Item_Class *itc,
2859 Elm_Genlist_Item *parent,
2860 Elm_Genlist_Item_Flags flags,
2862 const void *func_data)
2864 Elm_Genlist_Item *it;
2866 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2867 if (!it) return NULL;
2870 it->base.data = data;
2871 it->parent = parent;
2873 it->func.func = func;
2874 it->func.data = func_data;
2875 it->mouse_cursor = NULL;
2876 it->expanded_depth = 0;
2881 _item_block_add(Widget_Data *wd,
2882 Elm_Genlist_Item *it)
2884 Item_Block *itb = NULL;
2891 itb = calloc(1, sizeof(Item_Block));
2894 if (!it->rel->block)
2897 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2898 itb->items = eina_list_append(itb->items, it);
2904 wd->blocks = eina_inlist_prepend_relative
2905 (wd->blocks, EINA_INLIST_GET(itb),
2906 EINA_INLIST_GET(it->rel->block));
2908 eina_list_prepend_relative(itb->items, it, it->rel);
2912 wd->blocks = eina_inlist_append_relative
2913 (wd->blocks, EINA_INLIST_GET(itb),
2914 EINA_INLIST_GET(it->rel->block));
2916 eina_list_append_relative(itb->items, it, it->rel);
2926 itb = (Item_Block *)(wd->blocks);
2927 if (itb->count >= wd->max_items_per_block)
2929 itb = calloc(1, sizeof(Item_Block));
2933 eina_inlist_prepend(wd->blocks,
2934 EINA_INLIST_GET(itb));
2939 itb = calloc(1, sizeof(Item_Block));
2943 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2945 itb->items = eina_list_prepend(itb->items, it);
2951 itb = (Item_Block *)(wd->blocks->last);
2952 if (itb->count >= wd->max_items_per_block)
2954 itb = calloc(1, sizeof(Item_Block));
2958 eina_inlist_append(wd->blocks,
2959 EINA_INLIST_GET(itb));
2964 itb = calloc(1, sizeof(Item_Block));
2968 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2970 itb->items = eina_list_append(itb->items, it);
2976 itb = it->rel->block;
2977 if (!itb) goto newblock;
2979 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2981 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2984 itb->changed = EINA_TRUE;
2986 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2987 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2990 it->rel->relcount--;
2991 if ((it->rel->delete_me) && (!it->rel->relcount))
2995 if (itb->count > itb->wd->max_items_per_block)
2999 Elm_Genlist_Item *it2;
3001 newc = itb->count / 2;
3002 itb2 = calloc(1, sizeof(Item_Block));
3006 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3007 EINA_INLIST_GET(itb));
3008 itb2->changed = EINA_TRUE;
3009 while ((itb->count > newc) && (itb->items))
3013 l = eina_list_last(itb->items);
3015 itb->items = eina_list_remove_list(itb->items, l);
3018 itb2->items = eina_list_prepend(itb2->items, it2);
3026 _queue_process(Widget_Data *wd,
3030 Eina_Bool showme = EINA_FALSE;
3033 t0 = ecore_time_get();
3034 for (n = 0; (wd->queue) && (n < 128); n++)
3036 Elm_Genlist_Item *it;
3038 it = wd->queue->data;
3039 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3040 it->queued = EINA_FALSE;
3041 _item_block_add(wd, it);
3042 t = ecore_time_get();
3043 if (it->block->changed)
3045 showme = _item_block_recalc(it->block, it->block->num, 1,
3047 it->block->changed = 0;
3049 if (showme) it->block->showme = EINA_TRUE;
3050 if (eina_inlist_count(wd->blocks) > 1)
3052 if ((t - t0) > (ecore_animator_frametime_get())) break;
3059 _idle_process(void *data, Eina_Bool *wakeup)
3061 Widget_Data *wd = data;
3064 //static double q_start = 0.0;
3065 //if (q_start == 0.0) q_start = ecore_time_get();
3067 if (_queue_process(wd, 1) > 0) *wakeup = EINA_TRUE;
3071 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3073 return ECORE_CALLBACK_CANCEL;
3075 return ECORE_CALLBACK_RENEW;
3079 _item_idle_enterer(void *data)
3081 Widget_Data *wd = data;
3082 Eina_Bool wakeup = EINA_FALSE;
3083 Eina_Bool ok = _idle_process(data, &wakeup);
3088 if (wd->calc_job) ecore_job_del(wd->calc_job);
3089 wd->calc_job = ecore_job_add(_calc_job, wd);
3091 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3096 _item_queue(Widget_Data *wd,
3097 Elm_Genlist_Item *it)
3099 if (it->queued) return;
3100 it->queued = EINA_TRUE;
3101 wd->queue = eina_list_append(wd->queue, it);
3102 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3104 if (wd->queue_idle_enterer)
3106 ecore_idle_enterer_del(wd->queue_idle_enterer);
3107 wd->queue_idle_enterer = NULL;
3109 _queue_process(wd, 0);
3111 if (!wd->queue_idle_enterer)
3112 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3116 * Append item to the end of the genlist
3118 * This appends the given item to the end of the list or the end of
3119 * the children if the parent is given.
3121 * @param obj The genlist object
3122 * @param itc The item class for the item
3123 * @param data The item data
3124 * @param parent The parent item, or NULL if none
3125 * @param flags Item flags
3126 * @param func Convenience function called when item selected
3127 * @param func_data Data passed to @p func above.
3128 * @return A handle to the item added or NULL if not possible
3132 EAPI Elm_Genlist_Item *
3133 elm_genlist_item_append(Evas_Object *obj,
3134 const Elm_Genlist_Item_Class *itc,
3136 Elm_Genlist_Item *parent,
3137 Elm_Genlist_Item_Flags flags,
3139 const void *func_data)
3141 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3142 Widget_Data *wd = elm_widget_data_get(obj);
3143 if (!wd) return NULL;
3144 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3146 if (!it) return NULL;
3149 if (flags & ELM_GENLIST_ITEM_GROUP)
3150 wd->group_items = eina_list_append(wd->group_items, it);
3151 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3156 Elm_Genlist_Item *it2 = NULL;
3157 Eina_List *ll = eina_list_last(it->parent->items);
3158 if (ll) it2 = ll->data;
3159 it->parent->items = eina_list_append(it->parent->items, it);
3160 if (!it2) it2 = it->parent;
3162 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3163 EINA_INLIST_GET(it2));
3165 it->rel->relcount++;
3167 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3168 it->group_item = parent;
3169 else if (it->parent->group_item)
3170 it->group_item = it->parent->group_item;
3172 it->before = EINA_FALSE;
3173 _item_queue(wd, it);
3178 * Prepend item at start of the genlist
3180 * This adds an item to the beginning of the list or beginning of the
3181 * children of the parent if given.
3183 * @param obj The genlist object
3184 * @param itc The item class for the item
3185 * @param data The item data
3186 * @param parent The parent item, or NULL if none
3187 * @param flags Item flags
3188 * @param func Convenience function called when item selected
3189 * @param func_data Data passed to @p func above.
3190 * @return A handle to the item added or NULL if not possible
3194 EAPI Elm_Genlist_Item *
3195 elm_genlist_item_prepend(Evas_Object *obj,
3196 const Elm_Genlist_Item_Class *itc,
3198 Elm_Genlist_Item *parent,
3199 Elm_Genlist_Item_Flags flags,
3201 const void *func_data)
3203 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3204 Widget_Data *wd = elm_widget_data_get(obj);
3205 if (!wd) return NULL;
3206 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3208 if (!it) return NULL;
3211 if (flags & ELM_GENLIST_ITEM_GROUP)
3212 wd->group_items = eina_list_prepend(wd->group_items, it);
3213 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3218 Elm_Genlist_Item *it2 = NULL;
3219 Eina_List *ll = it->parent->items;
3220 if (ll) it2 = ll->data;
3221 it->parent->items = eina_list_prepend(it->parent->items, it);
3222 if (!it2) it2 = it->parent;
3224 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3225 EINA_INLIST_GET(it2));
3227 it->rel->relcount++;
3229 it->before = EINA_TRUE;
3230 _item_queue(wd, it);
3235 * Insert item before another in the genlist
3237 * This inserts an item before another in the list. It will be in the
3238 * same tree level or group as the item it is inseted before.
3240 * @param obj The genlist object
3241 * @param itc The item class for the item
3242 * @param data The item data
3243 * @param before The item to insert before
3244 * @param flags Item flags
3245 * @param func Convenience function called when item selected
3246 * @param func_data Data passed to @p func above.
3247 * @return A handle to the item added or NULL if not possible
3251 EAPI Elm_Genlist_Item *
3252 elm_genlist_item_insert_before(Evas_Object *obj,
3253 const Elm_Genlist_Item_Class *itc,
3255 Elm_Genlist_Item *parent,
3256 Elm_Genlist_Item *before,
3257 Elm_Genlist_Item_Flags flags,
3259 const void *func_data)
3261 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3262 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3263 Widget_Data *wd = elm_widget_data_get(obj);
3264 if (!wd) return NULL;
3265 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3267 if (!it) return NULL;
3270 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3273 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3274 EINA_INLIST_GET(before));
3276 it->rel->relcount++;
3277 it->before = EINA_TRUE;
3278 _item_queue(wd, it);
3283 * Insert an item after another in the genlst
3285 * This inserts an item after another in the list. It will be in the
3286 * same tree level or group as the item it is inseted after.
3288 * @param obj The genlist object
3289 * @param itc The item class for the item
3290 * @param data The item data
3291 * @param after The item to insert after
3292 * @param flags Item flags
3293 * @param func Convenience function called when item selected
3294 * @param func_data Data passed to @p func above.
3295 * @return A handle to the item added or NULL if not possible
3299 EAPI Elm_Genlist_Item *
3300 elm_genlist_item_insert_after(Evas_Object *obj,
3301 const Elm_Genlist_Item_Class *itc,
3303 Elm_Genlist_Item *parent,
3304 Elm_Genlist_Item *after,
3305 Elm_Genlist_Item_Flags flags,
3307 const void *func_data)
3309 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3310 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3311 Widget_Data *wd = elm_widget_data_get(obj);
3312 if (!wd) return NULL;
3313 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3315 if (!it) return NULL;
3316 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3317 EINA_INLIST_GET(after));
3320 it->parent->items = eina_list_append_relative(it->parent->items, it,
3324 it->rel->relcount++;
3325 it->before = EINA_FALSE;
3326 _item_queue(wd, it);
3333 * This clears all items in the list, leaving it empty.
3335 * @param obj The genlist object
3340 elm_genlist_clear(Evas_Object *obj)
3342 ELM_CHECK_WIDTYPE(obj, widtype);
3343 Widget_Data *wd = elm_widget_data_get(obj);
3345 if (wd->walking > 0)
3347 Elm_Genlist_Item *it;
3349 wd->clear_me = EINA_TRUE;
3350 EINA_INLIST_FOREACH(wd->items, it)
3352 it->delete_me = EINA_TRUE;
3358 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3360 if (wd->anchor_item == it)
3362 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3363 if (!wd->anchor_item)
3365 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3367 wd->items = eina_inlist_remove(wd->items, wd->items);
3368 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3369 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3370 elm_widget_item_pre_notify_del(it);
3371 if (it->realized) _item_unrealize(it, EINA_FALSE);
3372 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3373 it->itc->func.del((void *)it->base.data, it->base.widget);
3374 if (it->long_timer) ecore_timer_del(it->long_timer);
3375 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3376 elm_widget_item_del(it);
3378 wd->clear_me = EINA_FALSE;
3379 wd->anchor_item = NULL;
3382 Item_Block *itb = (Item_Block *)(wd->blocks);
3384 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3385 if (itb->items) eina_list_free(itb->items);
3390 ecore_job_del(wd->calc_job);
3391 wd->calc_job = NULL;
3393 if (wd->queue_idle_enterer)
3395 ecore_idle_enterer_del(wd->queue_idle_enterer);
3396 wd->queue_idle_enterer = NULL;
3398 if (wd->must_recalc_idler)
3400 ecore_idler_del(wd->must_recalc_idler);
3401 wd->must_recalc_idler = NULL;
3405 eina_list_free(wd->queue);
3410 eina_list_free(wd->selected);
3411 wd->selected = NULL;
3413 wd->show_item = NULL;
3420 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3421 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3427 * Enable or disable multi-select in the genlist
3429 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3430 * the list. This allows more than 1 item to be selected.
3432 * @param obj The genlist object
3433 * @param multi Multi-select enable/disable
3438 elm_genlist_multi_select_set(Evas_Object *obj,
3441 ELM_CHECK_WIDTYPE(obj, widtype);
3442 Widget_Data *wd = elm_widget_data_get(obj);
3448 * Gets if multi-select in genlist is enable or disable
3450 * @param obj The genlist object
3451 * @return Multi-select enable/disable
3452 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3457 elm_genlist_multi_select_get(const Evas_Object *obj)
3459 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3460 Widget_Data *wd = elm_widget_data_get(obj);
3461 if (!wd) return EINA_FALSE;
3466 * Get the selectd item in the genlist
3468 * This gets the selected item in the list (if multi-select is enabled
3469 * only the first item in the list is selected - which is not very
3470 * useful, so see elm_genlist_selected_items_get() for when
3471 * multi-select is used).
3473 * If no item is selected, NULL is returned.
3475 * @param obj The genlist object
3476 * @return The selected item, or NULL if none.
3480 EAPI Elm_Genlist_Item *
3481 elm_genlist_selected_item_get(const Evas_Object *obj)
3483 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3484 Widget_Data *wd = elm_widget_data_get(obj);
3485 if (!wd) return NULL;
3486 if (wd->selected) return wd->selected->data;
3491 * Get a list of selected items in the genlist
3493 * This returns a list of the selected items. This list pointer is
3494 * only valid so long as no items are selected or unselected (or
3495 * unselected implicitly by deletion). The list contains
3496 * Elm_Genlist_Item pointers.
3498 * @param obj The genlist object
3499 * @return The list of selected items, nor NULL if none are selected.
3503 EAPI const Eina_List *
3504 elm_genlist_selected_items_get(const Evas_Object *obj)
3506 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3507 Widget_Data *wd = elm_widget_data_get(obj);
3508 if (!wd) return NULL;
3509 return wd->selected;
3513 * Get a list of realized items in genlist
3515 * This returns a list of the realized items in the genlist. The list
3516 * contains Elm_Genlist_Item pointers. The list must be freed by the
3517 * caller when done with eina_list_free(). The item pointers in the
3518 * list are only valid so long as those items are not deleted or the
3519 * genlist is not deleted.
3521 * @param obj The genlist object
3522 * @return The list of realized items, nor NULL if none are realized.
3527 elm_genlist_realized_items_get(const Evas_Object *obj)
3529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3530 Widget_Data *wd = elm_widget_data_get(obj);
3531 Eina_List *list = NULL;
3533 Eina_Bool done = EINA_FALSE;
3534 if (!wd) return NULL;
3535 EINA_INLIST_FOREACH(wd->blocks, itb)
3540 Elm_Genlist_Item *it;
3543 EINA_LIST_FOREACH(itb->items, l, it)
3545 if (it->realized) list = eina_list_append(list, it);
3557 * Get the item that is at the x, y canvas coords
3559 * This returns the item at the given coordinates (which are canvas
3560 * relative not object-relative). If an item is at that coordinate,
3561 * that item handle is returned, and if @p posret is not NULL, the
3562 * integer pointed to is set to a value of -1, 0 or 1, depending if
3563 * the coordinate is on the upper portion of that item (-1), on the
3564 * middle section (0) or on the lower part (1). If NULL is returned as
3565 * an item (no item found there), then posret may indicate -1 or 1
3566 * based if the coordinate is above or below all items respectively in
3569 * @param it The item
3570 * @param x The input x coordinate
3571 * @param y The input y coordinate
3572 * @param posret The position relative to the item returned here
3573 * @return The item at the coordinates or NULL if none
3577 EAPI Elm_Genlist_Item *
3578 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3583 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3584 Widget_Data *wd = elm_widget_data_get(obj);
3585 Evas_Coord ox, oy, ow, oh;
3588 if (!wd) return NULL;
3589 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3591 EINA_INLIST_FOREACH(wd->blocks, itb)
3594 Elm_Genlist_Item *it;
3596 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3597 oy + itb->y - itb->wd->pan_y,
3598 itb->w, itb->h, x, y, 1, 1))
3600 EINA_LIST_FOREACH(itb->items, l, it)
3602 Evas_Coord itx, ity;
3604 itx = ox + itb->x + it->x - itb->wd->pan_x;
3605 ity = oy + itb->y + it->y - itb->wd->pan_y;
3606 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3610 if (y <= (ity + (it->h / 4))) *posret = -1;
3611 else if (y >= (ity + it->h - (it->h / 4)))
3617 lasty = ity + it->h;
3622 if (y > lasty) *posret = 1;
3629 * Get the first item in the genlist
3631 * This returns the first item in the list.
3633 * @param obj The genlist object
3634 * @return The first item, or NULL if none
3638 EAPI Elm_Genlist_Item *
3639 elm_genlist_first_item_get(const Evas_Object *obj)
3641 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3642 Widget_Data *wd = elm_widget_data_get(obj);
3643 if (!wd) return NULL;
3644 if (!wd->items) return NULL;
3645 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3646 while ((it) && (it->delete_me))
3647 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3652 * Get the last item in the genlist
3654 * This returns the last item in the list.
3656 * @return The last item, or NULL if none
3660 EAPI Elm_Genlist_Item *
3661 elm_genlist_last_item_get(const Evas_Object *obj)
3663 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3664 Widget_Data *wd = elm_widget_data_get(obj);
3665 if (!wd) return NULL;
3666 if (!wd->items) return NULL;
3667 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3668 while ((it) && (it->delete_me))
3669 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3674 * Get the next item in the genlist
3676 * This returns the item after the item @p it.
3678 * @param it The item
3679 * @return The item after @p it, or NULL if none
3683 EAPI Elm_Genlist_Item *
3684 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3686 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3689 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3690 if ((it) && (!it->delete_me)) break;
3692 return (Elm_Genlist_Item *)it;
3696 * Get the previous item in the genlist
3698 * This returns the item before the item @p it.
3700 * @param it The item
3701 * @return The item before @p it, or NULL if none
3705 EAPI Elm_Genlist_Item *
3706 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3708 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3711 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3712 if ((it) && (!it->delete_me)) break;
3714 return (Elm_Genlist_Item *)it;
3718 * Get the genlist object from an item
3720 * This returns the genlist object itself that an item belongs to.
3722 * @param it The item
3723 * @return The genlist object
3728 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3730 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3731 return it->base.widget;
3735 * Get the parent item of the given item
3737 * This returns the parent item of the item @p it given.
3739 * @param it The item
3740 * @return The parent of the item or NULL if none
3744 EAPI Elm_Genlist_Item *
3745 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3747 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3752 * Clear all sub-items (children) of the given item
3754 * This clears all items that are children (or their descendants) of the
3757 * @param it The item
3762 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3764 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3765 Eina_List *tl = NULL, *l;
3766 Elm_Genlist_Item *it2;
3768 EINA_LIST_FOREACH(it->items, l, it2)
3769 tl = eina_list_append(tl, it2);
3770 EINA_LIST_FREE(tl, it2)
3771 elm_genlist_item_del(it2);
3775 * Set the selected state of an item
3777 * This sets the selected state (1 selected, 0 not selected) of the given
3780 * @param it The item
3781 * @param selected The selected state
3786 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3789 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3790 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3792 if (it->delete_me) return;
3793 selected = !!selected;
3794 if (it->selected == selected) return;
3800 while (wd->selected)
3801 _item_unselect(wd->selected->data);
3803 _item_highlight(it);
3811 * Get the selected state of an item
3813 * This gets the selected state of an item (1 selected, 0 not selected).
3815 * @param it The item
3816 * @return The selected state
3821 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3823 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3824 return it->selected;
3828 * Sets the expanded state of an item (if it's a parent)
3830 * This expands or contracts a parent item (thus showing or hiding the
3833 * @param it The item
3834 * @param expanded The expanded state (1 expanded, 0 not expanded).
3839 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3842 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3843 if (it->expanded == expanded) return;
3844 it->expanded = expanded;
3848 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3849 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3854 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3855 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3860 * Get the expanded state of an item
3862 * This gets the expanded state of an item
3864 * @param it The item
3865 * @return Thre expanded state
3870 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3872 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3873 return it->expanded;
3877 * Get the depth of expanded item
3879 * @param it The genlist item object
3880 * @return The depth of expanded item
3885 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3887 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3888 return it->expanded_depth;
3892 * Sets the disabled state of an item.
3894 * A disabled item cannot be selected or unselected. It will also
3895 * change appearance to appear disabled. This sets the disabled state
3896 * (1 disabled, 0 not disabled).
3898 * @param it The item
3899 * @param disabled The disabled state
3904 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3907 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3908 if (it->disabled == disabled) return;
3909 if (it->delete_me) return;
3910 it->disabled = disabled;
3914 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3916 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3921 * Get the disabled state of an item
3923 * This gets the disabled state of the given item.
3925 * @param it The item
3926 * @return The disabled state
3931 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3933 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3934 if (it->delete_me) return EINA_FALSE;
3935 return it->disabled;
3939 * Sets the display only state of an item.
3941 * A display only item cannot be selected or unselected. It is for
3942 * display only and not selecting or otherwise clicking, dragging
3943 * etc. by the user, thus finger size rules will not be applied to
3946 * @param it The item
3947 * @param display_only The display only state
3952 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3953 Eina_Bool display_only)
3955 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3956 if (it->display_only == display_only) return;
3957 if (it->delete_me) return;
3958 it->display_only = display_only;
3959 it->mincalcd = EINA_FALSE;
3960 it->updateme = EINA_TRUE;
3961 if (it->block) it->block->updateme = EINA_TRUE;
3962 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3963 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3967 * Get the display only state of an item
3969 * This gets the display only state of the given item.
3971 * @param it The item
3972 * @return The display only state
3977 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3979 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3980 if (it->delete_me) return EINA_FALSE;
3981 return it->display_only;
3985 * Show the given item
3987 * This causes genlist to jump to the given item @p it and show it (by
3988 * scrolling), if it is not fully visible.
3990 * @param it The item
3995 elm_genlist_item_show(Elm_Genlist_Item *it)
3997 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3998 Evas_Coord gith = 0;
3999 if (it->delete_me) return;
4000 if ((it->queued) || (!it->mincalcd))
4002 it->wd->show_item = it;
4003 it->wd->bring_in = EINA_TRUE;
4004 it->showme = EINA_TRUE;
4007 if (it->wd->show_item)
4009 it->wd->show_item->showme = EINA_FALSE;
4010 it->wd->show_item = NULL;
4012 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4013 gith = it->group_item->h;
4014 elm_smart_scroller_child_region_show(it->wd->scr,
4015 it->x + it->block->x,
4016 it->y + it->block->y - gith,
4017 it->block->w, it->h);
4021 * Bring in the given item
4023 * This causes genlist to jump to the given item @p it and show it (by
4024 * scrolling), if it is not fully visible. This may use animation to
4025 * do so and take a period of time
4027 * @param it The item
4032 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4034 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4035 Evas_Coord gith = 0;
4036 if (it->delete_me) return;
4037 if ((it->queued) || (!it->mincalcd))
4039 it->wd->show_item = it;
4040 it->wd->bring_in = EINA_TRUE;
4041 it->showme = EINA_TRUE;
4044 if (it->wd->show_item)
4046 it->wd->show_item->showme = EINA_FALSE;
4047 it->wd->show_item = NULL;
4049 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4050 gith = it->group_item->h;
4051 elm_smart_scroller_region_bring_in(it->wd->scr,
4052 it->x + it->block->x,
4053 it->y + it->block->y - gith,
4054 it->block->w, it->h);
4058 * Show the given item at the top
4060 * This causes genlist to jump to the given item @p it and show it (by
4061 * scrolling), if it is not fully visible.
4063 * @param it The item
4068 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4070 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4072 Evas_Coord gith = 0;
4074 if (it->delete_me) return;
4075 if ((it->queued) || (!it->mincalcd))
4077 it->wd->show_item = it;
4078 it->wd->bring_in = EINA_TRUE;
4079 it->showme = EINA_TRUE;
4082 if (it->wd->show_item)
4084 it->wd->show_item->showme = EINA_FALSE;
4085 it->wd->show_item = NULL;
4087 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4088 if (it->group_item) gith = it->group_item->h;
4089 elm_smart_scroller_child_region_show(it->wd->scr,
4090 it->x + it->block->x,
4091 it->y + it->block->y - gith,
4096 * Bring in the given item at the top
4098 * This causes genlist to jump to the given item @p it and show it (by
4099 * scrolling), if it is not fully visible. This may use animation to
4100 * do so and take a period of time
4102 * @param it The item
4107 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4109 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4111 Evas_Coord gith = 0;
4113 if (it->delete_me) return;
4114 if ((it->queued) || (!it->mincalcd))
4116 it->wd->show_item = it;
4117 it->wd->bring_in = EINA_TRUE;
4118 it->showme = EINA_TRUE;
4121 if (it->wd->show_item)
4123 it->wd->show_item->showme = EINA_FALSE;
4124 it->wd->show_item = NULL;
4126 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4127 if (it->group_item) gith = it->group_item->h;
4128 elm_smart_scroller_region_bring_in(it->wd->scr,
4129 it->x + it->block->x,
4130 it->y + it->block->y - gith,
4135 * Show the given item at the middle
4137 * This causes genlist to jump to the given item @p it and show it (by
4138 * scrolling), if it is not fully visible.
4140 * @param it The item
4145 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4147 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4150 if (it->delete_me) return;
4151 if ((it->queued) || (!it->mincalcd))
4153 it->wd->show_item = it;
4154 it->wd->bring_in = EINA_TRUE;
4155 it->showme = EINA_TRUE;
4158 if (it->wd->show_item)
4160 it->wd->show_item->showme = EINA_FALSE;
4161 it->wd->show_item = NULL;
4163 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4164 elm_smart_scroller_child_region_show(it->wd->scr,
4165 it->x + it->block->x,
4166 it->y + it->block->y - oh / 2 +
4167 it->h / 2, it->block->w, oh);
4171 * Bring in the given item at the middle
4173 * This causes genlist to jump to the given item @p it and show it (by
4174 * scrolling), if it is not fully visible. This may use animation to
4175 * do so and take a period of time
4177 * @param it The item
4182 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4184 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4187 if (it->delete_me) return;
4188 if ((it->queued) || (!it->mincalcd))
4190 it->wd->show_item = it;
4191 it->wd->bring_in = EINA_TRUE;
4192 it->showme = EINA_TRUE;
4195 if (it->wd->show_item)
4197 it->wd->show_item->showme = EINA_FALSE;
4198 it->wd->show_item = NULL;
4200 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4201 elm_smart_scroller_region_bring_in(it->wd->scr,
4202 it->x + it->block->x,
4203 it->y + it->block->y - oh / 2 + it->h / 2,
4208 * Delete a given item
4210 * This deletes the item from genlist and calls the genlist item del
4211 * class callback defined in the item class, if it is set. This clears all
4212 * subitems if it is a tree.
4214 * @param it The item
4219 elm_genlist_item_del(Elm_Genlist_Item *it)
4221 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4222 if ((it->relcount > 0) || (it->walking > 0))
4224 elm_widget_item_pre_notify_del(it);
4225 elm_genlist_item_subitems_clear(it);
4226 it->delete_me = EINA_TRUE;
4227 if (it->wd->show_item == it) it->wd->show_item = NULL;
4229 it->wd->selected = eina_list_remove(it->wd->selected,
4233 if (it->realized) _item_unrealize(it, EINA_FALSE);
4234 it->block->changed = EINA_TRUE;
4235 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4236 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4238 if (it->itc->func.del)
4239 it->itc->func.del((void *)it->base.data, it->base.widget);
4246 * Set the data item from the genlist item
4248 * This set the data value passed on the elm_genlist_item_append() and
4249 * related item addition calls. This function will also call
4250 * elm_genlist_item_update() so the item will be updated to reflect the
4253 * @param it The item
4254 * @param data The new data pointer to set
4259 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4262 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4263 elm_widget_item_data_set(it, data);
4264 elm_genlist_item_update(it);
4268 * Get the data item from the genlist item
4270 * This returns the data value passed on the elm_genlist_item_append()
4271 * and related item addition calls and elm_genlist_item_data_set().
4273 * @param it The item
4274 * @return The data pointer provided when created
4279 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4281 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4282 return elm_widget_item_data_get(it);
4286 * Tells genlist to "orphan" icons fetchs by the item class
4288 * This instructs genlist to release references to icons in the item,
4289 * meaning that they will no longer be managed by genlist and are
4290 * floating "orphans" that can be re-used elsewhere if the user wants
4293 * @param it The item
4298 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4301 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4302 EINA_LIST_FREE(it->icon_objs, icon)
4304 elm_widget_sub_object_del(it->base.widget, icon);
4305 evas_object_smart_member_del(icon);
4306 evas_object_hide(icon);
4311 * Get the real evas object of the genlist item
4313 * This returns the actual evas object used for the specified genlist
4314 * item. This may be NULL as it may not be created, and may be deleted
4315 * at any time by genlist. Do not modify this object (move, resize,
4316 * show, hide etc.) as genlist is controlling it. This function is for
4317 * querying, emitting custom signals or hooking lower level callbacks
4318 * for events. Do not delete this object under any circumstances.
4320 * @param it The item
4321 * @return The object pointer
4325 EAPI const Evas_Object *
4326 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4328 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4329 return it->base.view;
4333 * Update the contents of an item
4335 * This updates an item by calling all the item class functions again
4336 * to get the icons, labels and states. Use this when the original
4337 * item data has changed and the changes are desired to be reflected.
4339 * @param it The item
4344 elm_genlist_item_update(Elm_Genlist_Item *it)
4346 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4347 if (!it->block) return;
4348 if (it->delete_me) return;
4349 it->mincalcd = EINA_FALSE;
4350 it->updateme = EINA_TRUE;
4351 it->block->updateme = EINA_TRUE;
4352 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4353 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4357 * Update the item class of an item
4359 * @param it The item
4360 * @parem itc The item class for the item
4365 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4366 const Elm_Genlist_Item_Class *itc)
4368 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4369 if (!it->block) return;
4370 EINA_SAFETY_ON_NULL_RETURN(itc);
4371 if (it->delete_me) return;
4373 it->nocache = EINA_TRUE;
4374 elm_genlist_item_update(it);
4377 static Evas_Object *
4378 _elm_genlist_item_label_create(void *data,
4380 void *item __UNUSED__)
4382 Evas_Object *label = elm_label_add(obj);
4385 elm_object_style_set(label, "tooltip");
4386 elm_label_label_set(label, data);
4391 _elm_genlist_item_label_del_cb(void *data,
4392 Evas_Object *obj __UNUSED__,
4393 void *event_info __UNUSED__)
4395 eina_stringshare_del(data);
4399 * Set the text to be shown in the genlist item.
4401 * @param item Target item
4402 * @param text The text to set in the content
4404 * Setup the text as tooltip to object. The item can have only one
4405 * tooltip, so any previous tooltip data is removed.
4410 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4413 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4414 text = eina_stringshare_add(text);
4415 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4417 _elm_genlist_item_label_del_cb);
4421 * Set the content to be shown in the tooltip item
4423 * Setup the tooltip to item. The item can have only one tooltip, so
4424 * any previous tooltip data is removed. @p func(with @p data) will be
4425 * called every time that need to show the tooltip and it should return a
4426 * valid Evas_Object. This object is then managed fully by tooltip
4427 * system and is deleted when the tooltip is gone.
4429 * @param item the genlist item being attached by a tooltip.
4430 * @param func the function used to create the tooltip contents.
4431 * @param data what to provide to @a func as callback data/context.
4432 * @param del_cb called when data is not needed anymore, either when
4433 * another callback replaces @func, the tooltip is unset with
4434 * elm_genlist_item_tooltip_unset() or the owner @a item
4435 * dies. This callback receives as the first parameter the
4436 * given @a data, and @c event_info is the item.
4441 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4442 Elm_Tooltip_Item_Content_Cb func,
4444 Evas_Smart_Cb del_cb)
4446 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4448 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4451 if (item->tooltip.del_cb)
4452 item->tooltip.del_cb((void *)item->tooltip.data,
4453 item->base.widget, item);
4455 item->tooltip.content_cb = func;
4456 item->tooltip.data = data;
4457 item->tooltip.del_cb = del_cb;
4459 if (item->base.view)
4461 elm_widget_item_tooltip_content_cb_set(item,
4462 item->tooltip.content_cb,
4463 item->tooltip.data, NULL);
4464 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4470 if (del_cb) del_cb((void *)data, NULL, NULL);
4474 * Unset tooltip from item
4476 * @param item genlist item to remove previously set tooltip.
4478 * Remove tooltip from item. The callback provided as del_cb to
4479 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4480 * it is not used anymore.
4482 * @see elm_genlist_item_tooltip_content_cb_set()
4487 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4489 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4490 if ((item->base.view) && (item->tooltip.content_cb))
4491 elm_widget_item_tooltip_unset(item);
4493 if (item->tooltip.del_cb)
4494 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4495 item->tooltip.del_cb = NULL;
4496 item->tooltip.content_cb = NULL;
4497 item->tooltip.data = NULL;
4498 if (item->tooltip.style)
4499 elm_genlist_item_tooltip_style_set(item, NULL);
4503 * Sets a different style for this item tooltip.
4505 * @note before you set a style you should define a tooltip with
4506 * elm_genlist_item_tooltip_content_cb_set() or
4507 * elm_genlist_item_tooltip_text_set()
4509 * @param item genlist item with tooltip already set.
4510 * @param style the theme style to use (default, transparent, ...)
4515 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4518 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4519 eina_stringshare_replace(&item->tooltip.style, style);
4520 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4524 * Get the style for this item tooltip.
4526 * @param item genlist item with tooltip already set.
4527 * @return style the theme style in use, defaults to "default". If the
4528 * object does not have a tooltip set, then NULL is returned.
4533 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4535 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4536 return item->tooltip.style;
4540 * Set the cursor to be shown when mouse is over the genlist item
4542 * @param item Target item
4543 * @param cursor the cursor name to be used.
4545 * @see elm_object_cursor_set()
4549 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4552 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4553 eina_stringshare_replace(&item->mouse_cursor, cursor);
4554 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4558 * Get the cursor to be shown when mouse is over the genlist item
4560 * @param item genlist item with cursor already set.
4561 * @return the cursor name.
4566 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4568 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4569 return elm_widget_item_cursor_get(item);
4573 * Unset the cursor to be shown when mouse is over the genlist item
4575 * @param item Target item
4577 * @see elm_object_cursor_unset()
4581 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4583 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4584 if (!item->mouse_cursor)
4587 if (item->base.view)
4588 elm_widget_item_cursor_unset(item);
4590 eina_stringshare_del(item->mouse_cursor);
4591 item->mouse_cursor = NULL;
4595 * Sets a different style for this item cursor.
4597 * @note before you set a style you should define a cursor with
4598 * elm_genlist_item_cursor_set()
4600 * @param item genlist item with cursor already set.
4601 * @param style the theme style to use (default, transparent, ...)
4606 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4609 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4610 elm_widget_item_cursor_style_set(item, style);
4614 * Get the style for this item cursor.
4616 * @param item genlist item with cursor already set.
4617 * @return style the theme style in use, defaults to "default". If the
4618 * object does not have a cursor set, then NULL is returned.
4623 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4625 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4626 return elm_widget_item_cursor_style_get(item);
4630 * Set if the cursor set should be searched on the theme or should use
4631 * the provided by the engine, only.
4633 * @note before you set if should look on theme you should define a
4634 * cursor with elm_object_cursor_set(). By default it will only look
4635 * for cursors provided by the engine.
4637 * @param item widget item with cursor already set.
4638 * @param engine_only boolean to define it cursors should be looked
4639 * only between the provided by the engine or searched on widget's
4645 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4646 Eina_Bool engine_only)
4648 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4649 elm_widget_item_cursor_engine_only_set(item, engine_only);
4653 * Get the cursor engine only usage for this item cursor.
4655 * @param item widget item with cursor already set.
4656 * @return engine_only boolean to define it cursors should be looked
4657 * only between the provided by the engine or searched on widget's
4658 * theme as well. If the object does not have a cursor set, then
4659 * EINA_FALSE is returned.
4664 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4666 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4667 return elm_widget_item_cursor_engine_only_get(item);
4671 * This sets the horizontal stretching mode
4673 * This sets the mode used for sizing items horizontally. Valid modes
4674 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4675 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4676 * the scroller will scroll horizontally. Otherwise items are expanded
4677 * to fill the width of the viewport of the scroller. If it is
4678 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4679 * limited to that size.
4681 * @param obj The genlist object
4682 * @param mode The mode to use
4687 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4690 ELM_CHECK_WIDTYPE(obj, widtype);
4691 Widget_Data *wd = elm_widget_data_get(obj);
4693 if (wd->mode == mode) return;
4699 * Gets the horizontal stretching mode
4701 * @param obj The genlist object
4702 * @return The mode to use
4703 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4708 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4710 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4711 Widget_Data *wd = elm_widget_data_get(obj);
4712 if (!wd) return ELM_LIST_LAST;
4717 * Set the always select mode.
4719 * Items will only call their selection func and callback when first
4720 * becoming selected. Any further clicks will do nothing, unless you
4721 * enable always select with elm_genlist_always_select_mode_set().
4722 * This means even if selected, every click will make the selected
4723 * callbacks be called.
4725 * @param obj The genlist object
4726 * @param always_select The always select mode
4727 * (EINA_TRUE = on, EINA_FALSE = off)
4732 elm_genlist_always_select_mode_set(Evas_Object *obj,
4733 Eina_Bool always_select)
4735 ELM_CHECK_WIDTYPE(obj, widtype);
4736 Widget_Data *wd = elm_widget_data_get(obj);
4738 wd->always_select = always_select;
4742 * Get the always select mode.
4744 * @param obj The genlist object
4745 * @return The always select mode
4746 * (EINA_TRUE = on, EINA_FALSE = off)
4751 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4753 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4754 Widget_Data *wd = elm_widget_data_get(obj);
4755 if (!wd) return EINA_FALSE;
4756 return wd->always_select;
4760 * Set no select mode
4762 * This will turn off the ability to select items entirely and they
4763 * will neither appear selected nor call selected callback functions.
4765 * @param obj The genlist object
4766 * @param no_select The no select mode
4767 * (EINA_TRUE = on, EINA_FALSE = off)
4772 elm_genlist_no_select_mode_set(Evas_Object *obj,
4773 Eina_Bool no_select)
4775 ELM_CHECK_WIDTYPE(obj, widtype);
4776 Widget_Data *wd = elm_widget_data_get(obj);
4778 wd->no_select = no_select;
4782 * Gets no select mode
4784 * @param obj The genlist object
4785 * @return The no select mode
4786 * (EINA_TRUE = on, EINA_FALSE = off)
4791 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4793 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4794 Widget_Data *wd = elm_widget_data_get(obj);
4795 if (!wd) return EINA_FALSE;
4796 return wd->no_select;
4802 * This will enable the compress mode where items are "compressed"
4803 * horizontally to fit the genlist scrollable viewport width. This is
4804 * special for genlist. Do not rely on
4805 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4806 * work as genlist needs to handle it specially.
4808 * @param obj The genlist object
4809 * @param compress The compress mode
4810 * (EINA_TRUE = on, EINA_FALSE = off)
4815 elm_genlist_compress_mode_set(Evas_Object *obj,
4818 ELM_CHECK_WIDTYPE(obj, widtype);
4819 Widget_Data *wd = elm_widget_data_get(obj);
4821 wd->compress = compress;
4825 * Get the compress mode
4827 * @param obj The genlist object
4828 * @return The compress mode
4829 * (EINA_TRUE = on, EINA_FALSE = off)
4834 elm_genlist_compress_mode_get(const Evas_Object *obj)
4836 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4837 Widget_Data *wd = elm_widget_data_get(obj);
4838 if (!wd) return EINA_FALSE;
4839 return wd->compress;
4843 * Set height-for-width mode
4845 * With height-for-width mode the item width will be fixed (restricted
4846 * to a minimum of) to the list width when calculating its size in
4847 * order to allow the height to be calculated based on it. This allows,
4848 * for instance, text block to wrap lines if the Edje part is
4849 * configured with "text.min: 0 1".
4851 * @note This mode will make list resize slower as it will have to
4852 * recalculate every item height again whenever the list width
4855 * @note When height-for-width mode is enabled, it also enables
4856 * compress mode (see elm_genlist_compress_mode_set()) and
4857 * disables homogeneous (see elm_genlist_homogeneous_set()).
4859 * @param obj The genlist object
4860 * @param setting The height-for-width mode (EINA_TRUE = on,
4866 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4867 Eina_Bool height_for_width)
4869 ELM_CHECK_WIDTYPE(obj, widtype);
4870 Widget_Data *wd = elm_widget_data_get(obj);
4872 wd->height_for_width = !!height_for_width;
4873 if (wd->height_for_width)
4875 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4876 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4881 * Get the height-for-width mode
4883 * @param obj The genlist object
4884 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4890 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4892 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4893 Widget_Data *wd = elm_widget_data_get(obj);
4894 if (!wd) return EINA_FALSE;
4895 return wd->height_for_width;
4901 * This will enable or disable the scroller bounce mode for the
4902 * genlist. See elm_scroller_bounce_set() for details
4904 * @param obj The genlist object
4905 * @param h_bounce Allow bounce horizontally
4906 * @param v_bounce Allow bounce vertically
4911 elm_genlist_bounce_set(Evas_Object *obj,
4915 ELM_CHECK_WIDTYPE(obj, widtype);
4916 Widget_Data *wd = elm_widget_data_get(obj);
4918 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4922 * Get the bounce mode
4924 * @param obj The genlist object
4925 * @param h_bounce Allow bounce horizontally
4926 * @param v_bounce Allow bounce vertically
4931 elm_genlist_bounce_get(const Evas_Object *obj,
4932 Eina_Bool *h_bounce,
4933 Eina_Bool *v_bounce)
4935 ELM_CHECK_WIDTYPE(obj, widtype);
4936 Widget_Data *wd = elm_widget_data_get(obj);
4938 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4942 * Set homogenous mode
4944 * This will enable the homogeneous mode where items are of the same
4945 * height and width so that genlist may do the lazy-loading at its
4946 * maximum. This implies 'compressed' mode.
4948 * @param obj The genlist object
4949 * @param homogeneous Assume the items within the genlist are of the
4950 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4955 elm_genlist_homogeneous_set(Evas_Object *obj,
4956 Eina_Bool homogeneous)
4958 ELM_CHECK_WIDTYPE(obj, widtype);
4959 Widget_Data *wd = elm_widget_data_get(obj);
4961 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4962 wd->homogeneous = homogeneous;
4966 * Get the homogenous mode
4968 * @param obj The genlist object
4969 * @return Assume the items within the genlist are of the same height
4970 * and width (EINA_TRUE = on, EINA_FALSE = off)
4975 elm_genlist_homogeneous_get(const Evas_Object *obj)
4977 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4978 Widget_Data *wd = elm_widget_data_get(obj);
4979 if (!wd) return EINA_FALSE;
4980 return wd->homogeneous;
4984 * Set the maximum number of items within an item block
4986 * This will configure the block count to tune to the target with
4987 * particular performance matrix.
4989 * @param obj The genlist object
4990 * @param n Maximum number of items within an item block
4995 elm_genlist_block_count_set(Evas_Object *obj,
4998 ELM_CHECK_WIDTYPE(obj, widtype);
4999 Widget_Data *wd = elm_widget_data_get(obj);
5001 wd->max_items_per_block = n;
5002 wd->item_cache_max = wd->max_items_per_block * 2;
5003 _item_cache_clean(wd);
5007 * Get the maximum number of items within an item block
5009 * @param obj The genlist object
5010 * @return Maximum number of items within an item block
5015 elm_genlist_block_count_get(const Evas_Object *obj)
5017 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5018 Widget_Data *wd = elm_widget_data_get(obj);
5020 return wd->max_items_per_block;
5024 * Set the timeout in seconds for the longpress event
5026 * @param obj The genlist object
5027 * @param timeout timeout in seconds
5032 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5035 ELM_CHECK_WIDTYPE(obj, widtype);
5036 Widget_Data *wd = elm_widget_data_get(obj);
5038 wd->longpress_timeout = timeout;
5042 * Get the timeout in seconds for the longpress event
5044 * @param obj The genlist object
5045 * @return timeout in seconds
5050 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5052 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5053 Widget_Data *wd = elm_widget_data_get(obj);
5055 return wd->longpress_timeout;
5059 * Set the scrollbar policy
5061 * This sets the scrollbar visibility policy for the given genlist
5062 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5063 * made visible if it is needed, and otherwise kept hidden.
5064 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5065 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5066 * respectively for the horizontal and vertical scrollbars.
5068 * @param obj The genlist object
5069 * @param policy_h Horizontal scrollbar policy
5070 * @param policy_v Vertical scrollbar policy
5075 elm_genlist_scroller_policy_set(Evas_Object *obj,
5076 Elm_Scroller_Policy policy_h,
5077 Elm_Scroller_Policy policy_v)
5079 ELM_CHECK_WIDTYPE(obj, widtype);
5080 Widget_Data *wd = elm_widget_data_get(obj);
5082 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5083 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5086 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5090 * Get the scrollbar policy
5092 * @param obj The genlist object
5093 * @param policy_h Horizontal scrollbar policy
5094 * @param policy_v Vertical scrollbar policy
5099 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5100 Elm_Scroller_Policy *policy_h,
5101 Elm_Scroller_Policy *policy_v)
5103 ELM_CHECK_WIDTYPE(obj, widtype);
5104 Widget_Data *wd = elm_widget_data_get(obj);
5105 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5106 if ((!wd) || (!wd->scr)) return;
5107 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5108 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5109 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5113 * Update the contents of all realized items
5115 * This updates all realized items by calling all the item class functions again
5116 * to get the icons, labels and states. Use this when the original
5117 * item data has changed and the changes are desired to be reflected.
5119 * @param it The item
5124 elm_genlist_realized_items_update(Evas_Object *obj)
5126 ELM_CHECK_WIDTYPE(obj, widtype);
5128 Eina_List *list, *l;
5129 Elm_Genlist_Item *it;
5131 list = elm_genlist_realized_items_get(obj);
5132 EINA_LIST_FOREACH(list, l, it)
5133 elm_genlist_item_update(it);
5137 * Set genlist item mode
5139 * @param item The genlist item
5140 * @param mode Mode name
5141 * @param mode_set Boolean to define set or unset mode.
5146 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5147 const char *mode_type,
5150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5151 Widget_Data *wd = it->wd;
5153 Elm_Genlist_Item *it2;
5156 if (!mode_type) return;
5158 if ((wd->mode_item == it) &&
5159 (!strcmp(mode_type, wd->mode_type)) &&
5162 if (!it->itc->mode_item_style) return;
5166 EINA_LIST_FOREACH(wd->selected, l, it2)
5168 elm_genlist_item_selected_set(it2, EINA_FALSE);
5172 it2 = elm_genlist_selected_item_get(wd->obj);
5173 if ((it2) && (it2->realized))
5174 elm_genlist_item_selected_set(it2, EINA_FALSE);
5177 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5179 ((it == wd->mode_item) && (!mode_set)))
5180 _item_mode_unset(wd);
5182 eina_stringshare_replace(&wd->mode_type, mode_type);
5183 if (mode_set) _item_mode_set(it);
5187 * Get active genlist mode type
5189 * @param obj The genlist object
5194 elm_genlist_mode_get(const Evas_Object *obj)
5196 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5197 Widget_Data *wd = elm_widget_data_get(obj);
5198 if (!wd) return NULL;
5199 return wd->mode_type;
5203 * Get active genlist mode item
5205 * @param obj The genlist object
5209 EAPI const Elm_Genlist_Item *
5210 elm_genlist_mode_item_get(const Evas_Object *obj)
5212 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5213 Widget_Data *wd = elm_widget_data_get(obj);
5214 if (!wd) return NULL;
5215 return wd->mode_item;