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_x, 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_unrealize(Elm_Genlist_Item *it,
378 static void _item_block_unrealize(Item_Block *itb);
379 static void _calc_job(void *data);
380 static void _on_focus_hook(void *data,
382 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
383 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
384 static Eina_Bool _item_single_select_up(Widget_Data *wd);
385 static Eina_Bool _item_single_select_down(Widget_Data *wd);
386 static Eina_Bool _event_hook(Evas_Object *obj,
388 Evas_Callback_Type type,
390 static void _signal_emit_hook(Evas_Object *obj,
391 const char *emission,
393 static Eina_Bool _deselect_all_items(Widget_Data *wd);
394 static void _pan_calculate(Evas_Object *obj);
395 static void _item_position(Elm_Genlist_Item *it,
399 static void _mode_item_realize(Elm_Genlist_Item *it);
400 static void _mode_item_unrealize(Elm_Genlist_Item *it);
401 static void _item_mode_set(Elm_Genlist_Item *it);
402 static void _item_mode_unset(Widget_Data *wd);
403 static void _group_items_recalc(void *data);
404 static void _item_move_after(Elm_Genlist_Item *it,
405 Elm_Genlist_Item *after);
406 static void _item_move_before(Elm_Genlist_Item *it,
407 Elm_Genlist_Item *before);
408 static void _item_auto_scroll(Widget_Data *wd);
410 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
412 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
413 static const char SIG_SELECTED[] = "selected";
414 static const char SIG_UNSELECTED[] = "unselected";
415 static const char SIG_EXPANDED[] = "expanded";
416 static const char SIG_CONTRACTED[] = "contracted";
417 static const char SIG_EXPAND_REQUEST[] = "expand,request";
418 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
419 static const char SIG_REALIZED[] = "realized";
420 static const char SIG_UNREALIZED[] = "unrealized";
421 static const char SIG_DRAG_START_UP[] = "drag,start,up";
422 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
423 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
424 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
425 static const char SIG_DRAG_STOP[] = "drag,stop";
426 static const char SIG_DRAG[] = "drag";
427 static const char SIG_LONGPRESSED[] = "longpressed";
428 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
429 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
430 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
431 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
432 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
433 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
434 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
435 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
436 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
437 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
438 static const char SIG_SWIPE[] = "swipe";
440 static const Evas_Smart_Cb_Description _signals[] = {
441 {SIG_CLICKED_DOUBLE, ""},
443 {SIG_UNSELECTED, ""},
445 {SIG_CONTRACTED, ""},
446 {SIG_EXPAND_REQUEST, ""},
447 {SIG_CONTRACT_REQUEST, ""},
449 {SIG_UNREALIZED, ""},
450 {SIG_DRAG_START_UP, ""},
451 {SIG_DRAG_START_DOWN, ""},
452 {SIG_DRAG_START_LEFT, ""},
453 {SIG_DRAG_START_RIGHT, ""},
456 {SIG_LONGPRESSED, ""},
457 {SIG_SCROLL_EDGE_TOP, ""},
458 {SIG_SCROLL_EDGE_BOTTOM, ""},
459 {SIG_SCROLL_EDGE_LEFT, ""},
460 {SIG_SCROLL_EDGE_RIGHT, ""},
461 {SIG_MULTI_SWIPE_LEFT, ""},
462 {SIG_MULTI_SWIPE_RIGHT, ""},
463 {SIG_MULTI_SWIPE_UP, ""},
464 {SIG_MULTI_SWIPE_DOWN, ""},
465 {SIG_MULTI_PINCH_OUT, ""},
466 {SIG_MULTI_PINCH_IN, ""},
471 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
474 _event_hook(Evas_Object *obj,
475 Evas_Object *src __UNUSED__,
476 Evas_Callback_Type type,
479 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
480 Evas_Event_Key_Down *ev = event_info;
481 Widget_Data *wd = elm_widget_data_get(obj);
482 if (!wd) return EINA_FALSE;
483 if (!wd->items) return EINA_FALSE;
484 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
485 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
487 Elm_Genlist_Item *it = NULL;
490 Evas_Coord step_x = 0;
491 Evas_Coord step_y = 0;
494 Evas_Coord page_x = 0;
495 Evas_Coord page_y = 0;
497 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
498 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
499 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
500 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
502 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
506 else if ((!strcmp(ev->keyname, "Right")) ||
507 (!strcmp(ev->keyname, "KP_Right")))
511 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
513 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
514 (_item_multi_select_up(wd)))
515 || (_item_single_select_up(wd)))
517 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
523 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
525 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
526 (_item_multi_select_down(wd)))
527 || (_item_single_select_down(wd)))
529 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
535 else if ((!strcmp(ev->keyname, "Home")) ||
536 (!strcmp(ev->keyname, "KP_Home")))
538 it = elm_genlist_first_item_get(obj);
539 elm_genlist_item_bring_in(it);
540 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
543 else if ((!strcmp(ev->keyname, "End")) ||
544 (!strcmp(ev->keyname, "KP_End")))
546 it = elm_genlist_last_item_get(obj);
547 elm_genlist_item_bring_in(it);
548 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
551 else if ((!strcmp(ev->keyname, "Prior")) ||
552 (!strcmp(ev->keyname, "KP_Prior")))
555 y -= -(page_y * v_h) / 100;
559 else if ((!strcmp(ev->keyname, "Next")) ||
560 (!strcmp(ev->keyname, "KP_Next")))
563 y += -(page_y * v_h) / 100;
567 else if (((!strcmp(ev->keyname, "Return")) ||
568 (!strcmp(ev->keyname, "KP_Enter")) ||
569 (!strcmp(ev->keyname, "space")))
570 && (!wd->multi) && (wd->selected))
572 it = elm_genlist_selected_item_get(obj);
573 elm_genlist_item_expanded_set(it,
574 !elm_genlist_item_expanded_get(it));
576 else if (!strcmp(ev->keyname, "Escape"))
578 if (!_deselect_all_items(wd)) return EINA_FALSE;
579 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
582 else return EINA_FALSE;
584 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
585 elm_smart_scroller_child_pos_set(wd->scr, x, y);
590 _deselect_all_items(Widget_Data *wd)
592 if (!wd->selected) return EINA_FALSE;
594 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
600 _item_multi_select_up(Widget_Data *wd)
602 if (!wd->selected) return EINA_FALSE;
603 if (!wd->multi) return EINA_FALSE;
605 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
606 if (!prev) return EINA_TRUE;
608 if (elm_genlist_item_selected_get(prev))
610 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
611 wd->last_selected_item = prev;
612 elm_genlist_item_show(wd->last_selected_item);
616 elm_genlist_item_selected_set(prev, EINA_TRUE);
617 elm_genlist_item_show(prev);
623 _item_multi_select_down(Widget_Data *wd)
625 if (!wd->selected) return EINA_FALSE;
626 if (!wd->multi) return EINA_FALSE;
628 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
629 if (!next) return EINA_TRUE;
631 if (elm_genlist_item_selected_get(next))
633 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
634 wd->last_selected_item = next;
635 elm_genlist_item_show(wd->last_selected_item);
639 elm_genlist_item_selected_set(next, EINA_TRUE);
640 elm_genlist_item_show(next);
646 _item_single_select_up(Widget_Data *wd)
648 Elm_Genlist_Item *prev;
651 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
652 while ((prev) && (prev->delete_me))
653 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
655 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
657 if (!prev) return EINA_FALSE;
659 _deselect_all_items(wd);
661 elm_genlist_item_selected_set(prev, EINA_TRUE);
662 elm_genlist_item_show(prev);
667 _item_single_select_down(Widget_Data *wd)
669 Elm_Genlist_Item *next;
672 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
673 while ((next) && (next->delete_me))
674 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
676 else next = elm_genlist_item_next_get(wd->last_selected_item);
678 if (!next) return EINA_FALSE;
680 _deselect_all_items(wd);
682 elm_genlist_item_selected_set(next, EINA_TRUE);
683 elm_genlist_item_show(next);
688 _on_focus_hook(void *data __UNUSED__,
691 Widget_Data *wd = elm_widget_data_get(obj);
693 if (elm_widget_focus_get(obj))
695 elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
696 evas_object_focus_set(wd->obj, EINA_TRUE);
697 if ((wd->selected) && (!wd->last_selected_item))
698 wd->last_selected_item = eina_list_data_get(wd->selected);
702 elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
703 evas_object_focus_set(wd->obj, EINA_FALSE);
708 _del_hook(Evas_Object *obj)
710 Widget_Data *wd = elm_widget_data_get(obj);
712 _item_cache_zero(wd);
713 if (wd->calc_job) ecore_job_del(wd->calc_job);
714 if (wd->update_job) ecore_job_del(wd->update_job);
715 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
716 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
717 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
718 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
719 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
724 _del_pre_hook(Evas_Object *obj)
726 Widget_Data *wd = elm_widget_data_get(obj);
728 evas_object_del(wd->pan_smart);
729 wd->pan_smart = NULL;
730 elm_genlist_clear(obj);
734 _mirrored_set(Evas_Object *obj,
737 Widget_Data *wd = elm_widget_data_get(obj);
739 _item_cache_zero(wd);
740 elm_smart_scroller_mirrored_set(wd->scr, rtl);
744 _theme_hook(Evas_Object *obj)
746 Widget_Data *wd = elm_widget_data_get(obj);
749 evas_event_freeze(evas_object_evas_get(wd->obj));
750 _item_cache_zero(wd);
751 _elm_widget_mirrored_reload(obj);
752 _mirrored_set(obj, elm_widget_mirrored_get(obj));
753 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
754 elm_widget_style_get(obj));
755 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
756 wd->item_width = wd->item_height = 0;
757 wd->group_item_width = wd->group_item_height = 0;
758 wd->minw = wd->minh = wd->realminw = 0;
759 EINA_INLIST_FOREACH(wd->blocks, itb)
762 Elm_Genlist_Item *it;
764 if (itb->realized) _item_block_unrealize(itb);
765 EINA_LIST_FOREACH(itb->items, l, it)
766 it->mincalcd = EINA_FALSE;
768 itb->changed = EINA_TRUE;
770 if (wd->calc_job) ecore_job_del(wd->calc_job);
771 wd->calc_job = ecore_job_add(_calc_job, wd);
773 evas_event_thaw(evas_object_evas_get(wd->obj));
774 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
778 _show_region_hook(void *data,
781 Widget_Data *wd = elm_widget_data_get(data);
782 Evas_Coord x, y, w, h;
784 elm_widget_show_region_get(obj, &x, &y, &w, &h);
785 //x & y are screen coordinates, Add with pan coordinates
788 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
792 _sizing_eval(Evas_Object *obj)
794 Widget_Data *wd = elm_widget_data_get(obj);
795 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
797 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
798 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
800 if (wd->height_for_width)
804 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
805 if ((vw != 0) && (vw != wd->prev_viewport_w))
809 wd->prev_viewport_w = vw;
810 EINA_INLIST_FOREACH(wd->blocks, itb)
812 itb->must_recalc = EINA_TRUE;
814 if (wd->calc_job) ecore_job_del(wd->calc_job);
815 wd->calc_job = ecore_job_add(_calc_job, wd);
818 if (wd->mode == ELM_LIST_LIMIT)
820 Evas_Coord vmw, vmh, vw, vh;
824 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
825 if ((minw > 0) && (vw < minw)) vw = minw;
826 else if ((maxw > 0) && (vw > maxw))
828 edje_object_size_min_calc
829 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
836 edje_object_size_min_calc
837 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
841 evas_object_size_hint_min_set(obj, minw, minh);
842 evas_object_size_hint_max_set(obj, maxw, maxh);
846 _signal_emit_hook(Evas_Object *obj,
847 const char *emission,
850 Widget_Data *wd = elm_widget_data_get(obj);
851 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
856 _item_highlight(Elm_Genlist_Item *it)
858 const char *selectraise;
859 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
860 (it->disabled) || (it->display_only) || (it->mode_view))
862 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
863 selectraise = edje_object_data_get(it->base.view, "selectraise");
864 if ((selectraise) && (!strcmp(selectraise, "on")))
866 evas_object_raise(it->base.view);
867 if ((it->group_item) && (it->group_item->realized))
868 evas_object_raise(it->group_item->base.view);
870 it->highlighted = EINA_TRUE;
874 _item_unhighlight(Elm_Genlist_Item *it)
876 const char *stacking, *selectraise;
877 if ((it->delete_me) || (!it->highlighted)) return;
878 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
879 stacking = edje_object_data_get(it->base.view, "stacking");
880 selectraise = edje_object_data_get(it->base.view, "selectraise");
883 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
884 else evas_object_raise(it->base.view);
886 it->highlighted = EINA_FALSE;
890 _item_block_del(Elm_Genlist_Item *it)
893 Item_Block *itb = it->block;
895 itb->items = eina_list_remove(itb->items, it);
897 itb->changed = EINA_TRUE;
898 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
899 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
902 il = EINA_INLIST_GET(itb);
903 Item_Block *itbn = (Item_Block *)(il->next);
905 it->parent->items = eina_list_remove(it->parent->items, it);
907 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
909 if (itbn) itbn->changed = EINA_TRUE;
913 if (itb->count < itb->wd->max_items_per_block/2)
915 il = EINA_INLIST_GET(itb);
916 Item_Block *itbp = (Item_Block *)(il->prev);
917 Item_Block *itbn = (Item_Block *)(il->next);
918 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
920 Elm_Genlist_Item *it2;
922 EINA_LIST_FREE(itb->items, it2)
925 itbp->items = eina_list_append(itbp->items, it2);
927 itbp->changed = EINA_TRUE;
929 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
930 EINA_INLIST_GET(itb));
933 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
937 Eina_List *last = eina_list_last(itb->items);
938 Elm_Genlist_Item *it2 = last->data;
941 itb->items = eina_list_remove_list(itb->items, last);
942 itbn->items = eina_list_prepend(itbn->items, it2);
944 itbn->changed = EINA_TRUE;
947 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
955 _item_del(Elm_Genlist_Item *it)
957 Evas_Object *tob = it->wd->obj;
959 evas_event_freeze(evas_object_evas_get(tob));
960 elm_widget_item_pre_notify_del(it);
961 elm_genlist_item_subitems_clear(it);
962 it->wd->walking -= it->walking;
963 if (it->wd->show_item == it) it->wd->show_item = NULL;
964 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
965 if (it->realized) _item_unrealize(it, EINA_FALSE);
966 if (it->block) _item_block_del(it);
967 if ((!it->delete_me) && (it->itc->func.del))
968 it->itc->func.del((void *)it->base.data, it->base.widget);
969 it->delete_me = EINA_TRUE;
971 it->wd->queue = eina_list_remove(it->wd->queue, it);
972 if (it->wd->anchor_item == it)
974 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
975 if (!it->wd->anchor_item)
976 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
978 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
980 it->parent->items = eina_list_remove(it->parent->items, it);
981 if (it->flags & ELM_GENLIST_ITEM_GROUP)
982 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
983 if (it->long_timer) ecore_timer_del(it->long_timer);
984 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
986 if (it->tooltip.del_cb)
987 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
989 evas_event_thaw(evas_object_evas_get(tob));
990 evas_event_thaw_eval(evas_object_evas_get(tob));
992 elm_widget_item_del(it);
996 _item_select(Elm_Genlist_Item *it)
998 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
1001 if (it->wd->always_select) goto call;
1004 it->selected = EINA_TRUE;
1005 it->wd->selected = eina_list_append(it->wd->selected, it);
1009 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1011 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
1014 if ((it->wd->clear_me) && (!it->wd->walking))
1015 elm_genlist_clear(it->base.widget);
1018 if ((!it->walking) && (it->delete_me))
1020 if (!it->relcount) _item_del(it);
1023 it->wd->last_selected_item = it;
1027 _item_unselect(Elm_Genlist_Item *it)
1029 if ((it->delete_me) || (!it->selected)) return;
1030 it->selected = EINA_FALSE;
1031 it->wd->selected = eina_list_remove(it->wd->selected, it);
1032 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1036 _mouse_move(void *data,
1037 Evas *evas __UNUSED__,
1041 Elm_Genlist_Item *it = data;
1042 Evas_Event_Mouse_Move *ev = event_info;
1043 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1044 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
1046 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1048 if (!it->wd->on_hold)
1050 it->wd->on_hold = EINA_TRUE;
1051 if (!it->wd->wasselected)
1053 _item_unhighlight(it);
1058 if (it->wd->multitouched)
1060 it->wd->cur_x = ev->cur.canvas.x;
1061 it->wd->cur_y = ev->cur.canvas.y;
1064 if ((it->dragging) && (it->down))
1066 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1069 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1070 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1071 if (abs((it->wd->history[it->wd->movements].x -
1072 it->wd->history[0].x)) > 40)
1073 it->wd->swipe = EINA_TRUE;
1075 it->wd->movements++;
1079 ecore_timer_del(it->long_timer);
1080 it->long_timer = NULL;
1082 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1085 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1089 ecore_timer_del(it->long_timer);
1090 it->long_timer = NULL;
1092 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1094 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1095 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1097 if (!it->wd->reorder_start_y)
1098 it->wd->reorder_start_y = it->block->y + it->y;
1100 if (it_scrl_y < oy) y_pos = oy;
1101 else if (it_scrl_y + it->wd->reorder_it->h > oy+oh)
1102 y_pos = oy + oh - it->wd->reorder_it->h;
1103 else y_pos = it_scrl_y;
1105 _item_position(it, it->base.view, it->scrl_x, y_pos);
1107 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1108 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1112 if (!it->display_only)
1113 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1114 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1115 x = ev->cur.canvas.x - x;
1116 y = ev->cur.canvas.y - y;
1119 if (adx < 0) adx = -dx;
1122 if (ady < 0) ady = -dy;
1125 if ((adx > minw) || (ady > minh))
1127 it->dragging = EINA_TRUE;
1130 ecore_timer_del(it->long_timer);
1131 it->long_timer = NULL;
1133 if (!it->wd->wasselected)
1135 _item_unhighlight(it);
1141 evas_object_smart_callback_call(it->base.widget,
1142 SIG_DRAG_START_UP, it);
1146 evas_object_smart_callback_call(it->base.widget,
1147 SIG_DRAG_START_LEFT, it);
1149 evas_object_smart_callback_call(it->base.widget,
1150 SIG_DRAG_START_RIGHT, it);
1156 evas_object_smart_callback_call(it->base.widget,
1157 SIG_DRAG_START_DOWN, it);
1161 evas_object_smart_callback_call(it->base.widget,
1162 SIG_DRAG_START_LEFT, it);
1164 evas_object_smart_callback_call(it->base.widget,
1165 SIG_DRAG_START_RIGHT, it);
1172 _long_press(void *data)
1174 Elm_Genlist_Item *it = data, *it_tmp;
1175 Eina_List *list, *l;
1177 it->long_timer = NULL;
1178 if ((it->disabled) || (it->dragging) || (it->display_only))
1179 return ECORE_CALLBACK_CANCEL;
1180 it->wd->longpressed = EINA_TRUE;
1181 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1182 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1184 it->wd->reorder_it = it;
1185 it->wd->reorder_start_y = 0;
1187 evas_object_raise(it->base.view);
1188 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1190 list = elm_genlist_realized_items_get(it->wd->obj);
1191 EINA_LIST_FOREACH(list, l, it_tmp)
1193 if (it != it_tmp) _item_unselect(it_tmp);
1195 if (elm_genlist_item_expanded_get(it))
1197 elm_genlist_item_expanded_set(it, EINA_FALSE);
1198 return ECORE_CALLBACK_RENEW;
1200 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1202 return ECORE_CALLBACK_CANCEL;
1206 _swipe(Elm_Genlist_Item *it)
1211 if ((it->display_only) || (it->disabled)) return;
1212 it->wd->swipe = EINA_FALSE;
1213 for (i = 0; i < it->wd->movements; i++)
1215 sum += it->wd->history[i].x;
1216 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1219 sum /= it->wd->movements;
1220 if (abs(sum - it->wd->history[0].x) <= 10) return;
1221 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1225 _swipe_cancel(void *data)
1227 Elm_Genlist_Item *it = data;
1229 if (!it) return ECORE_CALLBACK_CANCEL;
1230 it->wd->swipe = EINA_FALSE;
1231 it->wd->movements = 0;
1232 return ECORE_CALLBACK_RENEW;
1236 _multi_cancel(void *data)
1238 Widget_Data *wd = data;
1240 if (!wd) return ECORE_CALLBACK_CANCEL;
1241 wd->multi_timeout = EINA_TRUE;
1242 return ECORE_CALLBACK_RENEW;
1246 _multi_touch_gesture_eval(void *data)
1248 Elm_Genlist_Item *it = data;
1250 it->wd->multitouched = EINA_FALSE;
1251 if (it->wd->multi_timer)
1253 ecore_timer_del(it->wd->multi_timer);
1254 it->wd->multi_timer = NULL;
1256 if (it->wd->multi_timeout)
1258 it->wd->multi_timeout = EINA_FALSE;
1262 Evas_Coord minw = 0, minh = 0;
1263 Evas_Coord off_x, off_y, off_mx, off_my;
1265 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1266 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1267 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1268 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1269 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1271 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1273 if ((off_x + off_mx) > (off_y + off_my))
1275 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1276 evas_object_smart_callback_call(it->base.widget,
1277 SIG_MULTI_SWIPE_RIGHT, it);
1278 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1279 evas_object_smart_callback_call(it->base.widget,
1280 SIG_MULTI_SWIPE_LEFT, it);
1281 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1282 evas_object_smart_callback_call(it->base.widget,
1283 SIG_MULTI_PINCH_OUT, it);
1285 evas_object_smart_callback_call(it->base.widget,
1286 SIG_MULTI_PINCH_IN, it);
1290 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1291 evas_object_smart_callback_call(it->base.widget,
1292 SIG_MULTI_SWIPE_DOWN, it);
1293 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1294 evas_object_smart_callback_call(it->base.widget,
1295 SIG_MULTI_SWIPE_UP, it);
1296 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1297 evas_object_smart_callback_call(it->base.widget,
1298 SIG_MULTI_PINCH_OUT, it);
1300 evas_object_smart_callback_call(it->base.widget,
1301 SIG_MULTI_PINCH_IN, it);
1304 it->wd->multi_timeout = EINA_FALSE;
1308 _multi_down(void *data,
1309 Evas *evas __UNUSED__,
1310 Evas_Object *obj __UNUSED__,
1313 Elm_Genlist_Item *it = data;
1314 Evas_Event_Multi_Down *ev = event_info;
1316 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1317 it->wd->multi_device = ev->device;
1318 it->wd->multi_down = EINA_TRUE;
1319 it->wd->multitouched = EINA_TRUE;
1320 it->wd->prev_mx = ev->canvas.x;
1321 it->wd->prev_my = ev->canvas.y;
1322 if (!it->wd->wasselected)
1324 _item_unhighlight(it);
1327 it->wd->wasselected = EINA_FALSE;
1328 it->wd->longpressed = EINA_FALSE;
1331 ecore_timer_del(it->long_timer);
1332 it->long_timer = NULL;
1336 it->dragging = EINA_FALSE;
1337 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1339 if (it->swipe_timer)
1341 ecore_timer_del(it->swipe_timer);
1342 it->swipe_timer = NULL;
1344 if (it->wd->on_hold)
1346 it->wd->swipe = EINA_FALSE;
1347 it->wd->movements = 0;
1348 it->wd->on_hold = EINA_FALSE;
1353 _multi_up(void *data,
1354 Evas *evas __UNUSED__,
1355 Evas_Object *obj __UNUSED__,
1358 Elm_Genlist_Item *it = data;
1359 Evas_Event_Multi_Up *ev = event_info;
1361 if (it->wd->multi_device != ev->device) return;
1362 it->wd->multi_device = 0;
1363 it->wd->multi_down = EINA_FALSE;
1364 if (it->wd->mouse_down) return;
1365 _multi_touch_gesture_eval(data);
1369 _multi_move(void *data,
1370 Evas *evas __UNUSED__,
1371 Evas_Object *obj __UNUSED__,
1374 Elm_Genlist_Item *it = data;
1375 Evas_Event_Multi_Move *ev = event_info;
1377 if (it->wd->multi_device != ev->device) return;
1378 it->wd->cur_mx = ev->cur.canvas.x;
1379 it->wd->cur_my = ev->cur.canvas.y;
1383 _mouse_down(void *data,
1384 Evas *evas __UNUSED__,
1388 Elm_Genlist_Item *it = data;
1389 Evas_Event_Mouse_Down *ev = event_info;
1392 if (ev->button != 1) return;
1393 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1395 it->wd->on_hold = EINA_TRUE;
1398 it->down = EINA_TRUE;
1399 it->dragging = EINA_FALSE;
1400 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1401 it->dx = ev->canvas.x - x;
1402 it->dy = ev->canvas.y - y;
1403 it->wd->mouse_down = EINA_TRUE;
1404 if (!it->wd->multitouched)
1406 it->wd->prev_x = ev->canvas.x;
1407 it->wd->prev_y = ev->canvas.y;
1408 it->wd->multi_timeout = EINA_FALSE;
1409 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1410 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1412 it->wd->longpressed = EINA_FALSE;
1413 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1414 else it->wd->on_hold = EINA_FALSE;
1415 if (it->wd->on_hold) return;
1416 it->wd->wasselected = it->selected;
1417 _item_highlight(it);
1418 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1419 if ((!it->disabled) && (!it->display_only))
1421 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1422 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1424 if (it->long_timer) ecore_timer_del(it->long_timer);
1425 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1426 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1428 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1431 it->long_timer = NULL;
1432 it->wd->swipe = EINA_FALSE;
1433 it->wd->movements = 0;
1437 _mouse_up(void *data,
1438 Evas *evas __UNUSED__,
1439 Evas_Object *obj __UNUSED__,
1442 Elm_Genlist_Item *it = data;
1443 Evas_Event_Mouse_Up *ev = event_info;
1444 Eina_Bool dragged = EINA_FALSE;
1446 if (ev->button != 1) return;
1447 it->down = EINA_FALSE;
1448 it->wd->mouse_down = EINA_FALSE;
1449 if (it->wd->multitouched)
1451 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1452 if (it->wd->multi_down) return;
1453 _multi_touch_gesture_eval(data);
1456 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1457 else it->wd->on_hold = EINA_FALSE;
1460 ecore_timer_del(it->long_timer);
1461 it->long_timer = NULL;
1465 it->dragging = EINA_FALSE;
1466 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1469 if (it->swipe_timer)
1471 ecore_timer_del(it->swipe_timer);
1472 it->swipe_timer = NULL;
1474 if (it->wd->multi_timer)
1476 ecore_timer_del(it->wd->multi_timer);
1477 it->wd->multi_timer = NULL;
1478 it->wd->multi_timeout = EINA_FALSE;
1480 if (it->wd->on_hold)
1482 if (it->wd->swipe) _swipe(data);
1483 it->wd->longpressed = EINA_FALSE;
1484 it->wd->on_hold = EINA_FALSE;
1487 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1489 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1491 if (it->wd->reorder_rel)
1493 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent)
1495 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1496 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1498 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1502 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1503 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1506 edje_object_signal_emit(it->base.view, "elm,state,reorder,disabled", "elm");
1507 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1508 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1510 if (it->wd->longpressed)
1512 it->wd->longpressed = EINA_FALSE;
1513 if (!it->wd->wasselected)
1515 _item_unhighlight(it);
1518 it->wd->wasselected = EINA_FALSE;
1523 if (it->want_unrealize)
1525 _item_unrealize(it, EINA_FALSE);
1526 if (it->block->want_unrealize)
1527 _item_block_unrealize(it->block);
1530 if ((it->disabled) || (dragged) || (it->display_only)) return;
1531 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1536 _item_highlight(it);
1541 _item_unhighlight(it);
1549 Widget_Data *wd = it->wd;
1552 while (wd->selected)
1554 _item_unhighlight(wd->selected->data);
1555 _item_unselect(wd->selected->data);
1561 const Eina_List *l, *l_next;
1562 Elm_Genlist_Item *it2;
1564 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1567 _item_unhighlight(it2);
1568 _item_unselect(it2);
1570 //_item_highlight(it);
1573 _item_highlight(it);
1579 _signal_expand_toggle(void *data,
1580 Evas_Object *obj __UNUSED__,
1581 const char *emission __UNUSED__,
1582 const char *source __UNUSED__)
1584 Elm_Genlist_Item *it = data;
1587 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1589 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1593 _signal_expand(void *data,
1594 Evas_Object *obj __UNUSED__,
1595 const char *emission __UNUSED__,
1596 const char *source __UNUSED__)
1598 Elm_Genlist_Item *it = data;
1601 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1605 _signal_contract(void *data,
1606 Evas_Object *obj __UNUSED__,
1607 const char *emission __UNUSED__,
1608 const char *source __UNUSED__)
1610 Elm_Genlist_Item *it = data;
1613 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1617 _scr_hold_timer_cb(void *data)
1619 if (!data) return ECORE_CALLBACK_CANCEL;
1620 Widget_Data *wd = data;
1621 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1622 wd->scr_hold_timer = NULL;
1623 return ECORE_CALLBACK_CANCEL;
1627 _mode_finished_signal_cb(void *data,
1629 const char *emission __UNUSED__,
1630 const char *source __UNUSED__)
1634 Elm_Genlist_Item *it = data;
1635 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1637 Evas *te = evas_object_evas_get(obj);
1639 evas_event_freeze(te);
1640 it->nocache = EINA_FALSE;
1641 _mode_item_unrealize(it);
1642 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1643 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1644 evas_event_thaw(te);
1645 evas_event_thaw_eval(te);
1649 _item_cache_clean(Widget_Data *wd)
1651 evas_event_freeze(evas_object_evas_get(wd->obj));
1652 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1656 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1657 wd->item_cache = eina_inlist_remove(wd->item_cache,
1658 wd->item_cache->last);
1659 wd->item_cache_count--;
1660 if (itc->spacer) evas_object_del(itc->spacer);
1661 if (itc->base_view) evas_object_del(itc->base_view);
1662 if (itc->item_style) eina_stringshare_del(itc->item_style);
1665 evas_event_thaw(evas_object_evas_get(wd->obj));
1666 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1670 _item_cache_zero(Widget_Data *wd)
1672 int pmax = wd->item_cache_max;
1673 wd->item_cache_max = 0;
1674 _item_cache_clean(wd);
1675 wd->item_cache_max = pmax;
1679 _item_cache_add(Elm_Genlist_Item *it)
1683 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1684 if (it->wd->item_cache_max <= 0)
1686 evas_object_del(it->base.view);
1687 it->base.view = NULL;
1688 evas_object_del(it->spacer);
1690 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1691 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1695 it->wd->item_cache_count++;
1696 itc = calloc(1, sizeof(Item_Cache));
1697 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1698 EINA_INLIST_GET(itc));
1699 itc->spacer = it->spacer;
1701 itc->base_view = it->base.view;
1702 it->base.view = NULL;
1703 evas_object_hide(itc->base_view);
1704 evas_object_move(itc->base_view, -9999, -9999);
1705 itc->item_style = eina_stringshare_add(it->itc->item_style);
1706 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1707 itc->compress = (it->wd->compress);
1708 itc->selected = it->selected;
1709 itc->disabled = it->disabled;
1710 itc->expanded = it->expanded;
1713 ecore_timer_del(it->long_timer);
1714 it->long_timer = NULL;
1716 if (it->swipe_timer)
1718 ecore_timer_del(it->swipe_timer);
1719 it->swipe_timer = NULL;
1721 // FIXME: other callbacks?
1722 edje_object_signal_callback_del_full(itc->base_view,
1723 "elm,action,expand,toggle",
1724 "elm", _signal_expand_toggle, it);
1725 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1727 _signal_expand, it);
1728 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1729 "elm", _signal_contract, it);
1730 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1732 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1734 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1736 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1738 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1740 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1742 _item_cache_clean(it->wd);
1743 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1744 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1748 _item_cache_find(Elm_Genlist_Item *it)
1753 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1754 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1756 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1758 if ((itc->tree == tree) &&
1759 (itc->compress == it->wd->compress) &&
1760 (!strcmp(it->itc->item_style, itc->item_style)))
1762 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1763 EINA_INLIST_GET(itc));
1764 it->wd->item_cache_count--;
1772 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1774 if (!it->nostacking)
1776 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1777 evas_object_lower(it->base.view);
1779 evas_object_raise(it->base.view);
1782 if (it->order_num_in & 0x1)
1783 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1785 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1789 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1793 if (it->selected != itc->selected)
1796 edje_object_signal_emit(it->base.view,
1797 "elm,state,selected", "elm");
1799 if (it->disabled != itc->disabled)
1802 edje_object_signal_emit(it->base.view,
1803 "elm,state,disabled", "elm");
1805 if (it->expanded != itc->expanded)
1808 edje_object_signal_emit(it->base.view,
1809 "elm,state,expanded", "elm");
1815 edje_object_signal_emit(it->base.view,
1816 "elm,state,selected", "elm");
1818 edje_object_signal_emit(it->base.view,
1819 "elm,state,disabled", "elm");
1821 edje_object_signal_emit(it->base.view,
1822 "elm,state,expanded", "elm");
1827 _item_cache_free(Item_Cache *itc)
1829 if (itc->spacer) evas_object_del(itc->spacer);
1830 if (itc->base_view) evas_object_del(itc->base_view);
1831 if (itc->item_style) eina_stringshare_del(itc->item_style);
1836 _item_label_realize(Elm_Genlist_Item *it,
1837 Evas_Object *target,
1840 if (it->itc->func.label_get)
1845 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1846 EINA_LIST_FOREACH(*source, l, key)
1848 char *s = it->itc->func.label_get
1849 ((void *)it->base.data, it->base.widget, key);
1853 edje_object_part_text_set(target, key, s);
1858 edje_object_part_text_set(target, key, "");
1865 _item_icon_realize(Elm_Genlist_Item *it,
1866 Evas_Object *target,
1869 Eina_List *res = NULL;
1871 if (it->itc->func.icon_get)
1876 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1877 EINA_LIST_FOREACH(*source, l, key)
1879 Evas_Object *ic = it->itc->func.icon_get
1880 ((void *)it->base.data, it->base.widget, key);
1884 res = eina_list_append(res, ic);
1885 edje_object_part_swallow(target, key, ic);
1886 evas_object_show(ic);
1887 elm_widget_sub_object_add(it->base.widget, ic);
1889 elm_widget_disabled_set(ic, EINA_TRUE);
1898 _item_state_realize(Elm_Genlist_Item *it,
1899 Evas_Object *target,
1902 if (it->itc->func.state_get)
1908 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1909 EINA_LIST_FOREACH(*source, l, key)
1911 Eina_Bool on = it->itc->func.state_get
1912 ((void *)it->base.data, it->base.widget, key);
1916 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1917 edje_object_signal_emit(target, buf, "elm");
1921 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1922 edje_object_signal_emit(target, buf, "elm");
1929 _item_realize(Elm_Genlist_Item *it,
1933 Elm_Genlist_Item *it2;
1934 const char *treesize;
1936 int depth, tsize = 20;
1937 Item_Cache *itc = NULL;
1939 if (it->delete_me) return;
1940 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1943 if (it->order_num_in != in)
1945 it->order_num_in = in;
1946 _elm_genlist_item_odd_even_update(it);
1947 _elm_genlist_item_state_update(it, NULL);
1949 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1950 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1953 it->order_num_in = in;
1956 it->nocache = EINA_FALSE;
1958 itc = _item_cache_find(it);
1961 it->base.view = itc->base_view;
1962 itc->base_view = NULL;
1963 it->spacer = itc->spacer;
1968 const char *stacking_even;
1969 const char *stacking;
1971 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1972 edje_object_scale_set(it->base.view,
1973 elm_widget_scale_get(it->base.widget) *
1974 _elm_config->scale);
1975 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1976 elm_widget_sub_object_add(it->base.widget, it->base.view);
1978 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1979 strncpy(buf, "tree", sizeof(buf));
1980 else strncpy(buf, "item", sizeof(buf));
1981 if (it->wd->compress)
1982 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1984 strncat(buf, "/", sizeof(buf) - strlen(buf));
1985 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1987 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1988 elm_widget_style_get(it->base.widget));
1990 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1991 if (!stacking_even) stacking_even = "above";
1992 it->stacking_even = !!strcmp("above", stacking_even);
1994 stacking = edje_object_data_get(it->base.view, "stacking");
1995 if (!stacking) stacking = "yes";
1996 it->nostacking = !!strcmp("yes", stacking);
1998 edje_object_mirrored_set(it->base.view,
1999 elm_widget_mirrored_get(it->base.widget));
2001 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
2002 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2003 elm_widget_sub_object_add(it->base.widget, it->spacer);
2006 _elm_genlist_item_odd_even_update(it);
2008 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
2010 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
2012 it->expanded_depth = depth;
2013 treesize = edje_object_data_get(it->base.view, "treesize");
2014 if (treesize) tsize = atoi(treesize);
2015 evas_object_size_hint_min_set(it->spacer,
2016 (depth * tsize) * _elm_config->scale, 1);
2017 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
2020 edje_object_signal_callback_add(it->base.view,
2021 "elm,action,expand,toggle",
2022 "elm", _signal_expand_toggle, it);
2023 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
2024 "elm", _signal_expand, it);
2025 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
2026 "elm", _signal_contract, it);
2027 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
2029 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
2031 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
2033 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
2035 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
2037 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
2040 _elm_genlist_item_state_update(it, itc);
2043 if ((calc) && (it->wd->homogeneous) &&
2044 ((it->wd->item_width) ||
2045 ((it->wd->item_width) && (it->wd->group_item_width))))
2047 /* homogenous genlist shortcut */
2050 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2052 it->w = it->minw = it->wd->group_item_width;
2053 it->h = it->minh = it->wd->group_item_height;
2057 it->w = it->minw = it->wd->item_width;
2058 it->h = it->minh = it->wd->item_height;
2060 it->mincalcd = EINA_TRUE;
2065 /* FIXME: If you see that assert, please notify us and we
2066 will clean our mess */
2067 assert(eina_list_count(it->icon_objs) == 0);
2069 _item_label_realize(it, it->base.view, &it->labels);
2070 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
2071 _item_state_realize(it, it->base.view, &it->states);
2075 Evas_Coord mw = -1, mh = -1;
2077 if (!it->display_only)
2078 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2079 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2080 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2082 if (!it->display_only)
2083 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2084 it->w = it->minw = mw;
2085 it->h = it->minh = mh;
2086 it->mincalcd = EINA_TRUE;
2088 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2090 it->wd->group_item_width = mw;
2091 it->wd->group_item_height = mh;
2093 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2095 it->wd->item_width = mw;
2096 it->wd->item_height = mh;
2099 if (!calc) evas_object_show(it->base.view);
2102 if (it->tooltip.content_cb)
2104 elm_widget_item_tooltip_content_cb_set(it,
2105 it->tooltip.content_cb,
2106 it->tooltip.data, NULL);
2107 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2110 if (it->mouse_cursor)
2111 elm_widget_item_cursor_set(it, it->mouse_cursor);
2113 it->realized = EINA_TRUE;
2114 it->want_unrealize = EINA_FALSE;
2116 if (itc) _item_cache_free(itc);
2117 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2118 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2120 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2124 _item_unrealize(Elm_Genlist_Item *it,
2129 if (!it->realized) return;
2130 if (it->wd->reorder_it == it) return;
2131 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2133 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2136 ecore_timer_del(it->long_timer);
2137 it->long_timer = NULL;
2141 evas_object_del(it->base.view);
2142 it->base.view = NULL;
2143 evas_object_del(it->spacer);
2148 edje_object_mirrored_set(it->base.view,
2149 elm_widget_mirrored_get(it->base.widget));
2150 edje_object_scale_set(it->base.view,
2151 elm_widget_scale_get(it->base.widget)
2152 * _elm_config->scale);
2153 _item_cache_add(it);
2155 elm_widget_stringlist_free(it->labels);
2157 elm_widget_stringlist_free(it->icons);
2159 elm_widget_stringlist_free(it->states);
2161 EINA_LIST_FREE(it->icon_objs, icon)
2162 evas_object_del(icon);
2164 _mode_item_unrealize(it);
2166 it->realized = EINA_FALSE;
2167 it->want_unrealize = EINA_FALSE;
2168 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2169 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2173 _item_block_recalc(Item_Block *itb,
2178 Elm_Genlist_Item *it;
2179 Evas_Coord minw = 0, minh = 0;
2180 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2183 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2185 EINA_LIST_FOREACH(itb->items, l, it)
2187 if (it->delete_me) continue;
2188 showme |= it->showme;
2193 if (!it->mincalcd) changed = EINA_TRUE;
2196 _item_realize(it, in, EINA_TRUE);
2197 _item_unrealize(it, EINA_TRUE);
2202 _item_realize(it, in, EINA_TRUE);
2203 _item_unrealize(it, EINA_TRUE);
2207 _item_realize(it, in, EINA_FALSE);
2209 if (minw < it->minw) minw = it->minw;
2217 itb->changed = EINA_FALSE;
2218 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2219 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2224 _item_block_realize(Item_Block *itb)
2226 if (itb->realized) return;
2227 itb->realized = EINA_TRUE;
2228 itb->want_unrealize = EINA_FALSE;
2232 _item_block_unrealize(Item_Block *itb)
2235 Elm_Genlist_Item *it;
2236 Eina_Bool dragging = EINA_FALSE;
2238 if (!itb->realized) return;
2239 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2240 EINA_LIST_FOREACH(itb->items, l, it)
2242 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2246 dragging = EINA_TRUE;
2247 it->want_unrealize = EINA_TRUE;
2250 _item_unrealize(it, EINA_FALSE);
2255 itb->realized = EINA_FALSE;
2256 itb->want_unrealize = EINA_TRUE;
2259 itb->want_unrealize = EINA_FALSE;
2260 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2261 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2265 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2267 Evas_Coord rox, roy, row, roh, oy, oh;
2268 Eina_Bool top = EINA_FALSE;
2269 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2270 if (!reorder_it) return 0;
2272 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2273 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2275 if ((it->wd->reorder_start_y < it->block->y) &&
2276 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2278 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2279 if (it->block->count == 1)
2280 it->wd->reorder_rel = it;
2282 else if ((it->wd->reorder_start_y >= it->block->y) &&
2283 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2285 it->block->reorder_offset = it->wd->reorder_it->h;
2288 it->block->reorder_offset = 0;
2290 it->scrl_y += it->block->reorder_offset;
2292 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2293 rox, roy + (roh / 2), row, 1));
2296 it->wd->reorder_rel = it;
2297 it->scrl_y += it->wd->reorder_it->h;
2298 return it->wd->reorder_it->h;
2305 _reorder_move_animator_cb(void *data)
2307 Elm_Genlist_Item *it = data;
2308 Eina_Bool down = EINA_FALSE;
2310 int y, dy = it->h / 10 * _elm_config->scale, diff;
2312 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2314 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2317 diff = abs(it->old_scrl_y - it->scrl_y);
2318 if (diff > it->h) y = diff / 2;
2320 if (it->old_scrl_y < it->scrl_y)
2322 it->old_scrl_y += y;
2325 else if (it->old_scrl_y > it->scrl_y)
2327 it->old_scrl_y -= y;
2330 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2331 _group_items_recalc(it->wd);
2333 if ((it->wd->reorder_pan_move) ||
2334 (down && it->old_scrl_y >= it->scrl_y) ||
2335 (!down && it->old_scrl_y <= it->scrl_y))
2337 it->old_scrl_y = it->scrl_y;
2338 it->move_effect_enabled = EINA_FALSE;
2339 it->wd->reorder_move_animator = NULL;
2340 return ECORE_CALLBACK_CANCEL;
2342 return ECORE_CALLBACK_RENEW;
2346 _item_position(Elm_Genlist_Item *it,
2354 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2355 evas_object_resize(view, it->w, it->h);
2356 evas_object_move(view, it_x, it_y);
2357 evas_object_show(view);
2358 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2359 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2363 _item_block_position(Item_Block *itb,
2367 Elm_Genlist_Item *it;
2368 Elm_Genlist_Item *git;
2369 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2372 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2373 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2374 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2376 EINA_LIST_FOREACH(itb->items, l, it)
2378 if (it->delete_me) continue;
2379 else if (it->wd->reorder_it == it) continue;
2383 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2384 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2386 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2387 cvx, cvy, cvw, cvh));
2388 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2390 if ((itb->realized) && (!it->realized))
2392 if (vis) _item_realize(it, in, EINA_FALSE);
2398 if (it->wd->reorder_mode)
2399 y += _get_space_for_reorder_item(it);
2400 git = it->group_item;
2403 if (git->scrl_y < oy)
2405 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2406 git->scrl_y = (it->scrl_y + it->h) - git->h;
2407 git->want_realize = EINA_TRUE;
2409 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2411 if (!it->move_effect_enabled)
2413 it->move_effect_enabled = EINA_TRUE;
2414 it->wd->reorder_move_animator =
2416 _reorder_move_animator_cb, it);
2419 if (!it->move_effect_enabled)
2423 _item_position(it, it->mode_view, it->scrl_x,
2426 _item_position(it, it->base.view, it->scrl_x,
2429 it->old_scrl_x = it->scrl_x;
2430 it->old_scrl_y = it->scrl_y;
2435 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2442 if (vis) it->want_realize = EINA_TRUE;
2446 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2447 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2451 _group_items_recalc(void *data)
2453 Widget_Data *wd = data;
2455 Elm_Genlist_Item *git;
2457 evas_event_freeze(evas_object_evas_get(wd->obj));
2458 EINA_LIST_FOREACH(wd->group_items, l, git)
2460 if (git->want_realize)
2463 _item_realize(git, 0, EINA_FALSE);
2464 evas_object_resize(git->base.view, wd->minw, git->h);
2465 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2466 evas_object_show(git->base.view);
2467 evas_object_raise(git->base.view);
2469 else if (!git->want_realize && git->realized)
2472 _item_unrealize(git, EINA_FALSE);
2475 evas_event_thaw(evas_object_evas_get(wd->obj));
2476 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2480 _must_recalc_idler(void *data)
2482 Widget_Data *wd = data;
2483 if (wd->calc_job) ecore_job_del(wd->calc_job);
2484 wd->calc_job = ecore_job_add(_calc_job, wd);
2485 wd->must_recalc_idler = NULL;
2486 return ECORE_CALLBACK_CANCEL;
2490 _calc_job(void *data)
2492 Widget_Data *wd = data;
2493 Item_Block *itb, *chb = NULL;
2494 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2497 Eina_Bool minw_change = EINA_FALSE, changed = EINA_FALSE;
2498 Eina_Bool did_must_recalc = EINA_FALSE;
2501 t0 = ecore_time_get();
2502 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2506 evas_event_freeze(evas_object_evas_get(wd->obj));
2507 EINA_INLIST_FOREACH(wd->blocks, itb)
2509 Eina_Bool showme = EINA_FALSE;
2512 showme = itb->showme;
2513 itb->showme = EINA_FALSE;
2516 if (itb->realized) _item_block_unrealize(itb);
2518 if ((itb->changed) || (changed) ||
2519 ((itb->must_recalc) && (!did_must_recalc)))
2521 if ((changed) || (itb->must_recalc))
2524 Elm_Genlist_Item *it;
2525 EINA_LIST_FOREACH(itb->items, l, it)
2526 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2527 itb->changed = EINA_TRUE;
2528 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2529 itb->must_recalc = EINA_FALSE;
2531 if (itb->realized) _item_block_unrealize(itb);
2532 showme = _item_block_recalc(itb, in, EINA_FALSE);
2538 if (minw == -1) minw = itb->minw;
2539 else if ((!itb->must_recalc) && (minw < itb->minw))
2542 minw_change = EINA_TRUE;
2548 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2550 wd->show_item->showme = EINA_FALSE;
2552 elm_smart_scroller_region_bring_in(wd->scr,
2554 wd->show_item->block->x,
2556 wd->show_item->block->y,
2557 wd->show_item->block->w,
2560 elm_smart_scroller_child_region_show(wd->scr,
2562 wd->show_item->block->x,
2564 wd->show_item->block->y,
2565 wd->show_item->block->w,
2567 wd->show_item = NULL;
2572 EINA_INLIST_FOREACH(wd->blocks, itb)
2578 if ((chb) && (EINA_INLIST_GET(chb)->next))
2580 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2582 if (itb->realized) _item_block_unrealize(itb);
2585 wd->realminw = minw;
2586 if (minw < wd->w) minw = wd->w;
2587 if ((minw != wd->minw) || (minh != wd->minh))
2591 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2592 _sizing_eval(wd->obj);
2593 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scroll_enabled))
2595 Elm_Genlist_Item *it;
2598 it = wd->anchor_item;
2599 it_y = wd->anchor_y;
2600 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2601 it->block->y + it->y + it_y);
2602 wd->anchor_item = it;
2603 wd->anchor_y = it_y;
2606 t = ecore_time_get();
2607 if (did_must_recalc)
2609 if (!wd->must_recalc_idler)
2610 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2612 wd->calc_job = NULL;
2613 evas_object_smart_changed(wd->pan_smart);
2614 evas_event_thaw(evas_object_evas_get(wd->obj));
2615 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2619 _update_job(void *data)
2621 Widget_Data *wd = data;
2625 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2627 wd->update_job = NULL;
2630 evas_event_freeze(evas_object_evas_get(wd->obj));
2631 EINA_INLIST_FOREACH(wd->blocks, itb)
2633 Evas_Coord itminw, itminh;
2634 Elm_Genlist_Item *it;
2640 _item_block_position(itb, num);
2644 recalc = EINA_FALSE;
2645 EINA_LIST_FOREACH(itb->items, l2, it)
2652 it->updateme = EINA_FALSE;
2655 _item_unrealize(it, EINA_FALSE);
2656 _item_realize(it, num, EINA_FALSE);
2657 position = EINA_TRUE;
2661 _item_realize(it, num, EINA_TRUE);
2662 _item_unrealize(it, EINA_TRUE);
2664 if ((it->minw != itminw) || (it->minh != itminh))
2669 itb->updateme = EINA_FALSE;
2672 position = EINA_TRUE;
2673 itb->changed = EINA_TRUE;
2674 _item_block_recalc(itb, num0, EINA_FALSE);
2675 _item_block_position(itb, num0);
2680 if (wd->calc_job) ecore_job_del(wd->calc_job);
2681 wd->calc_job = ecore_job_add(_calc_job, wd);
2683 evas_event_thaw(evas_object_evas_get(wd->obj));
2684 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2688 _pan_set(Evas_Object *obj,
2692 Pan *sd = evas_object_smart_data_get(obj);
2695 // Evas_Coord ow, oh;
2696 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2697 // ow = sd->wd->minw - ow;
2698 // if (ow < 0) ow = 0;
2699 // oh = sd->wd->minh - oh;
2700 // if (oh < 0) oh = 0;
2701 // if (x < 0) x = 0;
2702 // if (y < 0) y = 0;
2703 // if (x > ow) x = ow;
2704 // if (y > oh) y = oh;
2705 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2709 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2711 if ((itb->y + itb->h) > y)
2713 Elm_Genlist_Item *it;
2716 EINA_LIST_FOREACH(itb->items, l2, it)
2718 if ((itb->y + it->y) >= y)
2720 sd->wd->anchor_item = it;
2721 sd->wd->anchor_y = -(itb->y + it->y - y);
2728 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2732 _pan_get(Evas_Object *obj,
2736 Pan *sd = evas_object_smart_data_get(obj);
2738 if (x) *x = sd->wd->pan_x;
2739 if (y) *y = sd->wd->pan_y;
2743 _pan_max_get(Evas_Object *obj,
2747 Pan *sd = evas_object_smart_data_get(obj);
2750 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2751 ow = sd->wd->minw - ow;
2753 oh = sd->wd->minh - oh;
2760 _pan_min_get(Evas_Object *obj __UNUSED__,
2769 _pan_child_size_get(Evas_Object *obj,
2773 Pan *sd = evas_object_smart_data_get(obj);
2775 if (w) *w = sd->wd->minw;
2776 if (h) *h = sd->wd->minh;
2780 _pan_add(Evas_Object *obj)
2783 Evas_Object_Smart_Clipped_Data *cd;
2786 cd = evas_object_smart_data_get(obj);
2789 sd->__clipped_data = *cd;
2791 evas_object_smart_data_set(obj, sd);
2795 _pan_del(Evas_Object *obj)
2797 Pan *sd = evas_object_smart_data_get(obj);
2802 ecore_job_del(sd->resize_job);
2803 sd->resize_job = NULL;
2809 _pan_resize_job(void *data)
2812 _sizing_eval(sd->wd->obj);
2813 sd->resize_job = NULL;
2817 _pan_resize(Evas_Object *obj,
2821 Pan *sd = evas_object_smart_data_get(obj);
2824 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2825 if ((ow == w) && (oh == h)) return;
2826 if ((sd->wd->height_for_width) && (ow != w))
2828 if (sd->resize_job) ecore_job_del(sd->resize_job);
2829 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2831 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2832 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2836 _pan_calculate(Evas_Object *obj)
2838 Pan *sd = evas_object_smart_data_get(obj);
2840 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2842 Elm_Genlist_Item *git;
2845 evas_event_freeze(evas_object_evas_get(obj));
2846 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2847 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2848 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2850 git->want_realize = EINA_FALSE;
2852 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2854 itb->w = sd->wd->minw;
2855 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2856 itb->y - sd->wd->pan_y + oy,
2858 cvx, cvy, cvw, cvh))
2860 if ((!itb->realized) || (itb->changed))
2861 _item_block_realize(itb);
2862 _item_block_position(itb, in);
2866 if (itb->realized) _item_block_unrealize(itb);
2870 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2871 _group_items_recalc(sd->wd);
2872 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2874 if (sd->wd->pan_y != sd->wd->old_pan_y)
2875 sd->wd->reorder_pan_move = EINA_TRUE;
2876 else sd->wd->reorder_pan_move = EINA_FALSE;
2877 evas_object_raise(sd->wd->reorder_it->base.view);
2878 sd->wd->old_pan_y = sd->wd->pan_y;
2879 sd->wd->start_time = ecore_loop_time_get();
2881 _item_auto_scroll(sd->wd);
2882 evas_event_thaw(evas_object_evas_get(obj));
2883 evas_event_thaw_eval(evas_object_evas_get(obj));
2887 _pan_move(Evas_Object *obj,
2888 Evas_Coord x __UNUSED__,
2889 Evas_Coord y __UNUSED__)
2891 Pan *sd = evas_object_smart_data_get(obj);
2893 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2894 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2898 _hold_on(void *data __UNUSED__,
2900 void *event_info __UNUSED__)
2902 Widget_Data *wd = elm_widget_data_get(obj);
2904 elm_smart_scroller_hold_set(wd->scr, 1);
2908 _hold_off(void *data __UNUSED__,
2910 void *event_info __UNUSED__)
2912 Widget_Data *wd = elm_widget_data_get(obj);
2914 elm_smart_scroller_hold_set(wd->scr, 0);
2918 _freeze_on(void *data __UNUSED__,
2920 void *event_info __UNUSED__)
2922 Widget_Data *wd = elm_widget_data_get(obj);
2924 elm_smart_scroller_freeze_set(wd->scr, 1);
2928 _freeze_off(void *data __UNUSED__,
2930 void *event_info __UNUSED__)
2932 Widget_Data *wd = elm_widget_data_get(obj);
2934 elm_smart_scroller_freeze_set(wd->scr, 0);
2938 _scroll_edge_left(void *data,
2939 Evas_Object *scr __UNUSED__,
2940 void *event_info __UNUSED__)
2942 Evas_Object *obj = data;
2943 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2947 _scroll_edge_right(void *data,
2948 Evas_Object *scr __UNUSED__,
2949 void *event_info __UNUSED__)
2951 Evas_Object *obj = data;
2952 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2956 _scroll_edge_top(void *data,
2957 Evas_Object *scr __UNUSED__,
2958 void *event_info __UNUSED__)
2960 Evas_Object *obj = data;
2961 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2965 _scroll_edge_bottom(void *data,
2966 Evas_Object *scr __UNUSED__,
2967 void *event_info __UNUSED__)
2969 Evas_Object *obj = data;
2970 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2974 _mode_item_realize(Elm_Genlist_Item *it)
2978 if ((it->mode_view) || (it->delete_me)) return;
2980 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2981 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2982 edje_object_scale_set(it->mode_view,
2983 elm_widget_scale_get(it->base.widget) *
2984 _elm_config->scale);
2985 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2986 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2988 strncpy(buf, "item", sizeof(buf));
2989 if (it->wd->compress)
2990 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2992 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2993 strncat(buf, "/", sizeof(buf) - strlen(buf));
2994 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2996 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2997 elm_widget_style_get(it->base.widget));
2998 edje_object_mirrored_set(it->mode_view,
2999 elm_widget_mirrored_get(it->base.widget));
3001 /* signal callback add */
3002 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3004 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3006 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3009 /* label_get, icon_get, state_get */
3010 /* FIXME: If you see that assert, please notify us and we
3011 will clean our mess */
3012 assert(eina_list_count(it->mode_icon_objs) == 0);
3014 _item_label_realize(it, it->mode_view, &it->mode_labels);
3015 it->mode_icon_objs = _item_icon_realize(it,
3018 _item_state_realize(it, it->mode_view, &it->mode_states);
3020 edje_object_part_swallow(it->mode_view,
3021 edje_object_data_get(it->mode_view, "mode_part"),
3024 it->want_unrealize = EINA_FALSE;
3025 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3026 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3030 _mode_item_unrealize(Elm_Genlist_Item *it)
3032 Widget_Data *wd = it->wd;
3034 if (!it->mode_view) return;
3036 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3037 elm_widget_stringlist_free(it->mode_labels);
3038 it->mode_labels = NULL;
3039 elm_widget_stringlist_free(it->mode_icons);
3040 it->mode_icons = NULL;
3041 elm_widget_stringlist_free(it->mode_states);
3043 EINA_LIST_FREE(it->mode_icon_objs, icon)
3044 evas_object_del(icon);
3046 edje_object_part_unswallow(it->mode_view, it->base.view);
3047 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3048 evas_object_del(it->mode_view);
3049 it->mode_view = NULL;
3051 if (wd->mode_item == it)
3052 wd->mode_item = NULL;
3053 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3054 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3058 _item_mode_set(Elm_Genlist_Item *it)
3061 Widget_Data *wd = it->wd;
3066 it->nocache = EINA_TRUE;
3068 if (wd->scr_hold_timer)
3070 ecore_timer_del(wd->scr_hold_timer);
3071 wd->scr_hold_timer = NULL;
3073 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3074 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3076 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3077 _mode_item_realize(it);
3078 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3079 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3080 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3082 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3083 edje_object_signal_emit(it->mode_view, buf, "elm");
3087 _item_mode_unset(Widget_Data *wd)
3090 if (!wd->mode_item) return;
3091 char buf[1024], buf2[1024];
3092 Elm_Genlist_Item *it;
3095 it->nocache = EINA_TRUE;
3097 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3098 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3100 edje_object_signal_emit(it->mode_view, buf, "elm");
3101 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3103 wd->mode_item = NULL;
3107 _item_auto_scroll(Widget_Data *wd)
3110 Elm_Genlist_Item *it;
3112 Evas_Coord ox, oy, ow, oh;
3114 if ((wd->expanded_item) && (wd->auto_scroll_enabled))
3116 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3117 if (wd->expanded_item->scrl_y > (oh + oy) / 2)
3119 EINA_LIST_FOREACH(wd->expanded_item->items, l, it)
3120 elm_genlist_item_bring_in(it);
3122 wd->auto_scroll_enabled = EINA_FALSE;
3127 * Add a new Genlist object
3129 * @param parent The parent object
3130 * @return The new object or NULL if it cannot be created
3135 elm_genlist_add(Evas_Object *parent)
3140 Evas_Coord minw, minh;
3141 static Evas_Smart *smart = NULL;
3145 static Evas_Smart_Class sc;
3147 evas_object_smart_clipped_smart_set(&_pan_sc);
3149 sc.name = "elm_genlist_pan";
3150 sc.version = EVAS_SMART_CLASS_VERSION;
3153 sc.resize = _pan_resize;
3154 sc.move = _pan_move;
3155 sc.calculate = _pan_calculate;
3156 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3159 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3161 ELM_SET_WIDTYPE(widtype, "genlist");
3162 elm_widget_type_set(obj, "genlist");
3163 elm_widget_sub_object_add(parent, obj);
3164 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3165 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3166 elm_widget_data_set(obj, wd);
3167 elm_widget_del_hook_set(obj, _del_hook);
3168 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3169 elm_widget_theme_hook_set(obj, _theme_hook);
3170 elm_widget_can_focus_set(obj, EINA_TRUE);
3171 elm_widget_event_hook_set(obj, _event_hook);
3172 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3174 wd->scr = elm_smart_scroller_add(e);
3175 elm_smart_scroller_widget_set(wd->scr, obj);
3176 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3177 elm_widget_style_get(obj));
3178 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3179 _elm_config->thumbscroll_bounce_enable);
3180 elm_widget_resize_object_set(obj, wd->scr);
3182 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3183 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3185 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3186 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3190 wd->mode = ELM_LIST_SCROLL;
3191 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3192 wd->item_cache_max = wd->max_items_per_block * 2;
3193 wd->longpress_timeout = _elm_config->longpress_timeout;
3195 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3196 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3197 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3198 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3200 wd->pan_smart = evas_object_smart_add(e, smart);
3201 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3204 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3205 _pan_set, _pan_get, _pan_max_get,
3206 _pan_min_get, _pan_child_size_get);
3208 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3210 evas_object_size_hint_min_set(obj, minw, minh);
3212 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3214 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3219 static Elm_Genlist_Item *
3220 _item_new(Widget_Data *wd,
3221 const Elm_Genlist_Item_Class *itc,
3223 Elm_Genlist_Item *parent,
3224 Elm_Genlist_Item_Flags flags,
3226 const void *func_data)
3228 Elm_Genlist_Item *it;
3230 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3231 if (!it) return NULL;
3234 it->base.data = data;
3235 it->parent = parent;
3237 it->func.func = func;
3238 it->func.data = func_data;
3239 it->mouse_cursor = NULL;
3240 it->expanded_depth = 0;
3245 _item_block_add(Widget_Data *wd,
3246 Elm_Genlist_Item *it)
3248 Item_Block *itb = NULL;
3255 itb = calloc(1, sizeof(Item_Block));
3258 if (!it->rel->block)
3261 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3262 itb->items = eina_list_append(itb->items, it);
3268 wd->blocks = eina_inlist_prepend_relative
3269 (wd->blocks, EINA_INLIST_GET(itb),
3270 EINA_INLIST_GET(it->rel->block));
3272 eina_list_prepend_relative(itb->items, it, it->rel);
3276 wd->blocks = eina_inlist_append_relative
3277 (wd->blocks, EINA_INLIST_GET(itb),
3278 EINA_INLIST_GET(it->rel->block));
3280 eina_list_append_relative(itb->items, it, it->rel);
3290 itb = (Item_Block *)(wd->blocks);
3291 if (itb->count >= wd->max_items_per_block)
3293 itb = calloc(1, sizeof(Item_Block));
3297 eina_inlist_prepend(wd->blocks,
3298 EINA_INLIST_GET(itb));
3303 itb = calloc(1, sizeof(Item_Block));
3307 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3309 itb->items = eina_list_prepend(itb->items, it);
3315 itb = (Item_Block *)(wd->blocks->last);
3316 if (itb->count >= wd->max_items_per_block)
3318 itb = calloc(1, sizeof(Item_Block));
3322 eina_inlist_append(wd->blocks,
3323 EINA_INLIST_GET(itb));
3328 itb = calloc(1, sizeof(Item_Block));
3332 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3334 itb->items = eina_list_append(itb->items, it);
3340 itb = it->rel->block;
3341 if (!itb) goto newblock;
3343 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3345 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3348 itb->changed = EINA_TRUE;
3350 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3351 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3354 it->rel->relcount--;
3355 if ((it->rel->delete_me) && (!it->rel->relcount))
3359 if (itb->count > itb->wd->max_items_per_block)
3363 Elm_Genlist_Item *it2;
3365 newc = itb->count / 2;
3366 itb2 = calloc(1, sizeof(Item_Block));
3370 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3371 EINA_INLIST_GET(itb));
3372 itb2->changed = EINA_TRUE;
3373 while ((itb->count > newc) && (itb->items))
3377 l = eina_list_last(itb->items);
3379 itb->items = eina_list_remove_list(itb->items, l);
3382 itb2->items = eina_list_prepend(itb2->items, it2);
3390 _queue_process(Widget_Data *wd)
3393 Eina_Bool showme = EINA_FALSE;
3396 t0 = ecore_time_get();
3397 //evas_event_freeze(evas_object_evas_get(wd->obj));
3398 for (n = 0; (wd->queue) && (n < 128); n++)
3400 Elm_Genlist_Item *it;
3402 it = wd->queue->data;
3403 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3404 it->queued = EINA_FALSE;
3405 _item_block_add(wd, it);
3406 t = ecore_time_get();
3407 if (it->block->changed)
3409 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3410 it->block->changed = 0;
3412 if (showme) it->block->showme = EINA_TRUE;
3413 if (eina_inlist_count(wd->blocks) > 1)
3415 if ((t - t0) > (ecore_animator_frametime_get())) break;
3418 //evas_event_thaw(evas_object_evas_get(wd->obj));
3419 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3424 _idle_process(void *data, Eina_Bool *wakeup)
3426 Widget_Data *wd = data;
3429 //static double q_start = 0.0;
3430 //if (q_start == 0.0) q_start = ecore_time_get();
3432 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3436 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3438 return ECORE_CALLBACK_CANCEL;
3440 return ECORE_CALLBACK_RENEW;
3444 _item_idle_enterer(void *data)
3446 Widget_Data *wd = data;
3447 Eina_Bool wakeup = EINA_FALSE;
3448 Eina_Bool ok = _idle_process(data, &wakeup);
3453 if (wd->calc_job) ecore_job_del(wd->calc_job);
3454 wd->calc_job = ecore_job_add(_calc_job, wd);
3456 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3461 _item_queue(Widget_Data *wd,
3462 Elm_Genlist_Item *it)
3464 if (it->queued) return;
3465 it->queued = EINA_TRUE;
3466 wd->queue = eina_list_append(wd->queue, it);
3467 // FIXME: why does a freeze then thaw here cause some genlist
3468 // elm_genlist_item_append() to be much much slower?
3469 // evas_event_freeze(evas_object_evas_get(wd->obj));
3470 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3472 if (wd->queue_idle_enterer)
3474 ecore_idle_enterer_del(wd->queue_idle_enterer);
3475 wd->queue_idle_enterer = NULL;
3479 // evas_event_thaw(evas_object_evas_get(wd->obj));
3480 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3481 if (!wd->queue_idle_enterer)
3482 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3486 _elm_genlist_item_compare(const void *data, const void *data1)
3488 Elm_Genlist_Item *item, *item1;
3489 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3490 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3491 return _elm_genlist_item_compare_cb(item->base.data, item1->base.data);
3495 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3500 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3501 _item_block_del(it);
3503 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3505 it->rel->relcount++;
3506 it->before = EINA_FALSE;
3507 if (after->group_item) it->group_item = after->group_item;
3508 _item_queue(it->wd, it);
3510 if (it->itc->func.moved)
3511 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3515 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3518 if (!before) return;
3520 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3521 _item_block_del(it);
3522 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3524 it->rel->relcount++;
3525 it->before = EINA_TRUE;
3526 if (before->group_item) it->group_item = before->group_item;
3527 _item_queue(it->wd, it);
3529 if (it->itc->func.moved)
3530 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3534 * Append item to the end of the genlist
3536 * This appends the given item to the end of the list or the end of
3537 * the children if the parent is given.
3539 * @param obj The genlist object
3540 * @param itc The item class for the item
3541 * @param data The item data
3542 * @param parent The parent item, or NULL if none
3543 * @param flags Item flags
3544 * @param func Convenience function called when item selected
3545 * @param func_data Data passed to @p func above.
3546 * @return A handle to the item added or NULL if not possible
3550 EAPI Elm_Genlist_Item *
3551 elm_genlist_item_append(Evas_Object *obj,
3552 const Elm_Genlist_Item_Class *itc,
3554 Elm_Genlist_Item *parent,
3555 Elm_Genlist_Item_Flags flags,
3557 const void *func_data)
3559 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3560 Widget_Data *wd = elm_widget_data_get(obj);
3561 if (!wd) return NULL;
3562 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3564 if (!it) return NULL;
3567 if (flags & ELM_GENLIST_ITEM_GROUP)
3568 wd->group_items = eina_list_append(wd->group_items, it);
3569 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3574 Elm_Genlist_Item *it2 = NULL;
3575 Eina_List *ll = eina_list_last(it->parent->items);
3576 if (ll) it2 = ll->data;
3577 it->parent->items = eina_list_append(it->parent->items, it);
3578 if (!it2) it2 = it->parent;
3580 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3581 EINA_INLIST_GET(it2));
3583 it->rel->relcount++;
3585 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3586 it->group_item = parent;
3587 else if (it->parent->group_item)
3588 it->group_item = it->parent->group_item;
3590 it->before = EINA_FALSE;
3591 _item_queue(wd, it);
3596 * Prepend item at start of the genlist
3598 * This adds an item to the beginning of the list or beginning of the
3599 * children of the parent if given.
3601 * @param obj The genlist object
3602 * @param itc The item class for the item
3603 * @param data The item data
3604 * @param parent The parent item, or NULL if none
3605 * @param flags Item flags
3606 * @param func Convenience function called when item selected
3607 * @param func_data Data passed to @p func above.
3608 * @return A handle to the item added or NULL if not possible
3612 EAPI Elm_Genlist_Item *
3613 elm_genlist_item_prepend(Evas_Object *obj,
3614 const Elm_Genlist_Item_Class *itc,
3616 Elm_Genlist_Item *parent,
3617 Elm_Genlist_Item_Flags flags,
3619 const void *func_data)
3621 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3622 Widget_Data *wd = elm_widget_data_get(obj);
3623 if (!wd) return NULL;
3624 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3626 if (!it) return NULL;
3629 if (flags & ELM_GENLIST_ITEM_GROUP)
3630 wd->group_items = eina_list_prepend(wd->group_items, it);
3631 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3636 Elm_Genlist_Item *it2 = NULL;
3637 Eina_List *ll = it->parent->items;
3638 if (ll) it2 = ll->data;
3639 it->parent->items = eina_list_prepend(it->parent->items, it);
3640 if (!it2) it2 = it->parent;
3642 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3643 EINA_INLIST_GET(it2));
3645 it->rel->relcount++;
3647 it->before = EINA_TRUE;
3648 _item_queue(wd, it);
3653 * Insert item before another in the genlist
3655 * This inserts an item before another in the list. It will be in the
3656 * same tree level or group as the item it is inseted before.
3658 * @param obj The genlist object
3659 * @param itc The item class for the item
3660 * @param data The item data
3661 * @param before The item to insert before
3662 * @param flags Item flags
3663 * @param func Convenience function called when item selected
3664 * @param func_data Data passed to @p func above.
3665 * @return A handle to the item added or NULL if not possible
3669 EAPI Elm_Genlist_Item *
3670 elm_genlist_item_insert_before(Evas_Object *obj,
3671 const Elm_Genlist_Item_Class *itc,
3673 Elm_Genlist_Item *parent,
3674 Elm_Genlist_Item *before,
3675 Elm_Genlist_Item_Flags flags,
3677 const void *func_data)
3679 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3680 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3681 Widget_Data *wd = elm_widget_data_get(obj);
3682 if (!wd) return NULL;
3683 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3685 if (!it) return NULL;
3688 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3691 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3692 EINA_INLIST_GET(before));
3694 it->rel->relcount++;
3695 it->before = EINA_TRUE;
3696 _item_queue(wd, it);
3701 * Insert a new item into the sorted genlist object
3703 * @param obj The genlist object
3704 * @param itc The item class for the item
3705 * @param data The item data
3706 * @param parent The parent item, or NULL if none
3707 * @param flags Item flags
3708 * @param comp The function called for the sort
3709 * @param func Convenience function called when item selected
3710 * @param func_data Data passed to @p func above.
3711 * @return A handle to the item added or NULL if not possible
3715 EAPI Elm_Genlist_Item *
3716 elm_genlist_item_sorted_insert(Evas_Object *obj,
3717 const Elm_Genlist_Item_Class *itc,
3719 Elm_Genlist_Item *parent,
3720 Elm_Genlist_Item_Flags flags,
3721 Eina_Compare_Cb comp,
3723 const void *func_data)
3725 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3726 Widget_Data *wd = elm_widget_data_get(obj);
3727 if (!wd) return NULL;
3728 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3730 if (!it) return NULL;
3732 _elm_genlist_item_compare_cb = comp;
3736 eina_list_sorted_insert(it->parent->items, comp, it);
3738 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3739 _elm_genlist_item_compare);
3740 if (EINA_INLIST_GET(it)->next)
3742 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3743 it->rel->relcount++;
3744 it->before = EINA_TRUE;
3746 else if (EINA_INLIST_GET(it)->prev)
3748 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3749 it->rel->relcount++;
3750 it->before = EINA_FALSE;
3752 _item_queue(wd, it);
3758 * Insert an item after another in the genlst
3760 * This inserts an item after another in the list. It will be in the
3761 * same tree level or group as the item it is inseted after.
3763 * @param obj The genlist object
3764 * @param itc The item class for the item
3765 * @param data The item data
3766 * @param after The item to insert after
3767 * @param flags Item flags
3768 * @param func Convenience function called when item selected
3769 * @param func_data Data passed to @p func above.
3770 * @return A handle to the item added or NULL if not possible
3774 EAPI Elm_Genlist_Item *
3775 elm_genlist_item_insert_after(Evas_Object *obj,
3776 const Elm_Genlist_Item_Class *itc,
3778 Elm_Genlist_Item *parent,
3779 Elm_Genlist_Item *after,
3780 Elm_Genlist_Item_Flags flags,
3782 const void *func_data)
3784 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3785 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3786 Widget_Data *wd = elm_widget_data_get(obj);
3787 if (!wd) return NULL;
3788 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3790 if (!it) return NULL;
3791 /* It make no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
3792 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
3794 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3795 EINA_INLIST_GET(after));
3798 it->parent->items = eina_list_append_relative(it->parent->items, it,
3802 it->rel->relcount++;
3803 it->before = EINA_FALSE;
3804 _item_queue(wd, it);
3811 * This clears all items in the list, leaving it empty.
3813 * @param obj The genlist object
3818 elm_genlist_clear(Evas_Object *obj)
3820 ELM_CHECK_WIDTYPE(obj, widtype);
3821 Widget_Data *wd = elm_widget_data_get(obj);
3823 if (wd->walking > 0)
3825 Elm_Genlist_Item *it;
3827 wd->clear_me = EINA_TRUE;
3828 EINA_INLIST_FOREACH(wd->items, it)
3830 it->delete_me = EINA_TRUE;
3834 evas_event_freeze(evas_object_evas_get(wd->obj));
3837 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3839 if (wd->anchor_item == it)
3841 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3842 if (!wd->anchor_item)
3844 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3846 wd->items = eina_inlist_remove(wd->items, wd->items);
3847 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3848 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3849 elm_widget_item_pre_notify_del(it);
3850 if (it->realized) _item_unrealize(it, EINA_FALSE);
3851 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3852 it->itc->func.del((void *)it->base.data, it->base.widget);
3853 if (it->long_timer) ecore_timer_del(it->long_timer);
3854 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3855 elm_widget_item_del(it);
3857 wd->clear_me = EINA_FALSE;
3858 wd->anchor_item = NULL;
3861 Item_Block *itb = (Item_Block *)(wd->blocks);
3863 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3864 if (itb->items) eina_list_free(itb->items);
3869 ecore_job_del(wd->calc_job);
3870 wd->calc_job = NULL;
3872 if (wd->queue_idle_enterer)
3874 ecore_idle_enterer_del(wd->queue_idle_enterer);
3875 wd->queue_idle_enterer = NULL;
3877 if (wd->must_recalc_idler)
3879 ecore_idler_del(wd->must_recalc_idler);
3880 wd->must_recalc_idler = NULL;
3884 eina_list_free(wd->queue);
3889 eina_list_free(wd->selected);
3890 wd->selected = NULL;
3892 if (wd->reorder_move_animator)
3894 ecore_animator_del(wd->reorder_move_animator);
3895 wd->reorder_move_animator = NULL;
3897 wd->show_item = NULL;
3905 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3906 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3909 evas_event_thaw(evas_object_evas_get(wd->obj));
3910 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3914 * Enable or disable multi-select in the genlist
3916 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3917 * the list. This allows more than 1 item to be selected.
3919 * @param obj The genlist object
3920 * @param multi Multi-select enable/disable
3925 elm_genlist_multi_select_set(Evas_Object *obj,
3928 ELM_CHECK_WIDTYPE(obj, widtype);
3929 Widget_Data *wd = elm_widget_data_get(obj);
3935 * Gets if multi-select in genlist is enable or disable
3937 * @param obj The genlist object
3938 * @return Multi-select enable/disable
3939 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3944 elm_genlist_multi_select_get(const Evas_Object *obj)
3946 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3947 Widget_Data *wd = elm_widget_data_get(obj);
3948 if (!wd) return EINA_FALSE;
3953 * Get the selectd item in the genlist
3955 * This gets the selected item in the list (if multi-select is enabled
3956 * only the first item in the list is selected - which is not very
3957 * useful, so see elm_genlist_selected_items_get() for when
3958 * multi-select is used).
3960 * If no item is selected, NULL is returned.
3962 * @param obj The genlist object
3963 * @return The selected item, or NULL if none.
3967 EAPI Elm_Genlist_Item *
3968 elm_genlist_selected_item_get(const Evas_Object *obj)
3970 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3971 Widget_Data *wd = elm_widget_data_get(obj);
3972 if (!wd) return NULL;
3973 if (wd->selected) return wd->selected->data;
3978 * Get a list of selected items in the genlist
3980 * This returns a list of the selected items. This list pointer is
3981 * only valid so long as no items are selected or unselected (or
3982 * unselected implicitly by deletion). The list contains
3983 * Elm_Genlist_Item pointers.
3985 * @param obj The genlist object
3986 * @return The list of selected items, nor NULL if none are selected.
3990 EAPI const Eina_List *
3991 elm_genlist_selected_items_get(const Evas_Object *obj)
3993 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3994 Widget_Data *wd = elm_widget_data_get(obj);
3995 if (!wd) return NULL;
3996 return wd->selected;
4000 * Get a list of realized items in genlist
4002 * This returns a list of the realized items in the genlist. The list
4003 * contains Elm_Genlist_Item pointers. The list must be freed by the
4004 * caller when done with eina_list_free(). The item pointers in the
4005 * list are only valid so long as those items are not deleted or the
4006 * genlist is not deleted.
4008 * @param obj The genlist object
4009 * @return The list of realized items, nor NULL if none are realized.
4014 elm_genlist_realized_items_get(const Evas_Object *obj)
4016 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4017 Widget_Data *wd = elm_widget_data_get(obj);
4018 Eina_List *list = NULL;
4020 Eina_Bool done = EINA_FALSE;
4021 if (!wd) return NULL;
4022 EINA_INLIST_FOREACH(wd->blocks, itb)
4027 Elm_Genlist_Item *it;
4030 EINA_LIST_FOREACH(itb->items, l, it)
4032 if (it->realized) list = eina_list_append(list, it);
4044 * Get the item that is at the x, y canvas coords
4046 * This returns the item at the given coordinates (which are canvas
4047 * relative not object-relative). If an item is at that coordinate,
4048 * that item handle is returned, and if @p posret is not NULL, the
4049 * integer pointed to is set to a value of -1, 0 or 1, depending if
4050 * the coordinate is on the upper portion of that item (-1), on the
4051 * middle section (0) or on the lower part (1). If NULL is returned as
4052 * an item (no item found there), then posret may indicate -1 or 1
4053 * based if the coordinate is above or below all items respectively in
4056 * @param it The item
4057 * @param x The input x coordinate
4058 * @param y The input y coordinate
4059 * @param posret The position relative to the item returned here
4060 * @return The item at the coordinates or NULL if none
4064 EAPI Elm_Genlist_Item *
4065 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4070 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4071 Widget_Data *wd = elm_widget_data_get(obj);
4072 Evas_Coord ox, oy, ow, oh;
4075 if (!wd) return NULL;
4076 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4078 EINA_INLIST_FOREACH(wd->blocks, itb)
4081 Elm_Genlist_Item *it;
4083 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4084 oy + itb->y - itb->wd->pan_y,
4085 itb->w, itb->h, x, y, 1, 1))
4087 EINA_LIST_FOREACH(itb->items, l, it)
4089 Evas_Coord itx, ity;
4091 itx = ox + itb->x + it->x - itb->wd->pan_x;
4092 ity = oy + itb->y + it->y - itb->wd->pan_y;
4093 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4097 if (y <= (ity + (it->h / 4))) *posret = -1;
4098 else if (y >= (ity + it->h - (it->h / 4)))
4104 lasty = ity + it->h;
4109 if (y > lasty) *posret = 1;
4116 * Get the first item in the genlist
4118 * This returns the first item in the list.
4120 * @param obj The genlist object
4121 * @return The first item, or NULL if none
4125 EAPI Elm_Genlist_Item *
4126 elm_genlist_first_item_get(const Evas_Object *obj)
4128 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4129 Widget_Data *wd = elm_widget_data_get(obj);
4130 if (!wd) return NULL;
4131 if (!wd->items) return NULL;
4132 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4133 while ((it) && (it->delete_me))
4134 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4139 * Get the last item in the genlist
4141 * This returns the last item in the list.
4143 * @return The last item, or NULL if none
4147 EAPI Elm_Genlist_Item *
4148 elm_genlist_last_item_get(const Evas_Object *obj)
4150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4151 Widget_Data *wd = elm_widget_data_get(obj);
4152 if (!wd) return NULL;
4153 if (!wd->items) return NULL;
4154 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4155 while ((it) && (it->delete_me))
4156 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4161 * Get the next item in the genlist
4163 * This returns the item after the item @p it.
4165 * @param it The item
4166 * @return The item after @p it, or NULL if none
4170 EAPI Elm_Genlist_Item *
4171 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4173 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4176 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4177 if ((it) && (!it->delete_me)) break;
4179 return (Elm_Genlist_Item *)it;
4183 * Get the previous item in the genlist
4185 * This returns the item before the item @p it.
4187 * @param it The item
4188 * @return The item before @p it, or NULL if none
4192 EAPI Elm_Genlist_Item *
4193 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4195 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4198 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4199 if ((it) && (!it->delete_me)) break;
4201 return (Elm_Genlist_Item *)it;
4205 * Get the genlist object from an item
4207 * This returns the genlist object itself that an item belongs to.
4209 * @param it The item
4210 * @return The genlist object
4215 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4217 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4218 return it->base.widget;
4222 * Get the parent item of the given item
4224 * This returns the parent item of the item @p it given.
4226 * @param it The item
4227 * @return The parent of the item or NULL if none
4231 EAPI Elm_Genlist_Item *
4232 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4234 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4239 * Clear all sub-items (children) of the given item
4241 * This clears all items that are children (or their descendants) of the
4244 * @param it The item
4249 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4251 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4252 Eina_List *tl = NULL, *l;
4253 Elm_Genlist_Item *it2;
4255 EINA_LIST_FOREACH(it->items, l, it2)
4256 tl = eina_list_append(tl, it2);
4257 EINA_LIST_FREE(tl, it2)
4258 elm_genlist_item_del(it2);
4262 * Set the selected state of an item
4264 * This sets the selected state (1 selected, 0 not selected) of the given
4267 * @param it The item
4268 * @param selected The selected state
4273 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4276 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4277 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4279 if ((it->delete_me) || (it->disabled)) return;
4280 selected = !!selected;
4281 if (it->selected == selected) return;
4287 while (wd->selected)
4289 _item_unhighlight(wd->selected->data);
4290 _item_unselect(wd->selected->data);
4293 _item_highlight(it);
4298 _item_unhighlight(it);
4304 * Get the selected state of an item
4306 * This gets the selected state of an item (1 selected, 0 not selected).
4308 * @param it The item
4309 * @return The selected state
4314 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4316 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4317 return it->selected;
4321 * Sets the expanded state of an item (if it's a parent)
4323 * This expands or contracts a parent item (thus showing or hiding the
4326 * @param it The item
4327 * @param expanded The expanded state (1 expanded, 0 not expanded).
4332 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4336 if (it->expanded == expanded) return;
4337 it->expanded = expanded;
4338 it->wd->expanded_item = it;
4342 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4343 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4344 it->wd->auto_scroll_enabled = EINA_TRUE;
4349 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4350 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4351 it->wd->auto_scroll_enabled = EINA_FALSE;
4356 * Get the expanded state of an item
4358 * This gets the expanded state of an item
4360 * @param it The item
4361 * @return Thre expanded state
4366 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4368 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4369 return it->expanded;
4373 * Get the depth of expanded item
4375 * @param it The genlist item object
4376 * @return The depth of expanded item
4381 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4383 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4384 return it->expanded_depth;
4388 * Sets the disabled state of an item.
4390 * A disabled item cannot be selected or unselected. It will also
4391 * change appearance to appear disabled. This sets the disabled state
4392 * (1 disabled, 0 not disabled).
4394 * @param it The item
4395 * @param disabled The disabled state
4400 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4403 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4406 if (it->disabled == disabled) return;
4407 if (it->delete_me) return;
4408 it->disabled = !!disabled;
4410 elm_genlist_item_selected_set(it, EINA_FALSE);
4414 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4416 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4417 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4418 elm_widget_disabled_set(obj, disabled);
4423 * Get the disabled state of an item
4425 * This gets the disabled state of the given item.
4427 * @param it The item
4428 * @return The disabled state
4433 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4435 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4436 if (it->delete_me) return EINA_FALSE;
4437 return it->disabled;
4441 * Sets the display only state of an item.
4443 * A display only item cannot be selected or unselected. It is for
4444 * display only and not selecting or otherwise clicking, dragging
4445 * etc. by the user, thus finger size rules will not be applied to
4448 * @param it The item
4449 * @param display_only The display only state
4454 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4455 Eina_Bool display_only)
4457 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4458 if (it->display_only == display_only) return;
4459 if (it->delete_me) return;
4460 it->display_only = display_only;
4461 it->mincalcd = EINA_FALSE;
4462 it->updateme = EINA_TRUE;
4463 if (it->block) it->block->updateme = EINA_TRUE;
4464 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4465 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4469 * Get the display only state of an item
4471 * This gets the display only state of the given item.
4473 * @param it The item
4474 * @return The display only state
4479 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4481 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4482 if (it->delete_me) return EINA_FALSE;
4483 return it->display_only;
4487 * Show the given item
4489 * This causes genlist to jump to the given item @p it and show it (by
4490 * scrolling), if it is not fully visible.
4492 * @param it The item
4497 elm_genlist_item_show(Elm_Genlist_Item *it)
4499 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4500 Evas_Coord gith = 0;
4501 if (it->delete_me) return;
4502 if ((it->queued) || (!it->mincalcd))
4504 it->wd->show_item = it;
4505 it->wd->bring_in = EINA_TRUE;
4506 it->showme = EINA_TRUE;
4509 if (it->wd->show_item)
4511 it->wd->show_item->showme = EINA_FALSE;
4512 it->wd->show_item = NULL;
4514 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4515 gith = it->group_item->h;
4516 elm_smart_scroller_child_region_show(it->wd->scr,
4517 it->x + it->block->x,
4518 it->y + it->block->y - gith,
4519 it->block->w, it->h);
4523 * Bring in the given item
4525 * This causes genlist to jump to the given item @p it and show it (by
4526 * scrolling), if it is not fully visible. This may use animation to
4527 * do so and take a period of time
4529 * @param it The item
4534 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4536 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4537 Evas_Coord gith = 0;
4538 if (it->delete_me) return;
4539 if ((it->queued) || (!it->mincalcd))
4541 it->wd->show_item = it;
4542 it->wd->bring_in = EINA_TRUE;
4543 it->showme = EINA_TRUE;
4546 if (it->wd->show_item)
4548 it->wd->show_item->showme = EINA_FALSE;
4549 it->wd->show_item = NULL;
4551 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4552 gith = it->group_item->h;
4553 elm_smart_scroller_region_bring_in(it->wd->scr,
4554 it->x + it->block->x,
4555 it->y + it->block->y - gith,
4556 it->block->w, it->h);
4560 * Show the given item at the top
4562 * This causes genlist to jump to the given item @p it and show it (by
4563 * scrolling), if it is not fully visible.
4565 * @param it The item
4570 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4572 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4574 Evas_Coord gith = 0;
4576 if (it->delete_me) return;
4577 if ((it->queued) || (!it->mincalcd))
4579 it->wd->show_item = it;
4580 it->wd->bring_in = EINA_TRUE;
4581 it->showme = EINA_TRUE;
4584 if (it->wd->show_item)
4586 it->wd->show_item->showme = EINA_FALSE;
4587 it->wd->show_item = NULL;
4589 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4590 if (it->group_item) gith = it->group_item->h;
4591 elm_smart_scroller_child_region_show(it->wd->scr,
4592 it->x + it->block->x,
4593 it->y + it->block->y - gith,
4598 * Bring in the given item at the top
4600 * This causes genlist to jump to the given item @p it and show it (by
4601 * scrolling), if it is not fully visible. This may use animation to
4602 * do so and take a period of time
4604 * @param it The item
4609 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4613 Evas_Coord gith = 0;
4615 if (it->delete_me) return;
4616 if ((it->queued) || (!it->mincalcd))
4618 it->wd->show_item = it;
4619 it->wd->bring_in = EINA_TRUE;
4620 it->showme = EINA_TRUE;
4623 if (it->wd->show_item)
4625 it->wd->show_item->showme = EINA_FALSE;
4626 it->wd->show_item = NULL;
4628 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4629 if (it->group_item) gith = it->group_item->h;
4630 elm_smart_scroller_region_bring_in(it->wd->scr,
4631 it->x + it->block->x,
4632 it->y + it->block->y - gith,
4637 * Show the given item at the middle
4639 * This causes genlist to jump to the given item @p it and show it (by
4640 * scrolling), if it is not fully visible.
4642 * @param it The item
4647 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4649 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4652 if (it->delete_me) return;
4653 if ((it->queued) || (!it->mincalcd))
4655 it->wd->show_item = it;
4656 it->wd->bring_in = EINA_TRUE;
4657 it->showme = EINA_TRUE;
4660 if (it->wd->show_item)
4662 it->wd->show_item->showme = EINA_FALSE;
4663 it->wd->show_item = NULL;
4665 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4666 elm_smart_scroller_child_region_show(it->wd->scr,
4667 it->x + it->block->x,
4668 it->y + it->block->y - oh / 2 +
4669 it->h / 2, it->block->w, oh);
4673 * Bring in the given item at the middle
4675 * This causes genlist to jump to the given item @p it and show it (by
4676 * scrolling), if it is not fully visible. This may use animation to
4677 * do so and take a period of time
4679 * @param it The item
4684 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4686 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4689 if (it->delete_me) return;
4690 if ((it->queued) || (!it->mincalcd))
4692 it->wd->show_item = it;
4693 it->wd->bring_in = EINA_TRUE;
4694 it->showme = EINA_TRUE;
4697 if (it->wd->show_item)
4699 it->wd->show_item->showme = EINA_FALSE;
4700 it->wd->show_item = NULL;
4702 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4703 elm_smart_scroller_region_bring_in(it->wd->scr,
4704 it->x + it->block->x,
4705 it->y + it->block->y - oh / 2 + it->h / 2,
4710 * Delete a given item
4712 * This deletes the item from genlist and calls the genlist item del
4713 * class callback defined in the item class, if it is set. This clears all
4714 * subitems if it is a tree.
4716 * @param it The item
4721 elm_genlist_item_del(Elm_Genlist_Item *it)
4723 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4724 if ((it->relcount > 0) || (it->walking > 0))
4726 elm_widget_item_pre_notify_del(it);
4727 elm_genlist_item_subitems_clear(it);
4728 it->delete_me = EINA_TRUE;
4729 if (it->wd->show_item == it) it->wd->show_item = NULL;
4731 it->wd->selected = eina_list_remove(it->wd->selected,
4735 if (it->realized) _item_unrealize(it, EINA_FALSE);
4736 it->block->changed = EINA_TRUE;
4737 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4738 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4740 if (it->itc->func.del)
4741 it->itc->func.del((void *)it->base.data, it->base.widget);
4748 * Set the data item from the genlist item
4750 * This set the data value passed on the elm_genlist_item_append() and
4751 * related item addition calls. This function will also call
4752 * elm_genlist_item_update() so the item will be updated to reflect the
4755 * @param it The item
4756 * @param data The new data pointer to set
4761 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4764 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4765 elm_widget_item_data_set(it, data);
4766 elm_genlist_item_update(it);
4770 * Get the data item from the genlist item
4772 * This returns the data value passed on the elm_genlist_item_append()
4773 * and related item addition calls and elm_genlist_item_data_set().
4775 * @param it The item
4776 * @return The data pointer provided when created
4781 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4783 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4784 return elm_widget_item_data_get(it);
4788 * Tells genlist to "orphan" icons fetchs by the item class
4790 * This instructs genlist to release references to icons in the item,
4791 * meaning that they will no longer be managed by genlist and are
4792 * floating "orphans" that can be re-used elsewhere if the user wants
4795 * @param it The item
4800 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4803 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4804 EINA_LIST_FREE(it->icon_objs, icon)
4806 elm_widget_sub_object_del(it->base.widget, icon);
4807 evas_object_smart_member_del(icon);
4808 evas_object_hide(icon);
4813 * Get the real evas object of the genlist item
4815 * This returns the actual evas object used for the specified genlist
4816 * item. This may be NULL as it may not be created, and may be deleted
4817 * at any time by genlist. Do not modify this object (move, resize,
4818 * show, hide etc.) as genlist is controlling it. This function is for
4819 * querying, emitting custom signals or hooking lower level callbacks
4820 * for events. Do not delete this object under any circumstances.
4822 * @param it The item
4823 * @return The object pointer
4827 EAPI const Evas_Object *
4828 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4830 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4831 return it->base.view;
4835 * Update the contents of an item
4837 * This updates an item by calling all the item class functions again
4838 * to get the icons, labels and states. Use this when the original
4839 * item data has changed and the changes are desired to be reflected.
4841 * @param it The item
4846 elm_genlist_item_update(Elm_Genlist_Item *it)
4848 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4849 if (!it->block) return;
4850 if (it->delete_me) return;
4851 it->mincalcd = EINA_FALSE;
4852 it->updateme = EINA_TRUE;
4853 it->block->updateme = EINA_TRUE;
4854 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4855 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4859 * Update the item class of an item
4861 * @param it The item
4862 * @parem itc The item class for the item
4867 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4868 const Elm_Genlist_Item_Class *itc)
4870 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4871 if (!it->block) return;
4872 EINA_SAFETY_ON_NULL_RETURN(itc);
4873 if (it->delete_me) return;
4875 it->nocache = EINA_TRUE;
4876 elm_genlist_item_update(it);
4879 static Evas_Object *
4880 _elm_genlist_item_label_create(void *data,
4882 void *item __UNUSED__)
4884 Evas_Object *label = elm_label_add(obj);
4887 elm_object_style_set(label, "tooltip");
4888 elm_label_label_set(label, data);
4893 _elm_genlist_item_label_del_cb(void *data,
4894 Evas_Object *obj __UNUSED__,
4895 void *event_info __UNUSED__)
4897 eina_stringshare_del(data);
4901 * Set the text to be shown in the genlist item.
4903 * @param item Target item
4904 * @param text The text to set in the content
4906 * Setup the text as tooltip to object. The item can have only one
4907 * tooltip, so any previous tooltip data is removed.
4912 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4915 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4916 text = eina_stringshare_add(text);
4917 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4919 _elm_genlist_item_label_del_cb);
4923 * Set the content to be shown in the tooltip item
4925 * Setup the tooltip to item. The item can have only one tooltip, so
4926 * any previous tooltip data is removed. @p func(with @p data) will be
4927 * called every time that need to show the tooltip and it should return a
4928 * valid Evas_Object. This object is then managed fully by tooltip
4929 * system and is deleted when the tooltip is gone.
4931 * @param item the genlist item being attached by a tooltip.
4932 * @param func the function used to create the tooltip contents.
4933 * @param data what to provide to @a func as callback data/context.
4934 * @param del_cb called when data is not needed anymore, either when
4935 * another callback replaces @func, the tooltip is unset with
4936 * elm_genlist_item_tooltip_unset() or the owner @a item
4937 * dies. This callback receives as the first parameter the
4938 * given @a data, and @c event_info is the item.
4943 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4944 Elm_Tooltip_Item_Content_Cb func,
4946 Evas_Smart_Cb del_cb)
4948 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4950 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4953 if (item->tooltip.del_cb)
4954 item->tooltip.del_cb((void *)item->tooltip.data,
4955 item->base.widget, item);
4957 item->tooltip.content_cb = func;
4958 item->tooltip.data = data;
4959 item->tooltip.del_cb = del_cb;
4961 if (item->base.view)
4963 elm_widget_item_tooltip_content_cb_set(item,
4964 item->tooltip.content_cb,
4965 item->tooltip.data, NULL);
4966 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4972 if (del_cb) del_cb((void *)data, NULL, NULL);
4976 * Unset tooltip from item
4978 * @param item genlist item to remove previously set tooltip.
4980 * Remove tooltip from item. The callback provided as del_cb to
4981 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4982 * it is not used anymore.
4984 * @see elm_genlist_item_tooltip_content_cb_set()
4989 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4991 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4992 if ((item->base.view) && (item->tooltip.content_cb))
4993 elm_widget_item_tooltip_unset(item);
4995 if (item->tooltip.del_cb)
4996 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4997 item->tooltip.del_cb = NULL;
4998 item->tooltip.content_cb = NULL;
4999 item->tooltip.data = NULL;
5000 if (item->tooltip.style)
5001 elm_genlist_item_tooltip_style_set(item, NULL);
5005 * Sets a different style for this item tooltip.
5007 * @note before you set a style you should define a tooltip with
5008 * elm_genlist_item_tooltip_content_cb_set() or
5009 * elm_genlist_item_tooltip_text_set()
5011 * @param item genlist item with tooltip already set.
5012 * @param style the theme style to use (default, transparent, ...)
5017 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
5020 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5021 eina_stringshare_replace(&item->tooltip.style, style);
5022 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
5026 * Get the style for this item tooltip.
5028 * @param item genlist item with tooltip already set.
5029 * @return style the theme style in use, defaults to "default". If the
5030 * object does not have a tooltip set, then NULL is returned.
5035 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
5037 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5038 return item->tooltip.style;
5042 * Set the cursor to be shown when mouse is over the genlist item
5044 * @param item Target item
5045 * @param cursor the cursor name to be used.
5047 * @see elm_object_cursor_set()
5051 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
5054 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5055 eina_stringshare_replace(&item->mouse_cursor, cursor);
5056 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
5060 * Get the cursor to be shown when mouse is over the genlist item
5062 * @param item genlist item with cursor already set.
5063 * @return the cursor name.
5068 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
5070 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5071 return elm_widget_item_cursor_get(item);
5075 * Unset the cursor to be shown when mouse is over the genlist item
5077 * @param item Target item
5079 * @see elm_object_cursor_unset()
5083 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
5085 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5086 if (!item->mouse_cursor)
5089 if (item->base.view)
5090 elm_widget_item_cursor_unset(item);
5092 eina_stringshare_del(item->mouse_cursor);
5093 item->mouse_cursor = NULL;
5097 * Sets a different style for this item cursor.
5099 * @note before you set a style you should define a cursor with
5100 * elm_genlist_item_cursor_set()
5102 * @param item genlist item with cursor already set.
5103 * @param style the theme style to use (default, transparent, ...)
5108 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5111 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5112 elm_widget_item_cursor_style_set(item, style);
5116 * Get the style for this item cursor.
5118 * @param item genlist item with cursor already set.
5119 * @return style the theme style in use, defaults to "default". If the
5120 * object does not have a cursor set, then NULL is returned.
5125 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5127 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5128 return elm_widget_item_cursor_style_get(item);
5132 * Set if the cursor set should be searched on the theme or should use
5133 * the provided by the engine, only.
5135 * @note before you set if should look on theme you should define a
5136 * cursor with elm_object_cursor_set(). By default it will only look
5137 * for cursors provided by the engine.
5139 * @param item widget item with cursor already set.
5140 * @param engine_only boolean to define it cursors should be looked
5141 * only between the provided by the engine or searched on widget's
5147 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5148 Eina_Bool engine_only)
5150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5151 elm_widget_item_cursor_engine_only_set(item, engine_only);
5155 * Get the cursor engine only usage for this item cursor.
5157 * @param item widget item with cursor already set.
5158 * @return engine_only boolean to define it cursors should be looked
5159 * only between the provided by the engine or searched on widget's
5160 * theme as well. If the object does not have a cursor set, then
5161 * EINA_FALSE is returned.
5166 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5168 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5169 return elm_widget_item_cursor_engine_only_get(item);
5173 * This sets the horizontal stretching mode
5175 * This sets the mode used for sizing items horizontally. Valid modes
5176 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5177 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5178 * the scroller will scroll horizontally. Otherwise items are expanded
5179 * to fill the width of the viewport of the scroller. If it is
5180 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5181 * limited to that size.
5183 * @param obj The genlist object
5184 * @param mode The mode to use
5189 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5192 ELM_CHECK_WIDTYPE(obj, widtype);
5193 Widget_Data *wd = elm_widget_data_get(obj);
5195 if (wd->mode == mode) return;
5201 * Gets the horizontal stretching mode
5203 * @param obj The genlist object
5204 * @return The mode to use
5205 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5210 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5212 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5213 Widget_Data *wd = elm_widget_data_get(obj);
5214 if (!wd) return ELM_LIST_LAST;
5219 * Set the always select mode.
5221 * Items will only call their selection func and callback when first
5222 * becoming selected. Any further clicks will do nothing, unless you
5223 * enable always select with elm_genlist_always_select_mode_set().
5224 * This means even if selected, every click will make the selected
5225 * callbacks be called.
5227 * @param obj The genlist object
5228 * @param always_select The always select mode
5229 * (EINA_TRUE = on, EINA_FALSE = off)
5234 elm_genlist_always_select_mode_set(Evas_Object *obj,
5235 Eina_Bool always_select)
5237 ELM_CHECK_WIDTYPE(obj, widtype);
5238 Widget_Data *wd = elm_widget_data_get(obj);
5240 wd->always_select = always_select;
5244 * Get the always select mode.
5246 * @param obj The genlist object
5247 * @return The always select mode
5248 * (EINA_TRUE = on, EINA_FALSE = off)
5253 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5255 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5256 Widget_Data *wd = elm_widget_data_get(obj);
5257 if (!wd) return EINA_FALSE;
5258 return wd->always_select;
5262 * Set no select mode
5264 * This will turn off the ability to select items entirely and they
5265 * will neither appear selected nor call selected callback functions.
5267 * @param obj The genlist object
5268 * @param no_select The no select mode
5269 * (EINA_TRUE = on, EINA_FALSE = off)
5274 elm_genlist_no_select_mode_set(Evas_Object *obj,
5275 Eina_Bool no_select)
5277 ELM_CHECK_WIDTYPE(obj, widtype);
5278 Widget_Data *wd = elm_widget_data_get(obj);
5280 wd->no_select = no_select;
5284 * Gets no select mode
5286 * @param obj The genlist object
5287 * @return The no select mode
5288 * (EINA_TRUE = on, EINA_FALSE = off)
5293 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5295 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5296 Widget_Data *wd = elm_widget_data_get(obj);
5297 if (!wd) return EINA_FALSE;
5298 return wd->no_select;
5304 * This will enable the compress mode where items are "compressed"
5305 * horizontally to fit the genlist scrollable viewport width. This is
5306 * special for genlist. Do not rely on
5307 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5308 * work as genlist needs to handle it specially.
5310 * @param obj The genlist object
5311 * @param compress The compress mode
5312 * (EINA_TRUE = on, EINA_FALSE = off)
5317 elm_genlist_compress_mode_set(Evas_Object *obj,
5320 ELM_CHECK_WIDTYPE(obj, widtype);
5321 Widget_Data *wd = elm_widget_data_get(obj);
5323 wd->compress = compress;
5324 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5328 * Get the compress mode
5330 * @param obj The genlist object
5331 * @return The compress mode
5332 * (EINA_TRUE = on, EINA_FALSE = off)
5337 elm_genlist_compress_mode_get(const Evas_Object *obj)
5339 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5340 Widget_Data *wd = elm_widget_data_get(obj);
5341 if (!wd) return EINA_FALSE;
5342 return wd->compress;
5346 * Set height-for-width mode
5348 * With height-for-width mode the item width will be fixed (restricted
5349 * to a minimum of) to the list width when calculating its size in
5350 * order to allow the height to be calculated based on it. This allows,
5351 * for instance, text block to wrap lines if the Edje part is
5352 * configured with "text.min: 0 1".
5354 * @note This mode will make list resize slower as it will have to
5355 * recalculate every item height again whenever the list width
5358 * @note When height-for-width mode is enabled, it also enables
5359 * compress mode (see elm_genlist_compress_mode_set()) and
5360 * disables homogeneous (see elm_genlist_homogeneous_set()).
5362 * @param obj The genlist object
5363 * @param setting The height-for-width mode (EINA_TRUE = on,
5369 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5370 Eina_Bool height_for_width)
5372 ELM_CHECK_WIDTYPE(obj, widtype);
5373 Widget_Data *wd = elm_widget_data_get(obj);
5375 wd->height_for_width = !!height_for_width;
5376 if (wd->height_for_width)
5378 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5379 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5384 * Get the height-for-width mode
5386 * @param obj The genlist object
5387 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5393 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5395 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5396 Widget_Data *wd = elm_widget_data_get(obj);
5397 if (!wd) return EINA_FALSE;
5398 return wd->height_for_width;
5404 * This will enable or disable the scroller bounce mode for the
5405 * genlist. See elm_scroller_bounce_set() for details
5407 * @param obj The genlist object
5408 * @param h_bounce Allow bounce horizontally
5409 * @param v_bounce Allow bounce vertically
5414 elm_genlist_bounce_set(Evas_Object *obj,
5418 ELM_CHECK_WIDTYPE(obj, widtype);
5419 Widget_Data *wd = elm_widget_data_get(obj);
5421 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5425 * Get the bounce mode
5427 * @param obj The genlist object
5428 * @param h_bounce Allow bounce horizontally
5429 * @param v_bounce Allow bounce vertically
5434 elm_genlist_bounce_get(const Evas_Object *obj,
5435 Eina_Bool *h_bounce,
5436 Eina_Bool *v_bounce)
5438 ELM_CHECK_WIDTYPE(obj, widtype);
5439 Widget_Data *wd = elm_widget_data_get(obj);
5441 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5445 * Set homogenous mode
5447 * This will enable the homogeneous mode where items are of the same
5448 * height and width so that genlist may do the lazy-loading at its
5449 * maximum. This implies 'compressed' mode.
5451 * @param obj The genlist object
5452 * @param homogeneous Assume the items within the genlist are of the
5453 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5458 elm_genlist_homogeneous_set(Evas_Object *obj,
5459 Eina_Bool homogeneous)
5461 ELM_CHECK_WIDTYPE(obj, widtype);
5462 Widget_Data *wd = elm_widget_data_get(obj);
5464 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5465 wd->homogeneous = homogeneous;
5469 * Get the homogenous mode
5471 * @param obj The genlist object
5472 * @return Assume the items within the genlist are of the same height
5473 * and width (EINA_TRUE = on, EINA_FALSE = off)
5478 elm_genlist_homogeneous_get(const Evas_Object *obj)
5480 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5481 Widget_Data *wd = elm_widget_data_get(obj);
5482 if (!wd) return EINA_FALSE;
5483 return wd->homogeneous;
5487 * Set the maximum number of items within an item block
5489 * This will configure the block count to tune to the target with
5490 * particular performance matrix.
5492 * @param obj The genlist object
5493 * @param n Maximum number of items within an item block
5498 elm_genlist_block_count_set(Evas_Object *obj,
5501 ELM_CHECK_WIDTYPE(obj, widtype);
5502 Widget_Data *wd = elm_widget_data_get(obj);
5504 wd->max_items_per_block = n;
5505 wd->item_cache_max = wd->max_items_per_block * 2;
5506 _item_cache_clean(wd);
5510 * Get the maximum number of items within an item block
5512 * @param obj The genlist object
5513 * @return Maximum number of items within an item block
5518 elm_genlist_block_count_get(const Evas_Object *obj)
5520 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5521 Widget_Data *wd = elm_widget_data_get(obj);
5523 return wd->max_items_per_block;
5527 * Set the timeout in seconds for the longpress event
5529 * @param obj The genlist object
5530 * @param timeout timeout in seconds
5535 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5538 ELM_CHECK_WIDTYPE(obj, widtype);
5539 Widget_Data *wd = elm_widget_data_get(obj);
5541 wd->longpress_timeout = timeout;
5545 * Get the timeout in seconds for the longpress event
5547 * @param obj The genlist object
5548 * @return timeout in seconds
5553 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5555 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5556 Widget_Data *wd = elm_widget_data_get(obj);
5558 return wd->longpress_timeout;
5562 * Set the scrollbar policy
5564 * This sets the scrollbar visibility policy for the given genlist
5565 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5566 * made visible if it is needed, and otherwise kept hidden.
5567 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5568 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5569 * respectively for the horizontal and vertical scrollbars.
5571 * @param obj The genlist object
5572 * @param policy_h Horizontal scrollbar policy
5573 * @param policy_v Vertical scrollbar policy
5578 elm_genlist_scroller_policy_set(Evas_Object *obj,
5579 Elm_Scroller_Policy policy_h,
5580 Elm_Scroller_Policy policy_v)
5582 ELM_CHECK_WIDTYPE(obj, widtype);
5583 Widget_Data *wd = elm_widget_data_get(obj);
5585 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5586 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5589 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5593 * Get the scrollbar policy
5595 * @param obj The genlist object
5596 * @param policy_h Horizontal scrollbar policy
5597 * @param policy_v Vertical scrollbar policy
5602 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5603 Elm_Scroller_Policy *policy_h,
5604 Elm_Scroller_Policy *policy_v)
5606 ELM_CHECK_WIDTYPE(obj, widtype);
5607 Widget_Data *wd = elm_widget_data_get(obj);
5608 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5609 if ((!wd) || (!wd->scr)) return;
5610 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5611 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5612 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5616 * Update the contents of all realized items
5618 * This updates all realized items by calling all the item class functions again
5619 * to get the icons, labels and states. Use this when the original
5620 * item data has changed and the changes are desired to be reflected.
5622 * @param it The item
5627 elm_genlist_realized_items_update(Evas_Object *obj)
5629 ELM_CHECK_WIDTYPE(obj, widtype);
5631 Eina_List *list, *l;
5632 Elm_Genlist_Item *it;
5634 list = elm_genlist_realized_items_get(obj);
5635 EINA_LIST_FOREACH(list, l, it)
5636 elm_genlist_item_update(it);
5640 * Set genlist item mode
5642 * @param item The genlist item
5643 * @param mode Mode name
5644 * @param mode_set Boolean to define set or unset mode.
5649 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5650 const char *mode_type,
5653 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5654 Widget_Data *wd = it->wd;
5656 Elm_Genlist_Item *it2;
5659 if (!mode_type) return;
5660 if ((it->delete_me) || (it->disabled)) return;
5662 if ((wd->mode_item == it) &&
5663 (!strcmp(mode_type, wd->mode_type)) &&
5666 if (!it->itc->mode_item_style) return;
5670 EINA_LIST_FOREACH(wd->selected, l, it2)
5672 elm_genlist_item_selected_set(it2, EINA_FALSE);
5676 it2 = elm_genlist_selected_item_get(wd->obj);
5677 if ((it2) && (it2->realized))
5678 elm_genlist_item_selected_set(it2, EINA_FALSE);
5681 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5683 ((it == wd->mode_item) && (!mode_set)))
5684 _item_mode_unset(wd);
5686 eina_stringshare_replace(&wd->mode_type, mode_type);
5687 if (mode_set) _item_mode_set(it);
5691 * Get active genlist mode type
5693 * @param obj The genlist object
5698 elm_genlist_mode_get(const Evas_Object *obj)
5700 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5701 Widget_Data *wd = elm_widget_data_get(obj);
5702 if (!wd) return NULL;
5703 return wd->mode_type;
5707 * Get active genlist mode item
5709 * @param obj The genlist object
5713 EAPI const Elm_Genlist_Item *
5714 elm_genlist_mode_item_get(const Evas_Object *obj)
5716 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5717 Widget_Data *wd = elm_widget_data_get(obj);
5718 if (!wd) return NULL;
5719 return wd->mode_item;
5725 * @param obj The genlist object
5726 * @param reorder_mode The reorder mode
5727 * (EINA_TRUE = on, EINA_FALSE = off)
5732 elm_genlist_reorder_mode_set(Evas_Object *obj,
5733 Eina_Bool reorder_mode)
5735 ELM_CHECK_WIDTYPE(obj, widtype);
5736 Widget_Data *wd = elm_widget_data_get(obj);
5738 wd->reorder_mode = reorder_mode;
5742 * Get the reorder mode
5744 * @param obj The genlist object
5745 * @return The reorder mode
5746 * (EINA_TRUE = on, EINA_FALSE = off)
5751 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5753 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5754 Widget_Data *wd = elm_widget_data_get(obj);
5755 if (!wd) return EINA_FALSE;
5756 return wd->reorder_mode;