3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
9 #define REORDER_EFFECT_TIME 0.5
12 * @defgroup Genlist Genlist
14 * The aim was to have more expansive list than the simple list in
15 * Elementary that could have more flexible items and allow many more entries
16 * while still being fast and low on memory usage. At the same time it was
17 * also made to be able to do tree structures. But the price to pay is more
18 * complex when it comes to usage. If all you want is a simple list with
19 * icons and a single label, use the normal List object.
21 * Genlist has a fairly large API, mostly because it's relatively complex,
22 * trying to be both expansive, powerful and efficient. First we will begin
23 * an overview on the theory behind genlist.
25 * Evas tracks every object you create. Every time it processes an event
26 * (mouse move, down, up etc.) it needs to walk through objects and find out
27 * what event that affects. Even worse every time it renders display updates,
28 * in order to just calculate what to re-draw, it needs to walk through many
29 * many many objects. Thus, the more objects you keep active, the more
30 * overhead Evas has in just doing its work. It is advisable to keep your
31 * active objects to the minimum working set you need. Also remember that
32 * object creation and deletion carries an overhead, so there is a
33 * middle-ground, which is not easily determined. But don't keep massive lists
34 * of objects you can't see or use. Genlist does this with list objects. It
35 * creates and destroys them dynamically as you scroll around. It groups them
36 * into blocks so it can determine the visibility etc. of a whole block at
37 * once as opposed to having to walk the whole list. This 2-level list allows
38 * for very large numbers of items to be in the list (tests have used up to
39 * 2,000,000 items). Also genlist employs a queue for adding items. As items
40 * may be different sizes, every item added needs to be calculated as to its
41 * size and thus this presents a lot of overhead on populating the list, this
42 * genlist employs a queue. Any item added is queued and spooled off over
43 * time, actually appearing some time later, so if your list has many members
44 * you may find it takes a while for them to all appear, with your process
45 * consuming a lot of CPU while it is busy spooling.
47 * Genlist also implements a tree structure, but it does so with callbacks to
48 * the application, with the application filling in tree structures when
49 * requested (allowing for efficient building of a very deep tree that could
50 * even be used for file-management). See the above smart signal callbacks for
53 * An item in the genlist world can have 0 or more text labels (they can be
54 * regular text or textblock - that's up to the style to determine), 0 or
55 * more icons (which are simply objects swallowed into the genlist item) and
56 * 0 or more boolean states that can be used for check, radio or other
57 * indicators by the edje theme style. An item may be one of several styles
58 * (Elementary provides 4 by default - "default", "double_label", "group_index"
59 * and "icon_top_text_bottom", but this can be extended by system or
60 * application custom themes/overlays/extensions).
62 * In order to implement the ability to add and delete items on the fly,
63 * Genlist implements a class/callback system where the application provides
64 * a structure with information about that type of item (genlist may contain
65 * multiple different items with different classes, states and styles).
66 * Genlist will call the functions in this struct (methods) when an item is
67 * "realized" (that is created dynamically while scrolling). All objects will
68 * simply be deleted when no longer needed with evas_object_del(). The
69 * Elm_Genlist_Item_Class structure contains the following members:
71 * item_style - This is a constant string and simply defines the name of the
72 * item style. It must be specified and the default should be "default".
74 * func.label_get - This function is called when an actual item object is
75 * created. The data parameter is the data parameter passed to
76 * elm_genlist_item_append() and related item creation functions. The obj
77 * parameter is the genlist object and the part parameter is the string name
78 * of the text part in the edje design that is listed as one of the possible
79 * labels that can be set. This function must return a strudup()'ed string as
80 * the caller will free() it when done.
82 * func.icon_get - This function is called when an actual item object is
83 * created. The data parameter is the data parameter passed to
84 * elm_genlist_item_append() and related item creation functions. The obj
85 * parameter is the genlist object and the part parameter is the string name
86 * of the icon part in the edje design that is listed as one of the possible
87 * icons that can be set. This must return NULL for no object or a valid
88 * object. The object will be deleted by genlist on shutdown or when the item
91 * func.state_get - This function is called when an actual item object is
92 * created. The data parameter is the data parameter passed to
93 * elm_genlist_item_append() and related item creation functions. The obj
94 * parameter is the genlist object and the part parameter is the string name
95 * of the state part in the edje design that is listed as one of the possible
96 * states that can be set. Return 0 for false or 1 for true. Genlist will
97 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
98 * true (the default is false), where XXX is the name of the part.
100 * func.del - This is called when elm_genlist_item_del() is called on an
101 * item, elm_genlist_clear() is called on the genlist, or
102 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
103 * intended for use when actual genlist items are deleted, so any backing
104 * data attached to the item (e.g. its data parameter on creation) can be
107 * Items can be added by several calls. All of them return a Elm_Genlist_Item
108 * handle that is an internal member inside the genlist. They all take a data
109 * parameter that is meant to be used for a handle to the applications
110 * internal data (eg the struct with the original item data). The parent
111 * parameter is the parent genlist item this belongs to if it is a tree or
112 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
113 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
114 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
115 * is displayed as an item that is able to expand and have child items.
116 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
117 * displayed at the top until the next group comes. The func parameter is a
118 * convenience callback that is called when the item is selected and the data
119 * parameter will be the func_data parameter, obj be the genlist object and
120 * event_info will be the genlist item.
122 * elm_genlist_item_append() appends an item to the end of the list, or if
123 * there is a parent, to the end of all the child items of the parent.
124 * elm_genlist_item_prepend() is the same but prepends to the beginning of
125 * the list or children list. elm_genlist_item_insert_before() inserts at
126 * item before another item and elm_genlist_item_insert_after() inserts after
127 * the indicated item.
129 * The application can clear the list with elm_genlist_clear() which deletes
130 * all the items in the list and elm_genlist_item_del() will delete a specific
131 * item. elm_genlist_item_subitems_clear() will clear all items that are
132 * children of the indicated parent item.
134 * If the application wants multiple items to be able to be selected,
135 * elm_genlist_multi_select_set() can enable this. If the list is
136 * single-selection only (the default), then elm_genlist_selected_item_get()
137 * will return the selected item, if any, or NULL I none is selected. If the
138 * list is multi-select then elm_genlist_selected_items_get() will return a
139 * list (that is only valid as long as no items are modified (added, deleted,
140 * selected or unselected)).
142 * To help inspect list items you can jump to the item at the top of the list
143 * with elm_genlist_first_item_get() which will return the item pointer, and
144 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
145 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
146 * and previous items respectively relative to the indicated item. Using
147 * these calls you can walk the entire item list/tree. Note that as a tree
148 * the items are flattened in the list, so elm_genlist_item_parent_get() will
149 * let you know which item is the parent (and thus know how to skip them if
152 * There are also convenience functions. elm_genlist_item_genlist_get() will
153 * return the genlist object the item belongs to. elm_genlist_item_show()
154 * will make the scroller scroll to show that specific item so its visible.
155 * elm_genlist_item_data_get() returns the data pointer set by the item
156 * creation functions.
158 * If an item changes (state of boolean changes, label or icons change),
159 * then use elm_genlist_item_update() to have genlist update the item with
160 * the new state. Genlist will re-realize the item thus call the functions
161 * in the _Elm_Genlist_Item_Class for that item.
163 * To programmatically (un)select an item use elm_genlist_item_selected_set().
164 * To get its selected state use elm_genlist_item_selected_get(). Similarly
165 * to expand/contract an item and get its expanded state, use
166 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
167 * again to make an item disabled (unable to be selected and appear
168 * differently) use elm_genlist_item_disabled_set() to set this and
169 * elm_genlist_item_disabled_get() to get the disabled state.
171 * In general to indicate how the genlist should expand items horizontally to
172 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
173 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
174 * mode means that if items are too wide to fit, the scroller will scroll
175 * horizontally. Otherwise items are expanded to fill the width of the
176 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
177 * to the viewport width and limited to that size. This can be combined with
178 * a different style that uses edjes' ellipsis feature (cutting text off like
181 * Items will only call their selection func and callback when first becoming
182 * selected. Any further clicks will do nothing, unless you enable always
183 * select with elm_genlist_always_select_mode_set(). This means even if
184 * selected, every click will make the selected callbacks be called.
185 * elm_genlist_no_select_mode_set() will turn off the ability to select
186 * items entirely and they will neither appear selected nor call selected
187 * callback functions.
189 * Remember that you can create new styles and add your own theme augmentation
190 * per application with elm_theme_extension_add(). If you absolutely must
191 * have a specific style that overrides any theme the user or system sets up
192 * you can use elm_theme_overlay_add() to add such a file.
196 typedef struct _Widget_Data Widget_Data;
197 typedef struct _Item_Block Item_Block;
198 typedef struct _Pan Pan;
199 typedef struct _Item_Cache Item_Cache;
203 Evas_Object *obj, *scr, *pan_smart;
204 Eina_Inlist *items, *blocks;
205 Eina_List *group_items;
207 Evas_Coord pan_x, pan_y, old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
208 Ecore_Job *calc_job, *update_job;
209 Ecore_Idle_Enterer *queue_idle_enterer;
210 Ecore_Idler *must_recalc_idler;
211 Eina_List *queue, *selected;
212 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item, *reorder_it, *reorder_rel, *expanded_item;
213 Eina_Inlist *item_cache;
214 Evas_Coord anchor_y, reorder_start_y;
216 Ecore_Timer *multi_timer, *scr_hold_timer;
217 Ecore_Animator *reorder_move_animator;
218 const char *mode_type;
219 unsigned int start_time;
220 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
221 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
222 Eina_Bool mouse_down : 1;
223 Eina_Bool multi_down : 1;
224 Eina_Bool multi_timeout : 1;
225 Eina_Bool multitouched : 1;
226 Eina_Bool on_hold : 1;
228 Eina_Bool always_select : 1;
229 Eina_Bool longpressed : 1;
230 Eina_Bool wasselected : 1;
231 Eina_Bool no_select : 1;
232 Eina_Bool bring_in : 1;
233 Eina_Bool compress : 1;
234 Eina_Bool height_for_width : 1;
235 Eina_Bool homogeneous : 1;
236 Eina_Bool clear_me : 1;
238 Eina_Bool reorder_mode : 1;
239 Eina_Bool reorder_pan_move : 1;
240 Eina_Bool auto_scroll_enabled : 1;
244 } history[SWIPE_MOVES];
246 int item_cache_count;
252 int group_item_width;
253 int group_item_height;
254 int max_items_per_block;
255 double longpress_timeout;
266 Evas_Coord x, y, w, h, minw, minh;
267 Eina_Bool want_unrealize : 1;
268 Eina_Bool realized : 1;
269 Eina_Bool changed : 1;
270 Eina_Bool updateme : 1;
271 Eina_Bool showme : 1;
272 Eina_Bool must_recalc : 1;
275 struct _Elm_Genlist_Item
277 Elm_Widget_Item base;
282 Evas_Coord x, y, w, h, minw, minh;
283 const Elm_Genlist_Item_Class *itc;
284 Elm_Genlist_Item *parent;
285 Elm_Genlist_Item *group_item;
286 Elm_Genlist_Item_Flags flags;
294 Eina_List *labels, *icons, *states, *icon_objs;
295 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
296 Ecore_Timer *long_timer;
297 Ecore_Timer *swipe_timer;
299 Evas_Coord scrl_x, scrl_y, old_scrl_y;
301 Elm_Genlist_Item *rel;
302 Evas_Object *mode_view;
307 Elm_Tooltip_Item_Content_Cb content_cb;
308 Evas_Smart_Cb del_cb;
312 const char *mouse_cursor;
319 Eina_Bool before : 1;
321 Eina_Bool want_unrealize : 1;
322 Eina_Bool want_realize : 1;
323 Eina_Bool realized : 1;
324 Eina_Bool selected : 1;
325 Eina_Bool highlighted : 1;
326 Eina_Bool expanded : 1;
327 Eina_Bool disabled : 1;
328 Eina_Bool display_only : 1;
329 Eina_Bool mincalcd : 1;
330 Eina_Bool queued : 1;
331 Eina_Bool showme : 1;
332 Eina_Bool delete_me : 1;
334 Eina_Bool dragging : 1;
335 Eina_Bool updateme : 1;
336 Eina_Bool nocache : 1;
337 Eina_Bool stacking_even : 1;
338 Eina_Bool nostacking : 1;
339 Eina_Bool move_effect_enabled : 1;
346 Evas_Object *base_view, *spacer;
348 const char *item_style; // it->itc->item_style
349 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
350 Eina_Bool compress : 1; // it->wd->compress
352 Eina_Bool selected : 1; // it->selected
353 Eina_Bool disabled : 1; // it->disabled
354 Eina_Bool expanded : 1; // it->expanded
357 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
358 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
362 Evas_Object_Smart_Clipped_Data __clipped_data;
364 Ecore_Job *resize_job;
367 static const char *widtype = NULL;
368 static void _item_cache_zero(Widget_Data *wd);
369 static void _del_hook(Evas_Object *obj);
370 static void _mirrored_set(Evas_Object *obj,
372 static void _theme_hook(Evas_Object *obj);
373 static void _show_region_hook(void *data,
375 static void _sizing_eval(Evas_Object *obj);
376 static void _item_realize(Elm_Genlist_Item *it,
379 static void _item_unrealize(Elm_Genlist_Item *it,
381 static void _item_block_unrealize(Item_Block *itb);
382 static void _calc_job(void *data);
383 static void _on_focus_hook(void *data,
385 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
386 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
387 static Eina_Bool _item_single_select_up(Widget_Data *wd);
388 static Eina_Bool _item_single_select_down(Widget_Data *wd);
389 static Eina_Bool _event_hook(Evas_Object *obj,
391 Evas_Callback_Type type,
393 static void _signal_emit_hook(Evas_Object *obj,
394 const char *emission,
396 static Eina_Bool _deselect_all_items(Widget_Data *wd);
397 static void _pan_calculate(Evas_Object *obj);
398 static void _item_position(Elm_Genlist_Item *it,
402 static void _mode_item_realize(Elm_Genlist_Item *it);
403 static void _mode_item_unrealize(Elm_Genlist_Item *it);
404 static void _item_mode_set(Elm_Genlist_Item *it);
405 static void _item_mode_unset(Widget_Data *wd);
406 static void _group_items_recalc(void *data);
407 static void _item_move_after(Elm_Genlist_Item *it,
408 Elm_Genlist_Item *after);
409 static void _item_move_before(Elm_Genlist_Item *it,
410 Elm_Genlist_Item *before);
411 static void _item_auto_scroll(Widget_Data *wd);
413 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
415 static const char SIG_ACTIVATED[] = "activated";
416 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
417 static const char SIG_SELECTED[] = "selected";
418 static const char SIG_UNSELECTED[] = "unselected";
419 static const char SIG_EXPANDED[] = "expanded";
420 static const char SIG_CONTRACTED[] = "contracted";
421 static const char SIG_EXPAND_REQUEST[] = "expand,request";
422 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
423 static const char SIG_REALIZED[] = "realized";
424 static const char SIG_UNREALIZED[] = "unrealized";
425 static const char SIG_DRAG_START_UP[] = "drag,start,up";
426 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
427 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
428 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
429 static const char SIG_DRAG_STOP[] = "drag,stop";
430 static const char SIG_DRAG[] = "drag";
431 static const char SIG_LONGPRESSED[] = "longpressed";
432 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
433 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
434 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
435 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
436 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
437 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
438 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
439 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
440 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
441 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
442 static const char SIG_SWIPE[] = "swipe";
444 static const Evas_Smart_Cb_Description _signals[] = {
445 {SIG_CLICKED_DOUBLE, ""},
448 {SIG_UNSELECTED, ""},
450 {SIG_CONTRACTED, ""},
451 {SIG_EXPAND_REQUEST, ""},
452 {SIG_CONTRACT_REQUEST, ""},
454 {SIG_UNREALIZED, ""},
455 {SIG_DRAG_START_UP, ""},
456 {SIG_DRAG_START_DOWN, ""},
457 {SIG_DRAG_START_LEFT, ""},
458 {SIG_DRAG_START_RIGHT, ""},
461 {SIG_LONGPRESSED, ""},
462 {SIG_SCROLL_EDGE_TOP, ""},
463 {SIG_SCROLL_EDGE_BOTTOM, ""},
464 {SIG_SCROLL_EDGE_LEFT, ""},
465 {SIG_SCROLL_EDGE_RIGHT, ""},
466 {SIG_MULTI_SWIPE_LEFT, ""},
467 {SIG_MULTI_SWIPE_RIGHT, ""},
468 {SIG_MULTI_SWIPE_UP, ""},
469 {SIG_MULTI_SWIPE_DOWN, ""},
470 {SIG_MULTI_PINCH_OUT, ""},
471 {SIG_MULTI_PINCH_IN, ""},
476 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
477 static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
480 _event_hook(Evas_Object *obj,
481 Evas_Object *src __UNUSED__,
482 Evas_Callback_Type type,
485 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
486 Evas_Event_Key_Down *ev = event_info;
487 Widget_Data *wd = elm_widget_data_get(obj);
488 if (!wd) return EINA_FALSE;
489 if (!wd->items) return EINA_FALSE;
490 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
491 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
493 Elm_Genlist_Item *it = NULL;
496 Evas_Coord step_x = 0;
497 Evas_Coord step_y = 0;
500 Evas_Coord page_x = 0;
501 Evas_Coord page_y = 0;
503 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
504 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
505 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
506 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
508 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
512 else if ((!strcmp(ev->keyname, "Right")) ||
513 (!strcmp(ev->keyname, "KP_Right")))
517 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
519 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
520 (_item_multi_select_up(wd)))
521 || (_item_single_select_up(wd)))
523 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
529 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
531 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
532 (_item_multi_select_down(wd)))
533 || (_item_single_select_down(wd)))
535 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
541 else if ((!strcmp(ev->keyname, "Home")) ||
542 (!strcmp(ev->keyname, "KP_Home")))
544 it = elm_genlist_first_item_get(obj);
545 elm_genlist_item_bring_in(it);
546 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
549 else if ((!strcmp(ev->keyname, "End")) ||
550 (!strcmp(ev->keyname, "KP_End")))
552 it = elm_genlist_last_item_get(obj);
553 elm_genlist_item_bring_in(it);
554 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
557 else if ((!strcmp(ev->keyname, "Prior")) ||
558 (!strcmp(ev->keyname, "KP_Prior")))
561 y -= -(page_y * v_h) / 100;
565 else if ((!strcmp(ev->keyname, "Next")) ||
566 (!strcmp(ev->keyname, "KP_Next")))
569 y += -(page_y * v_h) / 100;
573 else if (((!strcmp(ev->keyname, "Return")) ||
574 (!strcmp(ev->keyname, "KP_Enter")) ||
575 (!strcmp(ev->keyname, "space")))
576 && (!wd->multi) && (wd->selected))
578 it = elm_genlist_selected_item_get(obj);
579 elm_genlist_item_expanded_set(it,
580 !elm_genlist_item_expanded_get(it));
581 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
583 else if (!strcmp(ev->keyname, "Escape"))
585 if (!_deselect_all_items(wd)) return EINA_FALSE;
586 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
589 else return EINA_FALSE;
591 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
592 elm_smart_scroller_child_pos_set(wd->scr, x, y);
597 _deselect_all_items(Widget_Data *wd)
599 if (!wd->selected) return EINA_FALSE;
601 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
607 _item_multi_select_up(Widget_Data *wd)
609 if (!wd->selected) return EINA_FALSE;
610 if (!wd->multi) return EINA_FALSE;
612 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
613 if (!prev) return EINA_TRUE;
615 if (elm_genlist_item_selected_get(prev))
617 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
618 wd->last_selected_item = prev;
619 elm_genlist_item_show(wd->last_selected_item);
623 elm_genlist_item_selected_set(prev, EINA_TRUE);
624 elm_genlist_item_show(prev);
630 _item_multi_select_down(Widget_Data *wd)
632 if (!wd->selected) return EINA_FALSE;
633 if (!wd->multi) return EINA_FALSE;
635 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
636 if (!next) return EINA_TRUE;
638 if (elm_genlist_item_selected_get(next))
640 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
641 wd->last_selected_item = next;
642 elm_genlist_item_show(wd->last_selected_item);
646 elm_genlist_item_selected_set(next, EINA_TRUE);
647 elm_genlist_item_show(next);
653 _item_single_select_up(Widget_Data *wd)
655 Elm_Genlist_Item *prev;
658 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
659 while ((prev) && (prev->delete_me))
660 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
662 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
664 if (!prev) return EINA_FALSE;
666 _deselect_all_items(wd);
668 elm_genlist_item_selected_set(prev, EINA_TRUE);
669 elm_genlist_item_show(prev);
674 _item_single_select_down(Widget_Data *wd)
676 Elm_Genlist_Item *next;
679 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
680 while ((next) && (next->delete_me))
681 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
683 else next = elm_genlist_item_next_get(wd->last_selected_item);
685 if (!next) return EINA_FALSE;
687 _deselect_all_items(wd);
689 elm_genlist_item_selected_set(next, EINA_TRUE);
690 elm_genlist_item_show(next);
695 _on_focus_hook(void *data __UNUSED__,
698 Widget_Data *wd = elm_widget_data_get(obj);
700 if (elm_widget_focus_get(obj))
702 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
703 evas_object_focus_set(wd->obj, EINA_TRUE);
704 if ((wd->selected) && (!wd->last_selected_item))
705 wd->last_selected_item = eina_list_data_get(wd->selected);
709 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
710 evas_object_focus_set(wd->obj, EINA_FALSE);
715 _del_hook(Evas_Object *obj)
717 Widget_Data *wd = elm_widget_data_get(obj);
719 _item_cache_zero(wd);
720 if (wd->calc_job) ecore_job_del(wd->calc_job);
721 if (wd->update_job) ecore_job_del(wd->update_job);
722 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
723 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
724 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
725 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
726 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
731 _del_pre_hook(Evas_Object *obj)
733 Widget_Data *wd = elm_widget_data_get(obj);
735 evas_object_del(wd->pan_smart);
736 wd->pan_smart = NULL;
737 elm_genlist_clear(obj);
741 _mirrored_set(Evas_Object *obj,
744 Widget_Data *wd = elm_widget_data_get(obj);
746 _item_cache_zero(wd);
747 elm_smart_scroller_mirrored_set(wd->scr, rtl);
751 _theme_hook(Evas_Object *obj)
753 Widget_Data *wd = elm_widget_data_get(obj);
756 evas_event_freeze(evas_object_evas_get(wd->obj));
757 _item_cache_zero(wd);
758 _elm_widget_mirrored_reload(obj);
759 _mirrored_set(obj, elm_widget_mirrored_get(obj));
760 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
761 elm_widget_style_get(obj));
762 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
763 wd->item_width = wd->item_height = 0;
764 wd->group_item_width = wd->group_item_height = 0;
765 wd->minw = wd->minh = wd->realminw = 0;
766 EINA_INLIST_FOREACH(wd->blocks, itb)
769 Elm_Genlist_Item *it;
771 if (itb->realized) _item_block_unrealize(itb);
772 EINA_LIST_FOREACH(itb->items, l, it)
773 it->mincalcd = EINA_FALSE;
775 itb->changed = EINA_TRUE;
777 if (wd->calc_job) ecore_job_del(wd->calc_job);
778 wd->calc_job = ecore_job_add(_calc_job, wd);
780 evas_event_thaw(evas_object_evas_get(wd->obj));
781 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
785 _show_region_hook(void *data,
788 Widget_Data *wd = elm_widget_data_get(data);
789 Evas_Coord x, y, w, h;
791 elm_widget_show_region_get(obj, &x, &y, &w, &h);
792 //x & y are screen coordinates, Add with pan coordinates
795 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
799 _sizing_eval(Evas_Object *obj)
801 Widget_Data *wd = elm_widget_data_get(obj);
802 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
804 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
805 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
807 if (wd->height_for_width)
811 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
812 if ((vw != 0) && (vw != wd->prev_viewport_w))
816 wd->prev_viewport_w = vw;
817 EINA_INLIST_FOREACH(wd->blocks, itb)
819 itb->must_recalc = EINA_TRUE;
821 if (wd->calc_job) ecore_job_del(wd->calc_job);
822 wd->calc_job = ecore_job_add(_calc_job, wd);
825 if (wd->mode == ELM_LIST_LIMIT)
827 Evas_Coord vmw, vmh, vw, vh;
831 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
832 if ((minw > 0) && (vw < minw)) vw = minw;
833 else if ((maxw > 0) && (vw > maxw))
835 edje_object_size_min_calc
836 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
843 edje_object_size_min_calc
844 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
848 evas_object_size_hint_min_set(obj, minw, minh);
849 evas_object_size_hint_max_set(obj, maxw, maxh);
853 _signal_emit_hook(Evas_Object *obj,
854 const char *emission,
857 Widget_Data *wd = elm_widget_data_get(obj);
858 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
863 _item_highlight(Elm_Genlist_Item *it)
865 const char *selectraise;
866 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
867 (it->disabled) || (it->display_only) || (it->mode_view))
869 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
870 selectraise = edje_object_data_get(it->base.view, "selectraise");
871 if ((selectraise) && (!strcmp(selectraise, "on")))
873 evas_object_raise(it->base.view);
874 if ((it->group_item) && (it->group_item->realized))
875 evas_object_raise(it->group_item->base.view);
877 it->highlighted = EINA_TRUE;
881 _item_unhighlight(Elm_Genlist_Item *it)
883 const char *stacking, *selectraise;
884 if ((it->delete_me) || (!it->highlighted)) return;
885 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
886 stacking = edje_object_data_get(it->base.view, "stacking");
887 selectraise = edje_object_data_get(it->base.view, "selectraise");
890 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
891 else evas_object_raise(it->base.view);
893 it->highlighted = EINA_FALSE;
897 _item_block_del(Elm_Genlist_Item *it)
900 Item_Block *itb = it->block;
902 itb->items = eina_list_remove(itb->items, it);
904 itb->changed = EINA_TRUE;
905 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
906 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
909 il = EINA_INLIST_GET(itb);
910 Item_Block *itbn = (Item_Block *)(il->next);
912 it->parent->items = eina_list_remove(it->parent->items, it);
914 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
916 if (itbn) itbn->changed = EINA_TRUE;
920 if (itb->count < itb->wd->max_items_per_block/2)
922 il = EINA_INLIST_GET(itb);
923 Item_Block *itbp = (Item_Block *)(il->prev);
924 Item_Block *itbn = (Item_Block *)(il->next);
925 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
927 Elm_Genlist_Item *it2;
929 EINA_LIST_FREE(itb->items, it2)
932 itbp->items = eina_list_append(itbp->items, it2);
934 itbp->changed = EINA_TRUE;
936 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
937 EINA_INLIST_GET(itb));
940 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
944 Eina_List *last = eina_list_last(itb->items);
945 Elm_Genlist_Item *it2 = last->data;
948 itb->items = eina_list_remove_list(itb->items, last);
949 itbn->items = eina_list_prepend(itbn->items, it2);
951 itbn->changed = EINA_TRUE;
954 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
962 _item_del(Elm_Genlist_Item *it)
964 Evas_Object *tob = it->wd->obj;
966 evas_event_freeze(evas_object_evas_get(tob));
967 elm_widget_item_pre_notify_del(it);
968 elm_genlist_item_subitems_clear(it);
969 it->wd->walking -= it->walking;
970 if (it->wd->show_item == it) it->wd->show_item = NULL;
971 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
972 if (it->realized) _item_unrealize(it, EINA_FALSE);
973 if (it->block) _item_block_del(it);
974 if ((!it->delete_me) && (it->itc->func.del))
975 it->itc->func.del((void *)it->base.data, it->base.widget);
976 it->delete_me = EINA_TRUE;
978 it->wd->queue = eina_list_remove(it->wd->queue, it);
979 if (it->wd->anchor_item == it)
981 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
982 if (!it->wd->anchor_item)
983 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
985 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
987 it->parent->items = eina_list_remove(it->parent->items, it);
988 if (it->flags & ELM_GENLIST_ITEM_GROUP)
989 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
990 if (it->long_timer) ecore_timer_del(it->long_timer);
991 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
993 if (it->tooltip.del_cb)
994 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
996 evas_event_thaw(evas_object_evas_get(tob));
997 evas_event_thaw_eval(evas_object_evas_get(tob));
999 elm_widget_item_del(it);
1003 _item_select(Elm_Genlist_Item *it)
1005 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
1008 if (it->wd->always_select) goto call;
1011 it->selected = EINA_TRUE;
1012 it->wd->selected = eina_list_append(it->wd->selected, it);
1016 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1018 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
1021 if ((it->wd->clear_me) && (!it->wd->walking))
1022 elm_genlist_clear(it->base.widget);
1025 if ((!it->walking) && (it->delete_me))
1027 if (!it->relcount) _item_del(it);
1030 it->wd->last_selected_item = it;
1034 _item_unselect(Elm_Genlist_Item *it)
1036 if ((it->delete_me) || (!it->selected)) return;
1037 it->selected = EINA_FALSE;
1038 it->wd->selected = eina_list_remove(it->wd->selected, it);
1039 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1043 _mouse_move(void *data,
1044 Evas *evas __UNUSED__,
1048 Elm_Genlist_Item *it = data;
1049 Evas_Event_Mouse_Move *ev = event_info;
1050 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1051 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
1053 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1055 if (!it->wd->on_hold)
1057 it->wd->on_hold = EINA_TRUE;
1058 if (!it->wd->wasselected)
1060 _item_unhighlight(it);
1065 if (it->wd->multitouched)
1067 it->wd->cur_x = ev->cur.canvas.x;
1068 it->wd->cur_y = ev->cur.canvas.y;
1071 if ((it->dragging) && (it->down))
1073 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1076 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1077 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1078 if (abs((it->wd->history[it->wd->movements].x -
1079 it->wd->history[0].x)) > 40)
1080 it->wd->swipe = EINA_TRUE;
1082 it->wd->movements++;
1086 ecore_timer_del(it->long_timer);
1087 it->long_timer = NULL;
1089 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1092 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1096 ecore_timer_del(it->long_timer);
1097 it->long_timer = NULL;
1099 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1101 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1102 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1104 if (!it->wd->reorder_start_y)
1105 it->wd->reorder_start_y = it->block->y + it->y;
1107 if (it_scrl_y < oy) y_pos = oy;
1108 else if (it_scrl_y + it->wd->reorder_it->h > oy+oh)
1109 y_pos = oy + oh - it->wd->reorder_it->h;
1110 else y_pos = it_scrl_y;
1112 _item_position(it, it->base.view, it->scrl_x, y_pos);
1114 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1115 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1119 if (!it->display_only)
1120 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1121 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1122 x = ev->cur.canvas.x - x;
1123 y = ev->cur.canvas.y - y;
1126 if (adx < 0) adx = -dx;
1129 if (ady < 0) ady = -dy;
1132 if ((adx > minw) || (ady > minh))
1134 it->dragging = EINA_TRUE;
1137 ecore_timer_del(it->long_timer);
1138 it->long_timer = NULL;
1140 if (!it->wd->wasselected)
1142 _item_unhighlight(it);
1148 evas_object_smart_callback_call(it->base.widget,
1149 SIG_DRAG_START_UP, it);
1153 evas_object_smart_callback_call(it->base.widget,
1154 SIG_DRAG_START_LEFT, it);
1156 evas_object_smart_callback_call(it->base.widget,
1157 SIG_DRAG_START_RIGHT, it);
1163 evas_object_smart_callback_call(it->base.widget,
1164 SIG_DRAG_START_DOWN, it);
1168 evas_object_smart_callback_call(it->base.widget,
1169 SIG_DRAG_START_LEFT, it);
1171 evas_object_smart_callback_call(it->base.widget,
1172 SIG_DRAG_START_RIGHT, it);
1179 _long_press(void *data)
1181 Elm_Genlist_Item *it = data, *it_tmp;
1182 Eina_List *list, *l;
1184 it->long_timer = NULL;
1185 if ((it->disabled) || (it->dragging) || (it->display_only))
1186 return ECORE_CALLBACK_CANCEL;
1187 it->wd->longpressed = EINA_TRUE;
1188 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1189 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1191 it->wd->reorder_it = it;
1192 it->wd->reorder_start_y = 0;
1194 evas_object_raise(it->base.view);
1195 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1197 list = elm_genlist_realized_items_get(it->wd->obj);
1198 EINA_LIST_FOREACH(list, l, it_tmp)
1200 if (it != it_tmp) _item_unselect(it_tmp);
1202 if (elm_genlist_item_expanded_get(it))
1204 elm_genlist_item_expanded_set(it, EINA_FALSE);
1205 return ECORE_CALLBACK_RENEW;
1207 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1209 return ECORE_CALLBACK_CANCEL;
1213 _swipe(Elm_Genlist_Item *it)
1218 if ((it->display_only) || (it->disabled)) return;
1219 it->wd->swipe = EINA_FALSE;
1220 for (i = 0; i < it->wd->movements; i++)
1222 sum += it->wd->history[i].x;
1223 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1226 sum /= it->wd->movements;
1227 if (abs(sum - it->wd->history[0].x) <= 10) return;
1228 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1232 _swipe_cancel(void *data)
1234 Elm_Genlist_Item *it = data;
1236 if (!it) return ECORE_CALLBACK_CANCEL;
1237 it->wd->swipe = EINA_FALSE;
1238 it->wd->movements = 0;
1239 return ECORE_CALLBACK_RENEW;
1243 _multi_cancel(void *data)
1245 Widget_Data *wd = data;
1247 if (!wd) return ECORE_CALLBACK_CANCEL;
1248 wd->multi_timeout = EINA_TRUE;
1249 return ECORE_CALLBACK_RENEW;
1253 _multi_touch_gesture_eval(void *data)
1255 Elm_Genlist_Item *it = data;
1257 it->wd->multitouched = EINA_FALSE;
1258 if (it->wd->multi_timer)
1260 ecore_timer_del(it->wd->multi_timer);
1261 it->wd->multi_timer = NULL;
1263 if (it->wd->multi_timeout)
1265 it->wd->multi_timeout = EINA_FALSE;
1269 Evas_Coord minw = 0, minh = 0;
1270 Evas_Coord off_x, off_y, off_mx, off_my;
1272 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1273 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1274 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1275 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1276 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1278 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1280 if ((off_x + off_mx) > (off_y + off_my))
1282 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1283 evas_object_smart_callback_call(it->base.widget,
1284 SIG_MULTI_SWIPE_RIGHT, it);
1285 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1286 evas_object_smart_callback_call(it->base.widget,
1287 SIG_MULTI_SWIPE_LEFT, it);
1288 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1289 evas_object_smart_callback_call(it->base.widget,
1290 SIG_MULTI_PINCH_OUT, it);
1292 evas_object_smart_callback_call(it->base.widget,
1293 SIG_MULTI_PINCH_IN, it);
1297 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1298 evas_object_smart_callback_call(it->base.widget,
1299 SIG_MULTI_SWIPE_DOWN, it);
1300 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1301 evas_object_smart_callback_call(it->base.widget,
1302 SIG_MULTI_SWIPE_UP, it);
1303 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1304 evas_object_smart_callback_call(it->base.widget,
1305 SIG_MULTI_PINCH_OUT, it);
1307 evas_object_smart_callback_call(it->base.widget,
1308 SIG_MULTI_PINCH_IN, it);
1311 it->wd->multi_timeout = EINA_FALSE;
1315 _multi_down(void *data,
1316 Evas *evas __UNUSED__,
1317 Evas_Object *obj __UNUSED__,
1320 Elm_Genlist_Item *it = data;
1321 Evas_Event_Multi_Down *ev = event_info;
1323 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1324 it->wd->multi_device = ev->device;
1325 it->wd->multi_down = EINA_TRUE;
1326 it->wd->multitouched = EINA_TRUE;
1327 it->wd->prev_mx = ev->canvas.x;
1328 it->wd->prev_my = ev->canvas.y;
1329 if (!it->wd->wasselected)
1331 _item_unhighlight(it);
1334 it->wd->wasselected = EINA_FALSE;
1335 it->wd->longpressed = EINA_FALSE;
1338 ecore_timer_del(it->long_timer);
1339 it->long_timer = NULL;
1343 it->dragging = EINA_FALSE;
1344 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1346 if (it->swipe_timer)
1348 ecore_timer_del(it->swipe_timer);
1349 it->swipe_timer = NULL;
1351 if (it->wd->on_hold)
1353 it->wd->swipe = EINA_FALSE;
1354 it->wd->movements = 0;
1355 it->wd->on_hold = EINA_FALSE;
1360 _multi_up(void *data,
1361 Evas *evas __UNUSED__,
1362 Evas_Object *obj __UNUSED__,
1365 Elm_Genlist_Item *it = data;
1366 Evas_Event_Multi_Up *ev = event_info;
1368 if (it->wd->multi_device != ev->device) return;
1369 it->wd->multi_device = 0;
1370 it->wd->multi_down = EINA_FALSE;
1371 if (it->wd->mouse_down) return;
1372 _multi_touch_gesture_eval(data);
1376 _multi_move(void *data,
1377 Evas *evas __UNUSED__,
1378 Evas_Object *obj __UNUSED__,
1381 Elm_Genlist_Item *it = data;
1382 Evas_Event_Multi_Move *ev = event_info;
1384 if (it->wd->multi_device != ev->device) return;
1385 it->wd->cur_mx = ev->cur.canvas.x;
1386 it->wd->cur_my = ev->cur.canvas.y;
1390 _mouse_down(void *data,
1391 Evas *evas __UNUSED__,
1395 Elm_Genlist_Item *it = data;
1396 Evas_Event_Mouse_Down *ev = event_info;
1399 if (ev->button != 1) return;
1400 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1402 it->wd->on_hold = EINA_TRUE;
1405 it->down = EINA_TRUE;
1406 it->dragging = EINA_FALSE;
1407 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1408 it->dx = ev->canvas.x - x;
1409 it->dy = ev->canvas.y - y;
1410 it->wd->mouse_down = EINA_TRUE;
1411 if (!it->wd->multitouched)
1413 it->wd->prev_x = ev->canvas.x;
1414 it->wd->prev_y = ev->canvas.y;
1415 it->wd->multi_timeout = EINA_FALSE;
1416 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1417 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1419 it->wd->longpressed = EINA_FALSE;
1420 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1421 else it->wd->on_hold = EINA_FALSE;
1422 if (it->wd->on_hold) return;
1423 it->wd->wasselected = it->selected;
1424 _item_highlight(it);
1425 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1426 if ((!it->disabled) && (!it->display_only))
1428 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1429 evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
1431 if (it->long_timer) ecore_timer_del(it->long_timer);
1432 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1433 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1435 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1438 it->long_timer = NULL;
1439 it->wd->swipe = EINA_FALSE;
1440 it->wd->movements = 0;
1444 _mouse_up(void *data,
1445 Evas *evas __UNUSED__,
1446 Evas_Object *obj __UNUSED__,
1449 Elm_Genlist_Item *it = data;
1450 Evas_Event_Mouse_Up *ev = event_info;
1451 Eina_Bool dragged = EINA_FALSE;
1453 if (ev->button != 1) return;
1454 it->down = EINA_FALSE;
1455 it->wd->mouse_down = EINA_FALSE;
1456 if (it->wd->multitouched)
1458 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1459 if (it->wd->multi_down) return;
1460 _multi_touch_gesture_eval(data);
1463 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1464 else it->wd->on_hold = EINA_FALSE;
1467 ecore_timer_del(it->long_timer);
1468 it->long_timer = NULL;
1472 it->dragging = EINA_FALSE;
1473 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1476 if (it->swipe_timer)
1478 ecore_timer_del(it->swipe_timer);
1479 it->swipe_timer = NULL;
1481 if (it->wd->multi_timer)
1483 ecore_timer_del(it->wd->multi_timer);
1484 it->wd->multi_timer = NULL;
1485 it->wd->multi_timeout = EINA_FALSE;
1487 if (it->wd->on_hold)
1489 if (it->wd->swipe) _swipe(data);
1490 it->wd->longpressed = EINA_FALSE;
1491 it->wd->on_hold = EINA_FALSE;
1494 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1496 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1498 if (it->wd->reorder_rel)
1500 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent)
1502 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1503 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1505 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1509 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1510 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1513 edje_object_signal_emit(it->base.view, "elm,state,reorder,disabled", "elm");
1514 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1515 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1517 if (it->wd->longpressed)
1519 it->wd->longpressed = EINA_FALSE;
1520 if (!it->wd->wasselected)
1522 _item_unhighlight(it);
1525 it->wd->wasselected = EINA_FALSE;
1530 if (it->want_unrealize)
1532 _item_unrealize(it, EINA_FALSE);
1533 if (it->block->want_unrealize)
1534 _item_block_unrealize(it->block);
1537 if ((it->disabled) || (dragged) || (it->display_only)) return;
1538 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1543 _item_highlight(it);
1548 _item_unhighlight(it);
1556 Widget_Data *wd = it->wd;
1559 while (wd->selected)
1561 _item_unhighlight(wd->selected->data);
1562 _item_unselect(wd->selected->data);
1568 const Eina_List *l, *l_next;
1569 Elm_Genlist_Item *it2;
1571 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1574 _item_unhighlight(it2);
1575 _item_unselect(it2);
1577 //_item_highlight(it);
1580 _item_highlight(it);
1586 _signal_expand_toggle(void *data,
1587 Evas_Object *obj __UNUSED__,
1588 const char *emission __UNUSED__,
1589 const char *source __UNUSED__)
1591 Elm_Genlist_Item *it = data;
1594 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1596 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1600 _signal_expand(void *data,
1601 Evas_Object *obj __UNUSED__,
1602 const char *emission __UNUSED__,
1603 const char *source __UNUSED__)
1605 Elm_Genlist_Item *it = data;
1608 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1612 _signal_contract(void *data,
1613 Evas_Object *obj __UNUSED__,
1614 const char *emission __UNUSED__,
1615 const char *source __UNUSED__)
1617 Elm_Genlist_Item *it = data;
1620 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1624 _scr_hold_timer_cb(void *data)
1626 if (!data) return ECORE_CALLBACK_CANCEL;
1627 Widget_Data *wd = data;
1628 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1629 wd->scr_hold_timer = NULL;
1630 return ECORE_CALLBACK_CANCEL;
1634 _mode_finished_signal_cb(void *data,
1636 const char *emission __UNUSED__,
1637 const char *source __UNUSED__)
1641 Elm_Genlist_Item *it = data;
1642 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1644 Evas *te = evas_object_evas_get(obj);
1646 evas_event_freeze(te);
1647 it->nocache = EINA_FALSE;
1648 _mode_item_unrealize(it);
1649 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1650 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1651 evas_event_thaw(te);
1652 evas_event_thaw_eval(te);
1656 _item_cache_clean(Widget_Data *wd)
1658 evas_event_freeze(evas_object_evas_get(wd->obj));
1659 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1663 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1664 wd->item_cache = eina_inlist_remove(wd->item_cache,
1665 wd->item_cache->last);
1666 wd->item_cache_count--;
1667 if (itc->spacer) evas_object_del(itc->spacer);
1668 if (itc->base_view) evas_object_del(itc->base_view);
1669 if (itc->item_style) eina_stringshare_del(itc->item_style);
1672 evas_event_thaw(evas_object_evas_get(wd->obj));
1673 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1677 _item_cache_zero(Widget_Data *wd)
1679 int pmax = wd->item_cache_max;
1680 wd->item_cache_max = 0;
1681 _item_cache_clean(wd);
1682 wd->item_cache_max = pmax;
1686 _item_cache_add(Elm_Genlist_Item *it)
1690 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1691 if (it->wd->item_cache_max <= 0)
1693 evas_object_del(it->base.view);
1694 it->base.view = NULL;
1695 evas_object_del(it->spacer);
1697 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1698 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1702 it->wd->item_cache_count++;
1703 itc = calloc(1, sizeof(Item_Cache));
1704 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1705 EINA_INLIST_GET(itc));
1706 itc->spacer = it->spacer;
1708 itc->base_view = it->base.view;
1709 it->base.view = NULL;
1710 evas_object_hide(itc->base_view);
1711 evas_object_move(itc->base_view, -9999, -9999);
1712 itc->item_style = eina_stringshare_add(it->itc->item_style);
1713 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1714 itc->compress = (it->wd->compress);
1715 itc->selected = it->selected;
1716 itc->disabled = it->disabled;
1717 itc->expanded = it->expanded;
1720 ecore_timer_del(it->long_timer);
1721 it->long_timer = NULL;
1723 if (it->swipe_timer)
1725 ecore_timer_del(it->swipe_timer);
1726 it->swipe_timer = NULL;
1728 // FIXME: other callbacks?
1729 edje_object_signal_callback_del_full(itc->base_view,
1730 "elm,action,expand,toggle",
1731 "elm", _signal_expand_toggle, it);
1732 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1734 _signal_expand, it);
1735 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1736 "elm", _signal_contract, it);
1737 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1739 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1741 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1743 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1745 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1747 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1749 _item_cache_clean(it->wd);
1750 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1751 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1755 _item_cache_find(Elm_Genlist_Item *it)
1760 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1761 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1763 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1765 if ((itc->tree == tree) &&
1766 (itc->compress == it->wd->compress) &&
1767 (!strcmp(it->itc->item_style, itc->item_style)))
1769 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1770 EINA_INLIST_GET(itc));
1771 it->wd->item_cache_count--;
1779 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1781 if (!it->nostacking)
1783 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1784 evas_object_lower(it->base.view);
1786 evas_object_raise(it->base.view);
1789 if (it->order_num_in & 0x1)
1790 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1792 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1796 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1800 if (it->selected != itc->selected)
1803 edje_object_signal_emit(it->base.view,
1804 "elm,state,selected", "elm");
1806 if (it->disabled != itc->disabled)
1809 edje_object_signal_emit(it->base.view,
1810 "elm,state,disabled", "elm");
1812 if (it->expanded != itc->expanded)
1815 edje_object_signal_emit(it->base.view,
1816 "elm,state,expanded", "elm");
1822 edje_object_signal_emit(it->base.view,
1823 "elm,state,selected", "elm");
1825 edje_object_signal_emit(it->base.view,
1826 "elm,state,disabled", "elm");
1828 edje_object_signal_emit(it->base.view,
1829 "elm,state,expanded", "elm");
1834 _item_cache_free(Item_Cache *itc)
1836 if (itc->spacer) evas_object_del(itc->spacer);
1837 if (itc->base_view) evas_object_del(itc->base_view);
1838 if (itc->item_style) eina_stringshare_del(itc->item_style);
1843 _item_label_realize(Elm_Genlist_Item *it,
1844 Evas_Object *target,
1847 if (it->itc->func.label_get)
1852 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1853 EINA_LIST_FOREACH(*source, l, key)
1855 char *s = it->itc->func.label_get
1856 ((void *)it->base.data, it->base.widget, key);
1860 edje_object_part_text_set(target, key, s);
1865 edje_object_part_text_set(target, key, "");
1872 _item_icon_realize(Elm_Genlist_Item *it,
1873 Evas_Object *target,
1876 Eina_List *res = NULL;
1878 if (it->itc->func.icon_get)
1883 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1884 EINA_LIST_FOREACH(*source, l, key)
1886 Evas_Object *ic = it->itc->func.icon_get
1887 ((void *)it->base.data, it->base.widget, key);
1891 res = eina_list_append(res, ic);
1892 edje_object_part_swallow(target, key, ic);
1893 evas_object_show(ic);
1894 elm_widget_sub_object_add(it->base.widget, ic);
1896 elm_widget_disabled_set(ic, EINA_TRUE);
1905 _item_state_realize(Elm_Genlist_Item *it,
1906 Evas_Object *target,
1909 if (it->itc->func.state_get)
1915 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1916 EINA_LIST_FOREACH(*source, l, key)
1918 Eina_Bool on = it->itc->func.state_get
1919 ((void *)it->base.data, it->base.widget, key);
1923 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1924 edje_object_signal_emit(target, buf, "elm");
1928 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1929 edje_object_signal_emit(target, buf, "elm");
1936 _item_realize(Elm_Genlist_Item *it,
1940 Elm_Genlist_Item *it2;
1941 const char *treesize;
1943 int depth, tsize = 20;
1944 Item_Cache *itc = NULL;
1946 if (it->delete_me) return;
1947 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1950 if (it->order_num_in != in)
1952 it->order_num_in = in;
1953 _elm_genlist_item_odd_even_update(it);
1954 _elm_genlist_item_state_update(it, NULL);
1956 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1957 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1960 it->order_num_in = in;
1963 it->nocache = EINA_FALSE;
1965 itc = _item_cache_find(it);
1968 it->base.view = itc->base_view;
1969 itc->base_view = NULL;
1970 it->spacer = itc->spacer;
1975 const char *stacking_even;
1976 const char *stacking;
1978 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1979 edje_object_scale_set(it->base.view,
1980 elm_widget_scale_get(it->base.widget) *
1981 _elm_config->scale);
1982 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1983 elm_widget_sub_object_add(it->base.widget, it->base.view);
1985 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1986 strncpy(buf, "tree", sizeof(buf));
1987 else strncpy(buf, "item", sizeof(buf));
1988 if (it->wd->compress)
1989 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1991 strncat(buf, "/", sizeof(buf) - strlen(buf));
1992 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1994 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1995 elm_widget_style_get(it->base.widget));
1997 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1998 if (!stacking_even) stacking_even = "above";
1999 it->stacking_even = !!strcmp("above", stacking_even);
2001 stacking = edje_object_data_get(it->base.view, "stacking");
2002 if (!stacking) stacking = "yes";
2003 it->nostacking = !!strcmp("yes", stacking);
2005 edje_object_mirrored_set(it->base.view,
2006 elm_widget_mirrored_get(it->base.widget));
2008 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
2009 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2010 elm_widget_sub_object_add(it->base.widget, it->spacer);
2013 _elm_genlist_item_odd_even_update(it);
2015 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
2017 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
2019 it->expanded_depth = depth;
2020 treesize = edje_object_data_get(it->base.view, "treesize");
2021 if (treesize) tsize = atoi(treesize);
2022 evas_object_size_hint_min_set(it->spacer,
2023 (depth * tsize) * _elm_config->scale, 1);
2024 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
2027 edje_object_signal_callback_add(it->base.view,
2028 "elm,action,expand,toggle",
2029 "elm", _signal_expand_toggle, it);
2030 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
2031 "elm", _signal_expand, it);
2032 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
2033 "elm", _signal_contract, it);
2034 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
2036 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
2038 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
2040 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
2042 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
2044 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
2047 _elm_genlist_item_state_update(it, itc);
2050 if ((calc) && (it->wd->homogeneous) &&
2051 ((it->wd->item_width) ||
2052 ((it->wd->item_width) && (it->wd->group_item_width))))
2054 /* homogenous genlist shortcut */
2057 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2059 it->w = it->minw = it->wd->group_item_width;
2060 it->h = it->minh = it->wd->group_item_height;
2064 it->w = it->minw = it->wd->item_width;
2065 it->h = it->minh = it->wd->item_height;
2067 it->mincalcd = EINA_TRUE;
2072 /* FIXME: If you see that assert, please notify us and we
2073 will clean our mess */
2074 assert(eina_list_count(it->icon_objs) == 0);
2076 _item_label_realize(it, it->base.view, &it->labels);
2077 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
2078 _item_state_realize(it, it->base.view, &it->states);
2082 Evas_Coord mw = -1, mh = -1;
2084 if (!it->display_only)
2085 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2086 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2087 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2089 if (!it->display_only)
2090 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2091 it->w = it->minw = mw;
2092 it->h = it->minh = mh;
2093 it->mincalcd = EINA_TRUE;
2095 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2097 it->wd->group_item_width = mw;
2098 it->wd->group_item_height = mh;
2100 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2102 it->wd->item_width = mw;
2103 it->wd->item_height = mh;
2106 if (!calc) evas_object_show(it->base.view);
2109 if (it->tooltip.content_cb)
2111 elm_widget_item_tooltip_content_cb_set(it,
2112 it->tooltip.content_cb,
2113 it->tooltip.data, NULL);
2114 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2117 if (it->mouse_cursor)
2118 elm_widget_item_cursor_set(it, it->mouse_cursor);
2120 it->realized = EINA_TRUE;
2121 it->want_unrealize = EINA_FALSE;
2123 if (itc) _item_cache_free(itc);
2124 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2125 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2127 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2128 edje_object_message_signal_process(it->base.view);
2132 _item_unrealize(Elm_Genlist_Item *it,
2137 if (!it->realized) return;
2138 if (it->wd->reorder_it == it) return;
2139 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2141 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2144 ecore_timer_del(it->long_timer);
2145 it->long_timer = NULL;
2149 evas_object_del(it->base.view);
2150 it->base.view = NULL;
2151 evas_object_del(it->spacer);
2156 edje_object_mirrored_set(it->base.view,
2157 elm_widget_mirrored_get(it->base.widget));
2158 edje_object_scale_set(it->base.view,
2159 elm_widget_scale_get(it->base.widget)
2160 * _elm_config->scale);
2161 _item_cache_add(it);
2163 elm_widget_stringlist_free(it->labels);
2165 elm_widget_stringlist_free(it->icons);
2167 elm_widget_stringlist_free(it->states);
2169 EINA_LIST_FREE(it->icon_objs, icon)
2170 evas_object_del(icon);
2172 _mode_item_unrealize(it);
2174 it->realized = EINA_FALSE;
2175 it->want_unrealize = EINA_FALSE;
2176 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2177 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2181 _item_block_recalc(Item_Block *itb,
2186 Elm_Genlist_Item *it;
2187 Evas_Coord minw = 0, minh = 0;
2188 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2191 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2193 EINA_LIST_FOREACH(itb->items, l, it)
2195 if (it->delete_me) continue;
2196 showme |= it->showme;
2201 if (!it->mincalcd) changed = EINA_TRUE;
2204 _item_realize(it, in, EINA_TRUE);
2205 _item_unrealize(it, EINA_TRUE);
2210 _item_realize(it, in, EINA_TRUE);
2211 _item_unrealize(it, EINA_TRUE);
2215 _item_realize(it, in, EINA_FALSE);
2217 if (minw < it->minw) minw = it->minw;
2225 itb->changed = EINA_FALSE;
2226 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2227 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2232 _item_block_realize(Item_Block *itb)
2234 if (itb->realized) return;
2235 itb->realized = EINA_TRUE;
2236 itb->want_unrealize = EINA_FALSE;
2240 _item_block_unrealize(Item_Block *itb)
2243 Elm_Genlist_Item *it;
2244 Eina_Bool dragging = EINA_FALSE;
2246 if (!itb->realized) return;
2247 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2248 EINA_LIST_FOREACH(itb->items, l, it)
2250 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2254 dragging = EINA_TRUE;
2255 it->want_unrealize = EINA_TRUE;
2258 _item_unrealize(it, EINA_FALSE);
2263 itb->realized = EINA_FALSE;
2264 itb->want_unrealize = EINA_TRUE;
2267 itb->want_unrealize = EINA_FALSE;
2268 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2269 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2273 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2275 Evas_Coord rox, roy, row, roh, oy, oh;
2276 Eina_Bool top = EINA_FALSE;
2277 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2278 if (!reorder_it) return 0;
2280 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2281 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2283 if ((it->wd->reorder_start_y < it->block->y) &&
2284 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2286 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2287 if (it->block->count == 1)
2288 it->wd->reorder_rel = it;
2290 else if ((it->wd->reorder_start_y >= it->block->y) &&
2291 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2293 it->block->reorder_offset = it->wd->reorder_it->h;
2296 it->block->reorder_offset = 0;
2298 it->scrl_y += it->block->reorder_offset;
2300 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2301 rox, roy + (roh / 2), row, 1));
2304 it->wd->reorder_rel = it;
2305 it->scrl_y += it->wd->reorder_it->h;
2306 return it->wd->reorder_it->h;
2313 _reorder_move_animator_cb(void *data)
2315 Elm_Genlist_Item *it = data;
2316 Eina_Bool down = EINA_FALSE;
2318 int y, dy = it->h / 10 * _elm_config->scale, diff;
2320 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2322 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2325 diff = abs(it->old_scrl_y - it->scrl_y);
2326 if (diff > it->h) y = diff / 2;
2328 if (it->old_scrl_y < it->scrl_y)
2330 it->old_scrl_y += y;
2333 else if (it->old_scrl_y > it->scrl_y)
2335 it->old_scrl_y -= y;
2338 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2339 _group_items_recalc(it->wd);
2341 if ((it->wd->reorder_pan_move) ||
2342 (down && it->old_scrl_y >= it->scrl_y) ||
2343 (!down && it->old_scrl_y <= it->scrl_y))
2345 it->old_scrl_y = it->scrl_y;
2346 it->move_effect_enabled = EINA_FALSE;
2347 it->wd->reorder_move_animator = NULL;
2348 return ECORE_CALLBACK_CANCEL;
2350 return ECORE_CALLBACK_RENEW;
2354 _item_position(Elm_Genlist_Item *it,
2362 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2363 evas_object_resize(view, it->w, it->h);
2364 evas_object_move(view, it_x, it_y);
2365 evas_object_show(view);
2366 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2367 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2371 _item_block_position(Item_Block *itb,
2375 Elm_Genlist_Item *it;
2376 Elm_Genlist_Item *git;
2377 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2380 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2381 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2382 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2384 EINA_LIST_FOREACH(itb->items, l, it)
2386 if (it->delete_me) continue;
2387 else if (it->wd->reorder_it == it) continue;
2391 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2392 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2394 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2395 cvx, cvy, cvw, cvh));
2396 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2398 if ((itb->realized) && (!it->realized))
2400 if (vis) _item_realize(it, in, EINA_FALSE);
2406 if (it->wd->reorder_mode)
2407 y += _get_space_for_reorder_item(it);
2408 git = it->group_item;
2411 if (git->scrl_y < oy)
2413 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2414 git->scrl_y = (it->scrl_y + it->h) - git->h;
2415 git->want_realize = EINA_TRUE;
2417 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2419 if (!it->move_effect_enabled)
2421 it->move_effect_enabled = EINA_TRUE;
2422 it->wd->reorder_move_animator =
2424 _reorder_move_animator_cb, it);
2427 if (!it->move_effect_enabled)
2431 _item_position(it, it->mode_view, it->scrl_x,
2434 _item_position(it, it->base.view, it->scrl_x,
2437 it->old_scrl_y = it->scrl_y;
2442 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2449 if (vis) it->want_realize = EINA_TRUE;
2453 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2454 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2458 _group_items_recalc(void *data)
2460 Widget_Data *wd = data;
2462 Elm_Genlist_Item *git;
2464 evas_event_freeze(evas_object_evas_get(wd->obj));
2465 EINA_LIST_FOREACH(wd->group_items, l, git)
2467 if (git->want_realize)
2470 _item_realize(git, 0, EINA_FALSE);
2471 evas_object_resize(git->base.view, wd->minw, git->h);
2472 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2473 evas_object_show(git->base.view);
2474 evas_object_raise(git->base.view);
2476 else if (!git->want_realize && git->realized)
2479 _item_unrealize(git, EINA_FALSE);
2482 evas_event_thaw(evas_object_evas_get(wd->obj));
2483 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2487 _must_recalc_idler(void *data)
2489 Widget_Data *wd = data;
2490 if (wd->calc_job) ecore_job_del(wd->calc_job);
2491 wd->calc_job = ecore_job_add(_calc_job, wd);
2492 wd->must_recalc_idler = NULL;
2493 return ECORE_CALLBACK_CANCEL;
2497 _calc_job(void *data)
2499 Widget_Data *wd = data;
2500 Item_Block *itb, *chb = NULL;
2501 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2504 Eina_Bool minw_change = EINA_FALSE, changed = EINA_FALSE;
2505 Eina_Bool did_must_recalc = EINA_FALSE;
2508 t0 = ecore_time_get();
2509 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2513 evas_event_freeze(evas_object_evas_get(wd->obj));
2514 EINA_INLIST_FOREACH(wd->blocks, itb)
2516 Eina_Bool showme = EINA_FALSE;
2519 showme = itb->showme;
2520 itb->showme = EINA_FALSE;
2523 if (itb->realized) _item_block_unrealize(itb);
2525 if ((itb->changed) || (changed) ||
2526 ((itb->must_recalc) && (!did_must_recalc)))
2528 if ((changed) || (itb->must_recalc))
2531 Elm_Genlist_Item *it;
2532 EINA_LIST_FOREACH(itb->items, l, it)
2533 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2534 itb->changed = EINA_TRUE;
2535 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2536 itb->must_recalc = EINA_FALSE;
2538 if (itb->realized) _item_block_unrealize(itb);
2539 showme = _item_block_recalc(itb, in, EINA_FALSE);
2545 if (minw == -1) minw = itb->minw;
2546 else if ((!itb->must_recalc) && (minw < itb->minw))
2549 minw_change = EINA_TRUE;
2555 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2557 wd->show_item->showme = EINA_FALSE;
2559 elm_smart_scroller_region_bring_in(wd->scr,
2561 wd->show_item->block->x,
2563 wd->show_item->block->y,
2564 wd->show_item->block->w,
2567 elm_smart_scroller_child_region_show(wd->scr,
2569 wd->show_item->block->x,
2571 wd->show_item->block->y,
2572 wd->show_item->block->w,
2574 wd->show_item = NULL;
2579 EINA_INLIST_FOREACH(wd->blocks, itb)
2585 if ((chb) && (EINA_INLIST_GET(chb)->next))
2587 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2589 if (itb->realized) _item_block_unrealize(itb);
2592 wd->realminw = minw;
2593 if (minw < wd->w) minw = wd->w;
2594 if ((minw != wd->minw) || (minh != wd->minh))
2598 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2599 _sizing_eval(wd->obj);
2600 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scroll_enabled))
2602 Elm_Genlist_Item *it;
2605 it = wd->anchor_item;
2606 it_y = wd->anchor_y;
2607 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2608 it->block->y + it->y + it_y);
2609 wd->anchor_item = it;
2610 wd->anchor_y = it_y;
2613 t = ecore_time_get();
2614 if (did_must_recalc)
2616 if (!wd->must_recalc_idler)
2617 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2619 wd->calc_job = NULL;
2620 evas_object_smart_changed(wd->pan_smart);
2621 evas_event_thaw(evas_object_evas_get(wd->obj));
2622 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2626 _update_job(void *data)
2628 Widget_Data *wd = data;
2632 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2634 wd->update_job = NULL;
2637 evas_event_freeze(evas_object_evas_get(wd->obj));
2638 EINA_INLIST_FOREACH(wd->blocks, itb)
2640 Evas_Coord itminw, itminh;
2641 Elm_Genlist_Item *it;
2647 _item_block_position(itb, num);
2651 recalc = EINA_FALSE;
2652 EINA_LIST_FOREACH(itb->items, l2, it)
2659 it->updateme = EINA_FALSE;
2662 _item_unrealize(it, EINA_FALSE);
2663 _item_realize(it, num, EINA_FALSE);
2664 position = EINA_TRUE;
2668 _item_realize(it, num, EINA_TRUE);
2669 _item_unrealize(it, EINA_TRUE);
2671 if ((it->minw != itminw) || (it->minh != itminh))
2676 itb->updateme = EINA_FALSE;
2679 position = EINA_TRUE;
2680 itb->changed = EINA_TRUE;
2681 _item_block_recalc(itb, num0, EINA_FALSE);
2682 _item_block_position(itb, num0);
2687 if (wd->calc_job) ecore_job_del(wd->calc_job);
2688 wd->calc_job = ecore_job_add(_calc_job, wd);
2690 evas_event_thaw(evas_object_evas_get(wd->obj));
2691 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2695 _pan_set(Evas_Object *obj,
2699 Pan *sd = evas_object_smart_data_get(obj);
2702 // Evas_Coord ow, oh;
2703 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2704 // ow = sd->wd->minw - ow;
2705 // if (ow < 0) ow = 0;
2706 // oh = sd->wd->minh - oh;
2707 // if (oh < 0) oh = 0;
2708 // if (x < 0) x = 0;
2709 // if (y < 0) y = 0;
2710 // if (x > ow) x = ow;
2711 // if (y > oh) y = oh;
2712 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2716 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2718 if ((itb->y + itb->h) > y)
2720 Elm_Genlist_Item *it;
2723 EINA_LIST_FOREACH(itb->items, l2, it)
2725 if ((itb->y + it->y) >= y)
2727 sd->wd->anchor_item = it;
2728 sd->wd->anchor_y = -(itb->y + it->y - y);
2735 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2739 _pan_get(Evas_Object *obj,
2743 Pan *sd = evas_object_smart_data_get(obj);
2745 if (x) *x = sd->wd->pan_x;
2746 if (y) *y = sd->wd->pan_y;
2750 _pan_max_get(Evas_Object *obj,
2754 Pan *sd = evas_object_smart_data_get(obj);
2757 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2758 ow = sd->wd->minw - ow;
2760 oh = sd->wd->minh - oh;
2767 _pan_min_get(Evas_Object *obj __UNUSED__,
2776 _pan_child_size_get(Evas_Object *obj,
2780 Pan *sd = evas_object_smart_data_get(obj);
2782 if (w) *w = sd->wd->minw;
2783 if (h) *h = sd->wd->minh;
2787 _pan_add(Evas_Object *obj)
2790 Evas_Object_Smart_Clipped_Data *cd;
2793 cd = evas_object_smart_data_get(obj);
2796 sd->__clipped_data = *cd;
2798 evas_object_smart_data_set(obj, sd);
2802 _pan_del(Evas_Object *obj)
2804 Pan *sd = evas_object_smart_data_get(obj);
2809 ecore_job_del(sd->resize_job);
2810 sd->resize_job = NULL;
2816 _pan_resize_job(void *data)
2819 _sizing_eval(sd->wd->obj);
2820 sd->resize_job = NULL;
2824 _pan_resize(Evas_Object *obj,
2828 Pan *sd = evas_object_smart_data_get(obj);
2831 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2832 if ((ow == w) && (oh == h)) return;
2833 if ((sd->wd->height_for_width) && (ow != w))
2835 if (sd->resize_job) ecore_job_del(sd->resize_job);
2836 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2838 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2839 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2843 _pan_calculate(Evas_Object *obj)
2845 Pan *sd = evas_object_smart_data_get(obj);
2847 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2849 Elm_Genlist_Item *git;
2852 evas_event_freeze(evas_object_evas_get(obj));
2853 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2854 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2855 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2857 git->want_realize = EINA_FALSE;
2859 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2861 itb->w = sd->wd->minw;
2862 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2863 itb->y - sd->wd->pan_y + oy,
2865 cvx, cvy, cvw, cvh))
2867 if ((!itb->realized) || (itb->changed))
2868 _item_block_realize(itb);
2869 _item_block_position(itb, in);
2873 if (itb->realized) _item_block_unrealize(itb);
2877 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2878 _group_items_recalc(sd->wd);
2879 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2881 if (sd->wd->pan_y != sd->wd->old_pan_y)
2882 sd->wd->reorder_pan_move = EINA_TRUE;
2883 else sd->wd->reorder_pan_move = EINA_FALSE;
2884 evas_object_raise(sd->wd->reorder_it->base.view);
2885 sd->wd->old_pan_y = sd->wd->pan_y;
2886 sd->wd->start_time = ecore_loop_time_get();
2888 _item_auto_scroll(sd->wd);
2889 evas_event_thaw(evas_object_evas_get(obj));
2890 evas_event_thaw_eval(evas_object_evas_get(obj));
2894 _pan_move(Evas_Object *obj,
2895 Evas_Coord x __UNUSED__,
2896 Evas_Coord y __UNUSED__)
2898 Pan *sd = evas_object_smart_data_get(obj);
2900 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2901 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2905 _hold_on(void *data __UNUSED__,
2907 void *event_info __UNUSED__)
2909 Widget_Data *wd = elm_widget_data_get(obj);
2911 elm_smart_scroller_hold_set(wd->scr, 1);
2915 _hold_off(void *data __UNUSED__,
2917 void *event_info __UNUSED__)
2919 Widget_Data *wd = elm_widget_data_get(obj);
2921 elm_smart_scroller_hold_set(wd->scr, 0);
2925 _freeze_on(void *data __UNUSED__,
2927 void *event_info __UNUSED__)
2929 Widget_Data *wd = elm_widget_data_get(obj);
2931 elm_smart_scroller_freeze_set(wd->scr, 1);
2935 _freeze_off(void *data __UNUSED__,
2937 void *event_info __UNUSED__)
2939 Widget_Data *wd = elm_widget_data_get(obj);
2941 elm_smart_scroller_freeze_set(wd->scr, 0);
2945 _scroll_edge_left(void *data,
2946 Evas_Object *scr __UNUSED__,
2947 void *event_info __UNUSED__)
2949 Evas_Object *obj = data;
2950 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2954 _scroll_edge_right(void *data,
2955 Evas_Object *scr __UNUSED__,
2956 void *event_info __UNUSED__)
2958 Evas_Object *obj = data;
2959 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2963 _scroll_edge_top(void *data,
2964 Evas_Object *scr __UNUSED__,
2965 void *event_info __UNUSED__)
2967 Evas_Object *obj = data;
2968 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2972 _scroll_edge_bottom(void *data,
2973 Evas_Object *scr __UNUSED__,
2974 void *event_info __UNUSED__)
2976 Evas_Object *obj = data;
2977 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2981 _mode_item_realize(Elm_Genlist_Item *it)
2985 if ((it->mode_view) || (it->delete_me)) return;
2987 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2988 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2989 edje_object_scale_set(it->mode_view,
2990 elm_widget_scale_get(it->base.widget) *
2991 _elm_config->scale);
2992 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2993 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2995 strncpy(buf, "item", sizeof(buf));
2996 if (it->wd->compress)
2997 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2999 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3000 strncat(buf, "/", sizeof(buf) - strlen(buf));
3001 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3003 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3004 elm_widget_style_get(it->base.widget));
3005 edje_object_mirrored_set(it->mode_view,
3006 elm_widget_mirrored_get(it->base.widget));
3008 /* signal callback add */
3009 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3011 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3013 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3016 /* label_get, icon_get, state_get */
3017 /* FIXME: If you see that assert, please notify us and we
3018 will clean our mess */
3019 assert(eina_list_count(it->mode_icon_objs) == 0);
3021 _item_label_realize(it, it->mode_view, &it->mode_labels);
3022 it->mode_icon_objs = _item_icon_realize(it,
3025 _item_state_realize(it, it->mode_view, &it->mode_states);
3027 edje_object_part_swallow(it->mode_view,
3028 edje_object_data_get(it->mode_view, "mode_part"),
3031 it->want_unrealize = EINA_FALSE;
3032 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3033 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3037 _mode_item_unrealize(Elm_Genlist_Item *it)
3039 Widget_Data *wd = it->wd;
3041 if (!it->mode_view) return;
3043 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3044 elm_widget_stringlist_free(it->mode_labels);
3045 it->mode_labels = NULL;
3046 elm_widget_stringlist_free(it->mode_icons);
3047 it->mode_icons = NULL;
3048 elm_widget_stringlist_free(it->mode_states);
3050 EINA_LIST_FREE(it->mode_icon_objs, icon)
3051 evas_object_del(icon);
3053 edje_object_part_unswallow(it->mode_view, it->base.view);
3054 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3055 evas_object_del(it->mode_view);
3056 it->mode_view = NULL;
3058 if (wd->mode_item == it)
3059 wd->mode_item = NULL;
3060 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3061 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3065 _item_mode_set(Elm_Genlist_Item *it)
3068 Widget_Data *wd = it->wd;
3073 it->nocache = EINA_TRUE;
3075 if (wd->scr_hold_timer)
3077 ecore_timer_del(wd->scr_hold_timer);
3078 wd->scr_hold_timer = NULL;
3080 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3081 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3083 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3084 _mode_item_realize(it);
3085 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3086 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3087 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3089 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3090 edje_object_signal_emit(it->mode_view, buf, "elm");
3094 _item_mode_unset(Widget_Data *wd)
3097 if (!wd->mode_item) return;
3098 char buf[1024], buf2[1024];
3099 Elm_Genlist_Item *it;
3102 it->nocache = EINA_TRUE;
3104 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3105 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3107 edje_object_signal_emit(it->mode_view, buf, "elm");
3108 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3110 wd->mode_item = NULL;
3114 _item_auto_scroll(Widget_Data *wd)
3117 Elm_Genlist_Item *it;
3119 Evas_Coord ox, oy, ow, oh;
3121 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3123 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3124 if (wd->expanded_item->scrl_y > (oh + oy) / 2)
3126 EINA_LIST_FOREACH(wd->expanded_item->items, l, it)
3127 elm_genlist_item_bring_in(it);
3129 wd->auto_scroll_enabled = EINA_FALSE;
3134 * Add a new Genlist object
3136 * @param parent The parent object
3137 * @return The new object or NULL if it cannot be created
3142 elm_genlist_add(Evas_Object *parent)
3147 Evas_Coord minw, minh;
3148 static Evas_Smart *smart = NULL;
3152 static Evas_Smart_Class sc;
3154 evas_object_smart_clipped_smart_set(&_pan_sc);
3156 sc.name = "elm_genlist_pan";
3157 sc.version = EVAS_SMART_CLASS_VERSION;
3160 sc.resize = _pan_resize;
3161 sc.move = _pan_move;
3162 sc.calculate = _pan_calculate;
3163 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3166 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3168 ELM_SET_WIDTYPE(widtype, "genlist");
3169 elm_widget_type_set(obj, "genlist");
3170 elm_widget_sub_object_add(parent, obj);
3171 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3172 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3173 elm_widget_data_set(obj, wd);
3174 elm_widget_del_hook_set(obj, _del_hook);
3175 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3176 elm_widget_theme_hook_set(obj, _theme_hook);
3177 elm_widget_can_focus_set(obj, EINA_TRUE);
3178 elm_widget_event_hook_set(obj, _event_hook);
3179 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3181 wd->scr = elm_smart_scroller_add(e);
3182 elm_smart_scroller_widget_set(wd->scr, obj);
3183 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3184 elm_widget_style_get(obj));
3185 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3186 _elm_config->thumbscroll_bounce_enable);
3187 elm_widget_resize_object_set(obj, wd->scr);
3189 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3190 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3192 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3193 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3197 wd->mode = ELM_LIST_SCROLL;
3198 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3199 wd->item_cache_max = wd->max_items_per_block * 2;
3200 wd->longpress_timeout = _elm_config->longpress_timeout;
3202 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3203 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3204 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3205 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3207 wd->pan_smart = evas_object_smart_add(e, smart);
3208 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3211 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3212 _pan_set, _pan_get, _pan_max_get,
3213 _pan_min_get, _pan_child_size_get);
3215 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3217 evas_object_size_hint_min_set(obj, minw, minh);
3219 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3221 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3226 static Elm_Genlist_Item *
3227 _item_new(Widget_Data *wd,
3228 const Elm_Genlist_Item_Class *itc,
3230 Elm_Genlist_Item *parent,
3231 Elm_Genlist_Item_Flags flags,
3233 const void *func_data)
3235 Elm_Genlist_Item *it;
3237 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3238 if (!it) return NULL;
3241 it->base.data = data;
3242 it->parent = parent;
3244 it->func.func = func;
3245 it->func.data = func_data;
3246 it->mouse_cursor = NULL;
3247 it->expanded_depth = 0;
3252 _item_block_add(Widget_Data *wd,
3253 Elm_Genlist_Item *it)
3255 Item_Block *itb = NULL;
3262 itb = calloc(1, sizeof(Item_Block));
3265 if (!it->rel->block)
3268 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3269 itb->items = eina_list_append(itb->items, it);
3275 wd->blocks = eina_inlist_prepend_relative
3276 (wd->blocks, EINA_INLIST_GET(itb),
3277 EINA_INLIST_GET(it->rel->block));
3279 eina_list_prepend_relative(itb->items, it, it->rel);
3283 wd->blocks = eina_inlist_append_relative
3284 (wd->blocks, EINA_INLIST_GET(itb),
3285 EINA_INLIST_GET(it->rel->block));
3287 eina_list_append_relative(itb->items, it, it->rel);
3297 itb = (Item_Block *)(wd->blocks);
3298 if (itb->count >= wd->max_items_per_block)
3300 itb = calloc(1, sizeof(Item_Block));
3304 eina_inlist_prepend(wd->blocks,
3305 EINA_INLIST_GET(itb));
3310 itb = calloc(1, sizeof(Item_Block));
3314 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3316 itb->items = eina_list_prepend(itb->items, it);
3322 itb = (Item_Block *)(wd->blocks->last);
3323 if (itb->count >= wd->max_items_per_block)
3325 itb = calloc(1, sizeof(Item_Block));
3329 eina_inlist_append(wd->blocks,
3330 EINA_INLIST_GET(itb));
3335 itb = calloc(1, sizeof(Item_Block));
3339 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3341 itb->items = eina_list_append(itb->items, it);
3347 itb = it->rel->block;
3348 if (!itb) goto newblock;
3350 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3352 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3355 itb->changed = EINA_TRUE;
3357 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3358 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3361 it->rel->relcount--;
3362 if ((it->rel->delete_me) && (!it->rel->relcount))
3366 if (itb->count > itb->wd->max_items_per_block)
3370 Elm_Genlist_Item *it2;
3372 newc = itb->count / 2;
3373 itb2 = calloc(1, sizeof(Item_Block));
3377 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3378 EINA_INLIST_GET(itb));
3379 itb2->changed = EINA_TRUE;
3380 while ((itb->count > newc) && (itb->items))
3384 l = eina_list_last(itb->items);
3386 itb->items = eina_list_remove_list(itb->items, l);
3389 itb2->items = eina_list_prepend(itb2->items, it2);
3397 _queue_process(Widget_Data *wd)
3400 Eina_Bool showme = EINA_FALSE;
3403 t0 = ecore_time_get();
3404 //evas_event_freeze(evas_object_evas_get(wd->obj));
3405 for (n = 0; (wd->queue) && (n < 128); n++)
3407 Elm_Genlist_Item *it;
3409 it = wd->queue->data;
3410 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3411 it->queued = EINA_FALSE;
3412 _item_block_add(wd, it);
3413 t = ecore_time_get();
3414 if (it->block->changed)
3416 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3417 it->block->changed = 0;
3419 if (showme) it->block->showme = EINA_TRUE;
3420 if (eina_inlist_count(wd->blocks) > 1)
3422 if ((t - t0) > (ecore_animator_frametime_get())) break;
3425 //evas_event_thaw(evas_object_evas_get(wd->obj));
3426 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3431 _idle_process(void *data, Eina_Bool *wakeup)
3433 Widget_Data *wd = data;
3436 //static double q_start = 0.0;
3437 //if (q_start == 0.0) q_start = ecore_time_get();
3439 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3443 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3445 return ECORE_CALLBACK_CANCEL;
3447 return ECORE_CALLBACK_RENEW;
3451 _item_idle_enterer(void *data)
3453 Widget_Data *wd = data;
3454 Eina_Bool wakeup = EINA_FALSE;
3455 Eina_Bool ok = _idle_process(data, &wakeup);
3460 if (wd->calc_job) ecore_job_del(wd->calc_job);
3461 wd->calc_job = ecore_job_add(_calc_job, wd);
3463 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3468 _item_queue(Widget_Data *wd,
3469 Elm_Genlist_Item *it)
3471 if (it->queued) return;
3472 it->queued = EINA_TRUE;
3473 wd->queue = eina_list_append(wd->queue, it);
3474 // FIXME: why does a freeze then thaw here cause some genlist
3475 // elm_genlist_item_append() to be much much slower?
3476 // evas_event_freeze(evas_object_evas_get(wd->obj));
3477 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3479 if (wd->queue_idle_enterer)
3481 ecore_idle_enterer_del(wd->queue_idle_enterer);
3482 wd->queue_idle_enterer = NULL;
3486 // evas_event_thaw(evas_object_evas_get(wd->obj));
3487 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3488 if (!wd->queue_idle_enterer)
3489 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3493 _elm_genlist_item_compare_data(const void *data, const void *data1)
3495 const Elm_Genlist_Item *item = data;
3496 const Elm_Genlist_Item *item1 = data1;
3498 return _elm_genlist_item_compare_data_cb(item->base.data, item1->base.data);
3502 _elm_genlist_item_compare(const void *data, const void *data1)
3504 Elm_Genlist_Item *item, *item1;
3505 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3506 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3507 return _elm_genlist_item_compare_cb(item, item1);
3511 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3516 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3517 _item_block_del(it);
3519 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3521 it->rel->relcount++;
3522 it->before = EINA_FALSE;
3523 if (after->group_item) it->group_item = after->group_item;
3524 _item_queue(it->wd, it);
3526 // TODO: change this to smart callback
3527 if (it->itc->func.moved)
3528 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3532 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3535 if (!before) return;
3537 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3538 _item_block_del(it);
3539 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3541 it->rel->relcount++;
3542 it->before = EINA_TRUE;
3543 if (before->group_item) it->group_item = before->group_item;
3544 _item_queue(it->wd, it);
3546 // TODO: change this to smart callback
3547 if (it->itc->func.moved)
3548 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3552 * Append item to the end of the genlist
3554 * This appends the given item to the end of the list or the end of
3555 * the children if the parent is given.
3557 * @param obj The genlist object
3558 * @param itc The item class for the item
3559 * @param data The item data
3560 * @param parent The parent item, or NULL if none
3561 * @param flags Item flags
3562 * @param func Convenience function called when item selected
3563 * @param func_data Data passed to @p func above.
3564 * @return A handle to the item added or NULL if not possible
3568 EAPI Elm_Genlist_Item *
3569 elm_genlist_item_append(Evas_Object *obj,
3570 const Elm_Genlist_Item_Class *itc,
3572 Elm_Genlist_Item *parent,
3573 Elm_Genlist_Item_Flags flags,
3575 const void *func_data)
3577 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3578 Widget_Data *wd = elm_widget_data_get(obj);
3579 if (!wd) return NULL;
3580 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3582 if (!it) return NULL;
3585 if (flags & ELM_GENLIST_ITEM_GROUP)
3586 wd->group_items = eina_list_append(wd->group_items, it);
3587 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3592 Elm_Genlist_Item *it2 = NULL;
3593 Eina_List *ll = eina_list_last(it->parent->items);
3594 if (ll) it2 = ll->data;
3595 it->parent->items = eina_list_append(it->parent->items, it);
3596 if (!it2) it2 = it->parent;
3598 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3599 EINA_INLIST_GET(it2));
3601 it->rel->relcount++;
3603 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3604 it->group_item = parent;
3605 else if (it->parent->group_item)
3606 it->group_item = it->parent->group_item;
3608 it->before = EINA_FALSE;
3609 _item_queue(wd, it);
3614 * Prepend item at start of the genlist
3616 * This adds an item to the beginning of the list or beginning of the
3617 * children of the parent if given.
3619 * @param obj The genlist object
3620 * @param itc The item class for the item
3621 * @param data The item data
3622 * @param parent The parent item, or NULL if none
3623 * @param flags Item flags
3624 * @param func Convenience function called when item selected
3625 * @param func_data Data passed to @p func above.
3626 * @return A handle to the item added or NULL if not possible
3630 EAPI Elm_Genlist_Item *
3631 elm_genlist_item_prepend(Evas_Object *obj,
3632 const Elm_Genlist_Item_Class *itc,
3634 Elm_Genlist_Item *parent,
3635 Elm_Genlist_Item_Flags flags,
3637 const void *func_data)
3639 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3640 Widget_Data *wd = elm_widget_data_get(obj);
3641 if (!wd) return NULL;
3642 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3644 if (!it) return NULL;
3647 if (flags & ELM_GENLIST_ITEM_GROUP)
3648 wd->group_items = eina_list_prepend(wd->group_items, it);
3649 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3654 Elm_Genlist_Item *it2 = NULL;
3655 Eina_List *ll = it->parent->items;
3656 if (ll) it2 = ll->data;
3657 it->parent->items = eina_list_prepend(it->parent->items, it);
3658 if (!it2) it2 = it->parent;
3660 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3661 EINA_INLIST_GET(it2));
3663 it->rel->relcount++;
3665 it->before = EINA_TRUE;
3666 _item_queue(wd, it);
3671 * Insert item before another in the genlist
3673 * This inserts an item before another in the list. It will be in the
3674 * same tree level or group as the item it is inseted before.
3676 * @param obj The genlist object
3677 * @param itc The item class for the item
3678 * @param data The item data
3679 * @param before The item to insert before
3680 * @param flags Item flags
3681 * @param func Convenience function called when item selected
3682 * @param func_data Data passed to @p func above.
3683 * @return A handle to the item added or NULL if not possible
3687 EAPI Elm_Genlist_Item *
3688 elm_genlist_item_insert_before(Evas_Object *obj,
3689 const Elm_Genlist_Item_Class *itc,
3691 Elm_Genlist_Item *parent,
3692 Elm_Genlist_Item *before,
3693 Elm_Genlist_Item_Flags flags,
3695 const void *func_data)
3697 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3698 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3699 Widget_Data *wd = elm_widget_data_get(obj);
3700 if (!wd) return NULL;
3701 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3703 if (!it) return NULL;
3706 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3709 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3710 EINA_INLIST_GET(before));
3712 it->rel->relcount++;
3713 it->before = EINA_TRUE;
3714 _item_queue(wd, it);
3718 EAPI Elm_Genlist_Item *
3719 elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3720 const Elm_Genlist_Item_Class *itc,
3722 Elm_Genlist_Item *parent,
3723 Elm_Genlist_Item_Flags flags,
3724 Eina_Compare_Cb comp,
3726 const void *func_data)
3728 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3729 Widget_Data *wd = elm_widget_data_get(obj);
3730 if (!wd) return NULL;
3731 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3733 if (!it) return NULL;
3735 _elm_genlist_item_compare_cb = comp;
3740 eina_list_sorted_insert(it->parent->items, _elm_genlist_item_compare, it);
3742 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3743 _elm_genlist_item_compare);
3744 if (EINA_INLIST_GET(it)->next)
3746 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3747 it->rel->relcount++;
3748 it->before = EINA_TRUE;
3750 else if (EINA_INLIST_GET(it)->prev)
3752 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3753 it->rel->relcount++;
3754 it->before = EINA_FALSE;
3756 _item_queue(wd, it);
3762 * Insert a new item into the sorted genlist object
3764 * @param obj The genlist object
3765 * @param itc The item class for the item
3766 * @param data The item data
3767 * @param parent The parent item, or NULL if none
3768 * @param flags Item flags
3769 * @param comp The function called for the sort
3770 * @param func Convenience function called when item selected
3771 * @param func_data Data passed to @p func above.
3772 * @return A handle to the item added or NULL if not possible
3776 EAPI Elm_Genlist_Item *
3777 elm_genlist_item_sorted_insert(Evas_Object *obj,
3778 const Elm_Genlist_Item_Class *itc,
3780 Elm_Genlist_Item *parent,
3781 Elm_Genlist_Item_Flags flags,
3782 Eina_Compare_Cb comp,
3784 const void *func_data)
3786 _elm_genlist_item_compare_data_cb = comp;
3788 return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
3789 _elm_genlist_item_compare_data, func, func_data);
3793 * Insert an item after another in the genlst
3795 * This inserts an item after another in the list. It will be in the
3796 * same tree level or group as the item it is inseted after.
3798 * @param obj The genlist object
3799 * @param itc The item class for the item
3800 * @param data The item data
3801 * @param after The item to insert after
3802 * @param flags Item flags
3803 * @param func Convenience function called when item selected
3804 * @param func_data Data passed to @p func above.
3805 * @return A handle to the item added or NULL if not possible
3809 EAPI Elm_Genlist_Item *
3810 elm_genlist_item_insert_after(Evas_Object *obj,
3811 const Elm_Genlist_Item_Class *itc,
3813 Elm_Genlist_Item *parent,
3814 Elm_Genlist_Item *after,
3815 Elm_Genlist_Item_Flags flags,
3817 const void *func_data)
3819 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3820 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3821 Widget_Data *wd = elm_widget_data_get(obj);
3822 if (!wd) return NULL;
3823 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3825 if (!it) return NULL;
3826 /* It make no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3827 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3829 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3830 EINA_INLIST_GET(after));
3833 it->parent->items = eina_list_append_relative(it->parent->items, it,
3837 it->rel->relcount++;
3838 it->before = EINA_FALSE;
3839 _item_queue(wd, it);
3846 * This clears all items in the list, leaving it empty.
3848 * @param obj The genlist object
3853 elm_genlist_clear(Evas_Object *obj)
3855 ELM_CHECK_WIDTYPE(obj, widtype);
3856 Widget_Data *wd = elm_widget_data_get(obj);
3858 if (wd->walking > 0)
3860 Elm_Genlist_Item *it;
3862 wd->clear_me = EINA_TRUE;
3863 EINA_INLIST_FOREACH(wd->items, it)
3865 it->delete_me = EINA_TRUE;
3869 evas_event_freeze(evas_object_evas_get(wd->obj));
3872 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3874 if (wd->anchor_item == it)
3876 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3877 if (!wd->anchor_item)
3879 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3881 wd->items = eina_inlist_remove(wd->items, wd->items);
3882 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3883 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3884 elm_widget_item_pre_notify_del(it);
3885 if (it->realized) _item_unrealize(it, EINA_FALSE);
3886 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3887 it->itc->func.del((void *)it->base.data, it->base.widget);
3888 if (it->long_timer) ecore_timer_del(it->long_timer);
3889 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3890 elm_widget_item_del(it);
3892 wd->clear_me = EINA_FALSE;
3893 wd->anchor_item = NULL;
3896 Item_Block *itb = (Item_Block *)(wd->blocks);
3898 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3899 if (itb->items) eina_list_free(itb->items);
3904 ecore_job_del(wd->calc_job);
3905 wd->calc_job = NULL;
3907 if (wd->queue_idle_enterer)
3909 ecore_idle_enterer_del(wd->queue_idle_enterer);
3910 wd->queue_idle_enterer = NULL;
3912 if (wd->must_recalc_idler)
3914 ecore_idler_del(wd->must_recalc_idler);
3915 wd->must_recalc_idler = NULL;
3919 eina_list_free(wd->queue);
3924 eina_list_free(wd->selected);
3925 wd->selected = NULL;
3927 if (wd->reorder_move_animator)
3929 ecore_animator_del(wd->reorder_move_animator);
3930 wd->reorder_move_animator = NULL;
3932 wd->show_item = NULL;
3940 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3941 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3944 evas_event_thaw(evas_object_evas_get(wd->obj));
3945 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3949 * Enable or disable multi-select in the genlist
3951 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3952 * the list. This allows more than 1 item to be selected.
3954 * @param obj The genlist object
3955 * @param multi Multi-select enable/disable
3960 elm_genlist_multi_select_set(Evas_Object *obj,
3963 ELM_CHECK_WIDTYPE(obj, widtype);
3964 Widget_Data *wd = elm_widget_data_get(obj);
3970 * Gets if multi-select in genlist is enable or disable
3972 * @param obj The genlist object
3973 * @return Multi-select enable/disable
3974 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3979 elm_genlist_multi_select_get(const Evas_Object *obj)
3981 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3982 Widget_Data *wd = elm_widget_data_get(obj);
3983 if (!wd) return EINA_FALSE;
3988 * Get the selectd item in the genlist
3990 * This gets the selected item in the list (if multi-select is enabled
3991 * only the first item in the list is selected - which is not very
3992 * useful, so see elm_genlist_selected_items_get() for when
3993 * multi-select is used).
3995 * If no item is selected, NULL is returned.
3997 * @param obj The genlist object
3998 * @return The selected item, or NULL if none.
4002 EAPI Elm_Genlist_Item *
4003 elm_genlist_selected_item_get(const Evas_Object *obj)
4005 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4006 Widget_Data *wd = elm_widget_data_get(obj);
4007 if (!wd) return NULL;
4008 if (wd->selected) return wd->selected->data;
4013 * Get a list of selected items in the genlist
4015 * This returns a list of the selected items. This list pointer is
4016 * only valid so long as no items are selected or unselected (or
4017 * unselected implicitly by deletion). The list contains
4018 * Elm_Genlist_Item pointers.
4020 * @param obj The genlist object
4021 * @return The list of selected items, nor NULL if none are selected.
4025 EAPI const Eina_List *
4026 elm_genlist_selected_items_get(const Evas_Object *obj)
4028 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4029 Widget_Data *wd = elm_widget_data_get(obj);
4030 if (!wd) return NULL;
4031 return wd->selected;
4035 * Get a list of realized items in genlist
4037 * This returns a list of the realized items in the genlist. The list
4038 * contains Elm_Genlist_Item pointers. The list must be freed by the
4039 * caller when done with eina_list_free(). The item pointers in the
4040 * list are only valid so long as those items are not deleted or the
4041 * genlist is not deleted.
4043 * @param obj The genlist object
4044 * @return The list of realized items, nor NULL if none are realized.
4049 elm_genlist_realized_items_get(const Evas_Object *obj)
4051 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4052 Widget_Data *wd = elm_widget_data_get(obj);
4053 Eina_List *list = NULL;
4055 Eina_Bool done = EINA_FALSE;
4056 if (!wd) return NULL;
4057 EINA_INLIST_FOREACH(wd->blocks, itb)
4062 Elm_Genlist_Item *it;
4065 EINA_LIST_FOREACH(itb->items, l, it)
4067 if (it->realized) list = eina_list_append(list, it);
4079 * Get the item that is at the x, y canvas coords
4081 * This returns the item at the given coordinates (which are canvas
4082 * relative not object-relative). If an item is at that coordinate,
4083 * that item handle is returned, and if @p posret is not NULL, the
4084 * integer pointed to is set to a value of -1, 0 or 1, depending if
4085 * the coordinate is on the upper portion of that item (-1), on the
4086 * middle section (0) or on the lower part (1). If NULL is returned as
4087 * an item (no item found there), then posret may indicate -1 or 1
4088 * based if the coordinate is above or below all items respectively in
4091 * @param it The item
4092 * @param x The input x coordinate
4093 * @param y The input y coordinate
4094 * @param posret The position relative to the item returned here
4095 * @return The item at the coordinates or NULL if none
4099 EAPI Elm_Genlist_Item *
4100 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4105 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4106 Widget_Data *wd = elm_widget_data_get(obj);
4107 Evas_Coord ox, oy, ow, oh;
4110 if (!wd) return NULL;
4111 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4113 EINA_INLIST_FOREACH(wd->blocks, itb)
4116 Elm_Genlist_Item *it;
4118 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4119 oy + itb->y - itb->wd->pan_y,
4120 itb->w, itb->h, x, y, 1, 1))
4122 EINA_LIST_FOREACH(itb->items, l, it)
4124 Evas_Coord itx, ity;
4126 itx = ox + itb->x + it->x - itb->wd->pan_x;
4127 ity = oy + itb->y + it->y - itb->wd->pan_y;
4128 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4132 if (y <= (ity + (it->h / 4))) *posret = -1;
4133 else if (y >= (ity + it->h - (it->h / 4)))
4139 lasty = ity + it->h;
4144 if (y > lasty) *posret = 1;
4151 * Get the first item in the genlist
4153 * This returns the first item in the list.
4155 * @param obj The genlist object
4156 * @return The first item, or NULL if none
4160 EAPI Elm_Genlist_Item *
4161 elm_genlist_first_item_get(const Evas_Object *obj)
4163 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4164 Widget_Data *wd = elm_widget_data_get(obj);
4165 if (!wd) return NULL;
4166 if (!wd->items) return NULL;
4167 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4168 while ((it) && (it->delete_me))
4169 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4174 * Get the last item in the genlist
4176 * This returns the last item in the list.
4178 * @return The last item, or NULL if none
4182 EAPI Elm_Genlist_Item *
4183 elm_genlist_last_item_get(const Evas_Object *obj)
4185 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4186 Widget_Data *wd = elm_widget_data_get(obj);
4187 if (!wd) return NULL;
4188 if (!wd->items) return NULL;
4189 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4190 while ((it) && (it->delete_me))
4191 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4196 * Get the next item in the genlist
4198 * This returns the item after the item @p it.
4200 * @param it The item
4201 * @return The item after @p it, or NULL if none
4205 EAPI Elm_Genlist_Item *
4206 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4208 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4211 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4212 if ((it) && (!it->delete_me)) break;
4214 return (Elm_Genlist_Item *)it;
4218 * Get the previous item in the genlist
4220 * This returns the item before the item @p it.
4222 * @param it The item
4223 * @return The item before @p it, or NULL if none
4227 EAPI Elm_Genlist_Item *
4228 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4230 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4233 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4234 if ((it) && (!it->delete_me)) break;
4236 return (Elm_Genlist_Item *)it;
4240 * Get the genlist object from an item
4242 * This returns the genlist object itself that an item belongs to.
4244 * @param it The item
4245 * @return The genlist object
4250 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4252 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4253 return it->base.widget;
4257 * Get the parent item of the given item
4259 * This returns the parent item of the item @p it given.
4261 * @param it The item
4262 * @return The parent of the item or NULL if none
4266 EAPI Elm_Genlist_Item *
4267 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4269 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4274 * Clear all sub-items (children) of the given item
4276 * This clears all items that are children (or their descendants) of the
4279 * @param it The item
4284 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4286 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4287 Eina_List *tl = NULL, *l;
4288 Elm_Genlist_Item *it2;
4290 EINA_LIST_FOREACH(it->items, l, it2)
4291 tl = eina_list_append(tl, it2);
4292 EINA_LIST_FREE(tl, it2)
4293 elm_genlist_item_del(it2);
4297 * Set the selected state of an item
4299 * This sets the selected state (1 selected, 0 not selected) of the given
4302 * @param it The item
4303 * @param selected The selected state
4308 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4311 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4312 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4314 if ((it->delete_me) || (it->disabled)) return;
4315 selected = !!selected;
4316 if (it->selected == selected) return;
4322 while (wd->selected)
4324 _item_unhighlight(wd->selected->data);
4325 _item_unselect(wd->selected->data);
4328 _item_highlight(it);
4333 _item_unhighlight(it);
4339 * Get the selected state of an item
4341 * This gets the selected state of an item (1 selected, 0 not selected).
4343 * @param it The item
4344 * @return The selected state
4349 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4351 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4352 return it->selected;
4356 * Sets the expanded state of an item (if it's a parent)
4358 * This expands or contracts a parent item (thus showing or hiding the
4361 * @param it The item
4362 * @param expanded The expanded state (1 expanded, 0 not expanded).
4367 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4370 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4371 if (it->expanded == expanded) return;
4372 it->expanded = expanded;
4373 it->wd->expanded_item = it;
4377 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4378 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4379 it->wd->auto_scroll_enabled = EINA_TRUE;
4384 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4385 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4386 it->wd->auto_scroll_enabled = EINA_FALSE;
4391 * Get the expanded state of an item
4393 * This gets the expanded state of an item
4395 * @param it The item
4396 * @return Thre expanded state
4401 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4403 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4404 return it->expanded;
4408 * Get the depth of expanded item
4410 * @param it The genlist item object
4411 * @return The depth of expanded item
4416 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4418 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4419 return it->expanded_depth;
4423 * Sets the disabled state of an item.
4425 * A disabled item cannot be selected or unselected. It will also
4426 * change appearance to appear disabled. This sets the disabled state
4427 * (1 disabled, 0 not disabled).
4429 * @param it The item
4430 * @param disabled The disabled state
4435 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4438 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4441 if (it->disabled == disabled) return;
4442 if (it->delete_me) return;
4443 it->disabled = !!disabled;
4445 elm_genlist_item_selected_set(it, EINA_FALSE);
4449 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4451 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4452 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4453 elm_widget_disabled_set(obj, disabled);
4458 * Get the disabled state of an item
4460 * This gets the disabled state of the given item.
4462 * @param it The item
4463 * @return The disabled state
4468 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4471 if (it->delete_me) return EINA_FALSE;
4472 return it->disabled;
4476 * Sets the display only state of an item.
4478 * A display only item cannot be selected or unselected. It is for
4479 * display only and not selecting or otherwise clicking, dragging
4480 * etc. by the user, thus finger size rules will not be applied to
4483 * @param it The item
4484 * @param display_only The display only state
4489 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4490 Eina_Bool display_only)
4492 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4493 if (it->display_only == display_only) return;
4494 if (it->delete_me) return;
4495 it->display_only = display_only;
4496 it->mincalcd = EINA_FALSE;
4497 it->updateme = EINA_TRUE;
4498 if (it->block) it->block->updateme = EINA_TRUE;
4499 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4500 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4504 * Get the display only state of an item
4506 * This gets the display only state of the given item.
4508 * @param it The item
4509 * @return The display only state
4514 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4516 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4517 if (it->delete_me) return EINA_FALSE;
4518 return it->display_only;
4522 * Show the given item
4524 * This causes genlist to jump to the given item @p it and show it (by
4525 * scrolling), if it is not fully visible.
4527 * @param it The item
4532 elm_genlist_item_show(Elm_Genlist_Item *it)
4534 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4535 Evas_Coord gith = 0;
4536 if (it->delete_me) return;
4537 if ((it->queued) || (!it->mincalcd))
4539 it->wd->show_item = it;
4540 it->wd->bring_in = EINA_TRUE;
4541 it->showme = EINA_TRUE;
4544 if (it->wd->show_item)
4546 it->wd->show_item->showme = EINA_FALSE;
4547 it->wd->show_item = NULL;
4549 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4550 gith = it->group_item->h;
4551 elm_smart_scroller_child_region_show(it->wd->scr,
4552 it->x + it->block->x,
4553 it->y + it->block->y - gith,
4554 it->block->w, it->h);
4558 * Bring in the given item
4560 * This causes genlist to jump to the given item @p it and show it (by
4561 * scrolling), if it is not fully visible. This may use animation to
4562 * do so and take a period of time
4564 * @param it The item
4569 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4571 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4572 Evas_Coord gith = 0;
4573 if (it->delete_me) return;
4574 if ((it->queued) || (!it->mincalcd))
4576 it->wd->show_item = it;
4577 it->wd->bring_in = EINA_TRUE;
4578 it->showme = EINA_TRUE;
4581 if (it->wd->show_item)
4583 it->wd->show_item->showme = EINA_FALSE;
4584 it->wd->show_item = NULL;
4586 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4587 gith = it->group_item->h;
4588 elm_smart_scroller_region_bring_in(it->wd->scr,
4589 it->x + it->block->x,
4590 it->y + it->block->y - gith,
4591 it->block->w, it->h);
4595 * Show the given item at the top
4597 * This causes genlist to jump to the given item @p it and show it (by
4598 * scrolling), if it is not fully visible.
4600 * @param it The item
4605 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4607 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4609 Evas_Coord gith = 0;
4611 if (it->delete_me) return;
4612 if ((it->queued) || (!it->mincalcd))
4614 it->wd->show_item = it;
4615 it->wd->bring_in = EINA_TRUE;
4616 it->showme = EINA_TRUE;
4619 if (it->wd->show_item)
4621 it->wd->show_item->showme = EINA_FALSE;
4622 it->wd->show_item = NULL;
4624 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4625 if (it->group_item) gith = it->group_item->h;
4626 elm_smart_scroller_child_region_show(it->wd->scr,
4627 it->x + it->block->x,
4628 it->y + it->block->y - gith,
4633 * Bring in the given item at the top
4635 * This causes genlist to jump to the given item @p it and show it (by
4636 * scrolling), if it is not fully visible. This may use animation to
4637 * do so and take a period of time
4639 * @param it The item
4644 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4646 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4648 Evas_Coord gith = 0;
4650 if (it->delete_me) return;
4651 if ((it->queued) || (!it->mincalcd))
4653 it->wd->show_item = it;
4654 it->wd->bring_in = EINA_TRUE;
4655 it->showme = EINA_TRUE;
4658 if (it->wd->show_item)
4660 it->wd->show_item->showme = EINA_FALSE;
4661 it->wd->show_item = NULL;
4663 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4664 if (it->group_item) gith = it->group_item->h;
4665 elm_smart_scroller_region_bring_in(it->wd->scr,
4666 it->x + it->block->x,
4667 it->y + it->block->y - gith,
4672 * Show the given item at the middle
4674 * This causes genlist to jump to the given item @p it and show it (by
4675 * scrolling), if it is not fully visible.
4677 * @param it The item
4682 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4684 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4687 if (it->delete_me) return;
4688 if ((it->queued) || (!it->mincalcd))
4690 it->wd->show_item = it;
4691 it->wd->bring_in = EINA_TRUE;
4692 it->showme = EINA_TRUE;
4695 if (it->wd->show_item)
4697 it->wd->show_item->showme = EINA_FALSE;
4698 it->wd->show_item = NULL;
4700 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4701 elm_smart_scroller_child_region_show(it->wd->scr,
4702 it->x + it->block->x,
4703 it->y + it->block->y - oh / 2 +
4704 it->h / 2, it->block->w, oh);
4708 * Bring in the given item at the middle
4710 * This causes genlist to jump to the given item @p it and show it (by
4711 * scrolling), if it is not fully visible. This may use animation to
4712 * do so and take a period of time
4714 * @param it The item
4719 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4721 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4724 if (it->delete_me) return;
4725 if ((it->queued) || (!it->mincalcd))
4727 it->wd->show_item = it;
4728 it->wd->bring_in = EINA_TRUE;
4729 it->showme = EINA_TRUE;
4732 if (it->wd->show_item)
4734 it->wd->show_item->showme = EINA_FALSE;
4735 it->wd->show_item = NULL;
4737 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4738 elm_smart_scroller_region_bring_in(it->wd->scr,
4739 it->x + it->block->x,
4740 it->y + it->block->y - oh / 2 + it->h / 2,
4745 * Delete a given item
4747 * This deletes the item from genlist and calls the genlist item del
4748 * class callback defined in the item class, if it is set. This clears all
4749 * subitems if it is a tree.
4751 * @param it The item
4756 elm_genlist_item_del(Elm_Genlist_Item *it)
4758 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4759 if ((it->relcount > 0) || (it->walking > 0))
4761 elm_widget_item_pre_notify_del(it);
4762 elm_genlist_item_subitems_clear(it);
4763 it->delete_me = EINA_TRUE;
4764 if (it->wd->show_item == it) it->wd->show_item = NULL;
4766 it->wd->selected = eina_list_remove(it->wd->selected,
4770 if (it->realized) _item_unrealize(it, EINA_FALSE);
4771 it->block->changed = EINA_TRUE;
4772 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4773 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4775 if (it->itc->func.del)
4776 it->itc->func.del((void *)it->base.data, it->base.widget);
4783 * Set the data item from the genlist item
4785 * This sets the data value passed on the elm_genlist_item_append() and
4786 * related item addition calls. This function will not call
4787 * elm_genlist_item_update() anymore. So call elm_genlist_item_update()
4788 * manually only when it's needed.
4790 * @param it The item
4791 * @param data The new data pointer to set
4796 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4799 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4800 elm_widget_item_data_set(it, data);
4804 * Get the data item from the genlist item
4806 * This returns the data value passed on the elm_genlist_item_append()
4807 * and related item addition calls and elm_genlist_item_data_set().
4809 * @param it The item
4810 * @return The data pointer provided when created
4815 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4818 return elm_widget_item_data_get(it);
4822 * Tells genlist to "orphan" icons fetchs by the item class
4824 * This instructs genlist to release references to icons in the item,
4825 * meaning that they will no longer be managed by genlist and are
4826 * floating "orphans" that can be re-used elsewhere if the user wants
4829 * @param it The item
4834 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4837 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4838 EINA_LIST_FREE(it->icon_objs, icon)
4840 elm_widget_sub_object_del(it->base.widget, icon);
4841 evas_object_smart_member_del(icon);
4842 evas_object_hide(icon);
4847 * Get the real evas object of the genlist item
4849 * This returns the actual evas object used for the specified genlist
4850 * item. This may be NULL as it may not be created, and may be deleted
4851 * at any time by genlist. Do not modify this object (move, resize,
4852 * show, hide etc.) as genlist is controlling it. This function is for
4853 * querying, emitting custom signals or hooking lower level callbacks
4854 * for events. Do not delete this object under any circumstances.
4856 * @param it The item
4857 * @return The object pointer
4861 EAPI const Evas_Object *
4862 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4864 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4865 return it->base.view;
4869 * Update the contents of an item
4871 * This updates an item by calling all the item class functions again
4872 * to get the icons, labels and states. Use this when the original
4873 * item data has changed and the changes are desired to be reflected.
4875 * @param it The item
4880 elm_genlist_item_update(Elm_Genlist_Item *it)
4882 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4883 if (!it->block) return;
4884 if (it->delete_me) return;
4885 it->mincalcd = EINA_FALSE;
4886 it->updateme = EINA_TRUE;
4887 it->block->updateme = EINA_TRUE;
4888 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4889 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4893 * Update the item class of an item
4895 * @param it The item
4896 * @parem itc The item class for the item
4901 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4902 const Elm_Genlist_Item_Class *itc)
4904 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4905 if (!it->block) return;
4906 EINA_SAFETY_ON_NULL_RETURN(itc);
4907 if (it->delete_me) return;
4909 it->nocache = EINA_TRUE;
4910 elm_genlist_item_update(it);
4913 EAPI const Elm_Genlist_Item_Class *
4914 elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
4916 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4917 if (it->delete_me) return NULL;
4921 static Evas_Object *
4922 _elm_genlist_item_label_create(void *data,
4924 void *item __UNUSED__)
4926 Evas_Object *label = elm_label_add(obj);
4929 elm_object_style_set(label, "tooltip");
4930 elm_object_text_set(label, data);
4935 _elm_genlist_item_label_del_cb(void *data,
4936 Evas_Object *obj __UNUSED__,
4937 void *event_info __UNUSED__)
4939 eina_stringshare_del(data);
4943 * Set the text to be shown in the genlist item.
4945 * @param item Target item
4946 * @param text The text to set in the content
4948 * Setup the text as tooltip to object. The item can have only one
4949 * tooltip, so any previous tooltip data is removed.
4954 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4957 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4958 text = eina_stringshare_add(text);
4959 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4961 _elm_genlist_item_label_del_cb);
4965 * Set the content to be shown in the tooltip item
4967 * Setup the tooltip to item. The item can have only one tooltip, so
4968 * any previous tooltip data is removed. @p func(with @p data) will be
4969 * called every time that need to show the tooltip and it should return a
4970 * valid Evas_Object. This object is then managed fully by tooltip
4971 * system and is deleted when the tooltip is gone.
4973 * @param item the genlist item being attached by a tooltip.
4974 * @param func the function used to create the tooltip contents.
4975 * @param data what to provide to @a func as callback data/context.
4976 * @param del_cb called when data is not needed anymore, either when
4977 * another callback replaces @func, the tooltip is unset with
4978 * elm_genlist_item_tooltip_unset() or the owner @a item
4979 * dies. This callback receives as the first parameter the
4980 * given @a data, and @c event_info is the item.
4985 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4986 Elm_Tooltip_Item_Content_Cb func,
4988 Evas_Smart_Cb del_cb)
4990 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4992 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4995 if (item->tooltip.del_cb)
4996 item->tooltip.del_cb((void *)item->tooltip.data,
4997 item->base.widget, item);
4999 item->tooltip.content_cb = func;
5000 item->tooltip.data = data;
5001 item->tooltip.del_cb = del_cb;
5003 if (item->base.view)
5005 elm_widget_item_tooltip_content_cb_set(item,
5006 item->tooltip.content_cb,
5007 item->tooltip.data, NULL);
5008 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
5014 if (del_cb) del_cb((void *)data, NULL, NULL);
5018 * Unset tooltip from item
5020 * @param item genlist item to remove previously set tooltip.
5022 * Remove tooltip from item. The callback provided as del_cb to
5023 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
5024 * it is not used anymore.
5026 * @see elm_genlist_item_tooltip_content_cb_set()
5031 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
5033 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5034 if ((item->base.view) && (item->tooltip.content_cb))
5035 elm_widget_item_tooltip_unset(item);
5037 if (item->tooltip.del_cb)
5038 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
5039 item->tooltip.del_cb = NULL;
5040 item->tooltip.content_cb = NULL;
5041 item->tooltip.data = NULL;
5042 if (item->tooltip.style)
5043 elm_genlist_item_tooltip_style_set(item, NULL);
5047 * Sets a different style for this item tooltip.
5049 * @note before you set a style you should define a tooltip with
5050 * elm_genlist_item_tooltip_content_cb_set() or
5051 * elm_genlist_item_tooltip_text_set()
5053 * @param item genlist item with tooltip already set.
5054 * @param style the theme style to use (default, transparent, ...)
5059 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
5062 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5063 eina_stringshare_replace(&item->tooltip.style, style);
5064 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
5068 * Get the style for this item tooltip.
5070 * @param item genlist item with tooltip already set.
5071 * @return style the theme style in use, defaults to "default". If the
5072 * object does not have a tooltip set, then NULL is returned.
5077 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
5079 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5080 return item->tooltip.style;
5084 * Set the cursor to be shown when mouse is over the genlist item
5086 * @param item Target item
5087 * @param cursor the cursor name to be used.
5089 * @see elm_object_cursor_set()
5093 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
5096 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5097 eina_stringshare_replace(&item->mouse_cursor, cursor);
5098 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
5102 * Get the cursor to be shown when mouse is over the genlist item
5104 * @param item genlist item with cursor already set.
5105 * @return the cursor name.
5110 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
5112 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5113 return elm_widget_item_cursor_get(item);
5117 * Unset the cursor to be shown when mouse is over the genlist item
5119 * @param item Target item
5121 * @see elm_object_cursor_unset()
5125 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
5127 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5128 if (!item->mouse_cursor)
5131 if (item->base.view)
5132 elm_widget_item_cursor_unset(item);
5134 eina_stringshare_del(item->mouse_cursor);
5135 item->mouse_cursor = NULL;
5139 * Sets a different style for this item cursor.
5141 * @note before you set a style you should define a cursor with
5142 * elm_genlist_item_cursor_set()
5144 * @param item genlist item with cursor already set.
5145 * @param style the theme style to use (default, transparent, ...)
5150 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5153 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5154 elm_widget_item_cursor_style_set(item, style);
5158 * Get the style for this item cursor.
5160 * @param item genlist item with cursor already set.
5161 * @return style the theme style in use, defaults to "default". If the
5162 * object does not have a cursor set, then NULL is returned.
5167 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5169 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5170 return elm_widget_item_cursor_style_get(item);
5174 * Set if the cursor set should be searched on the theme or should use
5175 * the provided by the engine, only.
5177 * @note before you set if should look on theme you should define a
5178 * cursor with elm_object_cursor_set(). By default it will only look
5179 * for cursors provided by the engine.
5181 * @param item widget item with cursor already set.
5182 * @param engine_only boolean to define it cursors should be looked
5183 * only between the provided by the engine or searched on widget's
5189 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5190 Eina_Bool engine_only)
5192 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5193 elm_widget_item_cursor_engine_only_set(item, engine_only);
5197 * Get the cursor engine only usage for this item cursor.
5199 * @param item widget item with cursor already set.
5200 * @return engine_only boolean to define it cursors should be looked
5201 * only between the provided by the engine or searched on widget's
5202 * theme as well. If the object does not have a cursor set, then
5203 * EINA_FALSE is returned.
5208 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5210 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5211 return elm_widget_item_cursor_engine_only_get(item);
5215 * This sets the horizontal stretching mode
5217 * This sets the mode used for sizing items horizontally. Valid modes
5218 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5219 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5220 * the scroller will scroll horizontally. Otherwise items are expanded
5221 * to fill the width of the viewport of the scroller. If it is
5222 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5223 * limited to that size.
5225 * @param obj The genlist object
5226 * @param mode The mode to use
5231 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5234 ELM_CHECK_WIDTYPE(obj, widtype);
5235 Widget_Data *wd = elm_widget_data_get(obj);
5237 if (wd->mode == mode) return;
5243 * Gets the horizontal stretching mode
5245 * @param obj The genlist object
5246 * @return The mode to use
5247 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5252 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5254 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5255 Widget_Data *wd = elm_widget_data_get(obj);
5256 if (!wd) return ELM_LIST_LAST;
5261 * Set the always select mode.
5263 * Items will only call their selection func and callback when first
5264 * becoming selected. Any further clicks will do nothing, unless you
5265 * enable always select with elm_genlist_always_select_mode_set().
5266 * This means even if selected, every click will make the selected
5267 * callbacks be called.
5269 * @param obj The genlist object
5270 * @param always_select The always select mode
5271 * (EINA_TRUE = on, EINA_FALSE = off)
5276 elm_genlist_always_select_mode_set(Evas_Object *obj,
5277 Eina_Bool always_select)
5279 ELM_CHECK_WIDTYPE(obj, widtype);
5280 Widget_Data *wd = elm_widget_data_get(obj);
5282 wd->always_select = always_select;
5286 * Get the always select mode.
5288 * @param obj The genlist object
5289 * @return The always select mode
5290 * (EINA_TRUE = on, EINA_FALSE = off)
5295 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5297 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5298 Widget_Data *wd = elm_widget_data_get(obj);
5299 if (!wd) return EINA_FALSE;
5300 return wd->always_select;
5304 * Set no select mode
5306 * This will turn off the ability to select items entirely and they
5307 * will neither appear selected nor call selected callback functions.
5309 * @param obj The genlist object
5310 * @param no_select The no select mode
5311 * (EINA_TRUE = on, EINA_FALSE = off)
5316 elm_genlist_no_select_mode_set(Evas_Object *obj,
5317 Eina_Bool no_select)
5319 ELM_CHECK_WIDTYPE(obj, widtype);
5320 Widget_Data *wd = elm_widget_data_get(obj);
5322 wd->no_select = no_select;
5326 * Gets no select mode
5328 * @param obj The genlist object
5329 * @return The no select mode
5330 * (EINA_TRUE = on, EINA_FALSE = off)
5335 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5337 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5338 Widget_Data *wd = elm_widget_data_get(obj);
5339 if (!wd) return EINA_FALSE;
5340 return wd->no_select;
5346 * This will enable the compress mode where items are "compressed"
5347 * horizontally to fit the genlist scrollable viewport width. This is
5348 * special for genlist. Do not rely on
5349 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5350 * work as genlist needs to handle it specially.
5352 * @param obj The genlist object
5353 * @param compress The compress mode
5354 * (EINA_TRUE = on, EINA_FALSE = off)
5359 elm_genlist_compress_mode_set(Evas_Object *obj,
5362 ELM_CHECK_WIDTYPE(obj, widtype);
5363 Widget_Data *wd = elm_widget_data_get(obj);
5365 wd->compress = compress;
5366 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5370 * Get the compress mode
5372 * @param obj The genlist object
5373 * @return The compress mode
5374 * (EINA_TRUE = on, EINA_FALSE = off)
5379 elm_genlist_compress_mode_get(const Evas_Object *obj)
5381 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5382 Widget_Data *wd = elm_widget_data_get(obj);
5383 if (!wd) return EINA_FALSE;
5384 return wd->compress;
5388 * Set height-for-width mode
5390 * With height-for-width mode the item width will be fixed (restricted
5391 * to a minimum of) to the list width when calculating its size in
5392 * order to allow the height to be calculated based on it. This allows,
5393 * for instance, text block to wrap lines if the Edje part is
5394 * configured with "text.min: 0 1".
5396 * @note This mode will make list resize slower as it will have to
5397 * recalculate every item height again whenever the list width
5400 * @note When height-for-width mode is enabled, it also enables
5401 * compress mode (see elm_genlist_compress_mode_set()) and
5402 * disables homogeneous (see elm_genlist_homogeneous_set()).
5404 * @param obj The genlist object
5405 * @param setting The height-for-width mode (EINA_TRUE = on,
5411 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5412 Eina_Bool height_for_width)
5414 ELM_CHECK_WIDTYPE(obj, widtype);
5415 Widget_Data *wd = elm_widget_data_get(obj);
5417 wd->height_for_width = !!height_for_width;
5418 if (wd->height_for_width)
5420 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5421 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5426 * Get the height-for-width mode
5428 * @param obj The genlist object
5429 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5435 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5437 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5438 Widget_Data *wd = elm_widget_data_get(obj);
5439 if (!wd) return EINA_FALSE;
5440 return wd->height_for_width;
5446 * This will enable or disable the scroller bounce mode for the
5447 * genlist. See elm_scroller_bounce_set() for details
5449 * @param obj The genlist object
5450 * @param h_bounce Allow bounce horizontally
5451 * @param v_bounce Allow bounce vertically
5456 elm_genlist_bounce_set(Evas_Object *obj,
5460 ELM_CHECK_WIDTYPE(obj, widtype);
5461 Widget_Data *wd = elm_widget_data_get(obj);
5463 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5467 * Get the bounce mode
5469 * @param obj The genlist object
5470 * @param h_bounce Allow bounce horizontally
5471 * @param v_bounce Allow bounce vertically
5476 elm_genlist_bounce_get(const Evas_Object *obj,
5477 Eina_Bool *h_bounce,
5478 Eina_Bool *v_bounce)
5480 ELM_CHECK_WIDTYPE(obj, widtype);
5481 Widget_Data *wd = elm_widget_data_get(obj);
5483 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
5487 * Set homogenous mode
5489 * This will enable the homogeneous mode where items are of the same
5490 * height and width so that genlist may do the lazy-loading at its
5491 * maximum. This implies 'compressed' mode.
5493 * @param obj The genlist object
5494 * @param homogeneous Assume the items within the genlist are of the
5495 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5500 elm_genlist_homogeneous_set(Evas_Object *obj,
5501 Eina_Bool homogeneous)
5503 ELM_CHECK_WIDTYPE(obj, widtype);
5504 Widget_Data *wd = elm_widget_data_get(obj);
5506 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5507 wd->homogeneous = homogeneous;
5511 * Get the homogenous mode
5513 * @param obj The genlist object
5514 * @return Assume the items within the genlist are of the same height
5515 * and width (EINA_TRUE = on, EINA_FALSE = off)
5520 elm_genlist_homogeneous_get(const Evas_Object *obj)
5522 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5523 Widget_Data *wd = elm_widget_data_get(obj);
5524 if (!wd) return EINA_FALSE;
5525 return wd->homogeneous;
5529 * Set the maximum number of items within an item block
5531 * This will configure the block count to tune to the target with
5532 * particular performance matrix.
5534 * @param obj The genlist object
5535 * @param n Maximum number of items within an item block
5540 elm_genlist_block_count_set(Evas_Object *obj,
5543 ELM_CHECK_WIDTYPE(obj, widtype);
5544 Widget_Data *wd = elm_widget_data_get(obj);
5546 wd->max_items_per_block = n;
5547 wd->item_cache_max = wd->max_items_per_block * 2;
5548 _item_cache_clean(wd);
5552 * Get the maximum number of items within an item block
5554 * @param obj The genlist object
5555 * @return Maximum number of items within an item block
5560 elm_genlist_block_count_get(const Evas_Object *obj)
5562 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5563 Widget_Data *wd = elm_widget_data_get(obj);
5565 return wd->max_items_per_block;
5569 * Set the timeout in seconds for the longpress event
5571 * @param obj The genlist object
5572 * @param timeout timeout in seconds
5577 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5580 ELM_CHECK_WIDTYPE(obj, widtype);
5581 Widget_Data *wd = elm_widget_data_get(obj);
5583 wd->longpress_timeout = timeout;
5587 * Get the timeout in seconds for the longpress event
5589 * @param obj The genlist object
5590 * @return timeout in seconds
5595 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5597 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5598 Widget_Data *wd = elm_widget_data_get(obj);
5600 return wd->longpress_timeout;
5604 * Set the scrollbar policy
5606 * This sets the scrollbar visibility policy for the given genlist
5607 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5608 * made visible if it is needed, and otherwise kept hidden.
5609 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5610 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5611 * respectively for the horizontal and vertical scrollbars.
5613 * @param obj The genlist object
5614 * @param policy_h Horizontal scrollbar policy
5615 * @param policy_v Vertical scrollbar policy
5620 elm_genlist_scroller_policy_set(Evas_Object *obj,
5621 Elm_Scroller_Policy policy_h,
5622 Elm_Scroller_Policy policy_v)
5624 ELM_CHECK_WIDTYPE(obj, widtype);
5625 Widget_Data *wd = elm_widget_data_get(obj);
5627 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5628 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5631 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5635 * Get the scrollbar policy
5637 * @param obj The genlist object
5638 * @param policy_h Horizontal scrollbar policy
5639 * @param policy_v Vertical scrollbar policy
5644 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5645 Elm_Scroller_Policy *policy_h,
5646 Elm_Scroller_Policy *policy_v)
5648 ELM_CHECK_WIDTYPE(obj, widtype);
5649 Widget_Data *wd = elm_widget_data_get(obj);
5650 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5651 if ((!wd) || (!wd->scr)) return;
5652 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5653 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5654 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5658 * Update the contents of all realized items
5660 * This updates all realized items by calling all the item class functions again
5661 * to get the icons, labels and states. Use this when the original
5662 * item data has changed and the changes are desired to be reflected.
5664 * @param it The item
5669 elm_genlist_realized_items_update(Evas_Object *obj)
5671 ELM_CHECK_WIDTYPE(obj, widtype);
5673 Eina_List *list, *l;
5674 Elm_Genlist_Item *it;
5676 list = elm_genlist_realized_items_get(obj);
5677 EINA_LIST_FOREACH(list, l, it)
5678 elm_genlist_item_update(it);
5682 * Set genlist item mode
5684 * @param item The genlist item
5685 * @param mode Mode name
5686 * @param mode_set Boolean to define set or unset mode.
5691 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5692 const char *mode_type,
5695 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5696 Widget_Data *wd = it->wd;
5698 Elm_Genlist_Item *it2;
5701 if (!mode_type) return;
5702 if ((it->delete_me) || (it->disabled)) return;
5704 if ((wd->mode_item == it) &&
5705 (!strcmp(mode_type, wd->mode_type)) &&
5708 if (!it->itc->mode_item_style) return;
5712 EINA_LIST_FOREACH(wd->selected, l, it2)
5714 elm_genlist_item_selected_set(it2, EINA_FALSE);
5718 it2 = elm_genlist_selected_item_get(wd->obj);
5719 if ((it2) && (it2->realized))
5720 elm_genlist_item_selected_set(it2, EINA_FALSE);
5723 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5725 ((it == wd->mode_item) && (!mode_set)))
5726 _item_mode_unset(wd);
5728 eina_stringshare_replace(&wd->mode_type, mode_type);
5729 if (mode_set) _item_mode_set(it);
5733 * Get active genlist mode type
5735 * @param obj The genlist object
5740 elm_genlist_mode_get(const Evas_Object *obj)
5742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5743 Widget_Data *wd = elm_widget_data_get(obj);
5744 if (!wd) return NULL;
5745 return wd->mode_type;
5749 * Get active genlist mode item
5751 * @param obj The genlist object
5755 EAPI const Elm_Genlist_Item *
5756 elm_genlist_mode_item_get(const Evas_Object *obj)
5758 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5759 Widget_Data *wd = elm_widget_data_get(obj);
5760 if (!wd) return NULL;
5761 return wd->mode_item;
5767 * @param obj The genlist object
5768 * @param reorder_mode The reorder mode
5769 * (EINA_TRUE = on, EINA_FALSE = off)
5774 elm_genlist_reorder_mode_set(Evas_Object *obj,
5775 Eina_Bool reorder_mode)
5777 ELM_CHECK_WIDTYPE(obj, widtype);
5778 Widget_Data *wd = elm_widget_data_get(obj);
5780 wd->reorder_mode = reorder_mode;
5784 * Get the reorder mode
5786 * @param obj The genlist object
5787 * @return The reorder mode
5788 * (EINA_TRUE = on, EINA_FALSE = off)
5793 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5795 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5796 Widget_Data *wd = elm_widget_data_get(obj);
5797 if (!wd) return EINA_FALSE;
5798 return wd->reorder_mode;