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_Idler *queue_idler, *must_recalc_idler;
209 Eina_List *queue, *selected;
210 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
211 Eina_Inlist *item_cache;
214 Ecore_Timer *multi_timer, *scr_hold_timer;
215 const char *mode_type;
216 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
217 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
218 Eina_Bool mouse_down : 1;
219 Eina_Bool multi_down : 1;
220 Eina_Bool multi_timeout : 1;
221 Eina_Bool multitouched : 1;
222 Eina_Bool on_hold : 1;
224 Eina_Bool always_select : 1;
225 Eina_Bool longpressed : 1;
226 Eina_Bool wasselected : 1;
227 Eina_Bool no_select : 1;
228 Eina_Bool bring_in : 1;
229 Eina_Bool compress : 1;
230 Eina_Bool height_for_width : 1;
231 Eina_Bool homogeneous : 1;
232 Eina_Bool clear_me : 1;
237 } history[SWIPE_MOVES];
239 int item_cache_count;
245 int group_item_width;
246 int group_item_height;
247 int max_items_per_block;
248 double longpress_timeout;
258 Evas_Coord x, y, w, h, minw, minh;
259 Eina_Bool want_unrealize : 1;
260 Eina_Bool realized : 1;
261 Eina_Bool changed : 1;
262 Eina_Bool updateme : 1;
263 Eina_Bool showme : 1;
264 Eina_Bool must_recalc : 1;
267 struct _Elm_Genlist_Item
269 Elm_Widget_Item base;
274 Evas_Coord x, y, w, h, minw, minh;
275 const Elm_Genlist_Item_Class *itc;
276 Elm_Genlist_Item *parent;
277 Elm_Genlist_Item *group_item;
278 Elm_Genlist_Item_Flags flags;
286 Eina_List *labels, *icons, *states, *icon_objs;
287 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
288 Ecore_Timer *long_timer;
289 Ecore_Timer *swipe_timer;
291 Evas_Coord scrl_x, scrl_y;
293 Elm_Genlist_Item *rel;
294 Evas_Object *mode_view;
299 Elm_Tooltip_Item_Content_Cb content_cb;
300 Evas_Smart_Cb del_cb;
304 const char *mouse_cursor;
311 Eina_Bool before : 1;
313 Eina_Bool want_unrealize : 1;
314 Eina_Bool want_realize : 1;
315 Eina_Bool realized : 1;
316 Eina_Bool selected : 1;
317 Eina_Bool highlighted : 1;
318 Eina_Bool expanded : 1;
319 Eina_Bool disabled : 1;
320 Eina_Bool display_only : 1;
321 Eina_Bool mincalcd : 1;
322 Eina_Bool queued : 1;
323 Eina_Bool showme : 1;
324 Eina_Bool delete_me : 1;
326 Eina_Bool dragging : 1;
327 Eina_Bool updateme : 1;
328 Eina_Bool nocache : 1;
329 Eina_Bool stacking_even : 1;
330 Eina_Bool nostacking : 1;
337 Evas_Object *base_view, *spacer;
339 const char *item_style; // it->itc->item_style
340 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
341 Eina_Bool compress : 1; // it->wd->compress
343 Eina_Bool selected : 1; // it->selected
344 Eina_Bool disabled : 1; // it->disabled
345 Eina_Bool expanded : 1; // it->expanded
348 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
349 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
353 Evas_Object_Smart_Clipped_Data __clipped_data;
355 Ecore_Job *resize_job;
358 static const char *widtype = NULL;
359 static void _item_cache_zero(Widget_Data *wd);
360 static void _del_hook(Evas_Object *obj);
361 static void _mirrored_set(Evas_Object *obj,
363 static void _theme_hook(Evas_Object *obj);
364 static void _show_region_hook(void *data,
366 static void _sizing_eval(Evas_Object *obj);
367 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
368 static void _item_block_unrealize(Item_Block *itb);
369 static void _calc_job(void *data);
370 static void _on_focus_hook(void *data,
372 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
373 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
374 static Eina_Bool _item_single_select_up(Widget_Data *wd);
375 static Eina_Bool _item_single_select_down(Widget_Data *wd);
376 static Eina_Bool _event_hook(Evas_Object *obj,
378 Evas_Callback_Type type,
380 static void _signal_emit_hook(Evas_Object *obj,
381 const char *emission,
383 static Eina_Bool _deselect_all_items(Widget_Data *wd);
384 static void _pan_calculate(Evas_Object *obj);
385 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
386 static void _mode_item_realize(Elm_Genlist_Item *it);
387 static void _mode_item_unrealize(Elm_Genlist_Item *it);
388 static void _item_mode_set(Elm_Genlist_Item *it);
389 static void _item_mode_unset(Widget_Data *wd);
391 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
394 _event_hook(Evas_Object *obj,
395 Evas_Object *src __UNUSED__,
396 Evas_Callback_Type type,
399 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
400 Evas_Event_Key_Down *ev = event_info;
401 Widget_Data *wd = elm_widget_data_get(obj);
402 if (!wd) return EINA_FALSE;
403 if (!wd->items) return EINA_FALSE;
404 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
405 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
407 Elm_Genlist_Item *it = NULL;
410 Evas_Coord step_x = 0;
411 Evas_Coord step_y = 0;
414 Evas_Coord page_x = 0;
415 Evas_Coord page_y = 0;
417 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
418 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
419 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
420 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
422 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
426 else if ((!strcmp(ev->keyname, "Right")) ||
427 (!strcmp(ev->keyname, "KP_Right")))
431 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
433 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
434 (_item_multi_select_up(wd)))
435 || (_item_single_select_up(wd)))
437 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
443 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
445 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
446 (_item_multi_select_down(wd)))
447 || (_item_single_select_down(wd)))
449 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
455 else if ((!strcmp(ev->keyname, "Home")) ||
456 (!strcmp(ev->keyname, "KP_Home")))
458 it = elm_genlist_first_item_get(obj);
459 elm_genlist_item_bring_in(it);
460 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
463 else if ((!strcmp(ev->keyname, "End")) ||
464 (!strcmp(ev->keyname, "KP_End")))
466 it = elm_genlist_last_item_get(obj);
467 elm_genlist_item_bring_in(it);
468 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
471 else if ((!strcmp(ev->keyname, "Prior")) ||
472 (!strcmp(ev->keyname, "KP_Prior")))
475 y -= -(page_y * v_h) / 100;
479 else if ((!strcmp(ev->keyname, "Next")) ||
480 (!strcmp(ev->keyname, "KP_Next")))
483 y += -(page_y * v_h) / 100;
487 else if(((!strcmp(ev->keyname, "Return")) ||
488 (!strcmp(ev->keyname, "KP_Enter")) ||
489 (!strcmp(ev->keyname, "space")))
490 && (!wd->multi) && (wd->selected))
492 it = elm_genlist_selected_item_get(obj);
493 elm_genlist_item_expanded_set(it,
494 !elm_genlist_item_expanded_get(it));
496 else if (!strcmp(ev->keyname, "Escape"))
498 if (!_deselect_all_items(wd)) return EINA_FALSE;
499 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
502 else return EINA_FALSE;
504 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
505 elm_smart_scroller_child_pos_set(wd->scr, x, y);
510 _deselect_all_items(Widget_Data *wd)
512 if (!wd->selected) return EINA_FALSE;
514 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
520 _item_multi_select_up(Widget_Data *wd)
522 if (!wd->selected) return EINA_FALSE;
523 if (!wd->multi) return EINA_FALSE;
525 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
526 if (!prev) return EINA_TRUE;
528 if (elm_genlist_item_selected_get(prev))
530 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
531 wd->last_selected_item = prev;
532 elm_genlist_item_show(wd->last_selected_item);
536 elm_genlist_item_selected_set(prev, EINA_TRUE);
537 elm_genlist_item_show(prev);
543 _item_multi_select_down(Widget_Data *wd)
545 if (!wd->selected) return EINA_FALSE;
546 if (!wd->multi) return EINA_FALSE;
548 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
549 if (!next) return EINA_TRUE;
551 if (elm_genlist_item_selected_get(next))
553 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
554 wd->last_selected_item = next;
555 elm_genlist_item_show(wd->last_selected_item);
559 elm_genlist_item_selected_set(next, EINA_TRUE);
560 elm_genlist_item_show(next);
566 _item_single_select_up(Widget_Data *wd)
568 Elm_Genlist_Item *prev;
571 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
572 while ((prev) && (prev->delete_me))
573 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
575 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
577 if (!prev) return EINA_FALSE;
579 _deselect_all_items(wd);
581 elm_genlist_item_selected_set(prev, EINA_TRUE);
582 elm_genlist_item_show(prev);
587 _item_single_select_down(Widget_Data *wd)
589 Elm_Genlist_Item *next;
592 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
593 while ((next) && (next->delete_me))
594 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
596 else next = elm_genlist_item_next_get(wd->last_selected_item);
598 if (!next) return EINA_FALSE;
600 _deselect_all_items(wd);
602 elm_genlist_item_selected_set(next, EINA_TRUE);
603 elm_genlist_item_show(next);
608 _on_focus_hook(void *data __UNUSED__,
611 Widget_Data *wd = elm_widget_data_get(obj);
613 if (elm_widget_focus_get(obj))
615 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
616 evas_object_focus_set(wd->obj, EINA_TRUE);
617 if ((wd->selected) && (!wd->last_selected_item))
618 wd->last_selected_item = eina_list_data_get(wd->selected);
622 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
623 evas_object_focus_set(wd->obj, EINA_FALSE);
628 _del_hook(Evas_Object *obj)
630 Widget_Data *wd = elm_widget_data_get(obj);
632 _item_cache_zero(wd);
633 if (wd->calc_job) ecore_job_del(wd->calc_job);
634 if (wd->update_job) ecore_job_del(wd->update_job);
635 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
636 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
637 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
638 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
643 _del_pre_hook(Evas_Object *obj)
645 Widget_Data *wd = elm_widget_data_get(obj);
647 evas_object_del(wd->pan_smart);
648 wd->pan_smart = NULL;
649 elm_genlist_clear(obj);
653 _mirrored_set(Evas_Object *obj,
656 Widget_Data *wd = elm_widget_data_get(obj);
658 _item_cache_zero(wd);
659 elm_smart_scroller_mirrored_set(wd->scr, rtl);
663 _theme_hook(Evas_Object *obj)
665 Widget_Data *wd = elm_widget_data_get(obj);
668 _item_cache_zero(wd);
669 _elm_widget_mirrored_reload(obj);
670 _mirrored_set(obj, elm_widget_mirrored_get(obj));
671 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
672 elm_widget_style_get(obj));
673 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
674 wd->item_width = wd->item_height = 0;
675 wd->group_item_width = wd->group_item_height = 0;
676 wd->minw = wd->minh = wd->realminw = 0;
677 EINA_INLIST_FOREACH(wd->blocks, itb)
680 Elm_Genlist_Item *it;
682 if (itb->realized) _item_block_unrealize(itb);
683 EINA_LIST_FOREACH(itb->items, l, it)
684 it->mincalcd = EINA_FALSE;
686 itb->changed = EINA_TRUE;
688 if (wd->calc_job) ecore_job_del(wd->calc_job);
689 wd->calc_job = ecore_job_add(_calc_job, wd);
694 _show_region_hook(void *data,
697 Widget_Data *wd = elm_widget_data_get(data);
698 Evas_Coord x, y, w, h;
700 elm_widget_show_region_get(obj, &x, &y, &w, &h);
701 //x & y are screen coordinates, Add with pan coordinates
704 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
708 _sizing_eval(Evas_Object *obj)
710 Widget_Data *wd = elm_widget_data_get(obj);
711 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
713 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
714 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
716 if (wd->height_for_width)
720 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
721 if ((vw != 0) && (vw != wd->prev_viewport_w))
725 wd->prev_viewport_w = vw;
726 EINA_INLIST_FOREACH(wd->blocks, itb)
728 itb->must_recalc = EINA_TRUE;
730 if (wd->calc_job) ecore_job_del(wd->calc_job);
731 wd->calc_job = ecore_job_add(_calc_job, wd);
734 if (wd->mode == ELM_LIST_LIMIT)
736 Evas_Coord vmw, vmh, vw, vh;
740 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
741 if ((minw > 0) && (vw < minw)) vw = minw;
742 else if ((maxw > 0) && (vw > maxw))
744 edje_object_size_min_calc
745 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
752 edje_object_size_min_calc
753 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
757 evas_object_size_hint_min_set(obj, minw, minh);
758 evas_object_size_hint_max_set(obj, maxw, maxh);
762 _signal_emit_hook(Evas_Object *obj,
763 const char *emission,
766 Widget_Data *wd = elm_widget_data_get(obj);
767 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
772 _item_highlight(Elm_Genlist_Item *it)
774 const char *selectraise;
775 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
776 (it->disabled) || (it->display_only) || (it->mode_view))
778 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
779 selectraise = edje_object_data_get(it->base.view, "selectraise");
780 if ((selectraise) && (!strcmp(selectraise, "on")))
782 evas_object_raise(it->base.view);
783 if ((it->group_item) && (it->group_item->realized))
784 evas_object_raise(it->group_item->base.view);
786 it->highlighted = EINA_TRUE;
790 _item_block_del(Elm_Genlist_Item *it)
793 Item_Block *itb = it->block;
795 itb->items = eina_list_remove(itb->items, it);
797 itb->changed = EINA_TRUE;
798 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
799 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
802 il = EINA_INLIST_GET(itb);
803 Item_Block *itbn = (Item_Block *)(il->next);
805 it->parent->items = eina_list_remove(it->parent->items, it);
807 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
809 if (itbn) itbn->changed = EINA_TRUE;
815 il = EINA_INLIST_GET(itb);
816 Item_Block *itbp = (Item_Block *)(il->prev);
817 Item_Block *itbn = (Item_Block *)(il->next);
818 if ((itbp) && ((itbp->count + itb->count) < 48))
820 Elm_Genlist_Item *it2;
822 EINA_LIST_FREE(itb->items, it2)
825 itbp->items = eina_list_append(itbp->items, it2);
827 itbp->changed = EINA_TRUE;
829 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
830 EINA_INLIST_GET(itb));
833 else if ((itbn) && ((itbn->count + itb->count) < 48))
837 Eina_List *last = eina_list_last(itb->items);
838 Elm_Genlist_Item *it2 = last->data;
841 itb->items = eina_list_remove_list(itb->items, last);
842 itbn->items = eina_list_prepend(itbn->items, it2);
844 itbn->changed = EINA_TRUE;
847 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
855 _item_del(Elm_Genlist_Item *it)
857 elm_widget_item_pre_notify_del(it);
858 elm_genlist_item_subitems_clear(it);
859 it->wd->walking -= it->walking;
860 if (it->wd->show_item == it) it->wd->show_item = NULL;
861 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
862 if (it->realized) _item_unrealize(it, EINA_FALSE);
863 if (it->block) _item_block_del(it);
864 if ((!it->delete_me) && (it->itc->func.del))
865 it->itc->func.del((void *)it->base.data, it->base.widget);
866 it->delete_me = EINA_TRUE;
868 it->wd->queue = eina_list_remove(it->wd->queue, it);
869 if (it->wd->anchor_item == it)
871 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
872 if (!it->wd->anchor_item)
873 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
875 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
877 it->parent->items = eina_list_remove(it->parent->items, it);
878 if (it->flags & ELM_GENLIST_ITEM_GROUP)
879 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
880 if (it->long_timer) ecore_timer_del(it->long_timer);
881 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
883 if (it->tooltip.del_cb)
884 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
886 elm_widget_item_del(it);
890 _item_select(Elm_Genlist_Item *it)
892 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
895 if (it->wd->always_select) goto call;
898 it->selected = EINA_TRUE;
899 it->wd->selected = eina_list_append(it->wd->selected, it);
903 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
905 evas_object_smart_callback_call(it->base.widget, "selected", it);
908 if ((it->wd->clear_me) && (!it->wd->walking))
909 elm_genlist_clear(it->base.widget);
912 if ((!it->walking) && (it->delete_me))
914 if (!it->relcount) _item_del(it);
917 it->wd->last_selected_item = it;
921 _item_unselect(Elm_Genlist_Item *it)
923 const char *stacking, *selectraise;
925 if ((it->delete_me) || (!it->highlighted)) return;
926 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
927 stacking = edje_object_data_get(it->base.view, "stacking");
928 selectraise = edje_object_data_get(it->base.view, "selectraise");
931 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
932 else evas_object_raise(it->base.view);
934 it->highlighted = EINA_FALSE;
937 it->selected = EINA_FALSE;
938 it->wd->selected = eina_list_remove(it->wd->selected, it);
939 evas_object_smart_callback_call(it->base.widget, "unselected", it);
944 _mouse_move(void *data,
945 Evas *evas __UNUSED__,
949 Elm_Genlist_Item *it = data;
950 Evas_Event_Mouse_Move *ev = event_info;
951 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
953 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
955 if (!it->wd->on_hold)
957 it->wd->on_hold = EINA_TRUE;
958 if (!it->wd->wasselected)
962 if (it->wd->multitouched)
964 it->wd->cur_x = ev->cur.canvas.x;
965 it->wd->cur_y = ev->cur.canvas.y;
968 if ((it->dragging) && (it->down))
970 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
973 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
974 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
975 if (abs((it->wd->history[it->wd->movements].x -
976 it->wd->history[0].x)) > 40)
977 it->wd->swipe = EINA_TRUE;
983 ecore_timer_del(it->long_timer);
984 it->long_timer = NULL;
986 evas_object_smart_callback_call(it->base.widget, "drag", it);
989 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
993 ecore_timer_del(it->long_timer);
994 it->long_timer = NULL;
998 if (!it->display_only)
999 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1000 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1001 x = ev->cur.canvas.x - x;
1002 y = ev->cur.canvas.y - y;
1005 if (adx < 0) adx = -dx;
1008 if (ady < 0) ady = -dy;
1011 if ((adx > minw) || (ady > minh))
1013 it->dragging = EINA_TRUE;
1016 ecore_timer_del(it->long_timer);
1017 it->long_timer = NULL;
1019 if (!it->wd->wasselected)
1024 evas_object_smart_callback_call(it->base.widget,
1025 "drag,start,up", it);
1029 evas_object_smart_callback_call(it->base.widget,
1030 "drag,start,left", it);
1032 evas_object_smart_callback_call(it->base.widget,
1033 "drag,start,right", it);
1039 evas_object_smart_callback_call(it->base.widget,
1040 "drag,start,down", it);
1044 evas_object_smart_callback_call(it->base.widget,
1045 "drag,start,left", it);
1047 evas_object_smart_callback_call(it->base.widget,
1048 "drag,start,right", it);
1055 _long_press(void *data)
1057 Elm_Genlist_Item *it = data;
1059 it->long_timer = NULL;
1060 if ((it->disabled) || (it->dragging) || (it->display_only))
1061 return ECORE_CALLBACK_CANCEL;
1062 it->wd->longpressed = EINA_TRUE;
1063 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1064 return ECORE_CALLBACK_CANCEL;
1068 _swipe(Elm_Genlist_Item *it)
1073 if ((it->display_only) || (it->disabled)) return;
1074 it->wd->swipe = EINA_FALSE;
1075 for (i = 0; i < it->wd->movements; i++)
1077 sum += it->wd->history[i].x;
1078 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1081 sum /= it->wd->movements;
1082 if (abs(sum - it->wd->history[0].x) <= 10) return;
1083 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1087 _swipe_cancel(void *data)
1089 Elm_Genlist_Item *it = data;
1091 if (!it) return ECORE_CALLBACK_CANCEL;
1092 it->wd->swipe = EINA_FALSE;
1093 it->wd->movements = 0;
1094 return ECORE_CALLBACK_RENEW;
1098 _multi_cancel(void *data)
1100 Widget_Data *wd = data;
1102 if (!wd) return ECORE_CALLBACK_CANCEL;
1103 wd->multi_timeout = EINA_TRUE;
1104 return ECORE_CALLBACK_RENEW;
1108 _multi_touch_gesture_eval(void *data)
1110 Elm_Genlist_Item *it = data;
1112 it->wd->multitouched = EINA_FALSE;
1113 if (it->wd->multi_timer)
1115 ecore_timer_del(it->wd->multi_timer);
1116 it->wd->multi_timer = NULL;
1118 if (it->wd->multi_timeout)
1120 it->wd->multi_timeout = EINA_FALSE;
1124 Evas_Coord minw = 0, minh = 0;
1125 Evas_Coord off_x, off_y, off_mx, off_my;
1127 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1128 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1129 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1130 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1131 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1133 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1135 if ((off_x + off_mx) > (off_y + off_my))
1137 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1138 evas_object_smart_callback_call(it->base.widget,
1139 "multi,swipe,right", it);
1140 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1141 evas_object_smart_callback_call(it->base.widget,
1142 "multi,swipe,left", it);
1143 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1144 evas_object_smart_callback_call(it->base.widget,
1145 "multi,pinch,out", it);
1147 evas_object_smart_callback_call(it->base.widget,
1148 "multi,pinch,in", it);
1152 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1153 evas_object_smart_callback_call(it->base.widget,
1154 "multi,swipe,down", it);
1155 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1156 evas_object_smart_callback_call(it->base.widget,
1157 "multi,swipe,up", it);
1158 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1159 evas_object_smart_callback_call(it->base.widget,
1160 "multi,pinch,out", it);
1162 evas_object_smart_callback_call(it->base.widget,
1163 "multi,pinch,in", it);
1166 it->wd->multi_timeout = EINA_FALSE;
1170 _multi_down(void *data,
1171 Evas *evas __UNUSED__,
1172 Evas_Object *obj __UNUSED__,
1175 Elm_Genlist_Item *it = data;
1176 Evas_Event_Multi_Down *ev = event_info;
1178 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1179 it->wd->multi_device = ev->device;
1180 it->wd->multi_down = EINA_TRUE;
1181 it->wd->multitouched = EINA_TRUE;
1182 it->wd->prev_mx = ev->canvas.x;
1183 it->wd->prev_my = ev->canvas.y;
1184 if (!it->wd->wasselected) _item_unselect(it);
1185 it->wd->wasselected = EINA_FALSE;
1186 it->wd->longpressed = EINA_FALSE;
1189 ecore_timer_del(it->long_timer);
1190 it->long_timer = NULL;
1194 it->dragging = EINA_FALSE;
1195 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1197 if (it->swipe_timer)
1199 ecore_timer_del(it->swipe_timer);
1200 it->swipe_timer = NULL;
1202 if (it->wd->on_hold)
1204 it->wd->swipe = EINA_FALSE;
1205 it->wd->movements = 0;
1206 it->wd->on_hold = EINA_FALSE;
1211 _multi_up(void *data,
1212 Evas *evas __UNUSED__,
1213 Evas_Object *obj __UNUSED__,
1216 Elm_Genlist_Item *it = data;
1217 Evas_Event_Multi_Up *ev = event_info;
1219 if (it->wd->multi_device != ev->device) return;
1220 it->wd->multi_device = 0;
1221 it->wd->multi_down = EINA_FALSE;
1222 if (it->wd->mouse_down) return;
1223 _multi_touch_gesture_eval(data);
1227 _multi_move(void *data,
1228 Evas *evas __UNUSED__,
1229 Evas_Object *obj __UNUSED__,
1232 Elm_Genlist_Item *it = data;
1233 Evas_Event_Multi_Move *ev = event_info;
1235 if (it->wd->multi_device != ev->device) return;
1236 it->wd->cur_mx = ev->cur.canvas.x;
1237 it->wd->cur_my = ev->cur.canvas.y;
1241 _mouse_down(void *data,
1242 Evas *evas __UNUSED__,
1246 Elm_Genlist_Item *it = data;
1247 Evas_Event_Mouse_Down *ev = event_info;
1250 if (ev->button != 1) return;
1251 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1253 it->wd->on_hold = EINA_TRUE;
1256 it->down = EINA_TRUE;
1257 it->dragging = EINA_FALSE;
1258 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1259 it->dx = ev->canvas.x - x;
1260 it->dy = ev->canvas.y - y;
1261 it->wd->mouse_down = EINA_TRUE;
1262 if (!it->wd->multitouched)
1264 it->wd->prev_x = ev->canvas.x;
1265 it->wd->prev_y = ev->canvas.y;
1266 it->wd->multi_timeout = EINA_FALSE;
1267 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1268 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1270 it->wd->longpressed = EINA_FALSE;
1271 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1272 else it->wd->on_hold = EINA_FALSE;
1273 if (it->wd->on_hold) return;
1274 it->wd->wasselected = it->selected;
1275 _item_highlight(it);
1276 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1277 if ((!it->disabled) && (!it->display_only))
1279 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1280 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1282 if (it->long_timer) ecore_timer_del(it->long_timer);
1283 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1284 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1286 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1289 it->long_timer = NULL;
1290 it->wd->swipe = EINA_FALSE;
1291 it->wd->movements = 0;
1295 _mouse_up(void *data,
1296 Evas *evas __UNUSED__,
1297 Evas_Object *obj __UNUSED__,
1300 Elm_Genlist_Item *it = data;
1301 Evas_Event_Mouse_Up *ev = event_info;
1302 Eina_Bool dragged = EINA_FALSE;
1304 if (ev->button != 1) return;
1305 it->down = EINA_FALSE;
1306 it->wd->mouse_down = EINA_FALSE;
1307 if (it->wd->multitouched)
1309 if (it->wd->multi_down) return;
1310 _multi_touch_gesture_eval(data);
1313 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1314 else it->wd->on_hold = EINA_FALSE;
1317 ecore_timer_del(it->long_timer);
1318 it->long_timer = NULL;
1322 it->dragging = EINA_FALSE;
1323 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1326 if (it->swipe_timer)
1328 ecore_timer_del(it->swipe_timer);
1329 it->swipe_timer = NULL;
1331 if (it->wd->multi_timer)
1333 ecore_timer_del(it->wd->multi_timer);
1334 it->wd->multi_timer = NULL;
1335 it->wd->multi_timeout = EINA_FALSE;
1337 if (it->wd->on_hold)
1339 if (it->wd->swipe) _swipe(data);
1340 it->wd->longpressed = EINA_FALSE;
1341 it->wd->on_hold = EINA_FALSE;
1344 if (it->wd->longpressed)
1346 it->wd->longpressed = EINA_FALSE;
1347 if (!it->wd->wasselected)
1349 it->wd->wasselected = EINA_FALSE;
1354 if (it->want_unrealize)
1356 _item_unrealize(it, EINA_FALSE);
1357 if (it->block->want_unrealize)
1358 _item_block_unrealize(it->block);
1361 if ((it->disabled) || (dragged) || (it->display_only)) return;
1362 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1367 _item_highlight(it);
1370 else _item_unselect(it);
1376 Widget_Data *wd = it->wd;
1379 while (wd->selected) _item_unselect(wd->selected->data);
1384 const Eina_List *l, *l_next;
1385 Elm_Genlist_Item *it2;
1387 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1388 if (it2 != it) _item_unselect(it2);
1389 //_item_highlight(it);
1392 _item_highlight(it);
1398 _signal_expand_toggle(void *data,
1399 Evas_Object *obj __UNUSED__,
1400 const char *emission __UNUSED__,
1401 const char *source __UNUSED__)
1403 Elm_Genlist_Item *it = data;
1406 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1408 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1412 _signal_expand(void *data,
1413 Evas_Object *obj __UNUSED__,
1414 const char *emission __UNUSED__,
1415 const char *source __UNUSED__)
1417 Elm_Genlist_Item *it = data;
1420 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1424 _signal_contract(void *data,
1425 Evas_Object *obj __UNUSED__,
1426 const char *emission __UNUSED__,
1427 const char *source __UNUSED__)
1429 Elm_Genlist_Item *it = data;
1432 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1436 _scr_hold_timer_cb(void *data)
1438 if (!data) return ECORE_CALLBACK_CANCEL;
1439 Widget_Data *wd = data;
1440 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1441 wd->scr_hold_timer = NULL;
1442 return ECORE_CALLBACK_CANCEL;
1446 _mode_finished_signal_cb(void *data,
1448 const char *emission __UNUSED__,
1449 const char *source __UNUSED__)
1453 Elm_Genlist_Item *it = data;
1454 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1457 it->nocache = EINA_FALSE;
1458 _mode_item_unrealize(it);
1459 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1460 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1464 _item_cache_clean(Widget_Data *wd)
1466 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1470 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1471 wd->item_cache = eina_inlist_remove(wd->item_cache,
1472 wd->item_cache->last);
1473 wd->item_cache_count--;
1474 if (itc->spacer) evas_object_del(itc->spacer);
1475 if (itc->base_view) evas_object_del(itc->base_view);
1476 if (itc->item_style) eina_stringshare_del(itc->item_style);
1482 _item_cache_zero(Widget_Data *wd)
1484 int pmax = wd->item_cache_max;
1485 wd->item_cache_max = 0;
1486 _item_cache_clean(wd);
1487 wd->item_cache_max = pmax;
1491 _item_cache_add(Elm_Genlist_Item *it)
1495 if (it->wd->item_cache_max <= 0)
1497 evas_object_del(it->base.view);
1498 it->base.view = NULL;
1499 evas_object_del(it->spacer);
1504 it->wd->item_cache_count++;
1505 itc = calloc(1, sizeof(Item_Cache));
1506 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1507 EINA_INLIST_GET(itc));
1508 itc->spacer = it->spacer;
1510 itc->base_view = it->base.view;
1511 it->base.view = NULL;
1512 evas_object_hide(itc->base_view);
1513 evas_object_move(itc->base_view, -9999, -9999);
1514 itc->item_style = eina_stringshare_add(it->itc->item_style);
1515 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1516 itc->compress = (it->wd->compress);
1517 itc->selected = it->selected;
1518 itc->disabled = it->disabled;
1519 itc->expanded = it->expanded;
1522 ecore_timer_del(it->long_timer);
1523 it->long_timer = NULL;
1525 if (it->swipe_timer)
1527 ecore_timer_del(it->swipe_timer);
1528 it->swipe_timer = NULL;
1530 // FIXME: other callbacks?
1531 edje_object_signal_callback_del_full(itc->base_view,
1532 "elm,action,expand,toggle",
1533 "elm", _signal_expand_toggle, it);
1534 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1536 _signal_expand, it);
1537 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1538 "elm", _signal_contract, it);
1539 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1541 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1543 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1545 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1547 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1549 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1551 _item_cache_clean(it->wd);
1555 _item_cache_find(Elm_Genlist_Item *it)
1560 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1561 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1563 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1565 if ((itc->tree == tree) &&
1566 (itc->compress == it->wd->compress) &&
1567 (!strcmp(it->itc->item_style, itc->item_style)))
1569 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1570 EINA_INLIST_GET(itc));
1571 it->wd->item_cache_count--;
1579 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1581 if (!it->nostacking)
1583 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1584 evas_object_lower(it->base.view);
1586 evas_object_raise(it->base.view);
1589 if (it->order_num_in & 0x1)
1590 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1592 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1596 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1600 if (it->selected != itc->selected)
1603 edje_object_signal_emit(it->base.view,
1604 "elm,state,selected", "elm");
1606 if (it->disabled != itc->disabled)
1609 edje_object_signal_emit(it->base.view,
1610 "elm,state,disabled", "elm");
1612 if (it->expanded != itc->expanded)
1615 edje_object_signal_emit(it->base.view,
1616 "elm,state,expanded", "elm");
1622 edje_object_signal_emit(it->base.view,
1623 "elm,state,selected", "elm");
1625 edje_object_signal_emit(it->base.view,
1626 "elm,state,disabled", "elm");
1628 edje_object_signal_emit(it->base.view,
1629 "elm,state,expanded", "elm");
1634 _item_cache_free(Item_Cache *itc)
1636 if (itc->spacer) evas_object_del(itc->spacer);
1637 if (itc->base_view) evas_object_del(itc->base_view);
1638 if (itc->item_style) eina_stringshare_del(itc->item_style);
1643 _item_label_realize(Elm_Genlist_Item *it,
1644 Evas_Object *target,
1647 if (it->itc->func.label_get)
1652 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1653 EINA_LIST_FOREACH(*source, l, key)
1655 char *s = it->itc->func.label_get
1656 ((void *)it->base.data, it->base.widget, key);
1660 edje_object_part_text_set(target, key, s);
1665 edje_object_part_text_set(target, key, "");
1672 _item_icon_realize(Elm_Genlist_Item *it,
1673 Evas_Object *target,
1676 Eina_List *res = NULL;
1678 if (it->itc->func.icon_get)
1683 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1684 EINA_LIST_FOREACH(*source, l, key)
1686 Evas_Object *ic = it->itc->func.icon_get
1687 ((void *)it->base.data, it->base.widget, key);
1691 res = eina_list_append(res, ic);
1692 edje_object_part_swallow(target, key, ic);
1693 evas_object_show(ic);
1694 elm_widget_sub_object_add(it->base.widget, ic);
1703 _item_state_realize(Elm_Genlist_Item *it,
1704 Evas_Object *target,
1707 if (it->itc->func.state_get)
1713 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1714 EINA_LIST_FOREACH(*source, l, key)
1716 Eina_Bool on = it->itc->func.state_get
1717 ((void *)it->base.data, it->base.widget, key);
1721 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1722 edje_object_signal_emit(target, buf, "elm");
1726 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1727 edje_object_signal_emit(target, buf, "elm");
1734 _item_realize(Elm_Genlist_Item *it,
1738 Elm_Genlist_Item *it2;
1739 const char *treesize;
1741 int depth, tsize = 20;
1742 Item_Cache *itc = NULL;
1744 if (it->delete_me) return ;
1747 if (it->order_num_in != in)
1749 it->order_num_in = in;
1750 _elm_genlist_item_odd_even_update(it);
1751 _elm_genlist_item_state_update(it, NULL);
1755 it->order_num_in = in;
1758 it->nocache = EINA_FALSE;
1760 itc = _item_cache_find(it);
1763 it->base.view = itc->base_view;
1764 itc->base_view = NULL;
1765 it->spacer = itc->spacer;
1770 const char *stacking_even;
1771 const char *stacking;
1773 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1774 edje_object_scale_set(it->base.view,
1775 elm_widget_scale_get(it->base.widget) *
1776 _elm_config->scale);
1777 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1778 elm_widget_sub_object_add(it->base.widget, it->base.view);
1780 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1781 strncpy(buf, "tree", sizeof(buf));
1782 else strncpy(buf, "item", sizeof(buf));
1783 if (it->wd->compress)
1784 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1786 strncat(buf, "/", sizeof(buf) - strlen(buf));
1787 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1789 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1790 elm_widget_style_get(it->base.widget));
1792 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1793 if (!stacking_even) stacking_even = "above";
1794 it->stacking_even = !!strcmp("above", stacking_even);
1796 stacking = edje_object_data_get(it->base.view, "stacking");
1797 if (!stacking) stacking = "yes";
1798 it->nostacking = !!strcmp("yes", stacking);
1800 edje_object_mirrored_set(it->base.view,
1801 elm_widget_mirrored_get(it->base.widget));
1803 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1804 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1805 elm_widget_sub_object_add(it->base.widget, it->spacer);
1808 _elm_genlist_item_odd_even_update(it);
1810 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1812 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1814 it->expanded_depth = depth;
1815 treesize = edje_object_data_get(it->base.view, "treesize");
1816 if (treesize) tsize = atoi(treesize);
1817 evas_object_size_hint_min_set(it->spacer,
1818 (depth * tsize) * _elm_config->scale, 1);
1819 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1822 edje_object_signal_callback_add(it->base.view,
1823 "elm,action,expand,toggle",
1824 "elm", _signal_expand_toggle, it);
1825 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1826 "elm", _signal_expand, it);
1827 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1828 "elm", _signal_contract, it);
1829 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1831 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1833 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1835 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1837 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1839 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1842 _elm_genlist_item_state_update(it, itc);
1845 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1847 /* homogenous genlist shortcut */
1850 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1852 it->w = it->minw = it->wd->group_item_width;
1853 it->h = it->minh = it->wd->group_item_height;
1857 it->w = it->minw = it->wd->item_width;
1858 it->h = it->minh = it->wd->item_height;
1860 it->mincalcd = EINA_TRUE;
1865 /* FIXME: If you see that assert, please notify us and we
1866 will clean our mess */
1867 assert(eina_list_count(it->icon_objs) == 0);
1869 _item_label_realize(it, it->base.view, &it->labels);
1870 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1871 _item_state_realize(it, it->base.view, &it->states);
1875 Evas_Coord mw = -1, mh = -1;
1877 if (it->wd->height_for_width) mw = it->wd->w;
1879 if (!it->display_only)
1880 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1881 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1882 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1884 if (!it->display_only)
1885 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1886 it->w = it->minw = mw;
1887 it->h = it->minh = mh;
1888 it->mincalcd = EINA_TRUE;
1890 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1892 it->wd->group_item_width = mw;
1893 it->wd->group_item_height = mh;
1895 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1897 it->wd->item_width = mw;
1898 it->wd->item_height = mh;
1901 if (!calc) evas_object_show(it->base.view);
1904 if (it->tooltip.content_cb)
1906 elm_widget_item_tooltip_content_cb_set(it,
1907 it->tooltip.content_cb,
1908 it->tooltip.data, NULL);
1909 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1912 if (it->mouse_cursor)
1913 elm_widget_item_cursor_set(it, it->mouse_cursor);
1915 it->realized = EINA_TRUE;
1916 it->want_unrealize = EINA_FALSE;
1918 if (itc) _item_cache_free(itc);
1919 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1923 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1927 if (!it->realized) return;
1928 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1931 ecore_timer_del(it->long_timer);
1932 it->long_timer = NULL;
1936 evas_object_del(it->base.view);
1937 it->base.view = NULL;
1938 evas_object_del(it->spacer);
1943 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1944 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
1945 _item_cache_add(it);
1947 elm_widget_stringlist_free(it->labels);
1949 elm_widget_stringlist_free(it->icons);
1951 elm_widget_stringlist_free(it->states);
1953 EINA_LIST_FREE(it->icon_objs, icon)
1954 evas_object_del(icon);
1956 _mode_item_unrealize(it);
1958 it->realized = EINA_FALSE;
1959 it->want_unrealize = EINA_FALSE;
1963 _item_block_recalc(Item_Block *itb,
1969 Elm_Genlist_Item *it;
1970 Evas_Coord minw = 0, minh = 0;
1971 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1975 EINA_LIST_FOREACH(itb->items, l, it)
1977 if (it->delete_me) continue;
1978 showme |= it->showme;
1983 if (!it->mincalcd) changed = EINA_TRUE;
1986 _item_realize(it, in, EINA_TRUE);
1987 _item_unrealize(it, EINA_TRUE);
1992 _item_realize(it, in, EINA_TRUE);
1993 _item_unrealize(it, EINA_TRUE);
1997 _item_realize(it, in, EINA_FALSE);
1999 if (minw < it->minw) minw = it->minw;
2007 itb->changed = EINA_FALSE;
2008 /* force an evas norender to garbage collect deleted objects */
2009 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2014 _item_block_realize(Item_Block *itb,
2019 Elm_Genlist_Item *it;
2021 if (itb->realized) return;
2022 EINA_LIST_FOREACH(itb->items, l, it)
2024 if (it->delete_me) continue;
2025 if (full) _item_realize(it, in, EINA_FALSE);
2028 itb->realized = EINA_TRUE;
2029 itb->want_unrealize = EINA_FALSE;
2033 _item_block_unrealize(Item_Block *itb)
2036 Elm_Genlist_Item *it;
2037 Eina_Bool dragging = EINA_FALSE;
2039 if (!itb->realized) return;
2040 EINA_LIST_FOREACH(itb->items, l, it)
2042 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2046 dragging = EINA_TRUE;
2047 it->want_unrealize = EINA_TRUE;
2050 _item_unrealize(it, EINA_FALSE);
2055 itb->realized = EINA_FALSE;
2056 itb->want_unrealize = EINA_TRUE;
2059 itb->want_unrealize = EINA_FALSE;
2063 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2068 evas_object_resize(view, it->w, it->h);
2069 evas_object_move(view, it->scrl_x, it->scrl_y);
2070 evas_object_show(view);
2074 _item_block_position(Item_Block *itb,
2078 Elm_Genlist_Item *it;
2079 Elm_Genlist_Item *git;
2080 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2083 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2084 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2086 EINA_LIST_FOREACH(itb->items, l, it)
2088 if (it->delete_me) continue;
2092 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2093 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2095 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2096 cvx, cvy, cvw, cvh));
2097 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2099 if ((itb->realized) && (!it->realized))
2101 if (vis) _item_realize(it, in, EINA_FALSE);
2107 git = it->group_item;
2110 if (git->scrl_y < oy)
2112 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2113 git->scrl_y = (it->scrl_y + it->h) - git->h;
2114 git->want_realize = EINA_TRUE;
2117 _item_position(it, it->mode_view);
2119 _item_position(it, it->base.view);
2123 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2130 if (vis) it->want_realize = EINA_TRUE;
2137 _group_items_recalc(void *data)
2139 Widget_Data *wd = data;
2141 Elm_Genlist_Item *git;
2143 EINA_LIST_FOREACH(wd->group_items, l, git)
2145 if (git->want_realize)
2148 _item_realize(git, 0, EINA_FALSE);
2149 evas_object_resize(git->base.view, wd->minw, git->h);
2150 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2151 evas_object_show(git->base.view);
2152 evas_object_raise(git->base.view);
2154 else if (!git->want_realize && git->realized)
2157 _item_unrealize(git, EINA_FALSE);
2163 _must_recalc_idler(void *data)
2165 Widget_Data *wd = data;
2166 if (wd->calc_job) ecore_job_del(wd->calc_job);
2167 wd->calc_job = ecore_job_add(_calc_job, wd);
2168 wd->must_recalc_idler = NULL;
2169 return ECORE_CALLBACK_CANCEL;
2173 _calc_job(void *data)
2175 Widget_Data *wd = data;
2177 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2178 Item_Block *chb = NULL;
2179 int in = 0, minw_change = 0;
2180 Eina_Bool changed = EINA_FALSE;
2182 Eina_Bool did_must_recalc = EINA_FALSE;
2185 t0 = ecore_time_get();
2186 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2190 // if (wd->height_for_width) changed = EINA_TRUE;
2193 EINA_INLIST_FOREACH(wd->blocks, itb)
2195 Eina_Bool showme = EINA_FALSE;
2198 showme = itb->showme;
2199 itb->showme = EINA_FALSE;
2202 if (itb->realized) _item_block_unrealize(itb);
2204 if ((itb->changed) || (changed) ||
2205 ((itb->must_recalc) && (!did_must_recalc)))
2207 if ((changed) || (itb->must_recalc))
2210 Elm_Genlist_Item *it;
2211 EINA_LIST_FOREACH(itb->items, l, it)
2212 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2213 itb->changed = EINA_TRUE;
2214 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2215 itb->must_recalc = EINA_FALSE;
2217 if (itb->realized) _item_block_unrealize(itb);
2218 showme = _item_block_recalc(itb, in, 0, 1);
2224 if (minw == -1) minw = itb->minw;
2225 else if ((!itb->must_recalc) && (minw < itb->minw))
2234 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2236 wd->show_item->showme = EINA_FALSE;
2238 elm_smart_scroller_region_bring_in(wd->scr,
2240 wd->show_item->block->x,
2242 wd->show_item->block->y,
2243 wd->show_item->block->w,
2246 elm_smart_scroller_child_region_show(wd->scr,
2248 wd->show_item->block->x,
2250 wd->show_item->block->y,
2251 wd->show_item->block->w,
2253 wd->show_item = NULL;
2258 EINA_INLIST_FOREACH(wd->blocks, itb)
2264 if ((chb) && (EINA_INLIST_GET(chb)->next))
2266 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2268 if (itb->realized) _item_block_unrealize(itb);
2271 wd->realminw = minw;
2272 if (minw < wd->w) minw = wd->w;
2273 if ((minw != wd->minw) || (minh != wd->minh))
2277 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2278 _sizing_eval(wd->obj);
2279 if ((wd->anchor_item) && (wd->anchor_item->block))
2281 Elm_Genlist_Item *it;
2284 it = wd->anchor_item;
2285 it_y = wd->anchor_y;
2286 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2287 it->block->y + it->y + it_y);
2288 wd->anchor_item = it;
2289 wd->anchor_y = it_y;
2292 t = ecore_time_get();
2293 if (did_must_recalc)
2295 if (!wd->must_recalc_idler)
2296 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2298 wd->calc_job = NULL;
2299 evas_object_smart_changed(wd->pan_smart);
2303 _update_job(void *data)
2305 Widget_Data *wd = data;
2308 int num, num0, position = 0, recalc = 0;
2310 wd->update_job = NULL;
2312 EINA_INLIST_FOREACH(wd->blocks, itb)
2314 Evas_Coord itminw, itminh;
2315 Elm_Genlist_Item *it;
2321 _item_block_position(itb, num);
2326 EINA_LIST_FOREACH(itb->items, l2, it)
2333 it->updateme = EINA_FALSE;
2336 _item_unrealize(it, EINA_FALSE);
2337 _item_realize(it, num, EINA_FALSE);
2342 _item_realize(it, num, EINA_TRUE);
2343 _item_unrealize(it, EINA_TRUE);
2345 if ((it->minw != itminw) || (it->minh != itminh))
2350 itb->updateme = EINA_FALSE;
2354 itb->changed = EINA_TRUE;
2355 _item_block_recalc(itb, num0, 0, 1);
2356 _item_block_position(itb, num0);
2361 if (wd->calc_job) ecore_job_del(wd->calc_job);
2362 wd->calc_job = ecore_job_add(_calc_job, wd);
2367 _pan_set(Evas_Object *obj,
2371 Pan *sd = evas_object_smart_data_get(obj);
2374 // Evas_Coord ow, oh;
2375 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2376 // ow = sd->wd->minw - ow;
2377 // if (ow < 0) ow = 0;
2378 // oh = sd->wd->minh - oh;
2379 // if (oh < 0) oh = 0;
2380 // if (x < 0) x = 0;
2381 // if (y < 0) y = 0;
2382 // if (x > ow) x = ow;
2383 // if (y > oh) y = oh;
2384 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2388 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2390 if ((itb->y + itb->h) > y)
2392 Elm_Genlist_Item *it;
2395 EINA_LIST_FOREACH(itb->items, l2, it)
2397 if ((itb->y + it->y) >= y)
2399 sd->wd->anchor_item = it;
2400 sd->wd->anchor_y = -(itb->y + it->y - y);
2407 evas_object_smart_changed(obj);
2411 _pan_get(Evas_Object *obj,
2415 Pan *sd = evas_object_smart_data_get(obj);
2417 if (x) *x = sd->wd->pan_x;
2418 if (y) *y = sd->wd->pan_y;
2422 _pan_max_get(Evas_Object *obj,
2426 Pan *sd = evas_object_smart_data_get(obj);
2429 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2430 ow = sd->wd->minw - ow;
2432 oh = sd->wd->minh - oh;
2439 _pan_min_get(Evas_Object *obj __UNUSED__,
2448 _pan_child_size_get(Evas_Object *obj,
2452 Pan *sd = evas_object_smart_data_get(obj);
2454 if (w) *w = sd->wd->minw;
2455 if (h) *h = sd->wd->minh;
2459 _pan_add(Evas_Object *obj)
2462 Evas_Object_Smart_Clipped_Data *cd;
2465 cd = evas_object_smart_data_get(obj);
2468 sd->__clipped_data = *cd;
2470 evas_object_smart_data_set(obj, sd);
2474 _pan_del(Evas_Object *obj)
2476 Pan *sd = evas_object_smart_data_get(obj);
2481 ecore_job_del(sd->resize_job);
2482 sd->resize_job = NULL;
2488 _pan_resize_job(void *data)
2491 _sizing_eval(sd->wd->obj);
2492 sd->resize_job = NULL;
2496 _pan_resize(Evas_Object *obj,
2500 Pan *sd = evas_object_smart_data_get(obj);
2503 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2504 if ((ow == w) && (oh == h)) return;
2505 if ((sd->wd->height_for_width) && (ow != w))
2507 if (sd->resize_job) ecore_job_del(sd->resize_job);
2508 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2510 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2511 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2515 _pan_calculate(Evas_Object *obj)
2517 Pan *sd = evas_object_smart_data_get(obj);
2519 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2521 Elm_Genlist_Item *git;
2524 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2525 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2526 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2528 git->want_realize = EINA_FALSE;
2530 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2532 itb->w = sd->wd->minw;
2533 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2534 itb->y - sd->wd->pan_y + oy,
2536 cvx, cvy, cvw, cvh))
2538 if ((!itb->realized) || (itb->changed))
2539 _item_block_realize(itb, in, 0);
2540 _item_block_position(itb, in);
2544 if (itb->realized) _item_block_unrealize(itb);
2548 _group_items_recalc(sd->wd);
2552 _pan_move(Evas_Object *obj,
2553 Evas_Coord x __UNUSED__,
2554 Evas_Coord y __UNUSED__)
2556 Pan *sd = evas_object_smart_data_get(obj);
2558 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2559 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2563 _hold_on(void *data __UNUSED__,
2565 void *event_info __UNUSED__)
2567 Widget_Data *wd = elm_widget_data_get(obj);
2569 elm_smart_scroller_hold_set(wd->scr, 1);
2573 _hold_off(void *data __UNUSED__,
2575 void *event_info __UNUSED__)
2577 Widget_Data *wd = elm_widget_data_get(obj);
2579 elm_smart_scroller_hold_set(wd->scr, 0);
2583 _freeze_on(void *data __UNUSED__,
2585 void *event_info __UNUSED__)
2587 Widget_Data *wd = elm_widget_data_get(obj);
2589 elm_smart_scroller_freeze_set(wd->scr, 1);
2593 _freeze_off(void *data __UNUSED__,
2595 void *event_info __UNUSED__)
2597 Widget_Data *wd = elm_widget_data_get(obj);
2599 elm_smart_scroller_freeze_set(wd->scr, 0);
2603 _scroll_edge_left(void *data,
2604 Evas_Object *scr __UNUSED__,
2605 void *event_info __UNUSED__)
2607 Evas_Object *obj = data;
2608 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2612 _scroll_edge_right(void *data,
2613 Evas_Object *scr __UNUSED__,
2614 void *event_info __UNUSED__)
2616 Evas_Object *obj = data;
2617 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2621 _scroll_edge_top(void *data,
2622 Evas_Object *scr __UNUSED__,
2623 void *event_info __UNUSED__)
2625 Evas_Object *obj = data;
2626 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2630 _scroll_edge_bottom(void *data,
2631 Evas_Object *scr __UNUSED__,
2632 void *event_info __UNUSED__)
2634 Evas_Object *obj = data;
2635 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2639 _mode_item_realize(Elm_Genlist_Item *it)
2643 if ((it->mode_view) || (it->delete_me)) return;
2645 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2646 edje_object_scale_set(it->mode_view,
2647 elm_widget_scale_get(it->base.widget) *
2648 _elm_config->scale);
2649 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2650 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2652 strncpy(buf, "item", sizeof(buf));
2653 if (it->wd->compress)
2654 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2656 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2657 strncat(buf, "/", sizeof(buf) - strlen(buf));
2658 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2660 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2661 elm_widget_style_get(it->base.widget));
2662 edje_object_mirrored_set(it->mode_view,
2663 elm_widget_mirrored_get(it->base.widget));
2665 /* signal callback add */
2666 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2668 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2670 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2673 /* label_get, icon_get, state_get */
2674 /* FIXME: If you see that assert, please notify us and we
2675 will clean our mess */
2676 assert(eina_list_count(it->mode_icon_objs) == 0);
2678 _item_label_realize(it, it->mode_view, &it->mode_labels);
2679 it->mode_icon_objs = _item_icon_realize(it,
2682 _item_state_realize(it, it->mode_view, &it->mode_states);
2684 edje_object_part_swallow(it->mode_view,
2685 edje_object_data_get(it->mode_view, "mode_part"),
2688 it->want_unrealize = EINA_FALSE;
2692 _mode_item_unrealize(Elm_Genlist_Item *it)
2694 Widget_Data *wd = it->wd;
2696 if (!it->mode_view) return;
2698 elm_widget_stringlist_free(it->mode_labels);
2699 it->mode_labels = NULL;
2700 elm_widget_stringlist_free(it->mode_icons);
2701 it->mode_icons = NULL;
2702 elm_widget_stringlist_free(it->mode_states);
2704 EINA_LIST_FREE(it->mode_icon_objs, icon)
2705 evas_object_del(icon);
2707 edje_object_part_unswallow(it->mode_view, it->base.view);
2708 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2709 evas_object_del(it->mode_view);
2710 it->mode_view = NULL;
2712 if (wd->mode_item == it)
2713 wd->mode_item = NULL;
2717 _item_mode_set(Elm_Genlist_Item *it)
2720 Widget_Data *wd = it->wd;
2725 it->nocache = EINA_TRUE;
2727 if (wd->scr_hold_timer)
2729 ecore_timer_del(wd->scr_hold_timer);
2730 wd->scr_hold_timer = NULL;
2732 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2733 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2735 _mode_item_realize(it);
2736 _item_position(it, it->mode_view);
2738 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2739 edje_object_signal_emit(it->mode_view, buf, "elm");
2743 _item_mode_unset(Widget_Data *wd)
2746 if (!wd->mode_item) return;
2747 char buf[1024], buf2[1024];
2748 Elm_Genlist_Item *it;
2751 it->nocache = EINA_TRUE;
2753 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2754 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2756 edje_object_signal_emit(it->mode_view, buf, "elm");
2757 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2759 wd->mode_item = NULL;
2763 * Add a new Genlist object
2765 * @param parent The parent object
2766 * @return The new object or NULL if it cannot be created
2771 elm_genlist_add(Evas_Object *parent)
2776 Evas_Coord minw, minh;
2777 static Evas_Smart *smart = NULL;
2781 static Evas_Smart_Class sc;
2783 evas_object_smart_clipped_smart_set(&_pan_sc);
2785 sc.name = "elm_genlist_pan";
2786 sc.version = EVAS_SMART_CLASS_VERSION;
2789 sc.resize = _pan_resize;
2790 sc.move = _pan_move;
2791 sc.calculate = _pan_calculate;
2792 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2795 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2797 ELM_SET_WIDTYPE(widtype, "genlist");
2798 elm_widget_type_set(obj, "genlist");
2799 elm_widget_sub_object_add(parent, obj);
2800 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2801 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2802 elm_widget_data_set(obj, wd);
2803 elm_widget_del_hook_set(obj, _del_hook);
2804 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2805 elm_widget_theme_hook_set(obj, _theme_hook);
2806 elm_widget_can_focus_set(obj, EINA_TRUE);
2807 elm_widget_event_hook_set(obj, _event_hook);
2808 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2810 wd->scr = elm_smart_scroller_add(e);
2811 elm_smart_scroller_widget_set(wd->scr, obj);
2812 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2813 elm_widget_style_get(obj));
2814 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2815 _elm_config->thumbscroll_bounce_enable);
2816 elm_widget_resize_object_set(obj, wd->scr);
2818 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2819 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2821 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2822 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2826 wd->mode = ELM_LIST_SCROLL;
2827 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2828 wd->item_cache_max = wd->max_items_per_block * 2;
2829 wd->longpress_timeout = _elm_config->longpress_timeout;
2831 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2832 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2833 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2834 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2836 wd->pan_smart = evas_object_smart_add(e, smart);
2837 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2840 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2841 _pan_set, _pan_get, _pan_max_get,
2842 _pan_min_get, _pan_child_size_get);
2844 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2846 evas_object_size_hint_min_set(obj, minw, minh);
2848 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2853 static Elm_Genlist_Item *
2854 _item_new(Widget_Data *wd,
2855 const Elm_Genlist_Item_Class *itc,
2857 Elm_Genlist_Item *parent,
2858 Elm_Genlist_Item_Flags flags,
2860 const void *func_data)
2862 Elm_Genlist_Item *it;
2864 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2865 if (!it) return NULL;
2868 it->base.data = data;
2869 it->parent = parent;
2871 it->func.func = func;
2872 it->func.data = func_data;
2873 it->mouse_cursor = NULL;
2874 it->expanded_depth = 0;
2879 _item_block_add(Widget_Data *wd,
2880 Elm_Genlist_Item *it)
2882 Item_Block *itb = NULL;
2889 itb = calloc(1, sizeof(Item_Block));
2892 if (!it->rel->block)
2895 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2896 itb->items = eina_list_append(itb->items, it);
2902 wd->blocks = eina_inlist_prepend_relative
2903 (wd->blocks, EINA_INLIST_GET(itb),
2904 EINA_INLIST_GET(it->rel->block));
2906 eina_list_prepend_relative(itb->items, it, it->rel);
2910 wd->blocks = eina_inlist_append_relative
2911 (wd->blocks, EINA_INLIST_GET(itb),
2912 EINA_INLIST_GET(it->rel->block));
2914 eina_list_append_relative(itb->items, it, it->rel);
2924 itb = (Item_Block *)(wd->blocks);
2925 if (itb->count >= wd->max_items_per_block)
2927 itb = calloc(1, sizeof(Item_Block));
2931 eina_inlist_prepend(wd->blocks,
2932 EINA_INLIST_GET(itb));
2937 itb = calloc(1, sizeof(Item_Block));
2941 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2943 itb->items = eina_list_prepend(itb->items, it);
2949 itb = (Item_Block *)(wd->blocks->last);
2950 if (itb->count >= wd->max_items_per_block)
2952 itb = calloc(1, sizeof(Item_Block));
2956 eina_inlist_append(wd->blocks,
2957 EINA_INLIST_GET(itb));
2962 itb = calloc(1, sizeof(Item_Block));
2966 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2968 itb->items = eina_list_append(itb->items, it);
2974 itb = it->rel->block;
2975 if (!itb) goto newblock;
2977 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2979 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2982 itb->changed = EINA_TRUE;
2984 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2985 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2988 it->rel->relcount--;
2989 if ((it->rel->delete_me) && (!it->rel->relcount))
2993 if (itb->count > itb->wd->max_items_per_block)
2997 Elm_Genlist_Item *it2;
2999 newc = itb->count / 2;
3000 itb2 = calloc(1, sizeof(Item_Block));
3004 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3005 EINA_INLIST_GET(itb));
3006 itb2->changed = EINA_TRUE;
3007 while ((itb->count > newc) && (itb->items))
3011 l = eina_list_last(itb->items);
3013 itb->items = eina_list_remove_list(itb->items, l);
3016 itb2->items = eina_list_prepend(itb2->items, it2);
3024 _queue_process(Widget_Data *wd,
3028 Eina_Bool showme = EINA_FALSE;
3031 t0 = ecore_time_get();
3032 for (n = 0; (wd->queue) && (n < 128); n++)
3034 Elm_Genlist_Item *it;
3036 it = wd->queue->data;
3037 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3038 it->queued = EINA_FALSE;
3039 _item_block_add(wd, it);
3040 t = ecore_time_get();
3041 if (it->block->changed)
3043 showme = _item_block_recalc(it->block, it->block->num, 1,
3045 it->block->changed = 0;
3047 if (showme) it->block->showme = EINA_TRUE;
3048 if (eina_inlist_count(wd->blocks) > 1)
3050 if ((t - t0) > (ecore_animator_frametime_get())) break;
3057 _item_idler(void *data)
3059 Widget_Data *wd = data;
3062 //static double q_start = 0.0;
3063 //if (q_start == 0.0) q_start = ecore_time_get();
3066 if (_queue_process(wd, 1) > 0)
3068 if (wd->calc_job) ecore_job_del(wd->calc_job);
3069 wd->calc_job = ecore_job_add(_calc_job, wd);
3074 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3076 wd->queue_idler = NULL;
3077 return ECORE_CALLBACK_CANCEL;
3079 return ECORE_CALLBACK_RENEW;
3083 _item_queue(Widget_Data *wd,
3084 Elm_Genlist_Item *it)
3086 if (it->queued) return;
3087 it->queued = EINA_TRUE;
3088 wd->queue = eina_list_append(wd->queue, it);
3089 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3091 if (wd->queue_idler)
3093 ecore_idler_del(wd->queue_idler);
3094 wd->queue_idler = NULL;
3096 _queue_process(wd, 0);
3098 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3102 * Append item to the end of the genlist
3104 * This appends the given item to the end of the list or the end of
3105 * the children if the parent is given.
3107 * @param obj The genlist object
3108 * @param itc The item class for the item
3109 * @param data The item data
3110 * @param parent The parent item, or NULL if none
3111 * @param flags Item flags
3112 * @param func Convenience function called when item selected
3113 * @param func_data Data passed to @p func above.
3114 * @return A handle to the item added or NULL if not possible
3118 EAPI Elm_Genlist_Item *
3119 elm_genlist_item_append(Evas_Object *obj,
3120 const Elm_Genlist_Item_Class *itc,
3122 Elm_Genlist_Item *parent,
3123 Elm_Genlist_Item_Flags flags,
3125 const void *func_data)
3127 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3128 Widget_Data *wd = elm_widget_data_get(obj);
3129 if (!wd) return NULL;
3130 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3132 if (!it) return NULL;
3135 if (flags & ELM_GENLIST_ITEM_GROUP)
3136 wd->group_items = eina_list_append(wd->group_items, it);
3137 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3142 Elm_Genlist_Item *it2 = NULL;
3143 Eina_List *ll = eina_list_last(it->parent->items);
3144 if (ll) it2 = ll->data;
3145 it->parent->items = eina_list_append(it->parent->items, it);
3146 if (!it2) it2 = it->parent;
3148 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3149 EINA_INLIST_GET(it2));
3151 it->rel->relcount++;
3153 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3154 it->group_item = parent;
3155 else if (it->parent->group_item)
3156 it->group_item = it->parent->group_item;
3158 it->before = EINA_FALSE;
3159 _item_queue(wd, it);
3164 * Prepend item at start of the genlist
3166 * This adds an item to the beginning of the list or beginning of the
3167 * children of the parent if given.
3169 * @param obj The genlist object
3170 * @param itc The item class for the item
3171 * @param data The item data
3172 * @param parent The parent item, or NULL if none
3173 * @param flags Item flags
3174 * @param func Convenience function called when item selected
3175 * @param func_data Data passed to @p func above.
3176 * @return A handle to the item added or NULL if not possible
3180 EAPI Elm_Genlist_Item *
3181 elm_genlist_item_prepend(Evas_Object *obj,
3182 const Elm_Genlist_Item_Class *itc,
3184 Elm_Genlist_Item *parent,
3185 Elm_Genlist_Item_Flags flags,
3187 const void *func_data)
3189 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3190 Widget_Data *wd = elm_widget_data_get(obj);
3191 if (!wd) return NULL;
3192 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3194 if (!it) return NULL;
3197 if (flags & ELM_GENLIST_ITEM_GROUP)
3198 wd->group_items = eina_list_prepend(wd->group_items, it);
3199 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3204 Elm_Genlist_Item *it2 = NULL;
3205 Eina_List *ll = it->parent->items;
3206 if (ll) it2 = ll->data;
3207 it->parent->items = eina_list_prepend(it->parent->items, it);
3208 if (!it2) it2 = it->parent;
3210 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3211 EINA_INLIST_GET(it2));
3213 it->rel->relcount++;
3215 it->before = EINA_TRUE;
3216 _item_queue(wd, it);
3221 * Insert item before another in the genlist
3223 * This inserts an item before another in the list. It will be in the
3224 * same tree level or group as the item it is inseted before.
3226 * @param obj The genlist object
3227 * @param itc The item class for the item
3228 * @param data The item data
3229 * @param before The item to insert before
3230 * @param flags Item flags
3231 * @param func Convenience function called when item selected
3232 * @param func_data Data passed to @p func above.
3233 * @return A handle to the item added or NULL if not possible
3237 EAPI Elm_Genlist_Item *
3238 elm_genlist_item_insert_before(Evas_Object *obj,
3239 const Elm_Genlist_Item_Class *itc,
3241 Elm_Genlist_Item *parent,
3242 Elm_Genlist_Item *before,
3243 Elm_Genlist_Item_Flags flags,
3245 const void *func_data)
3247 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3248 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3249 Widget_Data *wd = elm_widget_data_get(obj);
3250 if (!wd) return NULL;
3251 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3253 if (!it) return NULL;
3256 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3259 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3260 EINA_INLIST_GET(before));
3262 it->rel->relcount++;
3263 it->before = EINA_TRUE;
3264 _item_queue(wd, it);
3269 * Insert an item after another in the genlst
3271 * This inserts an item after another in the list. It will be in the
3272 * same tree level or group as the item it is inseted after.
3274 * @param obj The genlist object
3275 * @param itc The item class for the item
3276 * @param data The item data
3277 * @param after The item to insert after
3278 * @param flags Item flags
3279 * @param func Convenience function called when item selected
3280 * @param func_data Data passed to @p func above.
3281 * @return A handle to the item added or NULL if not possible
3285 EAPI Elm_Genlist_Item *
3286 elm_genlist_item_insert_after(Evas_Object *obj,
3287 const Elm_Genlist_Item_Class *itc,
3289 Elm_Genlist_Item *parent,
3290 Elm_Genlist_Item *after,
3291 Elm_Genlist_Item_Flags flags,
3293 const void *func_data)
3295 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3296 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3297 Widget_Data *wd = elm_widget_data_get(obj);
3298 if (!wd) return NULL;
3299 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3301 if (!it) return NULL;
3302 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3303 EINA_INLIST_GET(after));
3306 it->parent->items = eina_list_append_relative(it->parent->items, it,
3310 it->rel->relcount++;
3311 it->before = EINA_FALSE;
3312 _item_queue(wd, it);
3319 * This clears all items in the list, leaving it empty.
3321 * @param obj The genlist object
3326 elm_genlist_clear(Evas_Object *obj)
3328 ELM_CHECK_WIDTYPE(obj, widtype);
3329 Widget_Data *wd = elm_widget_data_get(obj);
3331 if (wd->walking > 0)
3333 Elm_Genlist_Item *it;
3335 wd->clear_me = EINA_TRUE;
3336 EINA_INLIST_FOREACH(wd->items, it)
3338 it->delete_me = EINA_TRUE;
3344 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3346 if (wd->anchor_item == it)
3348 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3349 if (!wd->anchor_item)
3351 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3353 wd->items = eina_inlist_remove(wd->items, wd->items);
3354 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3355 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3356 elm_widget_item_pre_notify_del(it);
3357 if (it->realized) _item_unrealize(it, EINA_FALSE);
3358 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3359 it->itc->func.del((void *)it->base.data, it->base.widget);
3360 if (it->long_timer) ecore_timer_del(it->long_timer);
3361 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3362 elm_widget_item_del(it);
3364 wd->clear_me = EINA_FALSE;
3365 wd->anchor_item = NULL;
3368 Item_Block *itb = (Item_Block *)(wd->blocks);
3370 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3371 if (itb->items) eina_list_free(itb->items);
3376 ecore_job_del(wd->calc_job);
3377 wd->calc_job = NULL;
3379 if (wd->queue_idler)
3381 ecore_idler_del(wd->queue_idler);
3382 wd->queue_idler = NULL;
3384 if (wd->must_recalc_idler)
3386 ecore_idler_del(wd->must_recalc_idler);
3387 wd->must_recalc_idler = NULL;
3391 eina_list_free(wd->queue);
3396 eina_list_free(wd->selected);
3397 wd->selected = NULL;
3399 wd->show_item = NULL;
3406 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3407 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3413 * Enable or disable multi-select in the genlist
3415 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3416 * the list. This allows more than 1 item to be selected.
3418 * @param obj The genlist object
3419 * @param multi Multi-select enable/disable
3424 elm_genlist_multi_select_set(Evas_Object *obj,
3427 ELM_CHECK_WIDTYPE(obj, widtype);
3428 Widget_Data *wd = elm_widget_data_get(obj);
3434 * Gets if multi-select in genlist is enable or disable
3436 * @param obj The genlist object
3437 * @return Multi-select enable/disable
3438 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3443 elm_genlist_multi_select_get(const Evas_Object *obj)
3445 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3446 Widget_Data *wd = elm_widget_data_get(obj);
3447 if (!wd) return EINA_FALSE;
3452 * Get the selectd item in the genlist
3454 * This gets the selected item in the list (if multi-select is enabled
3455 * only the first item in the list is selected - which is not very
3456 * useful, so see elm_genlist_selected_items_get() for when
3457 * multi-select is used).
3459 * If no item is selected, NULL is returned.
3461 * @param obj The genlist object
3462 * @return The selected item, or NULL if none.
3466 EAPI Elm_Genlist_Item *
3467 elm_genlist_selected_item_get(const Evas_Object *obj)
3469 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3470 Widget_Data *wd = elm_widget_data_get(obj);
3471 if (!wd) return NULL;
3472 if (wd->selected) return wd->selected->data;
3477 * Get a list of selected items in the genlist
3479 * This returns a list of the selected items. This list pointer is
3480 * only valid so long as no items are selected or unselected (or
3481 * unselected implicitly by deletion). The list contains
3482 * Elm_Genlist_Item pointers.
3484 * @param obj The genlist object
3485 * @return The list of selected items, nor NULL if none are selected.
3489 EAPI const Eina_List *
3490 elm_genlist_selected_items_get(const Evas_Object *obj)
3492 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3493 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (!wd) return NULL;
3495 return wd->selected;
3499 * Get a list of realized items in genlist
3501 * This returns a list of the realized items in the genlist. The list
3502 * contains Elm_Genlist_Item pointers. The list must be freed by the
3503 * caller when done with eina_list_free(). The item pointers in the
3504 * list are only valid so long as those items are not deleted or the
3505 * genlist is not deleted.
3507 * @param obj The genlist object
3508 * @return The list of realized items, nor NULL if none are realized.
3513 elm_genlist_realized_items_get(const Evas_Object *obj)
3515 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3516 Widget_Data *wd = elm_widget_data_get(obj);
3517 Eina_List *list = NULL;
3519 Eina_Bool done = EINA_FALSE;
3520 if (!wd) return NULL;
3521 EINA_INLIST_FOREACH(wd->blocks, itb)
3526 Elm_Genlist_Item *it;
3529 EINA_LIST_FOREACH(itb->items, l, it)
3531 if (it->realized) list = eina_list_append(list, it);
3543 * Get the item that is at the x, y canvas coords
3545 * This returns the item at the given coordinates (which are canvas
3546 * relative not object-relative). If an item is at that coordinate,
3547 * that item handle is returned, and if @p posret is not NULL, the
3548 * integer pointed to is set to a value of -1, 0 or 1, depending if
3549 * the coordinate is on the upper portion of that item (-1), on the
3550 * middle section (0) or on the lower part (1). If NULL is returned as
3551 * an item (no item found there), then posret may indicate -1 or 1
3552 * based if the coordinate is above or below all items respectively in
3555 * @param it The item
3556 * @param x The input x coordinate
3557 * @param y The input y coordinate
3558 * @param posret The position relative to the item returned here
3559 * @return The item at the coordinates or NULL if none
3563 EAPI Elm_Genlist_Item *
3564 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3569 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3570 Widget_Data *wd = elm_widget_data_get(obj);
3571 Evas_Coord ox, oy, ow, oh;
3574 if (!wd) return NULL;
3575 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3577 EINA_INLIST_FOREACH(wd->blocks, itb)
3580 Elm_Genlist_Item *it;
3582 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3583 oy + itb->y - itb->wd->pan_y,
3584 itb->w, itb->h, x, y, 1, 1))
3586 EINA_LIST_FOREACH(itb->items, l, it)
3588 Evas_Coord itx, ity;
3590 itx = ox + itb->x + it->x - itb->wd->pan_x;
3591 ity = oy + itb->y + it->y - itb->wd->pan_y;
3592 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3596 if (y <= (ity + (it->h / 4))) *posret = -1;
3597 else if (y >= (ity + it->h - (it->h / 4)))
3603 lasty = ity + it->h;
3608 if (y > lasty) *posret = 1;
3615 * Get the first item in the genlist
3617 * This returns the first item in the list.
3619 * @param obj The genlist object
3620 * @return The first item, or NULL if none
3624 EAPI Elm_Genlist_Item *
3625 elm_genlist_first_item_get(const Evas_Object *obj)
3627 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3628 Widget_Data *wd = elm_widget_data_get(obj);
3629 if (!wd) return NULL;
3630 if (!wd->items) return NULL;
3631 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3632 while ((it) && (it->delete_me))
3633 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3638 * Get the last item in the genlist
3640 * This returns the last item in the list.
3642 * @return The last item, or NULL if none
3646 EAPI Elm_Genlist_Item *
3647 elm_genlist_last_item_get(const Evas_Object *obj)
3649 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3650 Widget_Data *wd = elm_widget_data_get(obj);
3651 if (!wd) return NULL;
3652 if (!wd->items) return NULL;
3653 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3654 while ((it) && (it->delete_me))
3655 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3660 * Get the next item in the genlist
3662 * This returns the item after the item @p it.
3664 * @param it The item
3665 * @return The item after @p it, or NULL if none
3669 EAPI Elm_Genlist_Item *
3670 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3672 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3675 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3676 if ((it) && (!it->delete_me)) break;
3678 return (Elm_Genlist_Item *)it;
3682 * Get the previous item in the genlist
3684 * This returns the item before the item @p it.
3686 * @param it The item
3687 * @return The item before @p it, or NULL if none
3691 EAPI Elm_Genlist_Item *
3692 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3694 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3697 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3698 if ((it) && (!it->delete_me)) break;
3700 return (Elm_Genlist_Item *)it;
3704 * Get the genlist object from an item
3706 * This returns the genlist object itself that an item belongs to.
3708 * @param it The item
3709 * @return The genlist object
3714 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3716 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3717 return it->base.widget;
3721 * Get the parent item of the given item
3723 * This returns the parent item of the item @p it given.
3725 * @param it The item
3726 * @return The parent of the item or NULL if none
3730 EAPI Elm_Genlist_Item *
3731 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3733 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3738 * Clear all sub-items (children) of the given item
3740 * This clears all items that are children (or their descendants) of the
3743 * @param it The item
3748 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3750 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3751 Eina_List *tl = NULL, *l;
3752 Elm_Genlist_Item *it2;
3754 EINA_LIST_FOREACH(it->items, l, it2)
3755 tl = eina_list_append(tl, it2);
3756 EINA_LIST_FREE(tl, it2)
3757 elm_genlist_item_del(it2);
3761 * Set the selected state of an item
3763 * This sets the selected state (1 selected, 0 not selected) of the given
3766 * @param it The item
3767 * @param selected The selected state
3772 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3775 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3776 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3778 if (it->delete_me) return;
3779 selected = !!selected;
3780 if (it->selected == selected) return;
3786 while (wd->selected)
3787 _item_unselect(wd->selected->data);
3789 _item_highlight(it);
3797 * Get the selected state of an item
3799 * This gets the selected state of an item (1 selected, 0 not selected).
3801 * @param it The item
3802 * @return The selected state
3807 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3809 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3810 return it->selected;
3814 * Sets the expanded state of an item (if it's a parent)
3816 * This expands or contracts a parent item (thus showing or hiding the
3819 * @param it The item
3820 * @param expanded The expanded state (1 expanded, 0 not expanded).
3825 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3828 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3829 if (it->expanded == expanded) return;
3830 it->expanded = expanded;
3834 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3835 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3840 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3841 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3846 * Get the expanded state of an item
3848 * This gets the expanded state of an item
3850 * @param it The item
3851 * @return Thre expanded state
3856 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3858 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3859 return it->expanded;
3863 * Get the depth of expanded item
3865 * @param it The genlist item object
3866 * @return The depth of expanded item
3871 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3873 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3874 return it->expanded_depth;
3878 * Sets the disabled state of an item.
3880 * A disabled item cannot be selected or unselected. It will also
3881 * change appearance to appear disabled. This sets the disabled state
3882 * (1 disabled, 0 not disabled).
3884 * @param it The item
3885 * @param disabled The disabled state
3890 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3893 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3894 if (it->disabled == disabled) return;
3895 if (it->delete_me) return;
3896 it->disabled = disabled;
3900 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3902 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3907 * Get the disabled state of an item
3909 * This gets the disabled state of the given item.
3911 * @param it The item
3912 * @return The disabled state
3917 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3919 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3920 if (it->delete_me) return EINA_FALSE;
3921 return it->disabled;
3925 * Sets the display only state of an item.
3927 * A display only item cannot be selected or unselected. It is for
3928 * display only and not selecting or otherwise clicking, dragging
3929 * etc. by the user, thus finger size rules will not be applied to
3932 * @param it The item
3933 * @param display_only The display only state
3938 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3939 Eina_Bool display_only)
3941 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3942 if (it->display_only == display_only) return;
3943 if (it->delete_me) return;
3944 it->display_only = display_only;
3945 it->mincalcd = EINA_FALSE;
3946 it->updateme = EINA_TRUE;
3947 if (it->block) it->block->updateme = EINA_TRUE;
3948 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3949 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3953 * Get the display only state of an item
3955 * This gets the display only state of the given item.
3957 * @param it The item
3958 * @return The display only state
3963 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3965 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3966 if (it->delete_me) return EINA_FALSE;
3967 return it->display_only;
3971 * Show the given item
3973 * This causes genlist to jump to the given item @p it and show it (by
3974 * scrolling), if it is not fully visible.
3976 * @param it The item
3981 elm_genlist_item_show(Elm_Genlist_Item *it)
3983 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3984 Evas_Coord gith = 0;
3985 if (it->delete_me) return;
3986 if ((it->queued) || (!it->mincalcd))
3988 it->wd->show_item = it;
3989 it->wd->bring_in = EINA_TRUE;
3990 it->showme = EINA_TRUE;
3993 if (it->wd->show_item)
3995 it->wd->show_item->showme = EINA_FALSE;
3996 it->wd->show_item = NULL;
3998 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3999 gith = it->group_item->h;
4000 elm_smart_scroller_child_region_show(it->wd->scr,
4001 it->x + it->block->x,
4002 it->y + it->block->y - gith,
4003 it->block->w, it->h);
4007 * Bring in the given item
4009 * This causes genlist to jump to the given item @p it and show it (by
4010 * scrolling), if it is not fully visible. This may use animation to
4011 * do so and take a period of time
4013 * @param it The item
4018 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4020 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4021 Evas_Coord gith = 0;
4022 if (it->delete_me) return;
4023 if ((it->queued) || (!it->mincalcd))
4025 it->wd->show_item = it;
4026 it->wd->bring_in = EINA_TRUE;
4027 it->showme = EINA_TRUE;
4030 if (it->wd->show_item)
4032 it->wd->show_item->showme = EINA_FALSE;
4033 it->wd->show_item = NULL;
4035 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4036 gith = it->group_item->h;
4037 elm_smart_scroller_region_bring_in(it->wd->scr,
4038 it->x + it->block->x,
4039 it->y + it->block->y - gith,
4040 it->block->w, it->h);
4044 * Show the given item at the top
4046 * This causes genlist to jump to the given item @p it and show it (by
4047 * scrolling), if it is not fully visible.
4049 * @param it The item
4054 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4056 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4058 Evas_Coord gith = 0;
4060 if (it->delete_me) return;
4061 if ((it->queued) || (!it->mincalcd))
4063 it->wd->show_item = it;
4064 it->wd->bring_in = EINA_TRUE;
4065 it->showme = EINA_TRUE;
4068 if (it->wd->show_item)
4070 it->wd->show_item->showme = EINA_FALSE;
4071 it->wd->show_item = NULL;
4073 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4074 if (it->group_item) gith = it->group_item->h;
4075 elm_smart_scroller_child_region_show(it->wd->scr,
4076 it->x + it->block->x,
4077 it->y + it->block->y - gith,
4082 * Bring in the given item at the top
4084 * This causes genlist to jump to the given item @p it and show it (by
4085 * scrolling), if it is not fully visible. This may use animation to
4086 * do so and take a period of time
4088 * @param it The item
4093 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4095 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4097 Evas_Coord gith = 0;
4099 if (it->delete_me) return;
4100 if ((it->queued) || (!it->mincalcd))
4102 it->wd->show_item = it;
4103 it->wd->bring_in = EINA_TRUE;
4104 it->showme = EINA_TRUE;
4107 if (it->wd->show_item)
4109 it->wd->show_item->showme = EINA_FALSE;
4110 it->wd->show_item = NULL;
4112 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4113 if (it->group_item) gith = it->group_item->h;
4114 elm_smart_scroller_region_bring_in(it->wd->scr,
4115 it->x + it->block->x,
4116 it->y + it->block->y - gith,
4121 * Show the given item at the middle
4123 * This causes genlist to jump to the given item @p it and show it (by
4124 * scrolling), if it is not fully visible.
4126 * @param it The item
4131 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4133 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4136 if (it->delete_me) return;
4137 if ((it->queued) || (!it->mincalcd))
4139 it->wd->show_item = it;
4140 it->wd->bring_in = EINA_TRUE;
4141 it->showme = EINA_TRUE;
4144 if (it->wd->show_item)
4146 it->wd->show_item->showme = EINA_FALSE;
4147 it->wd->show_item = NULL;
4149 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4150 elm_smart_scroller_child_region_show(it->wd->scr,
4151 it->x + it->block->x,
4152 it->y + it->block->y - oh / 2 +
4153 it->h / 2, it->block->w, oh);
4157 * Bring in the given item at the middle
4159 * This causes genlist to jump to the given item @p it and show it (by
4160 * scrolling), if it is not fully visible. This may use animation to
4161 * do so and take a period of time
4163 * @param it The item
4168 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4170 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4173 if (it->delete_me) return;
4174 if ((it->queued) || (!it->mincalcd))
4176 it->wd->show_item = it;
4177 it->wd->bring_in = EINA_TRUE;
4178 it->showme = EINA_TRUE;
4181 if (it->wd->show_item)
4183 it->wd->show_item->showme = EINA_FALSE;
4184 it->wd->show_item = NULL;
4186 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4187 elm_smart_scroller_region_bring_in(it->wd->scr,
4188 it->x + it->block->x,
4189 it->y + it->block->y - oh / 2 + it->h / 2,
4194 * Delete a given item
4196 * This deletes the item from genlist and calls the genlist item del
4197 * class callback defined in the item class, if it is set. This clears all
4198 * subitems if it is a tree.
4200 * @param it The item
4205 elm_genlist_item_del(Elm_Genlist_Item *it)
4207 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4208 if ((it->relcount > 0) || (it->walking > 0))
4210 elm_widget_item_pre_notify_del(it);
4211 elm_genlist_item_subitems_clear(it);
4212 it->delete_me = EINA_TRUE;
4213 if (it->wd->show_item == it) it->wd->show_item = NULL;
4215 it->wd->selected = eina_list_remove(it->wd->selected,
4219 if (it->realized) _item_unrealize(it, EINA_FALSE);
4220 it->block->changed = EINA_TRUE;
4221 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4222 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4224 if (it->itc->func.del)
4225 it->itc->func.del((void *)it->base.data, it->base.widget);
4232 * Set the data item from the genlist item
4234 * This set the data value passed on the elm_genlist_item_append() and
4235 * related item addition calls. This function will also call
4236 * elm_genlist_item_update() so the item will be updated to reflect the
4239 * @param it The item
4240 * @param data The new data pointer to set
4245 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4248 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4249 elm_widget_item_data_set(it, data);
4250 elm_genlist_item_update(it);
4254 * Get the data item from the genlist item
4256 * This returns the data value passed on the elm_genlist_item_append()
4257 * and related item addition calls and elm_genlist_item_data_set().
4259 * @param it The item
4260 * @return The data pointer provided when created
4265 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4267 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4268 return elm_widget_item_data_get(it);
4272 * Tells genlist to "orphan" icons fetchs by the item class
4274 * This instructs genlist to release references to icons in the item,
4275 * meaning that they will no longer be managed by genlist and are
4276 * floating "orphans" that can be re-used elsewhere if the user wants
4279 * @param it The item
4284 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4287 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4288 EINA_LIST_FREE(it->icon_objs, icon)
4290 elm_widget_sub_object_del(it->base.widget, icon);
4291 evas_object_smart_member_del(icon);
4292 evas_object_hide(icon);
4297 * Get the real evas object of the genlist item
4299 * This returns the actual evas object used for the specified genlist
4300 * item. This may be NULL as it may not be created, and may be deleted
4301 * at any time by genlist. Do not modify this object (move, resize,
4302 * show, hide etc.) as genlist is controlling it. This function is for
4303 * querying, emitting custom signals or hooking lower level callbacks
4304 * for events. Do not delete this object under any circumstances.
4306 * @param it The item
4307 * @return The object pointer
4311 EAPI const Evas_Object *
4312 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4315 return it->base.view;
4319 * Update the contents of an item
4321 * This updates an item by calling all the item class functions again
4322 * to get the icons, labels and states. Use this when the original
4323 * item data has changed and the changes are desired to be reflected.
4325 * @param it The item
4330 elm_genlist_item_update(Elm_Genlist_Item *it)
4332 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4333 if (!it->block) return;
4334 if (it->delete_me) return;
4335 it->mincalcd = EINA_FALSE;
4336 it->updateme = EINA_TRUE;
4337 it->block->updateme = EINA_TRUE;
4338 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4339 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4343 * Update the item class of an item
4345 * @param it The item
4346 * @parem itc The item class for the item
4351 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4352 const Elm_Genlist_Item_Class *itc)
4354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4355 if (!it->block) return;
4356 EINA_SAFETY_ON_NULL_RETURN(itc);
4357 if (it->delete_me) return;
4359 it->nocache = EINA_TRUE;
4360 elm_genlist_item_update(it);
4363 static Evas_Object *
4364 _elm_genlist_item_label_create(void *data,
4366 void *item __UNUSED__)
4368 Evas_Object *label = elm_label_add(obj);
4371 elm_object_style_set(label, "tooltip");
4372 elm_label_label_set(label, data);
4377 _elm_genlist_item_label_del_cb(void *data,
4378 Evas_Object *obj __UNUSED__,
4379 void *event_info __UNUSED__)
4381 eina_stringshare_del(data);
4385 * Set the text to be shown in the genlist item.
4387 * @param item Target item
4388 * @param text The text to set in the content
4390 * Setup the text as tooltip to object. The item can have only one
4391 * tooltip, so any previous tooltip data is removed.
4396 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4399 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4400 text = eina_stringshare_add(text);
4401 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4403 _elm_genlist_item_label_del_cb);
4407 * Set the content to be shown in the tooltip item
4409 * Setup the tooltip to item. The item can have only one tooltip, so
4410 * any previous tooltip data is removed. @p func(with @p data) will be
4411 * called every time that need to show the tooltip and it should return a
4412 * valid Evas_Object. This object is then managed fully by tooltip
4413 * system and is deleted when the tooltip is gone.
4415 * @param item the genlist item being attached by a tooltip.
4416 * @param func the function used to create the tooltip contents.
4417 * @param data what to provide to @a func as callback data/context.
4418 * @param del_cb called when data is not needed anymore, either when
4419 * another callback replaces @func, the tooltip is unset with
4420 * elm_genlist_item_tooltip_unset() or the owner @a item
4421 * dies. This callback receives as the first parameter the
4422 * given @a data, and @c event_info is the item.
4427 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4428 Elm_Tooltip_Item_Content_Cb func,
4430 Evas_Smart_Cb del_cb)
4432 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4434 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4437 if (item->tooltip.del_cb)
4438 item->tooltip.del_cb((void *)item->tooltip.data,
4439 item->base.widget, item);
4441 item->tooltip.content_cb = func;
4442 item->tooltip.data = data;
4443 item->tooltip.del_cb = del_cb;
4445 if (item->base.view)
4447 elm_widget_item_tooltip_content_cb_set(item,
4448 item->tooltip.content_cb,
4449 item->tooltip.data, NULL);
4450 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4456 if (del_cb) del_cb((void *)data, NULL, NULL);
4460 * Unset tooltip from item
4462 * @param item genlist item to remove previously set tooltip.
4464 * Remove tooltip from item. The callback provided as del_cb to
4465 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4466 * it is not used anymore.
4468 * @see elm_genlist_item_tooltip_content_cb_set()
4473 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4475 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4476 if ((item->base.view) && (item->tooltip.content_cb))
4477 elm_widget_item_tooltip_unset(item);
4479 if (item->tooltip.del_cb)
4480 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4481 item->tooltip.del_cb = NULL;
4482 item->tooltip.content_cb = NULL;
4483 item->tooltip.data = NULL;
4484 if (item->tooltip.style)
4485 elm_genlist_item_tooltip_style_set(item, NULL);
4489 * Sets a different style for this item tooltip.
4491 * @note before you set a style you should define a tooltip with
4492 * elm_genlist_item_tooltip_content_cb_set() or
4493 * elm_genlist_item_tooltip_text_set()
4495 * @param item genlist item with tooltip already set.
4496 * @param style the theme style to use (default, transparent, ...)
4501 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4504 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4505 eina_stringshare_replace(&item->tooltip.style, style);
4506 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4510 * Get the style for this item tooltip.
4512 * @param item genlist item with tooltip already set.
4513 * @return style the theme style in use, defaults to "default". If the
4514 * object does not have a tooltip set, then NULL is returned.
4519 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4521 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4522 return item->tooltip.style;
4526 * Set the cursor to be shown when mouse is over the genlist item
4528 * @param item Target item
4529 * @param cursor the cursor name to be used.
4531 * @see elm_object_cursor_set()
4535 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4538 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4539 eina_stringshare_replace(&item->mouse_cursor, cursor);
4540 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4544 * Get the cursor to be shown when mouse is over the genlist item
4546 * @param item genlist item with cursor already set.
4547 * @return the cursor name.
4552 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4554 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4555 return elm_widget_item_cursor_get(item);
4559 * Unset the cursor to be shown when mouse is over the genlist item
4561 * @param item Target item
4563 * @see elm_object_cursor_unset()
4567 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4569 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4570 if (!item->mouse_cursor)
4573 if (item->base.view)
4574 elm_widget_item_cursor_unset(item);
4576 eina_stringshare_del(item->mouse_cursor);
4577 item->mouse_cursor = NULL;
4581 * Sets a different style for this item cursor.
4583 * @note before you set a style you should define a cursor with
4584 * elm_genlist_item_cursor_set()
4586 * @param item genlist item with cursor already set.
4587 * @param style the theme style to use (default, transparent, ...)
4592 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4595 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4596 elm_widget_item_cursor_style_set(item, style);
4600 * Get the style for this item cursor.
4602 * @param item genlist item with cursor already set.
4603 * @return style the theme style in use, defaults to "default". If the
4604 * object does not have a cursor set, then NULL is returned.
4609 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4612 return elm_widget_item_cursor_style_get(item);
4616 * Set if the cursor set should be searched on the theme or should use
4617 * the provided by the engine, only.
4619 * @note before you set if should look on theme you should define a
4620 * cursor with elm_object_cursor_set(). By default it will only look
4621 * for cursors provided by the engine.
4623 * @param item widget item with cursor already set.
4624 * @param engine_only boolean to define it cursors should be looked
4625 * only between the provided by the engine or searched on widget's
4631 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4632 Eina_Bool engine_only)
4634 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4635 elm_widget_item_cursor_engine_only_set(item, engine_only);
4639 * Get the cursor engine only usage for this item cursor.
4641 * @param item widget item with cursor already set.
4642 * @return engine_only boolean to define it cursors should be looked
4643 * only between the provided by the engine or searched on widget's
4644 * theme as well. If the object does not have a cursor set, then
4645 * EINA_FALSE is returned.
4650 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4652 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4653 return elm_widget_item_cursor_engine_only_get(item);
4657 * This sets the horizontal stretching mode
4659 * This sets the mode used for sizing items horizontally. Valid modes
4660 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4661 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4662 * the scroller will scroll horizontally. Otherwise items are expanded
4663 * to fill the width of the viewport of the scroller. If it is
4664 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4665 * limited to that size.
4667 * @param obj The genlist object
4668 * @param mode The mode to use
4673 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4676 ELM_CHECK_WIDTYPE(obj, widtype);
4677 Widget_Data *wd = elm_widget_data_get(obj);
4679 if (wd->mode == mode) return;
4685 * Gets the horizontal stretching mode
4687 * @param obj The genlist object
4688 * @return The mode to use
4689 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4694 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4696 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4697 Widget_Data *wd = elm_widget_data_get(obj);
4698 if (!wd) return ELM_LIST_LAST;
4703 * Set the always select mode.
4705 * Items will only call their selection func and callback when first
4706 * becoming selected. Any further clicks will do nothing, unless you
4707 * enable always select with elm_genlist_always_select_mode_set().
4708 * This means even if selected, every click will make the selected
4709 * callbacks be called.
4711 * @param obj The genlist object
4712 * @param always_select The always select mode
4713 * (EINA_TRUE = on, EINA_FALSE = off)
4718 elm_genlist_always_select_mode_set(Evas_Object *obj,
4719 Eina_Bool always_select)
4721 ELM_CHECK_WIDTYPE(obj, widtype);
4722 Widget_Data *wd = elm_widget_data_get(obj);
4724 wd->always_select = always_select;
4728 * Get the always select mode.
4730 * @param obj The genlist object
4731 * @return The always select mode
4732 * (EINA_TRUE = on, EINA_FALSE = off)
4737 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4739 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4740 Widget_Data *wd = elm_widget_data_get(obj);
4741 if (!wd) return EINA_FALSE;
4742 return wd->always_select;
4746 * Set no select mode
4748 * This will turn off the ability to select items entirely and they
4749 * will neither appear selected nor call selected callback functions.
4751 * @param obj The genlist object
4752 * @param no_select The no select mode
4753 * (EINA_TRUE = on, EINA_FALSE = off)
4758 elm_genlist_no_select_mode_set(Evas_Object *obj,
4759 Eina_Bool no_select)
4761 ELM_CHECK_WIDTYPE(obj, widtype);
4762 Widget_Data *wd = elm_widget_data_get(obj);
4764 wd->no_select = no_select;
4768 * Gets no select mode
4770 * @param obj The genlist object
4771 * @return The no select mode
4772 * (EINA_TRUE = on, EINA_FALSE = off)
4777 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4779 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4780 Widget_Data *wd = elm_widget_data_get(obj);
4781 if (!wd) return EINA_FALSE;
4782 return wd->no_select;
4788 * This will enable the compress mode where items are "compressed"
4789 * horizontally to fit the genlist scrollable viewport width. This is
4790 * special for genlist. Do not rely on
4791 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4792 * work as genlist needs to handle it specially.
4794 * @param obj The genlist object
4795 * @param compress The compress mode
4796 * (EINA_TRUE = on, EINA_FALSE = off)
4801 elm_genlist_compress_mode_set(Evas_Object *obj,
4804 ELM_CHECK_WIDTYPE(obj, widtype);
4805 Widget_Data *wd = elm_widget_data_get(obj);
4807 wd->compress = compress;
4811 * Get the compress mode
4813 * @param obj The genlist object
4814 * @return The compress mode
4815 * (EINA_TRUE = on, EINA_FALSE = off)
4820 elm_genlist_compress_mode_get(const Evas_Object *obj)
4822 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4823 Widget_Data *wd = elm_widget_data_get(obj);
4824 if (!wd) return EINA_FALSE;
4825 return wd->compress;
4829 * Set height-for-width mode
4831 * With height-for-width mode the item width will be fixed (restricted
4832 * to a minimum of) to the list width when calculating its size in
4833 * order to allow the height to be calculated based on it. This allows,
4834 * for instance, text block to wrap lines if the Edje part is
4835 * configured with "text.min: 0 1".
4837 * @note This mode will make list resize slower as it will have to
4838 * recalculate every item height again whenever the list width
4841 * @note When height-for-width mode is enabled, it also enables
4842 * compress mode (see elm_genlist_compress_mode_set()) and
4843 * disables homogeneous (see elm_genlist_homogeneous_set()).
4845 * @param obj The genlist object
4846 * @param setting The height-for-width mode (EINA_TRUE = on,
4852 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4853 Eina_Bool height_for_width)
4855 ELM_CHECK_WIDTYPE(obj, widtype);
4856 Widget_Data *wd = elm_widget_data_get(obj);
4858 wd->height_for_width = !!height_for_width;
4859 if (wd->height_for_width)
4861 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4862 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4867 * Get the height-for-width mode
4869 * @param obj The genlist object
4870 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4876 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4878 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4879 Widget_Data *wd = elm_widget_data_get(obj);
4880 if (!wd) return EINA_FALSE;
4881 return wd->height_for_width;
4887 * This will enable or disable the scroller bounce mode for the
4888 * genlist. See elm_scroller_bounce_set() for details
4890 * @param obj The genlist object
4891 * @param h_bounce Allow bounce horizontally
4892 * @param v_bounce Allow bounce vertically
4897 elm_genlist_bounce_set(Evas_Object *obj,
4901 ELM_CHECK_WIDTYPE(obj, widtype);
4902 Widget_Data *wd = elm_widget_data_get(obj);
4904 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4908 * Get the bounce mode
4910 * @param obj The genlist object
4911 * @param h_bounce Allow bounce horizontally
4912 * @param v_bounce Allow bounce vertically
4917 elm_genlist_bounce_get(const Evas_Object *obj,
4918 Eina_Bool *h_bounce,
4919 Eina_Bool *v_bounce)
4921 ELM_CHECK_WIDTYPE(obj, widtype);
4922 Widget_Data *wd = elm_widget_data_get(obj);
4924 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4928 * Set homogenous mode
4930 * This will enable the homogeneous mode where items are of the same
4931 * height and width so that genlist may do the lazy-loading at its
4932 * maximum. This implies 'compressed' mode.
4934 * @param obj The genlist object
4935 * @param homogeneous Assume the items within the genlist are of the
4936 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4941 elm_genlist_homogeneous_set(Evas_Object *obj,
4942 Eina_Bool homogeneous)
4944 ELM_CHECK_WIDTYPE(obj, widtype);
4945 Widget_Data *wd = elm_widget_data_get(obj);
4947 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4948 wd->homogeneous = homogeneous;
4952 * Get the homogenous mode
4954 * @param obj The genlist object
4955 * @return Assume the items within the genlist are of the same height
4956 * and width (EINA_TRUE = on, EINA_FALSE = off)
4961 elm_genlist_homogeneous_get(const Evas_Object *obj)
4963 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4964 Widget_Data *wd = elm_widget_data_get(obj);
4965 if (!wd) return EINA_FALSE;
4966 return wd->homogeneous;
4970 * Set the maximum number of items within an item block
4972 * This will configure the block count to tune to the target with
4973 * particular performance matrix.
4975 * @param obj The genlist object
4976 * @param n Maximum number of items within an item block
4981 elm_genlist_block_count_set(Evas_Object *obj,
4984 ELM_CHECK_WIDTYPE(obj, widtype);
4985 Widget_Data *wd = elm_widget_data_get(obj);
4987 wd->max_items_per_block = n;
4988 wd->item_cache_max = wd->max_items_per_block * 2;
4989 _item_cache_clean(wd);
4993 * Get the maximum number of items within an item block
4995 * @param obj The genlist object
4996 * @return Maximum number of items within an item block
5001 elm_genlist_block_count_get(const Evas_Object *obj)
5003 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5004 Widget_Data *wd = elm_widget_data_get(obj);
5006 return wd->max_items_per_block;
5010 * Set the timeout in seconds for the longpress event
5012 * @param obj The genlist object
5013 * @param timeout timeout in seconds
5018 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5021 ELM_CHECK_WIDTYPE(obj, widtype);
5022 Widget_Data *wd = elm_widget_data_get(obj);
5024 wd->longpress_timeout = timeout;
5028 * Get the timeout in seconds for the longpress event
5030 * @param obj The genlist object
5031 * @return timeout in seconds
5036 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5038 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5039 Widget_Data *wd = elm_widget_data_get(obj);
5041 return wd->longpress_timeout;
5045 * Set the scrollbar policy
5047 * This sets the scrollbar visibility policy for the given genlist
5048 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5049 * made visible if it is needed, and otherwise kept hidden.
5050 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5051 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5052 * respectively for the horizontal and vertical scrollbars.
5054 * @param obj The genlist object
5055 * @param policy_h Horizontal scrollbar policy
5056 * @param policy_v Vertical scrollbar policy
5061 elm_genlist_scroller_policy_set(Evas_Object *obj,
5062 Elm_Scroller_Policy policy_h,
5063 Elm_Scroller_Policy policy_v)
5065 ELM_CHECK_WIDTYPE(obj, widtype);
5066 Widget_Data *wd = elm_widget_data_get(obj);
5068 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5069 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5072 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5076 * Get the scrollbar policy
5078 * @param obj The genlist object
5079 * @param policy_h Horizontal scrollbar policy
5080 * @param policy_v Vertical scrollbar policy
5085 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5086 Elm_Scroller_Policy *policy_h,
5087 Elm_Scroller_Policy *policy_v)
5089 ELM_CHECK_WIDTYPE(obj, widtype);
5090 Widget_Data *wd = elm_widget_data_get(obj);
5091 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5092 if ((!wd) || (!wd->scr)) return;
5093 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5094 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5095 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5099 * Update the contents of all realized items
5101 * This updates all realized items by calling all the item class functions again
5102 * to get the icons, labels and states. Use this when the original
5103 * item data has changed and the changes are desired to be reflected.
5105 * @param it The item
5110 elm_genlist_realized_items_update(Evas_Object *obj)
5112 ELM_CHECK_WIDTYPE(obj, widtype);
5114 Eina_List *list, *l;
5115 Elm_Genlist_Item *it;
5117 list = elm_genlist_realized_items_get(obj);
5118 EINA_LIST_FOREACH(list, l, it)
5119 elm_genlist_item_update(it);
5123 * Set genlist item mode
5125 * @param item The genlist item
5126 * @param mode Mode name
5127 * @param mode_set Boolean to define set or unset mode.
5132 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5133 const char *mode_type,
5136 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5137 Widget_Data *wd = it->wd;
5139 Elm_Genlist_Item *it2;
5142 if (!mode_type) return;
5144 if ((wd->mode_item == it) &&
5145 (!strcmp(mode_type, wd->mode_type)) &&
5148 if (!it->itc->mode_item_style) return;
5152 EINA_LIST_FOREACH(wd->selected, l, it2)
5154 elm_genlist_item_selected_set(it2, EINA_FALSE);
5158 it2 = elm_genlist_selected_item_get(wd->obj);
5159 if ((it2) && (it2->realized))
5160 elm_genlist_item_selected_set(it2, EINA_FALSE);
5163 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5165 ((it == wd->mode_item) && (!mode_set)))
5166 _item_mode_unset(wd);
5168 eina_stringshare_replace(&wd->mode_type, mode_type);
5169 if (mode_set) _item_mode_set(it);
5173 * Get active genlist mode type
5175 * @param obj The genlist object
5180 elm_genlist_mode_get(const Evas_Object *obj)
5182 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5183 Widget_Data *wd = elm_widget_data_get(obj);
5184 if (!wd) return NULL;
5185 return wd->mode_type;
5189 * Get active genlist mode item
5191 * @param obj The genlist object
5195 EAPI const Elm_Genlist_Item *
5196 elm_genlist_mode_item_get(const Evas_Object *obj)
5198 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5199 Widget_Data *wd = elm_widget_data_get(obj);
5200 if (!wd) return NULL;
5201 return wd->mode_item;