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;
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;
243 } history[SWIPE_MOVES];
245 int item_cache_count;
251 int group_item_width;
252 int group_item_height;
253 int max_items_per_block;
254 double longpress_timeout;
265 Evas_Coord x, y, w, h, minw, minh;
266 Eina_Bool want_unrealize : 1;
267 Eina_Bool realized : 1;
268 Eina_Bool changed : 1;
269 Eina_Bool updateme : 1;
270 Eina_Bool showme : 1;
271 Eina_Bool must_recalc : 1;
274 struct _Elm_Genlist_Item
276 Elm_Widget_Item base;
281 Evas_Coord x, y, w, h, minw, minh;
282 const Elm_Genlist_Item_Class *itc;
283 Elm_Genlist_Item *parent;
284 Elm_Genlist_Item *group_item;
285 Elm_Genlist_Item_Flags flags;
293 Eina_List *labels, *icons, *states, *icon_objs;
294 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
295 Ecore_Timer *long_timer;
296 Ecore_Timer *swipe_timer;
298 Evas_Coord scrl_x, scrl_y, old_scrl_x, old_scrl_y;
300 Elm_Genlist_Item *rel;
301 Evas_Object *mode_view;
306 Elm_Tooltip_Item_Content_Cb content_cb;
307 Evas_Smart_Cb del_cb;
311 const char *mouse_cursor;
318 Eina_Bool before : 1;
320 Eina_Bool want_unrealize : 1;
321 Eina_Bool want_realize : 1;
322 Eina_Bool realized : 1;
323 Eina_Bool selected : 1;
324 Eina_Bool highlighted : 1;
325 Eina_Bool expanded : 1;
326 Eina_Bool disabled : 1;
327 Eina_Bool display_only : 1;
328 Eina_Bool mincalcd : 1;
329 Eina_Bool queued : 1;
330 Eina_Bool showme : 1;
331 Eina_Bool delete_me : 1;
333 Eina_Bool dragging : 1;
334 Eina_Bool updateme : 1;
335 Eina_Bool nocache : 1;
336 Eina_Bool stacking_even : 1;
337 Eina_Bool nostacking : 1;
338 Eina_Bool move_effect_enabled : 1;
345 Evas_Object *base_view, *spacer;
347 const char *item_style; // it->itc->item_style
348 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
349 Eina_Bool compress : 1; // it->wd->compress
351 Eina_Bool selected : 1; // it->selected
352 Eina_Bool disabled : 1; // it->disabled
353 Eina_Bool expanded : 1; // it->expanded
356 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
357 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
361 Evas_Object_Smart_Clipped_Data __clipped_data;
363 Ecore_Job *resize_job;
366 static const char *widtype = NULL;
367 static void _item_cache_zero(Widget_Data *wd);
368 static void _del_hook(Evas_Object *obj);
369 static void _mirrored_set(Evas_Object *obj,
371 static void _theme_hook(Evas_Object *obj);
372 static void _show_region_hook(void *data,
374 static void _sizing_eval(Evas_Object *obj);
375 static void _item_unrealize(Elm_Genlist_Item *it,
377 static void _item_block_unrealize(Item_Block *itb);
378 static void _calc_job(void *data);
379 static void _on_focus_hook(void *data,
381 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
382 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
383 static Eina_Bool _item_single_select_up(Widget_Data *wd);
384 static Eina_Bool _item_single_select_down(Widget_Data *wd);
385 static Eina_Bool _event_hook(Evas_Object *obj,
387 Evas_Callback_Type type,
389 static void _signal_emit_hook(Evas_Object *obj,
390 const char *emission,
392 static Eina_Bool _deselect_all_items(Widget_Data *wd);
393 static void _pan_calculate(Evas_Object *obj);
394 static void _item_position(Elm_Genlist_Item *it,
398 static void _mode_item_realize(Elm_Genlist_Item *it);
399 static void _mode_item_unrealize(Elm_Genlist_Item *it);
400 static void _item_mode_set(Elm_Genlist_Item *it);
401 static void _item_mode_unset(Widget_Data *wd);
402 static void _group_items_recalc(void *data);
403 static void _item_move_after(Elm_Genlist_Item *it,
404 Elm_Genlist_Item *after);
405 static void _item_move_before(Elm_Genlist_Item *it,
406 Elm_Genlist_Item *before);
408 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
410 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
411 static const char SIG_SELECTED[] = "selected";
412 static const char SIG_UNSELECTED[] = "unselected";
413 static const char SIG_EXPANDED[] = "expanded";
414 static const char SIG_CONTRACTED[] = "contracted";
415 static const char SIG_EXPAND_REQUEST[] = "expand,request";
416 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
417 static const char SIG_REALIZED[] = "realized";
418 static const char SIG_UNREALIZED[] = "unrealized";
419 static const char SIG_DRAG_START_UP[] = "drag,start,up";
420 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
421 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
422 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
423 static const char SIG_DRAG_STOP[] = "drag,stop";
424 static const char SIG_DRAG[] = "drag";
425 static const char SIG_LONGPRESSED[] = "longpressed";
426 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
427 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
428 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
429 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
430 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
431 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
432 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
433 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
434 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
435 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
436 static const char SIG_SWIPE[] = "swipe";
438 static const Evas_Smart_Cb_Description _signals[] = {
439 {SIG_CLICKED_DOUBLE, ""},
441 {SIG_UNSELECTED, ""},
443 {SIG_CONTRACTED, ""},
444 {SIG_EXPAND_REQUEST, ""},
445 {SIG_CONTRACT_REQUEST, ""},
447 {SIG_UNREALIZED, ""},
448 {SIG_DRAG_START_UP, ""},
449 {SIG_DRAG_START_DOWN, ""},
450 {SIG_DRAG_START_LEFT, ""},
451 {SIG_DRAG_START_RIGHT, ""},
454 {SIG_LONGPRESSED, ""},
455 {SIG_SCROLL_EDGE_TOP, ""},
456 {SIG_SCROLL_EDGE_BOTTOM, ""},
457 {SIG_SCROLL_EDGE_LEFT, ""},
458 {SIG_SCROLL_EDGE_RIGHT, ""},
459 {SIG_MULTI_SWIPE_LEFT, ""},
460 {SIG_MULTI_SWIPE_RIGHT, ""},
461 {SIG_MULTI_SWIPE_UP, ""},
462 {SIG_MULTI_SWIPE_DOWN, ""},
463 {SIG_MULTI_PINCH_OUT, ""},
464 {SIG_MULTI_PINCH_IN, ""},
469 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
472 _event_hook(Evas_Object *obj,
473 Evas_Object *src __UNUSED__,
474 Evas_Callback_Type type,
477 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
478 Evas_Event_Key_Down *ev = event_info;
479 Widget_Data *wd = elm_widget_data_get(obj);
480 if (!wd) return EINA_FALSE;
481 if (!wd->items) return EINA_FALSE;
482 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
483 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
485 Elm_Genlist_Item *it = NULL;
488 Evas_Coord step_x = 0;
489 Evas_Coord step_y = 0;
492 Evas_Coord page_x = 0;
493 Evas_Coord page_y = 0;
495 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
496 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
497 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
498 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
500 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
504 else if ((!strcmp(ev->keyname, "Right")) ||
505 (!strcmp(ev->keyname, "KP_Right")))
509 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
511 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
512 (_item_multi_select_up(wd)))
513 || (_item_single_select_up(wd)))
515 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
521 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
523 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
524 (_item_multi_select_down(wd)))
525 || (_item_single_select_down(wd)))
527 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
533 else if ((!strcmp(ev->keyname, "Home")) ||
534 (!strcmp(ev->keyname, "KP_Home")))
536 it = elm_genlist_first_item_get(obj);
537 elm_genlist_item_bring_in(it);
538 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
541 else if ((!strcmp(ev->keyname, "End")) ||
542 (!strcmp(ev->keyname, "KP_End")))
544 it = elm_genlist_last_item_get(obj);
545 elm_genlist_item_bring_in(it);
546 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
549 else if ((!strcmp(ev->keyname, "Prior")) ||
550 (!strcmp(ev->keyname, "KP_Prior")))
553 y -= -(page_y * v_h) / 100;
557 else if ((!strcmp(ev->keyname, "Next")) ||
558 (!strcmp(ev->keyname, "KP_Next")))
561 y += -(page_y * v_h) / 100;
565 else if (((!strcmp(ev->keyname, "Return")) ||
566 (!strcmp(ev->keyname, "KP_Enter")) ||
567 (!strcmp(ev->keyname, "space")))
568 && (!wd->multi) && (wd->selected))
570 it = elm_genlist_selected_item_get(obj);
571 elm_genlist_item_expanded_set(it,
572 !elm_genlist_item_expanded_get(it));
574 else if (!strcmp(ev->keyname, "Escape"))
576 if (!_deselect_all_items(wd)) return EINA_FALSE;
577 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
580 else return EINA_FALSE;
582 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
583 elm_smart_scroller_child_pos_set(wd->scr, x, y);
588 _deselect_all_items(Widget_Data *wd)
590 if (!wd->selected) return EINA_FALSE;
592 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
598 _item_multi_select_up(Widget_Data *wd)
600 if (!wd->selected) return EINA_FALSE;
601 if (!wd->multi) return EINA_FALSE;
603 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
604 if (!prev) return EINA_TRUE;
606 if (elm_genlist_item_selected_get(prev))
608 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
609 wd->last_selected_item = prev;
610 elm_genlist_item_show(wd->last_selected_item);
614 elm_genlist_item_selected_set(prev, EINA_TRUE);
615 elm_genlist_item_show(prev);
621 _item_multi_select_down(Widget_Data *wd)
623 if (!wd->selected) return EINA_FALSE;
624 if (!wd->multi) return EINA_FALSE;
626 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
627 if (!next) return EINA_TRUE;
629 if (elm_genlist_item_selected_get(next))
631 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
632 wd->last_selected_item = next;
633 elm_genlist_item_show(wd->last_selected_item);
637 elm_genlist_item_selected_set(next, EINA_TRUE);
638 elm_genlist_item_show(next);
644 _item_single_select_up(Widget_Data *wd)
646 Elm_Genlist_Item *prev;
649 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
650 while ((prev) && (prev->delete_me))
651 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
653 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
655 if (!prev) return EINA_FALSE;
657 _deselect_all_items(wd);
659 elm_genlist_item_selected_set(prev, EINA_TRUE);
660 elm_genlist_item_show(prev);
665 _item_single_select_down(Widget_Data *wd)
667 Elm_Genlist_Item *next;
670 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
671 while ((next) && (next->delete_me))
672 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
674 else next = elm_genlist_item_next_get(wd->last_selected_item);
676 if (!next) return EINA_FALSE;
678 _deselect_all_items(wd);
680 elm_genlist_item_selected_set(next, EINA_TRUE);
681 elm_genlist_item_show(next);
686 _on_focus_hook(void *data __UNUSED__,
689 Widget_Data *wd = elm_widget_data_get(obj);
691 if (elm_widget_focus_get(obj))
693 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
694 evas_object_focus_set(wd->obj, EINA_TRUE);
695 if ((wd->selected) && (!wd->last_selected_item))
696 wd->last_selected_item = eina_list_data_get(wd->selected);
700 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
701 evas_object_focus_set(wd->obj, EINA_FALSE);
706 _del_hook(Evas_Object *obj)
708 Widget_Data *wd = elm_widget_data_get(obj);
710 _item_cache_zero(wd);
711 if (wd->calc_job) ecore_job_del(wd->calc_job);
712 if (wd->update_job) ecore_job_del(wd->update_job);
713 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
714 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
715 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
716 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
717 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
722 _del_pre_hook(Evas_Object *obj)
724 Widget_Data *wd = elm_widget_data_get(obj);
726 evas_object_del(wd->pan_smart);
727 wd->pan_smart = NULL;
728 elm_genlist_clear(obj);
732 _mirrored_set(Evas_Object *obj,
735 Widget_Data *wd = elm_widget_data_get(obj);
737 _item_cache_zero(wd);
738 elm_smart_scroller_mirrored_set(wd->scr, rtl);
742 _theme_hook(Evas_Object *obj)
744 Widget_Data *wd = elm_widget_data_get(obj);
747 evas_event_freeze(evas_object_evas_get(wd->obj));
748 _item_cache_zero(wd);
749 _elm_widget_mirrored_reload(obj);
750 _mirrored_set(obj, elm_widget_mirrored_get(obj));
751 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
752 elm_widget_style_get(obj));
753 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
754 wd->item_width = wd->item_height = 0;
755 wd->group_item_width = wd->group_item_height = 0;
756 wd->minw = wd->minh = wd->realminw = 0;
757 EINA_INLIST_FOREACH(wd->blocks, itb)
760 Elm_Genlist_Item *it;
762 if (itb->realized) _item_block_unrealize(itb);
763 EINA_LIST_FOREACH(itb->items, l, it)
764 it->mincalcd = EINA_FALSE;
766 itb->changed = EINA_TRUE;
768 if (wd->calc_job) ecore_job_del(wd->calc_job);
769 wd->calc_job = ecore_job_add(_calc_job, wd);
771 evas_event_thaw(evas_object_evas_get(wd->obj));
772 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
776 _show_region_hook(void *data,
779 Widget_Data *wd = elm_widget_data_get(data);
780 Evas_Coord x, y, w, h;
782 elm_widget_show_region_get(obj, &x, &y, &w, &h);
783 //x & y are screen coordinates, Add with pan coordinates
786 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
790 _sizing_eval(Evas_Object *obj)
792 Widget_Data *wd = elm_widget_data_get(obj);
793 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
795 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
796 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
798 if (wd->height_for_width)
802 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
803 if ((vw != 0) && (vw != wd->prev_viewport_w))
807 wd->prev_viewport_w = vw;
808 EINA_INLIST_FOREACH(wd->blocks, itb)
810 itb->must_recalc = EINA_TRUE;
812 if (wd->calc_job) ecore_job_del(wd->calc_job);
813 wd->calc_job = ecore_job_add(_calc_job, wd);
816 if (wd->mode == ELM_LIST_LIMIT)
818 Evas_Coord vmw, vmh, vw, vh;
822 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
823 if ((minw > 0) && (vw < minw)) vw = minw;
824 else if ((maxw > 0) && (vw > maxw))
826 edje_object_size_min_calc
827 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
834 edje_object_size_min_calc
835 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
839 evas_object_size_hint_min_set(obj, minw, minh);
840 evas_object_size_hint_max_set(obj, maxw, maxh);
844 _signal_emit_hook(Evas_Object *obj,
845 const char *emission,
848 Widget_Data *wd = elm_widget_data_get(obj);
849 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
854 _item_highlight(Elm_Genlist_Item *it)
856 const char *selectraise;
857 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
858 (it->disabled) || (it->display_only) || (it->mode_view))
860 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
861 selectraise = edje_object_data_get(it->base.view, "selectraise");
862 if ((selectraise) && (!strcmp(selectraise, "on")))
864 evas_object_raise(it->base.view);
865 if ((it->group_item) && (it->group_item->realized))
866 evas_object_raise(it->group_item->base.view);
868 it->highlighted = EINA_TRUE;
872 _item_unhighlight(Elm_Genlist_Item *it)
874 const char *stacking, *selectraise;
875 if ((it->delete_me) || (!it->highlighted)) return;
876 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
877 stacking = edje_object_data_get(it->base.view, "stacking");
878 selectraise = edje_object_data_get(it->base.view, "selectraise");
881 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
882 else evas_object_raise(it->base.view);
884 it->highlighted = EINA_FALSE;
888 _item_block_del(Elm_Genlist_Item *it)
891 Item_Block *itb = it->block;
893 itb->items = eina_list_remove(itb->items, it);
895 itb->changed = EINA_TRUE;
896 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
897 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
900 il = EINA_INLIST_GET(itb);
901 Item_Block *itbn = (Item_Block *)(il->next);
903 it->parent->items = eina_list_remove(it->parent->items, it);
905 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
907 if (itbn) itbn->changed = EINA_TRUE;
911 if (itb->count < itb->wd->max_items_per_block/2)
913 il = EINA_INLIST_GET(itb);
914 Item_Block *itbp = (Item_Block *)(il->prev);
915 Item_Block *itbn = (Item_Block *)(il->next);
916 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
918 Elm_Genlist_Item *it2;
920 EINA_LIST_FREE(itb->items, it2)
923 itbp->items = eina_list_append(itbp->items, it2);
925 itbp->changed = EINA_TRUE;
927 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
928 EINA_INLIST_GET(itb));
931 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
935 Eina_List *last = eina_list_last(itb->items);
936 Elm_Genlist_Item *it2 = last->data;
939 itb->items = eina_list_remove_list(itb->items, last);
940 itbn->items = eina_list_prepend(itbn->items, it2);
942 itbn->changed = EINA_TRUE;
945 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
953 _item_del(Elm_Genlist_Item *it)
955 Evas_Object *tob = it->wd->obj;
957 evas_event_freeze(evas_object_evas_get(tob));
958 elm_widget_item_pre_notify_del(it);
959 elm_genlist_item_subitems_clear(it);
960 it->wd->walking -= it->walking;
961 if (it->wd->show_item == it) it->wd->show_item = NULL;
962 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
963 if (it->realized) _item_unrealize(it, EINA_FALSE);
964 if (it->block) _item_block_del(it);
965 if ((!it->delete_me) && (it->itc->func.del))
966 it->itc->func.del((void *)it->base.data, it->base.widget);
967 it->delete_me = EINA_TRUE;
969 it->wd->queue = eina_list_remove(it->wd->queue, it);
970 if (it->wd->anchor_item == it)
972 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
973 if (!it->wd->anchor_item)
974 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
976 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
978 it->parent->items = eina_list_remove(it->parent->items, it);
979 if (it->flags & ELM_GENLIST_ITEM_GROUP)
980 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
981 if (it->long_timer) ecore_timer_del(it->long_timer);
982 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
984 if (it->tooltip.del_cb)
985 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
987 evas_event_thaw(evas_object_evas_get(tob));
988 evas_event_thaw_eval(evas_object_evas_get(tob));
990 elm_widget_item_del(it);
994 _item_select(Elm_Genlist_Item *it)
996 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
999 if (it->wd->always_select) goto call;
1002 it->selected = EINA_TRUE;
1003 it->wd->selected = eina_list_append(it->wd->selected, it);
1007 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1009 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
1012 if ((it->wd->clear_me) && (!it->wd->walking))
1013 elm_genlist_clear(it->base.widget);
1016 if ((!it->walking) && (it->delete_me))
1018 if (!it->relcount) _item_del(it);
1021 it->wd->last_selected_item = it;
1025 _item_unselect(Elm_Genlist_Item *it)
1027 if ((it->delete_me) || (!it->selected)) return;
1028 it->selected = EINA_FALSE;
1029 it->wd->selected = eina_list_remove(it->wd->selected, it);
1030 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1034 _mouse_move(void *data,
1035 Evas *evas __UNUSED__,
1039 Elm_Genlist_Item *it = data;
1040 Evas_Event_Mouse_Move *ev = event_info;
1041 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1042 Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
1044 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1046 if (!it->wd->on_hold)
1048 it->wd->on_hold = EINA_TRUE;
1049 if (!it->wd->wasselected)
1051 _item_unhighlight(it);
1056 if (it->wd->multitouched)
1058 it->wd->cur_x = ev->cur.canvas.x;
1059 it->wd->cur_y = ev->cur.canvas.y;
1062 if ((it->dragging) && (it->down))
1064 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1067 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1068 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1069 if (abs((it->wd->history[it->wd->movements].x -
1070 it->wd->history[0].x)) > 40)
1071 it->wd->swipe = EINA_TRUE;
1073 it->wd->movements++;
1077 ecore_timer_del(it->long_timer);
1078 it->long_timer = NULL;
1080 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1083 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1087 ecore_timer_del(it->long_timer);
1088 it->long_timer = NULL;
1090 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1092 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1093 it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1095 if (!it->wd->reorder_start_y)
1096 it->wd->reorder_start_y = it->block->y + it->y;
1098 if (it_scrl_y < oy) y_pos = oy;
1099 else if (it_scrl_y + it->wd->reorder_it->h > oy+oh)
1100 y_pos = oy + oh - it->wd->reorder_it->h;
1101 else y_pos = it_scrl_y;
1103 _item_position(it, it->base.view, it->scrl_x, y_pos);
1105 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1106 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1110 if (!it->display_only)
1111 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1112 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1113 x = ev->cur.canvas.x - x;
1114 y = ev->cur.canvas.y - y;
1117 if (adx < 0) adx = -dx;
1120 if (ady < 0) ady = -dy;
1123 if ((adx > minw) || (ady > minh))
1125 it->dragging = EINA_TRUE;
1128 ecore_timer_del(it->long_timer);
1129 it->long_timer = NULL;
1131 if (!it->wd->wasselected)
1133 _item_unhighlight(it);
1139 evas_object_smart_callback_call(it->base.widget,
1140 SIG_DRAG_START_UP, it);
1144 evas_object_smart_callback_call(it->base.widget,
1145 SIG_DRAG_START_LEFT, it);
1147 evas_object_smart_callback_call(it->base.widget,
1148 SIG_DRAG_START_RIGHT, it);
1154 evas_object_smart_callback_call(it->base.widget,
1155 SIG_DRAG_START_DOWN, it);
1159 evas_object_smart_callback_call(it->base.widget,
1160 SIG_DRAG_START_LEFT, it);
1162 evas_object_smart_callback_call(it->base.widget,
1163 SIG_DRAG_START_RIGHT, it);
1170 _long_press(void *data)
1172 Elm_Genlist_Item *it = data, *it_tmp;
1173 Eina_List *list, *l;
1175 it->long_timer = NULL;
1176 if ((it->disabled) || (it->dragging) || (it->display_only))
1177 return ECORE_CALLBACK_CANCEL;
1178 it->wd->longpressed = EINA_TRUE;
1179 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1180 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1182 it->wd->reorder_it = it;
1183 it->wd->reorder_start_y = 0;
1185 evas_object_raise(it->base.view);
1186 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1188 list = elm_genlist_realized_items_get(it->wd->obj);
1189 EINA_LIST_FOREACH(list, l, it_tmp)
1191 if (it != it_tmp) _item_unselect(it_tmp);
1193 if (elm_genlist_item_expanded_get(it))
1195 elm_genlist_item_expanded_set(it, EINA_FALSE);
1196 return ECORE_CALLBACK_RENEW;
1198 edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
1200 return ECORE_CALLBACK_CANCEL;
1204 _swipe(Elm_Genlist_Item *it)
1209 if ((it->display_only) || (it->disabled)) return;
1210 it->wd->swipe = EINA_FALSE;
1211 for (i = 0; i < it->wd->movements; i++)
1213 sum += it->wd->history[i].x;
1214 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1217 sum /= it->wd->movements;
1218 if (abs(sum - it->wd->history[0].x) <= 10) return;
1219 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1223 _swipe_cancel(void *data)
1225 Elm_Genlist_Item *it = data;
1227 if (!it) return ECORE_CALLBACK_CANCEL;
1228 it->wd->swipe = EINA_FALSE;
1229 it->wd->movements = 0;
1230 return ECORE_CALLBACK_RENEW;
1234 _multi_cancel(void *data)
1236 Widget_Data *wd = data;
1238 if (!wd) return ECORE_CALLBACK_CANCEL;
1239 wd->multi_timeout = EINA_TRUE;
1240 return ECORE_CALLBACK_RENEW;
1244 _multi_touch_gesture_eval(void *data)
1246 Elm_Genlist_Item *it = data;
1248 it->wd->multitouched = EINA_FALSE;
1249 if (it->wd->multi_timer)
1251 ecore_timer_del(it->wd->multi_timer);
1252 it->wd->multi_timer = NULL;
1254 if (it->wd->multi_timeout)
1256 it->wd->multi_timeout = EINA_FALSE;
1260 Evas_Coord minw = 0, minh = 0;
1261 Evas_Coord off_x, off_y, off_mx, off_my;
1263 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1264 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1265 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1266 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1267 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1269 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1271 if ((off_x + off_mx) > (off_y + off_my))
1273 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1274 evas_object_smart_callback_call(it->base.widget,
1275 SIG_MULTI_SWIPE_RIGHT, it);
1276 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1277 evas_object_smart_callback_call(it->base.widget,
1278 SIG_MULTI_SWIPE_LEFT, it);
1279 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1280 evas_object_smart_callback_call(it->base.widget,
1281 SIG_MULTI_PINCH_OUT, it);
1283 evas_object_smart_callback_call(it->base.widget,
1284 SIG_MULTI_PINCH_IN, it);
1288 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1289 evas_object_smart_callback_call(it->base.widget,
1290 SIG_MULTI_SWIPE_DOWN, it);
1291 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1292 evas_object_smart_callback_call(it->base.widget,
1293 SIG_MULTI_SWIPE_UP, it);
1294 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1295 evas_object_smart_callback_call(it->base.widget,
1296 SIG_MULTI_PINCH_OUT, it);
1298 evas_object_smart_callback_call(it->base.widget,
1299 SIG_MULTI_PINCH_IN, it);
1302 it->wd->multi_timeout = EINA_FALSE;
1306 _multi_down(void *data,
1307 Evas *evas __UNUSED__,
1308 Evas_Object *obj __UNUSED__,
1311 Elm_Genlist_Item *it = data;
1312 Evas_Event_Multi_Down *ev = event_info;
1314 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1315 it->wd->multi_device = ev->device;
1316 it->wd->multi_down = EINA_TRUE;
1317 it->wd->multitouched = EINA_TRUE;
1318 it->wd->prev_mx = ev->canvas.x;
1319 it->wd->prev_my = ev->canvas.y;
1320 if (!it->wd->wasselected)
1322 _item_unhighlight(it);
1325 it->wd->wasselected = EINA_FALSE;
1326 it->wd->longpressed = EINA_FALSE;
1329 ecore_timer_del(it->long_timer);
1330 it->long_timer = NULL;
1334 it->dragging = EINA_FALSE;
1335 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1337 if (it->swipe_timer)
1339 ecore_timer_del(it->swipe_timer);
1340 it->swipe_timer = NULL;
1342 if (it->wd->on_hold)
1344 it->wd->swipe = EINA_FALSE;
1345 it->wd->movements = 0;
1346 it->wd->on_hold = EINA_FALSE;
1351 _multi_up(void *data,
1352 Evas *evas __UNUSED__,
1353 Evas_Object *obj __UNUSED__,
1356 Elm_Genlist_Item *it = data;
1357 Evas_Event_Multi_Up *ev = event_info;
1359 if (it->wd->multi_device != ev->device) return;
1360 it->wd->multi_device = 0;
1361 it->wd->multi_down = EINA_FALSE;
1362 if (it->wd->mouse_down) return;
1363 _multi_touch_gesture_eval(data);
1367 _multi_move(void *data,
1368 Evas *evas __UNUSED__,
1369 Evas_Object *obj __UNUSED__,
1372 Elm_Genlist_Item *it = data;
1373 Evas_Event_Multi_Move *ev = event_info;
1375 if (it->wd->multi_device != ev->device) return;
1376 it->wd->cur_mx = ev->cur.canvas.x;
1377 it->wd->cur_my = ev->cur.canvas.y;
1381 _mouse_down(void *data,
1382 Evas *evas __UNUSED__,
1386 Elm_Genlist_Item *it = data;
1387 Evas_Event_Mouse_Down *ev = event_info;
1390 if (ev->button != 1) return;
1391 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1393 it->wd->on_hold = EINA_TRUE;
1396 it->down = EINA_TRUE;
1397 it->dragging = EINA_FALSE;
1398 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1399 it->dx = ev->canvas.x - x;
1400 it->dy = ev->canvas.y - y;
1401 it->wd->mouse_down = EINA_TRUE;
1402 if (!it->wd->multitouched)
1404 it->wd->prev_x = ev->canvas.x;
1405 it->wd->prev_y = ev->canvas.y;
1406 it->wd->multi_timeout = EINA_FALSE;
1407 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1408 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1410 it->wd->longpressed = EINA_FALSE;
1411 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1412 else it->wd->on_hold = EINA_FALSE;
1413 if (it->wd->on_hold) return;
1414 it->wd->wasselected = it->selected;
1415 _item_highlight(it);
1416 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1417 if ((!it->disabled) && (!it->display_only))
1419 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1420 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1422 if (it->long_timer) ecore_timer_del(it->long_timer);
1423 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1424 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1426 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1429 it->long_timer = NULL;
1430 it->wd->swipe = EINA_FALSE;
1431 it->wd->movements = 0;
1435 _mouse_up(void *data,
1436 Evas *evas __UNUSED__,
1437 Evas_Object *obj __UNUSED__,
1440 Elm_Genlist_Item *it = data;
1441 Evas_Event_Mouse_Up *ev = event_info;
1442 Eina_Bool dragged = EINA_FALSE;
1444 if (ev->button != 1) return;
1445 it->down = EINA_FALSE;
1446 it->wd->mouse_down = EINA_FALSE;
1447 if (it->wd->multitouched)
1449 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1450 if (it->wd->multi_down) return;
1451 _multi_touch_gesture_eval(data);
1454 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1455 else it->wd->on_hold = EINA_FALSE;
1458 ecore_timer_del(it->long_timer);
1459 it->long_timer = NULL;
1463 it->dragging = EINA_FALSE;
1464 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1467 if (it->swipe_timer)
1469 ecore_timer_del(it->swipe_timer);
1470 it->swipe_timer = NULL;
1472 if (it->wd->multi_timer)
1474 ecore_timer_del(it->wd->multi_timer);
1475 it->wd->multi_timer = NULL;
1476 it->wd->multi_timeout = EINA_FALSE;
1478 if (it->wd->on_hold)
1480 if (it->wd->swipe) _swipe(data);
1481 it->wd->longpressed = EINA_FALSE;
1482 it->wd->on_hold = EINA_FALSE;
1485 if ((it->wd->reorder_mode) && (it->wd->reorder_it))
1487 Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
1489 if (it->wd->reorder_rel)
1491 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent)
1493 if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
1494 _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1496 _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1500 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1501 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1504 edje_object_signal_emit(it->base.view, "elm,state,reorder,disabled", "elm");
1505 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1506 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1508 if (it->wd->longpressed)
1510 it->wd->longpressed = EINA_FALSE;
1511 if (!it->wd->wasselected)
1513 _item_unhighlight(it);
1516 it->wd->wasselected = EINA_FALSE;
1521 if (it->want_unrealize)
1523 _item_unrealize(it, EINA_FALSE);
1524 if (it->block->want_unrealize)
1525 _item_block_unrealize(it->block);
1528 if ((it->disabled) || (dragged) || (it->display_only)) return;
1529 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1534 _item_highlight(it);
1539 _item_unhighlight(it);
1547 Widget_Data *wd = it->wd;
1550 while (wd->selected)
1552 _item_unhighlight(wd->selected->data);
1553 _item_unselect(wd->selected->data);
1559 const Eina_List *l, *l_next;
1560 Elm_Genlist_Item *it2;
1562 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1565 _item_unhighlight(it2);
1566 _item_unselect(it2);
1568 //_item_highlight(it);
1571 _item_highlight(it);
1577 _signal_expand_toggle(void *data,
1578 Evas_Object *obj __UNUSED__,
1579 const char *emission __UNUSED__,
1580 const char *source __UNUSED__)
1582 Elm_Genlist_Item *it = data;
1585 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1587 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1591 _signal_expand(void *data,
1592 Evas_Object *obj __UNUSED__,
1593 const char *emission __UNUSED__,
1594 const char *source __UNUSED__)
1596 Elm_Genlist_Item *it = data;
1599 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1603 _signal_contract(void *data,
1604 Evas_Object *obj __UNUSED__,
1605 const char *emission __UNUSED__,
1606 const char *source __UNUSED__)
1608 Elm_Genlist_Item *it = data;
1611 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1615 _scr_hold_timer_cb(void *data)
1617 if (!data) return ECORE_CALLBACK_CANCEL;
1618 Widget_Data *wd = data;
1619 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1620 wd->scr_hold_timer = NULL;
1621 return ECORE_CALLBACK_CANCEL;
1625 _mode_finished_signal_cb(void *data,
1627 const char *emission __UNUSED__,
1628 const char *source __UNUSED__)
1632 Elm_Genlist_Item *it = data;
1633 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1635 Evas *te = evas_object_evas_get(obj);
1637 evas_event_freeze(te);
1638 it->nocache = EINA_FALSE;
1639 _mode_item_unrealize(it);
1640 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1641 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1642 evas_event_thaw(te);
1643 evas_event_thaw_eval(te);
1647 _item_cache_clean(Widget_Data *wd)
1649 evas_event_freeze(evas_object_evas_get(wd->obj));
1650 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1654 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1655 wd->item_cache = eina_inlist_remove(wd->item_cache,
1656 wd->item_cache->last);
1657 wd->item_cache_count--;
1658 if (itc->spacer) evas_object_del(itc->spacer);
1659 if (itc->base_view) evas_object_del(itc->base_view);
1660 if (itc->item_style) eina_stringshare_del(itc->item_style);
1663 evas_event_thaw(evas_object_evas_get(wd->obj));
1664 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1668 _item_cache_zero(Widget_Data *wd)
1670 int pmax = wd->item_cache_max;
1671 wd->item_cache_max = 0;
1672 _item_cache_clean(wd);
1673 wd->item_cache_max = pmax;
1677 _item_cache_add(Elm_Genlist_Item *it)
1681 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1682 if (it->wd->item_cache_max <= 0)
1684 evas_object_del(it->base.view);
1685 it->base.view = NULL;
1686 evas_object_del(it->spacer);
1688 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1689 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1693 it->wd->item_cache_count++;
1694 itc = calloc(1, sizeof(Item_Cache));
1695 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1696 EINA_INLIST_GET(itc));
1697 itc->spacer = it->spacer;
1699 itc->base_view = it->base.view;
1700 it->base.view = NULL;
1701 evas_object_hide(itc->base_view);
1702 evas_object_move(itc->base_view, -9999, -9999);
1703 itc->item_style = eina_stringshare_add(it->itc->item_style);
1704 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1705 itc->compress = (it->wd->compress);
1706 itc->selected = it->selected;
1707 itc->disabled = it->disabled;
1708 itc->expanded = it->expanded;
1711 ecore_timer_del(it->long_timer);
1712 it->long_timer = NULL;
1714 if (it->swipe_timer)
1716 ecore_timer_del(it->swipe_timer);
1717 it->swipe_timer = NULL;
1719 // FIXME: other callbacks?
1720 edje_object_signal_callback_del_full(itc->base_view,
1721 "elm,action,expand,toggle",
1722 "elm", _signal_expand_toggle, it);
1723 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1725 _signal_expand, it);
1726 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1727 "elm", _signal_contract, it);
1728 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1730 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1732 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1734 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1736 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1738 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1740 _item_cache_clean(it->wd);
1741 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1742 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1746 _item_cache_find(Elm_Genlist_Item *it)
1751 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1752 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1754 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1756 if ((itc->tree == tree) &&
1757 (itc->compress == it->wd->compress) &&
1758 (!strcmp(it->itc->item_style, itc->item_style)))
1760 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1761 EINA_INLIST_GET(itc));
1762 it->wd->item_cache_count--;
1770 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1772 if (!it->nostacking)
1774 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1775 evas_object_lower(it->base.view);
1777 evas_object_raise(it->base.view);
1780 if (it->order_num_in & 0x1)
1781 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1783 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1787 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1791 if (it->selected != itc->selected)
1794 edje_object_signal_emit(it->base.view,
1795 "elm,state,selected", "elm");
1797 if (it->disabled != itc->disabled)
1800 edje_object_signal_emit(it->base.view,
1801 "elm,state,disabled", "elm");
1803 if (it->expanded != itc->expanded)
1806 edje_object_signal_emit(it->base.view,
1807 "elm,state,expanded", "elm");
1813 edje_object_signal_emit(it->base.view,
1814 "elm,state,selected", "elm");
1816 edje_object_signal_emit(it->base.view,
1817 "elm,state,disabled", "elm");
1819 edje_object_signal_emit(it->base.view,
1820 "elm,state,expanded", "elm");
1825 _item_cache_free(Item_Cache *itc)
1827 if (itc->spacer) evas_object_del(itc->spacer);
1828 if (itc->base_view) evas_object_del(itc->base_view);
1829 if (itc->item_style) eina_stringshare_del(itc->item_style);
1834 _item_label_realize(Elm_Genlist_Item *it,
1835 Evas_Object *target,
1838 if (it->itc->func.label_get)
1843 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1844 EINA_LIST_FOREACH(*source, l, key)
1846 char *s = it->itc->func.label_get
1847 ((void *)it->base.data, it->base.widget, key);
1851 edje_object_part_text_set(target, key, s);
1856 edje_object_part_text_set(target, key, "");
1863 _item_icon_realize(Elm_Genlist_Item *it,
1864 Evas_Object *target,
1867 Eina_List *res = NULL;
1869 if (it->itc->func.icon_get)
1874 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1875 EINA_LIST_FOREACH(*source, l, key)
1877 Evas_Object *ic = it->itc->func.icon_get
1878 ((void *)it->base.data, it->base.widget, key);
1882 res = eina_list_append(res, ic);
1883 edje_object_part_swallow(target, key, ic);
1884 evas_object_show(ic);
1885 elm_widget_sub_object_add(it->base.widget, ic);
1887 elm_widget_disabled_set(ic, EINA_TRUE);
1896 _item_state_realize(Elm_Genlist_Item *it,
1897 Evas_Object *target,
1900 if (it->itc->func.state_get)
1906 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1907 EINA_LIST_FOREACH(*source, l, key)
1909 Eina_Bool on = it->itc->func.state_get
1910 ((void *)it->base.data, it->base.widget, key);
1914 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1915 edje_object_signal_emit(target, buf, "elm");
1919 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1920 edje_object_signal_emit(target, buf, "elm");
1927 _item_realize(Elm_Genlist_Item *it,
1931 Elm_Genlist_Item *it2;
1932 const char *treesize;
1934 int depth, tsize = 20;
1935 Item_Cache *itc = NULL;
1937 if (it->delete_me) return;
1938 //evas_event_freeze(evas_object_evas_get(it->wd->obj));
1941 if (it->order_num_in != in)
1943 it->order_num_in = in;
1944 _elm_genlist_item_odd_even_update(it);
1945 _elm_genlist_item_state_update(it, NULL);
1947 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
1948 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1951 it->order_num_in = in;
1954 it->nocache = EINA_FALSE;
1956 itc = _item_cache_find(it);
1959 it->base.view = itc->base_view;
1960 itc->base_view = NULL;
1961 it->spacer = itc->spacer;
1966 const char *stacking_even;
1967 const char *stacking;
1969 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1970 edje_object_scale_set(it->base.view,
1971 elm_widget_scale_get(it->base.widget) *
1972 _elm_config->scale);
1973 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1974 elm_widget_sub_object_add(it->base.widget, it->base.view);
1976 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1977 strncpy(buf, "tree", sizeof(buf));
1978 else strncpy(buf, "item", sizeof(buf));
1979 if (it->wd->compress)
1980 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1982 strncat(buf, "/", sizeof(buf) - strlen(buf));
1983 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1985 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1986 elm_widget_style_get(it->base.widget));
1988 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1989 if (!stacking_even) stacking_even = "above";
1990 it->stacking_even = !!strcmp("above", stacking_even);
1992 stacking = edje_object_data_get(it->base.view, "stacking");
1993 if (!stacking) stacking = "yes";
1994 it->nostacking = !!strcmp("yes", stacking);
1996 edje_object_mirrored_set(it->base.view,
1997 elm_widget_mirrored_get(it->base.widget));
1999 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
2000 evas_object_color_set(it->spacer, 0, 0, 0, 0);
2001 elm_widget_sub_object_add(it->base.widget, it->spacer);
2004 _elm_genlist_item_odd_even_update(it);
2006 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
2008 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
2010 it->expanded_depth = depth;
2011 treesize = edje_object_data_get(it->base.view, "treesize");
2012 if (treesize) tsize = atoi(treesize);
2013 evas_object_size_hint_min_set(it->spacer,
2014 (depth * tsize) * _elm_config->scale, 1);
2015 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
2018 edje_object_signal_callback_add(it->base.view,
2019 "elm,action,expand,toggle",
2020 "elm", _signal_expand_toggle, it);
2021 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
2022 "elm", _signal_expand, it);
2023 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
2024 "elm", _signal_contract, it);
2025 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
2027 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
2029 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
2031 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
2033 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
2035 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
2038 _elm_genlist_item_state_update(it, itc);
2041 if ((calc) && (it->wd->homogeneous) &&
2042 ((it->wd->item_width) ||
2043 ((it->wd->item_width) && (it->wd->group_item_width))))
2045 /* homogenous genlist shortcut */
2048 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2050 it->w = it->minw = it->wd->group_item_width;
2051 it->h = it->minh = it->wd->group_item_height;
2055 it->w = it->minw = it->wd->item_width;
2056 it->h = it->minh = it->wd->item_height;
2058 it->mincalcd = EINA_TRUE;
2063 /* FIXME: If you see that assert, please notify us and we
2064 will clean our mess */
2065 assert(eina_list_count(it->icon_objs) == 0);
2067 _item_label_realize(it, it->base.view, &it->labels);
2068 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
2069 _item_state_realize(it, it->base.view, &it->states);
2073 Evas_Coord mw = -1, mh = -1;
2075 if (!it->display_only)
2076 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2077 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2078 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2080 if (!it->display_only)
2081 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2082 it->w = it->minw = mw;
2083 it->h = it->minh = mh;
2084 it->mincalcd = EINA_TRUE;
2086 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2088 it->wd->group_item_width = mw;
2089 it->wd->group_item_height = mh;
2091 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2093 it->wd->item_width = mw;
2094 it->wd->item_height = mh;
2097 if (!calc) evas_object_show(it->base.view);
2100 if (it->tooltip.content_cb)
2102 elm_widget_item_tooltip_content_cb_set(it,
2103 it->tooltip.content_cb,
2104 it->tooltip.data, NULL);
2105 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2108 if (it->mouse_cursor)
2109 elm_widget_item_cursor_set(it, it->mouse_cursor);
2111 it->realized = EINA_TRUE;
2112 it->want_unrealize = EINA_FALSE;
2114 if (itc) _item_cache_free(itc);
2115 //evas_event_thaw(evas_object_evas_get(it->wd->obj));
2116 //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2118 evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2122 _item_unrealize(Elm_Genlist_Item *it,
2127 if (!it->realized) return;
2128 if (it->wd->reorder_it == it) return;
2129 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2131 evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2134 ecore_timer_del(it->long_timer);
2135 it->long_timer = NULL;
2139 evas_object_del(it->base.view);
2140 it->base.view = NULL;
2141 evas_object_del(it->spacer);
2146 edje_object_mirrored_set(it->base.view,
2147 elm_widget_mirrored_get(it->base.widget));
2148 edje_object_scale_set(it->base.view,
2149 elm_widget_scale_get(it->base.widget)
2150 * _elm_config->scale);
2151 _item_cache_add(it);
2153 elm_widget_stringlist_free(it->labels);
2155 elm_widget_stringlist_free(it->icons);
2157 elm_widget_stringlist_free(it->states);
2159 EINA_LIST_FREE(it->icon_objs, icon)
2160 evas_object_del(icon);
2162 _mode_item_unrealize(it);
2164 it->realized = EINA_FALSE;
2165 it->want_unrealize = EINA_FALSE;
2166 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2167 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2171 _item_block_recalc(Item_Block *itb,
2176 Elm_Genlist_Item *it;
2177 Evas_Coord minw = 0, minh = 0;
2178 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2181 //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2183 EINA_LIST_FOREACH(itb->items, l, it)
2185 if (it->delete_me) continue;
2186 showme |= it->showme;
2191 if (!it->mincalcd) changed = EINA_TRUE;
2194 _item_realize(it, in, EINA_TRUE);
2195 _item_unrealize(it, EINA_TRUE);
2200 _item_realize(it, in, EINA_TRUE);
2201 _item_unrealize(it, EINA_TRUE);
2205 _item_realize(it, in, EINA_FALSE);
2207 if (minw < it->minw) minw = it->minw;
2215 itb->changed = EINA_FALSE;
2216 //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2217 //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2222 _item_block_realize(Item_Block *itb)
2224 if (itb->realized) return;
2225 itb->realized = EINA_TRUE;
2226 itb->want_unrealize = EINA_FALSE;
2230 _item_block_unrealize(Item_Block *itb)
2233 Elm_Genlist_Item *it;
2234 Eina_Bool dragging = EINA_FALSE;
2236 if (!itb->realized) return;
2237 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2238 EINA_LIST_FOREACH(itb->items, l, it)
2240 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2244 dragging = EINA_TRUE;
2245 it->want_unrealize = EINA_TRUE;
2248 _item_unrealize(it, EINA_FALSE);
2253 itb->realized = EINA_FALSE;
2254 itb->want_unrealize = EINA_TRUE;
2257 itb->want_unrealize = EINA_FALSE;
2258 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2259 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2263 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2265 Evas_Coord rox, roy, row, roh, oy, oh;
2266 Eina_Bool top = EINA_FALSE;
2267 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2268 if (!reorder_it) return 0;
2270 evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
2271 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2273 if ((it->wd->reorder_start_y < it->block->y) &&
2274 (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
2276 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2277 if (it->block->count == 1)
2278 it->wd->reorder_rel = it;
2280 else if ((it->wd->reorder_start_y >= it->block->y) &&
2281 (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
2283 it->block->reorder_offset = it->wd->reorder_it->h;
2286 it->block->reorder_offset = 0;
2288 it->scrl_y += it->block->reorder_offset;
2290 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2291 rox, roy + (roh / 2), row, 1));
2294 it->wd->reorder_rel = it;
2295 it->scrl_y += it->wd->reorder_it->h;
2296 return it->wd->reorder_it->h;
2303 _reorder_move_animator_cb(void *data)
2305 Elm_Genlist_Item *it = data;
2306 Eina_Bool down = EINA_FALSE;
2308 int y, dy = it->h / 10 * _elm_config->scale, diff;
2310 t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
2312 if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
2315 diff = abs(it->old_scrl_y - it->scrl_y);
2316 if (diff > it->h) y = diff / 2;
2318 if (it->old_scrl_y < it->scrl_y)
2320 it->old_scrl_y += y;
2323 else if (it->old_scrl_y > it->scrl_y)
2325 it->old_scrl_y -= y;
2328 _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
2329 _group_items_recalc(it->wd);
2331 if ((it->wd->reorder_pan_move) ||
2332 (down && it->old_scrl_y >= it->scrl_y) ||
2333 (!down && it->old_scrl_y <= it->scrl_y))
2335 it->old_scrl_y = it->scrl_y;
2336 it->move_effect_enabled = EINA_FALSE;
2337 it->wd->reorder_move_animator = NULL;
2338 return ECORE_CALLBACK_CANCEL;
2340 return ECORE_CALLBACK_RENEW;
2344 _item_position(Elm_Genlist_Item *it,
2352 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2353 evas_object_resize(view, it->w, it->h);
2354 evas_object_move(view, it_x, it_y);
2355 evas_object_show(view);
2356 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2357 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2361 _item_block_position(Item_Block *itb,
2365 Elm_Genlist_Item *it;
2366 Elm_Genlist_Item *git;
2367 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2370 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2371 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2372 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2374 EINA_LIST_FOREACH(itb->items, l, it)
2376 if (it->delete_me) continue;
2377 else if (it->wd->reorder_it == it) continue;
2381 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2382 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2384 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2385 cvx, cvy, cvw, cvh));
2386 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2388 if ((itb->realized) && (!it->realized))
2390 if (vis) _item_realize(it, in, EINA_FALSE);
2396 if (it->wd->reorder_mode)
2397 y += _get_space_for_reorder_item(it);
2398 git = it->group_item;
2401 if (git->scrl_y < oy)
2403 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2404 git->scrl_y = (it->scrl_y + it->h) - git->h;
2405 git->want_realize = EINA_TRUE;
2407 if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
2409 if (!it->move_effect_enabled)
2411 it->move_effect_enabled = EINA_TRUE;
2412 it->wd->reorder_move_animator =
2414 _reorder_move_animator_cb, it);
2417 if (!it->move_effect_enabled)
2421 _item_position(it, it->mode_view, it->scrl_x,
2424 _item_position(it, it->base.view, it->scrl_x,
2427 it->old_scrl_x = it->scrl_x;
2428 it->old_scrl_y = it->scrl_y;
2433 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2440 if (vis) it->want_realize = EINA_TRUE;
2444 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2445 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2449 _group_items_recalc(void *data)
2451 Widget_Data *wd = data;
2453 Elm_Genlist_Item *git;
2455 evas_event_freeze(evas_object_evas_get(wd->obj));
2456 EINA_LIST_FOREACH(wd->group_items, l, git)
2458 if (git->want_realize)
2461 _item_realize(git, 0, EINA_FALSE);
2462 evas_object_resize(git->base.view, wd->minw, git->h);
2463 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2464 evas_object_show(git->base.view);
2465 evas_object_raise(git->base.view);
2467 else if (!git->want_realize && git->realized)
2470 _item_unrealize(git, EINA_FALSE);
2473 evas_event_thaw(evas_object_evas_get(wd->obj));
2474 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2478 _must_recalc_idler(void *data)
2480 Widget_Data *wd = data;
2481 if (wd->calc_job) ecore_job_del(wd->calc_job);
2482 wd->calc_job = ecore_job_add(_calc_job, wd);
2483 wd->must_recalc_idler = NULL;
2484 return ECORE_CALLBACK_CANCEL;
2488 _calc_job(void *data)
2490 Widget_Data *wd = data;
2491 Item_Block *itb, *chb = NULL;
2492 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2495 Eina_Bool minw_change = EINA_FALSE, changed = EINA_FALSE;
2496 Eina_Bool did_must_recalc = EINA_FALSE;
2499 t0 = ecore_time_get();
2500 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2504 evas_event_freeze(evas_object_evas_get(wd->obj));
2505 EINA_INLIST_FOREACH(wd->blocks, itb)
2507 Eina_Bool showme = EINA_FALSE;
2510 showme = itb->showme;
2511 itb->showme = EINA_FALSE;
2514 if (itb->realized) _item_block_unrealize(itb);
2516 if ((itb->changed) || (changed) ||
2517 ((itb->must_recalc) && (!did_must_recalc)))
2519 if ((changed) || (itb->must_recalc))
2522 Elm_Genlist_Item *it;
2523 EINA_LIST_FOREACH(itb->items, l, it)
2524 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2525 itb->changed = EINA_TRUE;
2526 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2527 itb->must_recalc = EINA_FALSE;
2529 if (itb->realized) _item_block_unrealize(itb);
2530 showme = _item_block_recalc(itb, in, EINA_FALSE);
2536 if (minw == -1) minw = itb->minw;
2537 else if ((!itb->must_recalc) && (minw < itb->minw))
2540 minw_change = EINA_TRUE;
2546 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2548 wd->show_item->showme = EINA_FALSE;
2550 elm_smart_scroller_region_bring_in(wd->scr,
2552 wd->show_item->block->x,
2554 wd->show_item->block->y,
2555 wd->show_item->block->w,
2558 elm_smart_scroller_child_region_show(wd->scr,
2560 wd->show_item->block->x,
2562 wd->show_item->block->y,
2563 wd->show_item->block->w,
2565 wd->show_item = NULL;
2570 EINA_INLIST_FOREACH(wd->blocks, itb)
2576 if ((chb) && (EINA_INLIST_GET(chb)->next))
2578 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2580 if (itb->realized) _item_block_unrealize(itb);
2583 wd->realminw = minw;
2584 if (minw < wd->w) minw = wd->w;
2585 if ((minw != wd->minw) || (minh != wd->minh))
2589 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2590 _sizing_eval(wd->obj);
2591 if ((wd->anchor_item) && (wd->anchor_item->block))
2593 Elm_Genlist_Item *it;
2596 it = wd->anchor_item;
2597 it_y = wd->anchor_y;
2598 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2599 it->block->y + it->y + it_y);
2600 wd->anchor_item = it;
2601 wd->anchor_y = it_y;
2604 t = ecore_time_get();
2605 if (did_must_recalc)
2607 if (!wd->must_recalc_idler)
2608 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2610 wd->calc_job = NULL;
2611 evas_object_smart_changed(wd->pan_smart);
2612 evas_event_thaw(evas_object_evas_get(wd->obj));
2613 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2617 _update_job(void *data)
2619 Widget_Data *wd = data;
2623 Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
2625 wd->update_job = NULL;
2628 evas_event_freeze(evas_object_evas_get(wd->obj));
2629 EINA_INLIST_FOREACH(wd->blocks, itb)
2631 Evas_Coord itminw, itminh;
2632 Elm_Genlist_Item *it;
2638 _item_block_position(itb, num);
2642 recalc = EINA_FALSE;
2643 EINA_LIST_FOREACH(itb->items, l2, it)
2650 it->updateme = EINA_FALSE;
2653 _item_unrealize(it, EINA_FALSE);
2654 _item_realize(it, num, EINA_FALSE);
2655 position = EINA_TRUE;
2659 _item_realize(it, num, EINA_TRUE);
2660 _item_unrealize(it, EINA_TRUE);
2662 if ((it->minw != itminw) || (it->minh != itminh))
2667 itb->updateme = EINA_FALSE;
2670 position = EINA_TRUE;
2671 itb->changed = EINA_TRUE;
2672 _item_block_recalc(itb, num0, EINA_FALSE);
2673 _item_block_position(itb, num0);
2678 if (wd->calc_job) ecore_job_del(wd->calc_job);
2679 wd->calc_job = ecore_job_add(_calc_job, wd);
2681 evas_event_thaw(evas_object_evas_get(wd->obj));
2682 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2686 _pan_set(Evas_Object *obj,
2690 Pan *sd = evas_object_smart_data_get(obj);
2693 // Evas_Coord ow, oh;
2694 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2695 // ow = sd->wd->minw - ow;
2696 // if (ow < 0) ow = 0;
2697 // oh = sd->wd->minh - oh;
2698 // if (oh < 0) oh = 0;
2699 // if (x < 0) x = 0;
2700 // if (y < 0) y = 0;
2701 // if (x > ow) x = ow;
2702 // if (y > oh) y = oh;
2703 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2707 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2709 if ((itb->y + itb->h) > y)
2711 Elm_Genlist_Item *it;
2714 EINA_LIST_FOREACH(itb->items, l2, it)
2716 if ((itb->y + it->y) >= y)
2718 sd->wd->anchor_item = it;
2719 sd->wd->anchor_y = -(itb->y + it->y - y);
2726 if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
2730 _pan_get(Evas_Object *obj,
2734 Pan *sd = evas_object_smart_data_get(obj);
2736 if (x) *x = sd->wd->pan_x;
2737 if (y) *y = sd->wd->pan_y;
2741 _pan_max_get(Evas_Object *obj,
2745 Pan *sd = evas_object_smart_data_get(obj);
2748 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2749 ow = sd->wd->minw - ow;
2751 oh = sd->wd->minh - oh;
2758 _pan_min_get(Evas_Object *obj __UNUSED__,
2767 _pan_child_size_get(Evas_Object *obj,
2771 Pan *sd = evas_object_smart_data_get(obj);
2773 if (w) *w = sd->wd->minw;
2774 if (h) *h = sd->wd->minh;
2778 _pan_add(Evas_Object *obj)
2781 Evas_Object_Smart_Clipped_Data *cd;
2784 cd = evas_object_smart_data_get(obj);
2787 sd->__clipped_data = *cd;
2789 evas_object_smart_data_set(obj, sd);
2793 _pan_del(Evas_Object *obj)
2795 Pan *sd = evas_object_smart_data_get(obj);
2800 ecore_job_del(sd->resize_job);
2801 sd->resize_job = NULL;
2807 _pan_resize_job(void *data)
2810 _sizing_eval(sd->wd->obj);
2811 sd->resize_job = NULL;
2815 _pan_resize(Evas_Object *obj,
2819 Pan *sd = evas_object_smart_data_get(obj);
2822 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2823 if ((ow == w) && (oh == h)) return;
2824 if ((sd->wd->height_for_width) && (ow != w))
2826 if (sd->resize_job) ecore_job_del(sd->resize_job);
2827 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2829 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2830 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2834 _pan_calculate(Evas_Object *obj)
2836 Pan *sd = evas_object_smart_data_get(obj);
2838 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2840 Elm_Genlist_Item *git;
2843 evas_event_freeze(evas_object_evas_get(obj));
2844 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2845 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2846 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2848 git->want_realize = EINA_FALSE;
2850 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2852 itb->w = sd->wd->minw;
2853 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2854 itb->y - sd->wd->pan_y + oy,
2856 cvx, cvy, cvw, cvh))
2858 if ((!itb->realized) || (itb->changed))
2859 _item_block_realize(itb);
2860 _item_block_position(itb, in);
2864 if (itb->realized) _item_block_unrealize(itb);
2868 if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
2869 _group_items_recalc(sd->wd);
2870 if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
2872 if (sd->wd->pan_y != sd->wd->old_pan_y)
2873 sd->wd->reorder_pan_move = EINA_TRUE;
2874 else sd->wd->reorder_pan_move = EINA_FALSE;
2875 evas_object_raise(sd->wd->reorder_it->base.view);
2876 sd->wd->old_pan_y = sd->wd->pan_y;
2877 sd->wd->start_time = ecore_loop_time_get();
2879 evas_event_thaw(evas_object_evas_get(obj));
2880 evas_event_thaw_eval(evas_object_evas_get(obj));
2884 _pan_move(Evas_Object *obj,
2885 Evas_Coord x __UNUSED__,
2886 Evas_Coord y __UNUSED__)
2888 Pan *sd = evas_object_smart_data_get(obj);
2890 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2891 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2895 _hold_on(void *data __UNUSED__,
2897 void *event_info __UNUSED__)
2899 Widget_Data *wd = elm_widget_data_get(obj);
2901 elm_smart_scroller_hold_set(wd->scr, 1);
2905 _hold_off(void *data __UNUSED__,
2907 void *event_info __UNUSED__)
2909 Widget_Data *wd = elm_widget_data_get(obj);
2911 elm_smart_scroller_hold_set(wd->scr, 0);
2915 _freeze_on(void *data __UNUSED__,
2917 void *event_info __UNUSED__)
2919 Widget_Data *wd = elm_widget_data_get(obj);
2921 elm_smart_scroller_freeze_set(wd->scr, 1);
2925 _freeze_off(void *data __UNUSED__,
2927 void *event_info __UNUSED__)
2929 Widget_Data *wd = elm_widget_data_get(obj);
2931 elm_smart_scroller_freeze_set(wd->scr, 0);
2935 _scroll_edge_left(void *data,
2936 Evas_Object *scr __UNUSED__,
2937 void *event_info __UNUSED__)
2939 Evas_Object *obj = data;
2940 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2944 _scroll_edge_right(void *data,
2945 Evas_Object *scr __UNUSED__,
2946 void *event_info __UNUSED__)
2948 Evas_Object *obj = data;
2949 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2953 _scroll_edge_top(void *data,
2954 Evas_Object *scr __UNUSED__,
2955 void *event_info __UNUSED__)
2957 Evas_Object *obj = data;
2958 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2962 _scroll_edge_bottom(void *data,
2963 Evas_Object *scr __UNUSED__,
2964 void *event_info __UNUSED__)
2966 Evas_Object *obj = data;
2967 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2971 _mode_item_realize(Elm_Genlist_Item *it)
2975 if ((it->mode_view) || (it->delete_me)) return;
2977 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2978 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2979 edje_object_scale_set(it->mode_view,
2980 elm_widget_scale_get(it->base.widget) *
2981 _elm_config->scale);
2982 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2983 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2985 strncpy(buf, "item", sizeof(buf));
2986 if (it->wd->compress)
2987 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2989 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2990 strncat(buf, "/", sizeof(buf) - strlen(buf));
2991 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2993 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2994 elm_widget_style_get(it->base.widget));
2995 edje_object_mirrored_set(it->mode_view,
2996 elm_widget_mirrored_get(it->base.widget));
2998 /* signal callback add */
2999 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3001 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3003 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3006 /* label_get, icon_get, state_get */
3007 /* FIXME: If you see that assert, please notify us and we
3008 will clean our mess */
3009 assert(eina_list_count(it->mode_icon_objs) == 0);
3011 _item_label_realize(it, it->mode_view, &it->mode_labels);
3012 it->mode_icon_objs = _item_icon_realize(it,
3015 _item_state_realize(it, it->mode_view, &it->mode_states);
3017 edje_object_part_swallow(it->mode_view,
3018 edje_object_data_get(it->mode_view, "mode_part"),
3021 it->want_unrealize = EINA_FALSE;
3022 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3023 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3027 _mode_item_unrealize(Elm_Genlist_Item *it)
3029 Widget_Data *wd = it->wd;
3031 if (!it->mode_view) return;
3033 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3034 elm_widget_stringlist_free(it->mode_labels);
3035 it->mode_labels = NULL;
3036 elm_widget_stringlist_free(it->mode_icons);
3037 it->mode_icons = NULL;
3038 elm_widget_stringlist_free(it->mode_states);
3040 EINA_LIST_FREE(it->mode_icon_objs, icon)
3041 evas_object_del(icon);
3043 edje_object_part_unswallow(it->mode_view, it->base.view);
3044 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3045 evas_object_del(it->mode_view);
3046 it->mode_view = NULL;
3048 if (wd->mode_item == it)
3049 wd->mode_item = NULL;
3050 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3051 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3055 _item_mode_set(Elm_Genlist_Item *it)
3058 Widget_Data *wd = it->wd;
3063 it->nocache = EINA_TRUE;
3065 if (wd->scr_hold_timer)
3067 ecore_timer_del(wd->scr_hold_timer);
3068 wd->scr_hold_timer = NULL;
3070 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3071 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3073 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3074 _mode_item_realize(it);
3075 _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
3076 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3077 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3079 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3080 edje_object_signal_emit(it->mode_view, buf, "elm");
3084 _item_mode_unset(Widget_Data *wd)
3087 if (!wd->mode_item) return;
3088 char buf[1024], buf2[1024];
3089 Elm_Genlist_Item *it;
3092 it->nocache = EINA_TRUE;
3094 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3095 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3097 edje_object_signal_emit(it->mode_view, buf, "elm");
3098 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3100 wd->mode_item = NULL;
3104 * Add a new Genlist object
3106 * @param parent The parent object
3107 * @return The new object or NULL if it cannot be created
3112 elm_genlist_add(Evas_Object *parent)
3117 Evas_Coord minw, minh;
3118 static Evas_Smart *smart = NULL;
3122 static Evas_Smart_Class sc;
3124 evas_object_smart_clipped_smart_set(&_pan_sc);
3126 sc.name = "elm_genlist_pan";
3127 sc.version = EVAS_SMART_CLASS_VERSION;
3130 sc.resize = _pan_resize;
3131 sc.move = _pan_move;
3132 sc.calculate = _pan_calculate;
3133 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3136 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3138 ELM_SET_WIDTYPE(widtype, "genlist");
3139 elm_widget_type_set(obj, "genlist");
3140 elm_widget_sub_object_add(parent, obj);
3141 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3142 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3143 elm_widget_data_set(obj, wd);
3144 elm_widget_del_hook_set(obj, _del_hook);
3145 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3146 elm_widget_theme_hook_set(obj, _theme_hook);
3147 elm_widget_can_focus_set(obj, EINA_TRUE);
3148 elm_widget_event_hook_set(obj, _event_hook);
3149 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3151 wd->scr = elm_smart_scroller_add(e);
3152 elm_smart_scroller_widget_set(wd->scr, obj);
3153 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3154 elm_widget_style_get(obj));
3155 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3156 _elm_config->thumbscroll_bounce_enable);
3157 elm_widget_resize_object_set(obj, wd->scr);
3159 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3160 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3162 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3163 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3167 wd->mode = ELM_LIST_SCROLL;
3168 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3169 wd->item_cache_max = wd->max_items_per_block * 2;
3170 wd->longpress_timeout = _elm_config->longpress_timeout;
3172 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3173 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3174 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3175 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3177 wd->pan_smart = evas_object_smart_add(e, smart);
3178 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3181 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3182 _pan_set, _pan_get, _pan_max_get,
3183 _pan_min_get, _pan_child_size_get);
3185 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3187 evas_object_size_hint_min_set(obj, minw, minh);
3189 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3191 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3196 static Elm_Genlist_Item *
3197 _item_new(Widget_Data *wd,
3198 const Elm_Genlist_Item_Class *itc,
3200 Elm_Genlist_Item *parent,
3201 Elm_Genlist_Item_Flags flags,
3203 const void *func_data)
3205 Elm_Genlist_Item *it;
3207 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3208 if (!it) return NULL;
3211 it->base.data = data;
3212 it->parent = parent;
3214 it->func.func = func;
3215 it->func.data = func_data;
3216 it->mouse_cursor = NULL;
3217 it->expanded_depth = 0;
3222 _item_block_add(Widget_Data *wd,
3223 Elm_Genlist_Item *it)
3225 Item_Block *itb = NULL;
3232 itb = calloc(1, sizeof(Item_Block));
3235 if (!it->rel->block)
3238 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3239 itb->items = eina_list_append(itb->items, it);
3245 wd->blocks = eina_inlist_prepend_relative
3246 (wd->blocks, EINA_INLIST_GET(itb),
3247 EINA_INLIST_GET(it->rel->block));
3249 eina_list_prepend_relative(itb->items, it, it->rel);
3253 wd->blocks = eina_inlist_append_relative
3254 (wd->blocks, EINA_INLIST_GET(itb),
3255 EINA_INLIST_GET(it->rel->block));
3257 eina_list_append_relative(itb->items, it, it->rel);
3267 itb = (Item_Block *)(wd->blocks);
3268 if (itb->count >= wd->max_items_per_block)
3270 itb = calloc(1, sizeof(Item_Block));
3274 eina_inlist_prepend(wd->blocks,
3275 EINA_INLIST_GET(itb));
3280 itb = calloc(1, sizeof(Item_Block));
3284 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3286 itb->items = eina_list_prepend(itb->items, it);
3292 itb = (Item_Block *)(wd->blocks->last);
3293 if (itb->count >= wd->max_items_per_block)
3295 itb = calloc(1, sizeof(Item_Block));
3299 eina_inlist_append(wd->blocks,
3300 EINA_INLIST_GET(itb));
3305 itb = calloc(1, sizeof(Item_Block));
3309 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3311 itb->items = eina_list_append(itb->items, it);
3317 itb = it->rel->block;
3318 if (!itb) goto newblock;
3320 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3322 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3325 itb->changed = EINA_TRUE;
3327 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3328 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3331 it->rel->relcount--;
3332 if ((it->rel->delete_me) && (!it->rel->relcount))
3336 if (itb->count > itb->wd->max_items_per_block)
3340 Elm_Genlist_Item *it2;
3342 newc = itb->count / 2;
3343 itb2 = calloc(1, sizeof(Item_Block));
3347 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3348 EINA_INLIST_GET(itb));
3349 itb2->changed = EINA_TRUE;
3350 while ((itb->count > newc) && (itb->items))
3354 l = eina_list_last(itb->items);
3356 itb->items = eina_list_remove_list(itb->items, l);
3359 itb2->items = eina_list_prepend(itb2->items, it2);
3367 _queue_process(Widget_Data *wd)
3370 Eina_Bool showme = EINA_FALSE;
3373 t0 = ecore_time_get();
3374 //evas_event_freeze(evas_object_evas_get(wd->obj));
3375 for (n = 0; (wd->queue) && (n < 128); n++)
3377 Elm_Genlist_Item *it;
3379 it = wd->queue->data;
3380 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3381 it->queued = EINA_FALSE;
3382 _item_block_add(wd, it);
3383 t = ecore_time_get();
3384 if (it->block->changed)
3386 showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
3387 it->block->changed = 0;
3389 if (showme) it->block->showme = EINA_TRUE;
3390 if (eina_inlist_count(wd->blocks) > 1)
3392 if ((t - t0) > (ecore_animator_frametime_get())) break;
3395 //evas_event_thaw(evas_object_evas_get(wd->obj));
3396 //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3401 _idle_process(void *data, Eina_Bool *wakeup)
3403 Widget_Data *wd = data;
3406 //static double q_start = 0.0;
3407 //if (q_start == 0.0) q_start = ecore_time_get();
3409 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3413 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3415 return ECORE_CALLBACK_CANCEL;
3417 return ECORE_CALLBACK_RENEW;
3421 _item_idle_enterer(void *data)
3423 Widget_Data *wd = data;
3424 Eina_Bool wakeup = EINA_FALSE;
3425 Eina_Bool ok = _idle_process(data, &wakeup);
3430 if (wd->calc_job) ecore_job_del(wd->calc_job);
3431 wd->calc_job = ecore_job_add(_calc_job, wd);
3433 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3438 _item_queue(Widget_Data *wd,
3439 Elm_Genlist_Item *it)
3441 if (it->queued) return;
3442 it->queued = EINA_TRUE;
3443 wd->queue = eina_list_append(wd->queue, it);
3444 // FIXME: why does a freeze then thaw here cause some genlist
3445 // elm_genlist_item_append() to be much much slower?
3446 // evas_event_freeze(evas_object_evas_get(wd->obj));
3447 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3449 if (wd->queue_idle_enterer)
3451 ecore_idle_enterer_del(wd->queue_idle_enterer);
3452 wd->queue_idle_enterer = NULL;
3456 // evas_event_thaw(evas_object_evas_get(wd->obj));
3457 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3458 if (!wd->queue_idle_enterer)
3459 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3463 _elm_genlist_item_compare(const void *data, const void *data1)
3465 Elm_Genlist_Item *item, *item1;
3466 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3467 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3468 return _elm_genlist_item_compare_cb(item->base.data, item1->base.data);
3472 _item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3477 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3478 _item_block_del(it);
3480 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
3482 it->rel->relcount++;
3483 it->before = EINA_FALSE;
3484 if (after->group_item) it->group_item = after->group_item;
3485 _item_queue(it->wd, it);
3487 if (it->itc->func.moved)
3488 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
3492 _item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
3495 if (!before) return;
3497 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3498 _item_block_del(it);
3499 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
3501 it->rel->relcount++;
3502 it->before = EINA_TRUE;
3503 if (before->group_item) it->group_item = before->group_item;
3504 _item_queue(it->wd, it);
3506 if (it->itc->func.moved)
3507 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
3511 * Append item to the end of the genlist
3513 * This appends the given item to the end of the list or the end of
3514 * the children if the parent is given.
3516 * @param obj The genlist object
3517 * @param itc The item class for the item
3518 * @param data The item data
3519 * @param parent The parent item, or NULL if none
3520 * @param flags Item flags
3521 * @param func Convenience function called when item selected
3522 * @param func_data Data passed to @p func above.
3523 * @return A handle to the item added or NULL if not possible
3527 EAPI Elm_Genlist_Item *
3528 elm_genlist_item_append(Evas_Object *obj,
3529 const Elm_Genlist_Item_Class *itc,
3531 Elm_Genlist_Item *parent,
3532 Elm_Genlist_Item_Flags flags,
3534 const void *func_data)
3536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3537 Widget_Data *wd = elm_widget_data_get(obj);
3538 if (!wd) return NULL;
3539 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3541 if (!it) return NULL;
3544 if (flags & ELM_GENLIST_ITEM_GROUP)
3545 wd->group_items = eina_list_append(wd->group_items, it);
3546 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3551 Elm_Genlist_Item *it2 = NULL;
3552 Eina_List *ll = eina_list_last(it->parent->items);
3553 if (ll) it2 = ll->data;
3554 it->parent->items = eina_list_append(it->parent->items, it);
3555 if (!it2) it2 = it->parent;
3557 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3558 EINA_INLIST_GET(it2));
3560 it->rel->relcount++;
3562 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3563 it->group_item = parent;
3564 else if (it->parent->group_item)
3565 it->group_item = it->parent->group_item;
3567 it->before = EINA_FALSE;
3568 _item_queue(wd, it);
3573 * Prepend item at start of the genlist
3575 * This adds an item to the beginning of the list or beginning of the
3576 * children of the parent if given.
3578 * @param obj The genlist object
3579 * @param itc The item class for the item
3580 * @param data The item data
3581 * @param parent The parent item, or NULL if none
3582 * @param flags Item flags
3583 * @param func Convenience function called when item selected
3584 * @param func_data Data passed to @p func above.
3585 * @return A handle to the item added or NULL if not possible
3589 EAPI Elm_Genlist_Item *
3590 elm_genlist_item_prepend(Evas_Object *obj,
3591 const Elm_Genlist_Item_Class *itc,
3593 Elm_Genlist_Item *parent,
3594 Elm_Genlist_Item_Flags flags,
3596 const void *func_data)
3598 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3599 Widget_Data *wd = elm_widget_data_get(obj);
3600 if (!wd) return NULL;
3601 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3603 if (!it) return NULL;
3606 if (flags & ELM_GENLIST_ITEM_GROUP)
3607 wd->group_items = eina_list_prepend(wd->group_items, it);
3608 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3613 Elm_Genlist_Item *it2 = NULL;
3614 Eina_List *ll = it->parent->items;
3615 if (ll) it2 = ll->data;
3616 it->parent->items = eina_list_prepend(it->parent->items, it);
3617 if (!it2) it2 = it->parent;
3619 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3620 EINA_INLIST_GET(it2));
3622 it->rel->relcount++;
3624 it->before = EINA_TRUE;
3625 _item_queue(wd, it);
3630 * Insert item before another in the genlist
3632 * This inserts an item before another in the list. It will be in the
3633 * same tree level or group as the item it is inseted before.
3635 * @param obj The genlist object
3636 * @param itc The item class for the item
3637 * @param data The item data
3638 * @param before The item to insert before
3639 * @param flags Item flags
3640 * @param func Convenience function called when item selected
3641 * @param func_data Data passed to @p func above.
3642 * @return A handle to the item added or NULL if not possible
3646 EAPI Elm_Genlist_Item *
3647 elm_genlist_item_insert_before(Evas_Object *obj,
3648 const Elm_Genlist_Item_Class *itc,
3650 Elm_Genlist_Item *parent,
3651 Elm_Genlist_Item *before,
3652 Elm_Genlist_Item_Flags flags,
3654 const void *func_data)
3656 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3657 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3658 Widget_Data *wd = elm_widget_data_get(obj);
3659 if (!wd) return NULL;
3660 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3662 if (!it) return NULL;
3665 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3668 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3669 EINA_INLIST_GET(before));
3671 it->rel->relcount++;
3672 it->before = EINA_TRUE;
3673 _item_queue(wd, it);
3678 * Insert a new item into the sorted genlist object
3680 * @param obj The genlist object
3681 * @param itc The item class for the item
3682 * @param data The item data
3683 * @param parent The parent item, or NULL if none
3684 * @param flags Item flags
3685 * @param comp The function called for the sort
3686 * @param func Convenience function called when item selected
3687 * @param func_data Data passed to @p func above.
3688 * @return A handle to the item added or NULL if not possible
3692 EAPI Elm_Genlist_Item *
3693 elm_genlist_item_sorted_insert(Evas_Object *obj,
3694 const Elm_Genlist_Item_Class *itc,
3696 Elm_Genlist_Item *parent,
3697 Elm_Genlist_Item_Flags flags,
3698 Eina_Compare_Cb comp,
3700 const void *func_data)
3702 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3703 Widget_Data *wd = elm_widget_data_get(obj);
3704 if (!wd) return NULL;
3705 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3707 if (!it) return NULL;
3709 _elm_genlist_item_compare_cb = comp;
3713 eina_list_sorted_insert(it->parent->items, comp, it);
3715 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3716 _elm_genlist_item_compare);
3717 if (EINA_INLIST_GET(it)->next)
3719 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3720 it->rel->relcount++;
3721 it->before = EINA_TRUE;
3723 else if (EINA_INLIST_GET(it)->prev)
3725 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3726 it->rel->relcount++;
3727 it->before = EINA_FALSE;
3729 _item_queue(wd, it);
3735 * Insert an item after another in the genlst
3737 * This inserts an item after another in the list. It will be in the
3738 * same tree level or group as the item it is inseted after.
3740 * @param obj The genlist object
3741 * @param itc The item class for the item
3742 * @param data The item data
3743 * @param after The item to insert after
3744 * @param flags Item flags
3745 * @param func Convenience function called when item selected
3746 * @param func_data Data passed to @p func above.
3747 * @return A handle to the item added or NULL if not possible
3751 EAPI Elm_Genlist_Item *
3752 elm_genlist_item_insert_after(Evas_Object *obj,
3753 const Elm_Genlist_Item_Class *itc,
3755 Elm_Genlist_Item *parent,
3756 Elm_Genlist_Item *after,
3757 Elm_Genlist_Item_Flags flags,
3759 const void *func_data)
3761 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3762 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3763 Widget_Data *wd = elm_widget_data_get(obj);
3764 if (!wd) return NULL;
3765 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3767 if (!it) return NULL;
3768 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3769 EINA_INLIST_GET(after));
3772 it->parent->items = eina_list_append_relative(it->parent->items, it,
3776 it->rel->relcount++;
3777 it->before = EINA_FALSE;
3778 _item_queue(wd, it);
3785 * This clears all items in the list, leaving it empty.
3787 * @param obj The genlist object
3792 elm_genlist_clear(Evas_Object *obj)
3794 ELM_CHECK_WIDTYPE(obj, widtype);
3795 Widget_Data *wd = elm_widget_data_get(obj);
3797 if (wd->walking > 0)
3799 Elm_Genlist_Item *it;
3801 wd->clear_me = EINA_TRUE;
3802 EINA_INLIST_FOREACH(wd->items, it)
3804 it->delete_me = EINA_TRUE;
3808 evas_event_freeze(evas_object_evas_get(wd->obj));
3811 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3813 if (wd->anchor_item == it)
3815 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3816 if (!wd->anchor_item)
3818 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3820 wd->items = eina_inlist_remove(wd->items, wd->items);
3821 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3822 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3823 elm_widget_item_pre_notify_del(it);
3824 if (it->realized) _item_unrealize(it, EINA_FALSE);
3825 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3826 it->itc->func.del((void *)it->base.data, it->base.widget);
3827 if (it->long_timer) ecore_timer_del(it->long_timer);
3828 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3829 elm_widget_item_del(it);
3831 wd->clear_me = EINA_FALSE;
3832 wd->anchor_item = NULL;
3835 Item_Block *itb = (Item_Block *)(wd->blocks);
3837 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3838 if (itb->items) eina_list_free(itb->items);
3843 ecore_job_del(wd->calc_job);
3844 wd->calc_job = NULL;
3846 if (wd->queue_idle_enterer)
3848 ecore_idle_enterer_del(wd->queue_idle_enterer);
3849 wd->queue_idle_enterer = NULL;
3851 if (wd->must_recalc_idler)
3853 ecore_idler_del(wd->must_recalc_idler);
3854 wd->must_recalc_idler = NULL;
3858 eina_list_free(wd->queue);
3863 eina_list_free(wd->selected);
3864 wd->selected = NULL;
3866 if (wd->reorder_move_animator)
3868 ecore_animator_del(wd->reorder_move_animator);
3869 wd->reorder_move_animator = NULL;
3871 wd->show_item = NULL;
3879 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3880 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3883 evas_event_thaw(evas_object_evas_get(wd->obj));
3884 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3888 * Enable or disable multi-select in the genlist
3890 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3891 * the list. This allows more than 1 item to be selected.
3893 * @param obj The genlist object
3894 * @param multi Multi-select enable/disable
3899 elm_genlist_multi_select_set(Evas_Object *obj,
3902 ELM_CHECK_WIDTYPE(obj, widtype);
3903 Widget_Data *wd = elm_widget_data_get(obj);
3909 * Gets if multi-select in genlist is enable or disable
3911 * @param obj The genlist object
3912 * @return Multi-select enable/disable
3913 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3918 elm_genlist_multi_select_get(const Evas_Object *obj)
3920 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3921 Widget_Data *wd = elm_widget_data_get(obj);
3922 if (!wd) return EINA_FALSE;
3927 * Get the selectd item in the genlist
3929 * This gets the selected item in the list (if multi-select is enabled
3930 * only the first item in the list is selected - which is not very
3931 * useful, so see elm_genlist_selected_items_get() for when
3932 * multi-select is used).
3934 * If no item is selected, NULL is returned.
3936 * @param obj The genlist object
3937 * @return The selected item, or NULL if none.
3941 EAPI Elm_Genlist_Item *
3942 elm_genlist_selected_item_get(const Evas_Object *obj)
3944 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3945 Widget_Data *wd = elm_widget_data_get(obj);
3946 if (!wd) return NULL;
3947 if (wd->selected) return wd->selected->data;
3952 * Get a list of selected items in the genlist
3954 * This returns a list of the selected items. This list pointer is
3955 * only valid so long as no items are selected or unselected (or
3956 * unselected implicitly by deletion). The list contains
3957 * Elm_Genlist_Item pointers.
3959 * @param obj The genlist object
3960 * @return The list of selected items, nor NULL if none are selected.
3964 EAPI const Eina_List *
3965 elm_genlist_selected_items_get(const Evas_Object *obj)
3967 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3968 Widget_Data *wd = elm_widget_data_get(obj);
3969 if (!wd) return NULL;
3970 return wd->selected;
3974 * Get a list of realized items in genlist
3976 * This returns a list of the realized items in the genlist. The list
3977 * contains Elm_Genlist_Item pointers. The list must be freed by the
3978 * caller when done with eina_list_free(). The item pointers in the
3979 * list are only valid so long as those items are not deleted or the
3980 * genlist is not deleted.
3982 * @param obj The genlist object
3983 * @return The list of realized items, nor NULL if none are realized.
3988 elm_genlist_realized_items_get(const Evas_Object *obj)
3990 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3991 Widget_Data *wd = elm_widget_data_get(obj);
3992 Eina_List *list = NULL;
3994 Eina_Bool done = EINA_FALSE;
3995 if (!wd) return NULL;
3996 EINA_INLIST_FOREACH(wd->blocks, itb)
4001 Elm_Genlist_Item *it;
4004 EINA_LIST_FOREACH(itb->items, l, it)
4006 if (it->realized) list = eina_list_append(list, it);
4018 * Get the item that is at the x, y canvas coords
4020 * This returns the item at the given coordinates (which are canvas
4021 * relative not object-relative). If an item is at that coordinate,
4022 * that item handle is returned, and if @p posret is not NULL, the
4023 * integer pointed to is set to a value of -1, 0 or 1, depending if
4024 * the coordinate is on the upper portion of that item (-1), on the
4025 * middle section (0) or on the lower part (1). If NULL is returned as
4026 * an item (no item found there), then posret may indicate -1 or 1
4027 * based if the coordinate is above or below all items respectively in
4030 * @param it The item
4031 * @param x The input x coordinate
4032 * @param y The input y coordinate
4033 * @param posret The position relative to the item returned here
4034 * @return The item at the coordinates or NULL if none
4038 EAPI Elm_Genlist_Item *
4039 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4044 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4045 Widget_Data *wd = elm_widget_data_get(obj);
4046 Evas_Coord ox, oy, ow, oh;
4049 if (!wd) return NULL;
4050 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4052 EINA_INLIST_FOREACH(wd->blocks, itb)
4055 Elm_Genlist_Item *it;
4057 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4058 oy + itb->y - itb->wd->pan_y,
4059 itb->w, itb->h, x, y, 1, 1))
4061 EINA_LIST_FOREACH(itb->items, l, it)
4063 Evas_Coord itx, ity;
4065 itx = ox + itb->x + it->x - itb->wd->pan_x;
4066 ity = oy + itb->y + it->y - itb->wd->pan_y;
4067 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4071 if (y <= (ity + (it->h / 4))) *posret = -1;
4072 else if (y >= (ity + it->h - (it->h / 4)))
4078 lasty = ity + it->h;
4083 if (y > lasty) *posret = 1;
4090 * Get the first item in the genlist
4092 * This returns the first item in the list.
4094 * @param obj The genlist object
4095 * @return The first item, or NULL if none
4099 EAPI Elm_Genlist_Item *
4100 elm_genlist_first_item_get(const Evas_Object *obj)
4102 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4103 Widget_Data *wd = elm_widget_data_get(obj);
4104 if (!wd) return NULL;
4105 if (!wd->items) return NULL;
4106 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4107 while ((it) && (it->delete_me))
4108 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4113 * Get the last item in the genlist
4115 * This returns the last item in the list.
4117 * @return The last item, or NULL if none
4121 EAPI Elm_Genlist_Item *
4122 elm_genlist_last_item_get(const Evas_Object *obj)
4124 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4125 Widget_Data *wd = elm_widget_data_get(obj);
4126 if (!wd) return NULL;
4127 if (!wd->items) return NULL;
4128 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4129 while ((it) && (it->delete_me))
4130 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4135 * Get the next item in the genlist
4137 * This returns the item after the item @p it.
4139 * @param it The item
4140 * @return The item after @p it, or NULL if none
4144 EAPI Elm_Genlist_Item *
4145 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4147 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4150 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4151 if ((it) && (!it->delete_me)) break;
4153 return (Elm_Genlist_Item *)it;
4157 * Get the previous item in the genlist
4159 * This returns the item before the item @p it.
4161 * @param it The item
4162 * @return The item before @p it, or NULL if none
4166 EAPI Elm_Genlist_Item *
4167 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4169 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4172 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4173 if ((it) && (!it->delete_me)) break;
4175 return (Elm_Genlist_Item *)it;
4179 * Get the genlist object from an item
4181 * This returns the genlist object itself that an item belongs to.
4183 * @param it The item
4184 * @return The genlist object
4189 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4191 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4192 return it->base.widget;
4196 * Get the parent item of the given item
4198 * This returns the parent item of the item @p it given.
4200 * @param it The item
4201 * @return The parent of the item or NULL if none
4205 EAPI Elm_Genlist_Item *
4206 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4208 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4213 * Clear all sub-items (children) of the given item
4215 * This clears all items that are children (or their descendants) of the
4218 * @param it The item
4223 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4225 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4226 Eina_List *tl = NULL, *l;
4227 Elm_Genlist_Item *it2;
4229 EINA_LIST_FOREACH(it->items, l, it2)
4230 tl = eina_list_append(tl, it2);
4231 EINA_LIST_FREE(tl, it2)
4232 elm_genlist_item_del(it2);
4236 * Set the selected state of an item
4238 * This sets the selected state (1 selected, 0 not selected) of the given
4241 * @param it The item
4242 * @param selected The selected state
4247 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4250 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4251 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4253 if ((it->delete_me) || (it->disabled)) return;
4254 selected = !!selected;
4255 if (it->selected == selected) return;
4261 while (wd->selected)
4263 _item_unhighlight(wd->selected->data);
4264 _item_unselect(wd->selected->data);
4267 _item_highlight(it);
4272 _item_unhighlight(it);
4278 * Get the selected state of an item
4280 * This gets the selected state of an item (1 selected, 0 not selected).
4282 * @param it The item
4283 * @return The selected state
4288 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4290 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4291 return it->selected;
4295 * Sets the expanded state of an item (if it's a parent)
4297 * This expands or contracts a parent item (thus showing or hiding the
4300 * @param it The item
4301 * @param expanded The expanded state (1 expanded, 0 not expanded).
4306 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4310 if (it->expanded == expanded) return;
4311 it->expanded = expanded;
4315 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4316 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4321 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4322 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4327 * Get the expanded state of an item
4329 * This gets the expanded state of an item
4331 * @param it The item
4332 * @return Thre expanded state
4337 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4340 return it->expanded;
4344 * Get the depth of expanded item
4346 * @param it The genlist item object
4347 * @return The depth of expanded item
4352 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4355 return it->expanded_depth;
4359 * Sets the disabled state of an item.
4361 * A disabled item cannot be selected or unselected. It will also
4362 * change appearance to appear disabled. This sets the disabled state
4363 * (1 disabled, 0 not disabled).
4365 * @param it The item
4366 * @param disabled The disabled state
4371 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4374 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4377 if (it->disabled == disabled) return;
4378 if (it->delete_me) return;
4379 it->disabled = !!disabled;
4381 elm_genlist_item_selected_set(it, EINA_FALSE);
4385 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4387 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4388 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4389 elm_widget_disabled_set(obj, disabled);
4394 * Get the disabled state of an item
4396 * This gets the disabled state of the given item.
4398 * @param it The item
4399 * @return The disabled state
4404 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4406 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4407 if (it->delete_me) return EINA_FALSE;
4408 return it->disabled;
4412 * Sets the display only state of an item.
4414 * A display only item cannot be selected or unselected. It is for
4415 * display only and not selecting or otherwise clicking, dragging
4416 * etc. by the user, thus finger size rules will not be applied to
4419 * @param it The item
4420 * @param display_only The display only state
4425 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4426 Eina_Bool display_only)
4428 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4429 if (it->display_only == display_only) return;
4430 if (it->delete_me) return;
4431 it->display_only = display_only;
4432 it->mincalcd = EINA_FALSE;
4433 it->updateme = EINA_TRUE;
4434 if (it->block) it->block->updateme = EINA_TRUE;
4435 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4436 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4440 * Get the display only state of an item
4442 * This gets the display only state of the given item.
4444 * @param it The item
4445 * @return The display only state
4450 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4452 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4453 if (it->delete_me) return EINA_FALSE;
4454 return it->display_only;
4458 * Show the given item
4460 * This causes genlist to jump to the given item @p it and show it (by
4461 * scrolling), if it is not fully visible.
4463 * @param it The item
4468 elm_genlist_item_show(Elm_Genlist_Item *it)
4470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4471 Evas_Coord gith = 0;
4472 if (it->delete_me) return;
4473 if ((it->queued) || (!it->mincalcd))
4475 it->wd->show_item = it;
4476 it->wd->bring_in = EINA_TRUE;
4477 it->showme = EINA_TRUE;
4480 if (it->wd->show_item)
4482 it->wd->show_item->showme = EINA_FALSE;
4483 it->wd->show_item = NULL;
4485 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4486 gith = it->group_item->h;
4487 elm_smart_scroller_child_region_show(it->wd->scr,
4488 it->x + it->block->x,
4489 it->y + it->block->y - gith,
4490 it->block->w, it->h);
4494 * Bring in the given item
4496 * This causes genlist to jump to the given item @p it and show it (by
4497 * scrolling), if it is not fully visible. This may use animation to
4498 * do so and take a period of time
4500 * @param it The item
4505 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4507 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4508 Evas_Coord gith = 0;
4509 if (it->delete_me) return;
4510 if ((it->queued) || (!it->mincalcd))
4512 it->wd->show_item = it;
4513 it->wd->bring_in = EINA_TRUE;
4514 it->showme = EINA_TRUE;
4517 if (it->wd->show_item)
4519 it->wd->show_item->showme = EINA_FALSE;
4520 it->wd->show_item = NULL;
4522 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4523 gith = it->group_item->h;
4524 elm_smart_scroller_region_bring_in(it->wd->scr,
4525 it->x + it->block->x,
4526 it->y + it->block->y - gith,
4527 it->block->w, it->h);
4531 * Show the given item at the top
4533 * This causes genlist to jump to the given item @p it and show it (by
4534 * scrolling), if it is not fully visible.
4536 * @param it The item
4541 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4543 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4545 Evas_Coord gith = 0;
4547 if (it->delete_me) return;
4548 if ((it->queued) || (!it->mincalcd))
4550 it->wd->show_item = it;
4551 it->wd->bring_in = EINA_TRUE;
4552 it->showme = EINA_TRUE;
4555 if (it->wd->show_item)
4557 it->wd->show_item->showme = EINA_FALSE;
4558 it->wd->show_item = NULL;
4560 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4561 if (it->group_item) gith = it->group_item->h;
4562 elm_smart_scroller_child_region_show(it->wd->scr,
4563 it->x + it->block->x,
4564 it->y + it->block->y - gith,
4569 * Bring in the given item at the top
4571 * This causes genlist to jump to the given item @p it and show it (by
4572 * scrolling), if it is not fully visible. This may use animation to
4573 * do so and take a period of time
4575 * @param it The item
4580 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4582 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4584 Evas_Coord gith = 0;
4586 if (it->delete_me) return;
4587 if ((it->queued) || (!it->mincalcd))
4589 it->wd->show_item = it;
4590 it->wd->bring_in = EINA_TRUE;
4591 it->showme = EINA_TRUE;
4594 if (it->wd->show_item)
4596 it->wd->show_item->showme = EINA_FALSE;
4597 it->wd->show_item = NULL;
4599 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4600 if (it->group_item) gith = it->group_item->h;
4601 elm_smart_scroller_region_bring_in(it->wd->scr,
4602 it->x + it->block->x,
4603 it->y + it->block->y - gith,
4608 * Show the given item at the middle
4610 * This causes genlist to jump to the given item @p it and show it (by
4611 * scrolling), if it is not fully visible.
4613 * @param it The item
4618 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4620 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4623 if (it->delete_me) return;
4624 if ((it->queued) || (!it->mincalcd))
4626 it->wd->show_item = it;
4627 it->wd->bring_in = EINA_TRUE;
4628 it->showme = EINA_TRUE;
4631 if (it->wd->show_item)
4633 it->wd->show_item->showme = EINA_FALSE;
4634 it->wd->show_item = NULL;
4636 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4637 elm_smart_scroller_child_region_show(it->wd->scr,
4638 it->x + it->block->x,
4639 it->y + it->block->y - oh / 2 +
4640 it->h / 2, it->block->w, oh);
4644 * Bring in the given item at the middle
4646 * This causes genlist to jump to the given item @p it and show it (by
4647 * scrolling), if it is not fully visible. This may use animation to
4648 * do so and take a period of time
4650 * @param it The item
4655 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4657 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4660 if (it->delete_me) return;
4661 if ((it->queued) || (!it->mincalcd))
4663 it->wd->show_item = it;
4664 it->wd->bring_in = EINA_TRUE;
4665 it->showme = EINA_TRUE;
4668 if (it->wd->show_item)
4670 it->wd->show_item->showme = EINA_FALSE;
4671 it->wd->show_item = NULL;
4673 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4674 elm_smart_scroller_region_bring_in(it->wd->scr,
4675 it->x + it->block->x,
4676 it->y + it->block->y - oh / 2 + it->h / 2,
4681 * Delete a given item
4683 * This deletes the item from genlist and calls the genlist item del
4684 * class callback defined in the item class, if it is set. This clears all
4685 * subitems if it is a tree.
4687 * @param it The item
4692 elm_genlist_item_del(Elm_Genlist_Item *it)
4694 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4695 if ((it->relcount > 0) || (it->walking > 0))
4697 elm_widget_item_pre_notify_del(it);
4698 elm_genlist_item_subitems_clear(it);
4699 it->delete_me = EINA_TRUE;
4700 if (it->wd->show_item == it) it->wd->show_item = NULL;
4702 it->wd->selected = eina_list_remove(it->wd->selected,
4706 if (it->realized) _item_unrealize(it, EINA_FALSE);
4707 it->block->changed = EINA_TRUE;
4708 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4709 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4711 if (it->itc->func.del)
4712 it->itc->func.del((void *)it->base.data, it->base.widget);
4719 * Set the data item from the genlist item
4721 * This set the data value passed on the elm_genlist_item_append() and
4722 * related item addition calls. This function will also call
4723 * elm_genlist_item_update() so the item will be updated to reflect the
4726 * @param it The item
4727 * @param data The new data pointer to set
4732 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4735 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4736 elm_widget_item_data_set(it, data);
4737 elm_genlist_item_update(it);
4741 * Get the data item from the genlist item
4743 * This returns the data value passed on the elm_genlist_item_append()
4744 * and related item addition calls and elm_genlist_item_data_set().
4746 * @param it The item
4747 * @return The data pointer provided when created
4752 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4754 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4755 return elm_widget_item_data_get(it);
4759 * Tells genlist to "orphan" icons fetchs by the item class
4761 * This instructs genlist to release references to icons in the item,
4762 * meaning that they will no longer be managed by genlist and are
4763 * floating "orphans" that can be re-used elsewhere if the user wants
4766 * @param it The item
4771 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4774 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4775 EINA_LIST_FREE(it->icon_objs, icon)
4777 elm_widget_sub_object_del(it->base.widget, icon);
4778 evas_object_smart_member_del(icon);
4779 evas_object_hide(icon);
4784 * Get the real evas object of the genlist item
4786 * This returns the actual evas object used for the specified genlist
4787 * item. This may be NULL as it may not be created, and may be deleted
4788 * at any time by genlist. Do not modify this object (move, resize,
4789 * show, hide etc.) as genlist is controlling it. This function is for
4790 * querying, emitting custom signals or hooking lower level callbacks
4791 * for events. Do not delete this object under any circumstances.
4793 * @param it The item
4794 * @return The object pointer
4798 EAPI const Evas_Object *
4799 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4801 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4802 return it->base.view;
4806 * Update the contents of an item
4808 * This updates an item by calling all the item class functions again
4809 * to get the icons, labels and states. Use this when the original
4810 * item data has changed and the changes are desired to be reflected.
4812 * @param it The item
4817 elm_genlist_item_update(Elm_Genlist_Item *it)
4819 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4820 if (!it->block) return;
4821 if (it->delete_me) return;
4822 it->mincalcd = EINA_FALSE;
4823 it->updateme = EINA_TRUE;
4824 it->block->updateme = EINA_TRUE;
4825 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4826 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4830 * Update the item class of an item
4832 * @param it The item
4833 * @parem itc The item class for the item
4838 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4839 const Elm_Genlist_Item_Class *itc)
4841 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4842 if (!it->block) return;
4843 EINA_SAFETY_ON_NULL_RETURN(itc);
4844 if (it->delete_me) return;
4846 it->nocache = EINA_TRUE;
4847 elm_genlist_item_update(it);
4850 static Evas_Object *
4851 _elm_genlist_item_label_create(void *data,
4853 void *item __UNUSED__)
4855 Evas_Object *label = elm_label_add(obj);
4858 elm_object_style_set(label, "tooltip");
4859 elm_label_label_set(label, data);
4864 _elm_genlist_item_label_del_cb(void *data,
4865 Evas_Object *obj __UNUSED__,
4866 void *event_info __UNUSED__)
4868 eina_stringshare_del(data);
4872 * Set the text to be shown in the genlist item.
4874 * @param item Target item
4875 * @param text The text to set in the content
4877 * Setup the text as tooltip to object. The item can have only one
4878 * tooltip, so any previous tooltip data is removed.
4883 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4886 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4887 text = eina_stringshare_add(text);
4888 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4890 _elm_genlist_item_label_del_cb);
4894 * Set the content to be shown in the tooltip item
4896 * Setup the tooltip to item. The item can have only one tooltip, so
4897 * any previous tooltip data is removed. @p func(with @p data) will be
4898 * called every time that need to show the tooltip and it should return a
4899 * valid Evas_Object. This object is then managed fully by tooltip
4900 * system and is deleted when the tooltip is gone.
4902 * @param item the genlist item being attached by a tooltip.
4903 * @param func the function used to create the tooltip contents.
4904 * @param data what to provide to @a func as callback data/context.
4905 * @param del_cb called when data is not needed anymore, either when
4906 * another callback replaces @func, the tooltip is unset with
4907 * elm_genlist_item_tooltip_unset() or the owner @a item
4908 * dies. This callback receives as the first parameter the
4909 * given @a data, and @c event_info is the item.
4914 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4915 Elm_Tooltip_Item_Content_Cb func,
4917 Evas_Smart_Cb del_cb)
4919 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4921 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4924 if (item->tooltip.del_cb)
4925 item->tooltip.del_cb((void *)item->tooltip.data,
4926 item->base.widget, item);
4928 item->tooltip.content_cb = func;
4929 item->tooltip.data = data;
4930 item->tooltip.del_cb = del_cb;
4932 if (item->base.view)
4934 elm_widget_item_tooltip_content_cb_set(item,
4935 item->tooltip.content_cb,
4936 item->tooltip.data, NULL);
4937 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4943 if (del_cb) del_cb((void *)data, NULL, NULL);
4947 * Unset tooltip from item
4949 * @param item genlist item to remove previously set tooltip.
4951 * Remove tooltip from item. The callback provided as del_cb to
4952 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4953 * it is not used anymore.
4955 * @see elm_genlist_item_tooltip_content_cb_set()
4960 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4962 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4963 if ((item->base.view) && (item->tooltip.content_cb))
4964 elm_widget_item_tooltip_unset(item);
4966 if (item->tooltip.del_cb)
4967 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4968 item->tooltip.del_cb = NULL;
4969 item->tooltip.content_cb = NULL;
4970 item->tooltip.data = NULL;
4971 if (item->tooltip.style)
4972 elm_genlist_item_tooltip_style_set(item, NULL);
4976 * Sets a different style for this item tooltip.
4978 * @note before you set a style you should define a tooltip with
4979 * elm_genlist_item_tooltip_content_cb_set() or
4980 * elm_genlist_item_tooltip_text_set()
4982 * @param item genlist item with tooltip already set.
4983 * @param style the theme style to use (default, transparent, ...)
4988 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4991 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4992 eina_stringshare_replace(&item->tooltip.style, style);
4993 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4997 * Get the style for this item tooltip.
4999 * @param item genlist item with tooltip already set.
5000 * @return style the theme style in use, defaults to "default". If the
5001 * object does not have a tooltip set, then NULL is returned.
5006 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
5008 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5009 return item->tooltip.style;
5013 * Set the cursor to be shown when mouse is over the genlist item
5015 * @param item Target item
5016 * @param cursor the cursor name to be used.
5018 * @see elm_object_cursor_set()
5022 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
5025 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5026 eina_stringshare_replace(&item->mouse_cursor, cursor);
5027 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
5031 * Get the cursor to be shown when mouse is over the genlist item
5033 * @param item genlist item with cursor already set.
5034 * @return the cursor name.
5039 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
5041 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5042 return elm_widget_item_cursor_get(item);
5046 * Unset the cursor to be shown when mouse is over the genlist item
5048 * @param item Target item
5050 * @see elm_object_cursor_unset()
5054 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
5056 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5057 if (!item->mouse_cursor)
5060 if (item->base.view)
5061 elm_widget_item_cursor_unset(item);
5063 eina_stringshare_del(item->mouse_cursor);
5064 item->mouse_cursor = NULL;
5068 * Sets a different style for this item cursor.
5070 * @note before you set a style you should define a cursor with
5071 * elm_genlist_item_cursor_set()
5073 * @param item genlist item with cursor already set.
5074 * @param style the theme style to use (default, transparent, ...)
5079 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5082 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5083 elm_widget_item_cursor_style_set(item, style);
5087 * Get the style for this item cursor.
5089 * @param item genlist item with cursor already set.
5090 * @return style the theme style in use, defaults to "default". If the
5091 * object does not have a cursor set, then NULL is returned.
5096 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5099 return elm_widget_item_cursor_style_get(item);
5103 * Set if the cursor set should be searched on the theme or should use
5104 * the provided by the engine, only.
5106 * @note before you set if should look on theme you should define a
5107 * cursor with elm_object_cursor_set(). By default it will only look
5108 * for cursors provided by the engine.
5110 * @param item widget item with cursor already set.
5111 * @param engine_only boolean to define it cursors should be looked
5112 * only between the provided by the engine or searched on widget's
5118 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5119 Eina_Bool engine_only)
5121 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5122 elm_widget_item_cursor_engine_only_set(item, engine_only);
5126 * Get the cursor engine only usage for this item cursor.
5128 * @param item widget item with cursor already set.
5129 * @return engine_only boolean to define it cursors should be looked
5130 * only between the provided by the engine or searched on widget's
5131 * theme as well. If the object does not have a cursor set, then
5132 * EINA_FALSE is returned.
5137 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5139 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5140 return elm_widget_item_cursor_engine_only_get(item);
5144 * This sets the horizontal stretching mode
5146 * This sets the mode used for sizing items horizontally. Valid modes
5147 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5148 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5149 * the scroller will scroll horizontally. Otherwise items are expanded
5150 * to fill the width of the viewport of the scroller. If it is
5151 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5152 * limited to that size.
5154 * @param obj The genlist object
5155 * @param mode The mode to use
5160 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5163 ELM_CHECK_WIDTYPE(obj, widtype);
5164 Widget_Data *wd = elm_widget_data_get(obj);
5166 if (wd->mode == mode) return;
5172 * Gets the horizontal stretching mode
5174 * @param obj The genlist object
5175 * @return The mode to use
5176 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5181 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5183 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5184 Widget_Data *wd = elm_widget_data_get(obj);
5185 if (!wd) return ELM_LIST_LAST;
5190 * Set the always select mode.
5192 * Items will only call their selection func and callback when first
5193 * becoming selected. Any further clicks will do nothing, unless you
5194 * enable always select with elm_genlist_always_select_mode_set().
5195 * This means even if selected, every click will make the selected
5196 * callbacks be called.
5198 * @param obj The genlist object
5199 * @param always_select The always select mode
5200 * (EINA_TRUE = on, EINA_FALSE = off)
5205 elm_genlist_always_select_mode_set(Evas_Object *obj,
5206 Eina_Bool always_select)
5208 ELM_CHECK_WIDTYPE(obj, widtype);
5209 Widget_Data *wd = elm_widget_data_get(obj);
5211 wd->always_select = always_select;
5215 * Get the always select mode.
5217 * @param obj The genlist object
5218 * @return The always select mode
5219 * (EINA_TRUE = on, EINA_FALSE = off)
5224 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5226 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5227 Widget_Data *wd = elm_widget_data_get(obj);
5228 if (!wd) return EINA_FALSE;
5229 return wd->always_select;
5233 * Set no select mode
5235 * This will turn off the ability to select items entirely and they
5236 * will neither appear selected nor call selected callback functions.
5238 * @param obj The genlist object
5239 * @param no_select The no select mode
5240 * (EINA_TRUE = on, EINA_FALSE = off)
5245 elm_genlist_no_select_mode_set(Evas_Object *obj,
5246 Eina_Bool no_select)
5248 ELM_CHECK_WIDTYPE(obj, widtype);
5249 Widget_Data *wd = elm_widget_data_get(obj);
5251 wd->no_select = no_select;
5255 * Gets no select mode
5257 * @param obj The genlist object
5258 * @return The no select mode
5259 * (EINA_TRUE = on, EINA_FALSE = off)
5264 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5266 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5267 Widget_Data *wd = elm_widget_data_get(obj);
5268 if (!wd) return EINA_FALSE;
5269 return wd->no_select;
5275 * This will enable the compress mode where items are "compressed"
5276 * horizontally to fit the genlist scrollable viewport width. This is
5277 * special for genlist. Do not rely on
5278 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5279 * work as genlist needs to handle it specially.
5281 * @param obj The genlist object
5282 * @param compress The compress mode
5283 * (EINA_TRUE = on, EINA_FALSE = off)
5288 elm_genlist_compress_mode_set(Evas_Object *obj,
5291 ELM_CHECK_WIDTYPE(obj, widtype);
5292 Widget_Data *wd = elm_widget_data_get(obj);
5294 wd->compress = compress;
5295 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
5299 * Get the compress mode
5301 * @param obj The genlist object
5302 * @return The compress mode
5303 * (EINA_TRUE = on, EINA_FALSE = off)
5308 elm_genlist_compress_mode_get(const Evas_Object *obj)
5310 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5311 Widget_Data *wd = elm_widget_data_get(obj);
5312 if (!wd) return EINA_FALSE;
5313 return wd->compress;
5317 * Set height-for-width mode
5319 * With height-for-width mode the item width will be fixed (restricted
5320 * to a minimum of) to the list width when calculating its size in
5321 * order to allow the height to be calculated based on it. This allows,
5322 * for instance, text block to wrap lines if the Edje part is
5323 * configured with "text.min: 0 1".
5325 * @note This mode will make list resize slower as it will have to
5326 * recalculate every item height again whenever the list width
5329 * @note When height-for-width mode is enabled, it also enables
5330 * compress mode (see elm_genlist_compress_mode_set()) and
5331 * disables homogeneous (see elm_genlist_homogeneous_set()).
5333 * @param obj The genlist object
5334 * @param setting The height-for-width mode (EINA_TRUE = on,
5340 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5341 Eina_Bool height_for_width)
5343 ELM_CHECK_WIDTYPE(obj, widtype);
5344 Widget_Data *wd = elm_widget_data_get(obj);
5346 wd->height_for_width = !!height_for_width;
5347 if (wd->height_for_width)
5349 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5350 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5355 * Get the height-for-width mode
5357 * @param obj The genlist object
5358 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5364 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5366 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5367 Widget_Data *wd = elm_widget_data_get(obj);
5368 if (!wd) return EINA_FALSE;
5369 return wd->height_for_width;
5375 * This will enable or disable the scroller bounce mode for the
5376 * genlist. See elm_scroller_bounce_set() for details
5378 * @param obj The genlist object
5379 * @param h_bounce Allow bounce horizontally
5380 * @param v_bounce Allow bounce vertically
5385 elm_genlist_bounce_set(Evas_Object *obj,
5389 ELM_CHECK_WIDTYPE(obj, widtype);
5390 Widget_Data *wd = elm_widget_data_get(obj);
5392 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5396 * Get the bounce mode
5398 * @param obj The genlist object
5399 * @param h_bounce Allow bounce horizontally
5400 * @param v_bounce Allow bounce vertically
5405 elm_genlist_bounce_get(const Evas_Object *obj,
5406 Eina_Bool *h_bounce,
5407 Eina_Bool *v_bounce)
5409 ELM_CHECK_WIDTYPE(obj, widtype);
5410 Widget_Data *wd = elm_widget_data_get(obj);
5412 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5416 * Set homogenous mode
5418 * This will enable the homogeneous mode where items are of the same
5419 * height and width so that genlist may do the lazy-loading at its
5420 * maximum. This implies 'compressed' mode.
5422 * @param obj The genlist object
5423 * @param homogeneous Assume the items within the genlist are of the
5424 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5429 elm_genlist_homogeneous_set(Evas_Object *obj,
5430 Eina_Bool homogeneous)
5432 ELM_CHECK_WIDTYPE(obj, widtype);
5433 Widget_Data *wd = elm_widget_data_get(obj);
5435 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5436 wd->homogeneous = homogeneous;
5440 * Get the homogenous mode
5442 * @param obj The genlist object
5443 * @return Assume the items within the genlist are of the same height
5444 * and width (EINA_TRUE = on, EINA_FALSE = off)
5449 elm_genlist_homogeneous_get(const Evas_Object *obj)
5451 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5452 Widget_Data *wd = elm_widget_data_get(obj);
5453 if (!wd) return EINA_FALSE;
5454 return wd->homogeneous;
5458 * Set the maximum number of items within an item block
5460 * This will configure the block count to tune to the target with
5461 * particular performance matrix.
5463 * @param obj The genlist object
5464 * @param n Maximum number of items within an item block
5469 elm_genlist_block_count_set(Evas_Object *obj,
5472 ELM_CHECK_WIDTYPE(obj, widtype);
5473 Widget_Data *wd = elm_widget_data_get(obj);
5475 wd->max_items_per_block = n;
5476 wd->item_cache_max = wd->max_items_per_block * 2;
5477 _item_cache_clean(wd);
5481 * Get the maximum number of items within an item block
5483 * @param obj The genlist object
5484 * @return Maximum number of items within an item block
5489 elm_genlist_block_count_get(const Evas_Object *obj)
5491 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5492 Widget_Data *wd = elm_widget_data_get(obj);
5494 return wd->max_items_per_block;
5498 * Set the timeout in seconds for the longpress event
5500 * @param obj The genlist object
5501 * @param timeout timeout in seconds
5506 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5509 ELM_CHECK_WIDTYPE(obj, widtype);
5510 Widget_Data *wd = elm_widget_data_get(obj);
5512 wd->longpress_timeout = timeout;
5516 * Get the timeout in seconds for the longpress event
5518 * @param obj The genlist object
5519 * @return timeout in seconds
5524 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5526 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5527 Widget_Data *wd = elm_widget_data_get(obj);
5529 return wd->longpress_timeout;
5533 * Set the scrollbar policy
5535 * This sets the scrollbar visibility policy for the given genlist
5536 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5537 * made visible if it is needed, and otherwise kept hidden.
5538 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5539 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5540 * respectively for the horizontal and vertical scrollbars.
5542 * @param obj The genlist object
5543 * @param policy_h Horizontal scrollbar policy
5544 * @param policy_v Vertical scrollbar policy
5549 elm_genlist_scroller_policy_set(Evas_Object *obj,
5550 Elm_Scroller_Policy policy_h,
5551 Elm_Scroller_Policy policy_v)
5553 ELM_CHECK_WIDTYPE(obj, widtype);
5554 Widget_Data *wd = elm_widget_data_get(obj);
5556 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5557 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5560 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5564 * Get the scrollbar policy
5566 * @param obj The genlist object
5567 * @param policy_h Horizontal scrollbar policy
5568 * @param policy_v Vertical scrollbar policy
5573 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5574 Elm_Scroller_Policy *policy_h,
5575 Elm_Scroller_Policy *policy_v)
5577 ELM_CHECK_WIDTYPE(obj, widtype);
5578 Widget_Data *wd = elm_widget_data_get(obj);
5579 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5580 if ((!wd) || (!wd->scr)) return;
5581 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5582 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5583 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5587 * Update the contents of all realized items
5589 * This updates all realized items by calling all the item class functions again
5590 * to get the icons, labels and states. Use this when the original
5591 * item data has changed and the changes are desired to be reflected.
5593 * @param it The item
5598 elm_genlist_realized_items_update(Evas_Object *obj)
5600 ELM_CHECK_WIDTYPE(obj, widtype);
5602 Eina_List *list, *l;
5603 Elm_Genlist_Item *it;
5605 list = elm_genlist_realized_items_get(obj);
5606 EINA_LIST_FOREACH(list, l, it)
5607 elm_genlist_item_update(it);
5611 * Set genlist item mode
5613 * @param item The genlist item
5614 * @param mode Mode name
5615 * @param mode_set Boolean to define set or unset mode.
5620 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5621 const char *mode_type,
5624 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5625 Widget_Data *wd = it->wd;
5627 Elm_Genlist_Item *it2;
5630 if (!mode_type) return;
5631 if ((it->delete_me) || (it->disabled)) return;
5633 if ((wd->mode_item == it) &&
5634 (!strcmp(mode_type, wd->mode_type)) &&
5637 if (!it->itc->mode_item_style) return;
5641 EINA_LIST_FOREACH(wd->selected, l, it2)
5643 elm_genlist_item_selected_set(it2, EINA_FALSE);
5647 it2 = elm_genlist_selected_item_get(wd->obj);
5648 if ((it2) && (it2->realized))
5649 elm_genlist_item_selected_set(it2, EINA_FALSE);
5652 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5654 ((it == wd->mode_item) && (!mode_set)))
5655 _item_mode_unset(wd);
5657 eina_stringshare_replace(&wd->mode_type, mode_type);
5658 if (mode_set) _item_mode_set(it);
5662 * Get active genlist mode type
5664 * @param obj The genlist object
5669 elm_genlist_mode_get(const Evas_Object *obj)
5671 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5672 Widget_Data *wd = elm_widget_data_get(obj);
5673 if (!wd) return NULL;
5674 return wd->mode_type;
5678 * Get active genlist mode item
5680 * @param obj The genlist object
5684 EAPI const Elm_Genlist_Item *
5685 elm_genlist_mode_item_get(const Evas_Object *obj)
5687 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5688 Widget_Data *wd = elm_widget_data_get(obj);
5689 if (!wd) return NULL;
5690 return wd->mode_item;
5696 * @param obj The genlist object
5697 * @param reorder_mode The reorder mode
5698 * (EINA_TRUE = on, EINA_FALSE = off)
5703 elm_genlist_reorder_mode_set(Evas_Object *obj,
5704 Eina_Bool reorder_mode)
5706 ELM_CHECK_WIDTYPE(obj, widtype);
5707 Widget_Data *wd = elm_widget_data_get(obj);
5709 wd->reorder_mode = reorder_mode;
5713 * Get the reorder mode
5715 * @param obj The genlist object
5716 * @return The reorder mode
5717 * (EINA_TRUE = on, EINA_FALSE = off)
5722 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5724 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5725 Widget_Data *wd = elm_widget_data_get(obj);
5726 if (!wd) return EINA_FALSE;
5727 return wd->reorder_mode;