3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
11 * @defgroup Genlist Genlist
13 * The aim was to have more expansive list than the simple list in
14 * Elementary that could have more flexible items and allow many more entries
15 * while still being fast and low on memory usage. At the same time it was
16 * also made to be able to do tree structures. But the price to pay is more
17 * complex when it comes to usage. If all you want is a simple list with
18 * icons and a single label, use the normal List object.
20 * Genlist has a fairly large API, mostly because it's relatively complex,
21 * trying to be both expansive, powerful and efficient. First we will begin
22 * an overview on the theory behind genlist.
24 * Evas tracks every object you create. Every time it processes an event
25 * (mouse move, down, up etc.) it needs to walk through objects and find out
26 * what event that affects. Even worse every time it renders display updates,
27 * in order to just calculate what to re-draw, it needs to walk through many
28 * many many objects. Thus, the more objects you keep active, the more
29 * overhead Evas has in just doing its work. It is advisable to keep your
30 * active objects to the minimum working set you need. Also remember that
31 * object creation and deletion carries an overhead, so there is a
32 * middle-ground, which is not easily determined. But don't keep massive lists
33 * of objects you can't see or use. Genlist does this with list objects. It
34 * creates and destroys them dynamically as you scroll around. It groups them
35 * into blocks so it can determine the visibility etc. of a whole block at
36 * once as opposed to having to walk the whole list. This 2-level list allows
37 * for very large numbers of items to be in the list (tests have used up to
38 * 2,000,000 items). Also genlist employs a queue for adding items. As items
39 * may be different sizes, every item added needs to be calculated as to its
40 * size and thus this presents a lot of overhead on populating the list, this
41 * genlist employs a queue. Any item added is queued and spooled off over
42 * time, actually appearing some time later, so if your list has many members
43 * you may find it takes a while for them to all appear, with your process
44 * consuming a lot of CPU while it is busy spooling.
46 * Genlist also implements a tree structure, but it does so with callbacks to
47 * the application, with the application filling in tree structures when
48 * requested (allowing for efficient building of a very deep tree that could
49 * even be used for file-management). See the above smart signal callbacks for
52 * An item in the genlist world can have 0 or more text labels (they can be
53 * regular text or textblock - that's up to the style to determine), 0 or
54 * more icons (which are simply objects swallowed into the genlist item) and
55 * 0 or more boolean states that can be used for check, radio or other
56 * indicators by the edje theme style. An item may be one of several styles
57 * (Elementary provides 4 by default - "default", "double_label", "group_index"
58 * and "icon_top_text_bottom", but this can be extended by system or
59 * application custom themes/overlays/extensions).
61 * In order to implement the ability to add and delete items on the fly,
62 * Genlist implements a class/callback system where the application provides
63 * a structure with information about that type of item (genlist may contain
64 * multiple different items with different classes, states and styles).
65 * Genlist will call the functions in this struct (methods) when an item is
66 * "realized" (that is created dynamically while scrolling). All objects will
67 * simply be deleted when no longer needed with evas_object_del(). The
68 * Elm_Genlist_Item_Class structure contains the following members:
70 * item_style - This is a constant string and simply defines the name of the
71 * item style. It must be specified and the default should be "default".
73 * func.label_get - This function is called when an actual item object is
74 * created. The data parameter is the data parameter passed to
75 * elm_genlist_item_append() and related item creation functions. The obj
76 * parameter is the genlist object and the part parameter is the string name
77 * of the text part in the edje design that is listed as one of the possible
78 * labels that can be set. This function must return a strudup()'ed string as
79 * the caller will free() it when done.
81 * func.icon_get - This function is called when an actual item object is
82 * created. The data parameter is the data parameter passed to
83 * elm_genlist_item_append() and related item creation functions. The obj
84 * parameter is the genlist object and the part parameter is the string name
85 * of the icon part in the edje design that is listed as one of the possible
86 * icons that can be set. This must return NULL for no object or a valid
87 * object. The object will be deleted by genlist on shutdown or when the item
90 * func.state_get - This function is called when an actual item object is
91 * created. The data parameter is the data parameter passed to
92 * elm_genlist_item_append() and related item creation functions. The obj
93 * parameter is the genlist object and the part parameter is the string name
94 * of the state part in the edje design that is listed as one of the possible
95 * states that can be set. Return 0 for false or 1 for true. Genlist will
96 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
97 * true (the default is false), where XXX is the name of the part.
99 * func.del - This is called when elm_genlist_item_del() is called on an
100 * item, elm_genlist_clear() is called on the genlist, or
101 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
102 * intended for use when actual genlist items are deleted, so any backing
103 * data attached to the item (e.g. its data parameter on creation) can be
106 * Items can be added by several calls. All of them return a Elm_Genlist_Item
107 * handle that is an internal member inside the genlist. They all take a data
108 * parameter that is meant to be used for a handle to the applications
109 * internal data (eg the struct with the original item data). The parent
110 * parameter is the parent genlist item this belongs to if it is a tree or
111 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
112 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
113 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
114 * is displayed as an item that is able to expand and have child items.
115 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
116 * displayed at the top until the next group comes. The func parameter is a
117 * convenience callback that is called when the item is selected and the data
118 * parameter will be the func_data parameter, obj be the genlist object and
119 * event_info will be the genlist item.
121 * elm_genlist_item_append() appends an item to the end of the list, or if
122 * there is a parent, to the end of all the child items of the parent.
123 * elm_genlist_item_prepend() is the same but prepends to the beginning of
124 * the list or children list. elm_genlist_item_insert_before() inserts at
125 * item before another item and elm_genlist_item_insert_after() inserts after
126 * the indicated item.
128 * The application can clear the list with elm_genlist_clear() which deletes
129 * all the items in the list and elm_genlist_item_del() will delete a specific
130 * item. elm_genlist_item_subitems_clear() will clear all items that are
131 * children of the indicated parent item.
133 * If the application wants multiple items to be able to be selected,
134 * elm_genlist_multi_select_set() can enable this. If the list is
135 * single-selection only (the default), then elm_genlist_selected_item_get()
136 * will return the selected item, if any, or NULL I none is selected. If the
137 * list is multi-select then elm_genlist_selected_items_get() will return a
138 * list (that is only valid as long as no items are modified (added, deleted,
139 * selected or unselected)).
141 * To help inspect list items you can jump to the item at the top of the list
142 * with elm_genlist_first_item_get() which will return the item pointer, and
143 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
144 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
145 * and previous items respectively relative to the indicated item. Using
146 * these calls you can walk the entire item list/tree. Note that as a tree
147 * the items are flattened in the list, so elm_genlist_item_parent_get() will
148 * let you know which item is the parent (and thus know how to skip them if
151 * There are also convenience functions. elm_genlist_item_genlist_get() will
152 * return the genlist object the item belongs to. elm_genlist_item_show()
153 * will make the scroller scroll to show that specific item so its visible.
154 * elm_genlist_item_data_get() returns the data pointer set by the item
155 * creation functions.
157 * If an item changes (state of boolean changes, label or icons change),
158 * then use elm_genlist_item_update() to have genlist update the item with
159 * the new state. Genlist will re-realize the item thus call the functions
160 * in the _Elm_Genlist_Item_Class for that item.
162 * To programmatically (un)select an item use elm_genlist_item_selected_set().
163 * To get its selected state use elm_genlist_item_selected_get(). Similarly
164 * to expand/contract an item and get its expanded state, use
165 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
166 * again to make an item disabled (unable to be selected and appear
167 * differently) use elm_genlist_item_disabled_set() to set this and
168 * elm_genlist_item_disabled_get() to get the disabled state.
170 * In general to indicate how the genlist should expand items horizontally to
171 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
172 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
173 * mode means that if items are too wide to fit, the scroller will scroll
174 * horizontally. Otherwise items are expanded to fill the width of the
175 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
176 * to the viewport width and limited to that size. This can be combined with
177 * a different style that uses edjes' ellipsis feature (cutting text off like
180 * Items will only call their selection func and callback when first becoming
181 * selected. Any further clicks will do nothing, unless you enable always
182 * select with elm_genlist_always_select_mode_set(). This means even if
183 * selected, every click will make the selected callbacks be called.
184 * elm_genlist_no_select_mode_set() will turn off the ability to select
185 * items entirely and they will neither appear selected nor call selected
186 * callback functions.
188 * Remember that you can create new styles and add your own theme augmentation
189 * per application with elm_theme_extension_add(). If you absolutely must
190 * have a specific style that overrides any theme the user or system sets up
191 * you can use elm_theme_overlay_add() to add such a file.
195 typedef struct _Widget_Data Widget_Data;
196 typedef struct _Item_Block Item_Block;
197 typedef struct _Pan Pan;
198 typedef struct _Item_Cache Item_Cache;
202 Evas_Object *obj, *scr, *pan_smart;
203 Eina_Inlist *items, *blocks;
204 Eina_List *group_items;
206 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
207 Ecore_Job *calc_job, *update_job;
208 Ecore_Idle_Enterer *queue_idle_enterer;
209 Ecore_Idler *must_recalc_idler;
210 Eina_List *queue, *selected;
211 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
212 Eina_Inlist *item_cache;
215 Ecore_Timer *multi_timer, *scr_hold_timer;
216 const char *mode_type;
217 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
218 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
219 Eina_Bool mouse_down : 1;
220 Eina_Bool multi_down : 1;
221 Eina_Bool multi_timeout : 1;
222 Eina_Bool multitouched : 1;
223 Eina_Bool on_hold : 1;
225 Eina_Bool always_select : 1;
226 Eina_Bool longpressed : 1;
227 Eina_Bool wasselected : 1;
228 Eina_Bool no_select : 1;
229 Eina_Bool bring_in : 1;
230 Eina_Bool compress : 1;
231 Eina_Bool height_for_width : 1;
232 Eina_Bool homogeneous : 1;
233 Eina_Bool clear_me : 1;
238 } history[SWIPE_MOVES];
240 int item_cache_count;
246 int group_item_width;
247 int group_item_height;
248 int max_items_per_block;
249 double longpress_timeout;
259 Evas_Coord x, y, w, h, minw, minh;
260 Eina_Bool want_unrealize : 1;
261 Eina_Bool realized : 1;
262 Eina_Bool changed : 1;
263 Eina_Bool updateme : 1;
264 Eina_Bool showme : 1;
265 Eina_Bool must_recalc : 1;
268 struct _Elm_Genlist_Item
270 Elm_Widget_Item base;
275 Evas_Coord x, y, w, h, minw, minh;
276 const Elm_Genlist_Item_Class *itc;
277 Elm_Genlist_Item *parent;
278 Elm_Genlist_Item *group_item;
279 Elm_Genlist_Item_Flags flags;
287 Eina_List *labels, *icons, *states, *icon_objs;
288 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
289 Ecore_Timer *long_timer;
290 Ecore_Timer *swipe_timer;
292 Evas_Coord scrl_x, scrl_y;
294 Elm_Genlist_Item *rel;
295 Evas_Object *mode_view;
300 Elm_Tooltip_Item_Content_Cb content_cb;
301 Evas_Smart_Cb del_cb;
305 const char *mouse_cursor;
312 Eina_Bool before : 1;
314 Eina_Bool want_unrealize : 1;
315 Eina_Bool want_realize : 1;
316 Eina_Bool realized : 1;
317 Eina_Bool selected : 1;
318 Eina_Bool highlighted : 1;
319 Eina_Bool expanded : 1;
320 Eina_Bool disabled : 1;
321 Eina_Bool display_only : 1;
322 Eina_Bool mincalcd : 1;
323 Eina_Bool queued : 1;
324 Eina_Bool showme : 1;
325 Eina_Bool delete_me : 1;
327 Eina_Bool dragging : 1;
328 Eina_Bool updateme : 1;
329 Eina_Bool nocache : 1;
330 Eina_Bool stacking_even : 1;
331 Eina_Bool nostacking : 1;
338 Evas_Object *base_view, *spacer;
340 const char *item_style; // it->itc->item_style
341 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
342 Eina_Bool compress : 1; // it->wd->compress
344 Eina_Bool selected : 1; // it->selected
345 Eina_Bool disabled : 1; // it->disabled
346 Eina_Bool expanded : 1; // it->expanded
349 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
350 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
354 Evas_Object_Smart_Clipped_Data __clipped_data;
356 Ecore_Job *resize_job;
359 static const char *widtype = NULL;
360 static void _item_cache_zero(Widget_Data *wd);
361 static void _del_hook(Evas_Object *obj);
362 static void _mirrored_set(Evas_Object *obj,
364 static void _theme_hook(Evas_Object *obj);
365 static void _show_region_hook(void *data,
367 static void _sizing_eval(Evas_Object *obj);
368 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
369 static void _item_block_unrealize(Item_Block *itb);
370 static void _calc_job(void *data);
371 static void _on_focus_hook(void *data,
373 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
374 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
375 static Eina_Bool _item_single_select_up(Widget_Data *wd);
376 static Eina_Bool _item_single_select_down(Widget_Data *wd);
377 static Eina_Bool _event_hook(Evas_Object *obj,
379 Evas_Callback_Type type,
381 static void _signal_emit_hook(Evas_Object *obj,
382 const char *emission,
384 static Eina_Bool _deselect_all_items(Widget_Data *wd);
385 static void _pan_calculate(Evas_Object *obj);
386 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
387 static void _mode_item_realize(Elm_Genlist_Item *it);
388 static void _mode_item_unrealize(Elm_Genlist_Item *it);
389 static void _item_mode_set(Elm_Genlist_Item *it);
390 static void _item_mode_unset(Widget_Data *wd);
392 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
394 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
395 static const char SIG_SELECTED[] = "selected";
396 static const char SIG_UNSELECTED[] = "unselected";
397 static const char SIG_EXPANDED[] = "expanded";
398 static const char SIG_CONTRACTED[] = "contracted";
399 static const char SIG_EXPAND_REQUEST[] = "expand,request";
400 static const char SIG_CONTRACT_REQUEST[] = "contract,request";
401 static const char SIG_REALIZED[] = "realized";
402 static const char SIG_UNREALIZED[] = "unrealized";
403 static const char SIG_DRAG_START_UP[] = "drag,start,up";
404 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
405 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
406 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
407 static const char SIG_DRAG_STOP[] = "drag,stop";
408 static const char SIG_DRAG[] = "drag";
409 static const char SIG_LONGPRESSED[] = "longpressed";
410 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
411 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
412 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
413 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
414 static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
415 static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
416 static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
417 static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
418 static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
419 static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
420 static const char SIG_SWIPE[] = "swipe";
422 static const Evas_Smart_Cb_Description _signals[] = {
423 {SIG_CLICKED_DOUBLE, ""},
425 {SIG_UNSELECTED, ""},
427 {SIG_CONTRACTED, ""},
428 {SIG_EXPAND_REQUEST, ""},
429 {SIG_CONTRACT_REQUEST, ""},
431 {SIG_UNREALIZED, ""},
432 {SIG_DRAG_START_UP, ""},
433 {SIG_DRAG_START_DOWN, ""},
434 {SIG_DRAG_START_LEFT, ""},
435 {SIG_DRAG_START_RIGHT, ""},
438 {SIG_LONGPRESSED, ""},
439 {SIG_SCROLL_EDGE_TOP, ""},
440 {SIG_SCROLL_EDGE_BOTTOM, ""},
441 {SIG_SCROLL_EDGE_LEFT, ""},
442 {SIG_SCROLL_EDGE_RIGHT, ""},
443 {SIG_MULTI_SWIPE_LEFT, ""},
444 {SIG_MULTI_SWIPE_RIGHT, ""},
445 {SIG_MULTI_SWIPE_UP, ""},
446 {SIG_MULTI_SWIPE_DOWN, ""},
447 {SIG_MULTI_PINCH_OUT, ""},
448 {SIG_MULTI_PINCH_IN, ""},
453 static Eina_Compare_Cb _elm_genlist_item_compare_cb;
456 _event_hook(Evas_Object *obj,
457 Evas_Object *src __UNUSED__,
458 Evas_Callback_Type type,
461 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
462 Evas_Event_Key_Down *ev = event_info;
463 Widget_Data *wd = elm_widget_data_get(obj);
464 if (!wd) return EINA_FALSE;
465 if (!wd->items) return EINA_FALSE;
466 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
467 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
469 Elm_Genlist_Item *it = NULL;
472 Evas_Coord step_x = 0;
473 Evas_Coord step_y = 0;
476 Evas_Coord page_x = 0;
477 Evas_Coord page_y = 0;
479 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
480 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
481 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
482 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
484 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
488 else if ((!strcmp(ev->keyname, "Right")) ||
489 (!strcmp(ev->keyname, "KP_Right")))
493 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
495 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
496 (_item_multi_select_up(wd)))
497 || (_item_single_select_up(wd)))
499 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
505 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
507 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
508 (_item_multi_select_down(wd)))
509 || (_item_single_select_down(wd)))
511 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
517 else if ((!strcmp(ev->keyname, "Home")) ||
518 (!strcmp(ev->keyname, "KP_Home")))
520 it = elm_genlist_first_item_get(obj);
521 elm_genlist_item_bring_in(it);
522 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
525 else if ((!strcmp(ev->keyname, "End")) ||
526 (!strcmp(ev->keyname, "KP_End")))
528 it = elm_genlist_last_item_get(obj);
529 elm_genlist_item_bring_in(it);
530 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
533 else if ((!strcmp(ev->keyname, "Prior")) ||
534 (!strcmp(ev->keyname, "KP_Prior")))
537 y -= -(page_y * v_h) / 100;
541 else if ((!strcmp(ev->keyname, "Next")) ||
542 (!strcmp(ev->keyname, "KP_Next")))
545 y += -(page_y * v_h) / 100;
549 else if(((!strcmp(ev->keyname, "Return")) ||
550 (!strcmp(ev->keyname, "KP_Enter")) ||
551 (!strcmp(ev->keyname, "space")))
552 && (!wd->multi) && (wd->selected))
554 it = elm_genlist_selected_item_get(obj);
555 elm_genlist_item_expanded_set(it,
556 !elm_genlist_item_expanded_get(it));
558 else if (!strcmp(ev->keyname, "Escape"))
560 if (!_deselect_all_items(wd)) return EINA_FALSE;
561 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
564 else return EINA_FALSE;
566 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
567 elm_smart_scroller_child_pos_set(wd->scr, x, y);
572 _deselect_all_items(Widget_Data *wd)
574 if (!wd->selected) return EINA_FALSE;
576 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
582 _item_multi_select_up(Widget_Data *wd)
584 if (!wd->selected) return EINA_FALSE;
585 if (!wd->multi) return EINA_FALSE;
587 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
588 if (!prev) return EINA_TRUE;
590 if (elm_genlist_item_selected_get(prev))
592 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
593 wd->last_selected_item = prev;
594 elm_genlist_item_show(wd->last_selected_item);
598 elm_genlist_item_selected_set(prev, EINA_TRUE);
599 elm_genlist_item_show(prev);
605 _item_multi_select_down(Widget_Data *wd)
607 if (!wd->selected) return EINA_FALSE;
608 if (!wd->multi) return EINA_FALSE;
610 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
611 if (!next) return EINA_TRUE;
613 if (elm_genlist_item_selected_get(next))
615 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
616 wd->last_selected_item = next;
617 elm_genlist_item_show(wd->last_selected_item);
621 elm_genlist_item_selected_set(next, EINA_TRUE);
622 elm_genlist_item_show(next);
628 _item_single_select_up(Widget_Data *wd)
630 Elm_Genlist_Item *prev;
633 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
634 while ((prev) && (prev->delete_me))
635 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
637 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
639 if (!prev) return EINA_FALSE;
641 _deselect_all_items(wd);
643 elm_genlist_item_selected_set(prev, EINA_TRUE);
644 elm_genlist_item_show(prev);
649 _item_single_select_down(Widget_Data *wd)
651 Elm_Genlist_Item *next;
654 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
655 while ((next) && (next->delete_me))
656 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
658 else next = elm_genlist_item_next_get(wd->last_selected_item);
660 if (!next) return EINA_FALSE;
662 _deselect_all_items(wd);
664 elm_genlist_item_selected_set(next, EINA_TRUE);
665 elm_genlist_item_show(next);
670 _on_focus_hook(void *data __UNUSED__,
673 Widget_Data *wd = elm_widget_data_get(obj);
675 if (elm_widget_focus_get(obj))
677 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
678 evas_object_focus_set(wd->obj, EINA_TRUE);
679 if ((wd->selected) && (!wd->last_selected_item))
680 wd->last_selected_item = eina_list_data_get(wd->selected);
684 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
685 evas_object_focus_set(wd->obj, EINA_FALSE);
690 _del_hook(Evas_Object *obj)
692 Widget_Data *wd = elm_widget_data_get(obj);
694 _item_cache_zero(wd);
695 if (wd->calc_job) ecore_job_del(wd->calc_job);
696 if (wd->update_job) ecore_job_del(wd->update_job);
697 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
698 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
699 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
700 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
701 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
706 _del_pre_hook(Evas_Object *obj)
708 Widget_Data *wd = elm_widget_data_get(obj);
710 evas_object_del(wd->pan_smart);
711 wd->pan_smart = NULL;
712 elm_genlist_clear(obj);
716 _mirrored_set(Evas_Object *obj,
719 Widget_Data *wd = elm_widget_data_get(obj);
721 _item_cache_zero(wd);
722 elm_smart_scroller_mirrored_set(wd->scr, rtl);
726 _theme_hook(Evas_Object *obj)
728 Widget_Data *wd = elm_widget_data_get(obj);
731 _item_cache_zero(wd);
732 _elm_widget_mirrored_reload(obj);
733 _mirrored_set(obj, elm_widget_mirrored_get(obj));
734 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
735 elm_widget_style_get(obj));
736 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
737 wd->item_width = wd->item_height = 0;
738 wd->group_item_width = wd->group_item_height = 0;
739 wd->minw = wd->minh = wd->realminw = 0;
740 EINA_INLIST_FOREACH(wd->blocks, itb)
743 Elm_Genlist_Item *it;
745 if (itb->realized) _item_block_unrealize(itb);
746 EINA_LIST_FOREACH(itb->items, l, it)
747 it->mincalcd = EINA_FALSE;
749 itb->changed = EINA_TRUE;
751 if (wd->calc_job) ecore_job_del(wd->calc_job);
752 wd->calc_job = ecore_job_add(_calc_job, wd);
757 _show_region_hook(void *data,
760 Widget_Data *wd = elm_widget_data_get(data);
761 Evas_Coord x, y, w, h;
763 elm_widget_show_region_get(obj, &x, &y, &w, &h);
764 //x & y are screen coordinates, Add with pan coordinates
767 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
771 _sizing_eval(Evas_Object *obj)
773 Widget_Data *wd = elm_widget_data_get(obj);
774 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
776 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
777 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
779 if (wd->height_for_width)
783 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
784 if ((vw != 0) && (vw != wd->prev_viewport_w))
788 wd->prev_viewport_w = vw;
789 EINA_INLIST_FOREACH(wd->blocks, itb)
791 itb->must_recalc = EINA_TRUE;
793 if (wd->calc_job) ecore_job_del(wd->calc_job);
794 wd->calc_job = ecore_job_add(_calc_job, wd);
797 if (wd->mode == ELM_LIST_LIMIT)
799 Evas_Coord vmw, vmh, vw, vh;
803 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
804 if ((minw > 0) && (vw < minw)) vw = minw;
805 else if ((maxw > 0) && (vw > maxw))
807 edje_object_size_min_calc
808 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
815 edje_object_size_min_calc
816 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
820 evas_object_size_hint_min_set(obj, minw, minh);
821 evas_object_size_hint_max_set(obj, maxw, maxh);
825 _signal_emit_hook(Evas_Object *obj,
826 const char *emission,
829 Widget_Data *wd = elm_widget_data_get(obj);
830 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
835 _item_highlight(Elm_Genlist_Item *it)
837 const char *selectraise;
838 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
839 (it->disabled) || (it->display_only) || (it->mode_view))
841 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
842 selectraise = edje_object_data_get(it->base.view, "selectraise");
843 if ((selectraise) && (!strcmp(selectraise, "on")))
845 evas_object_raise(it->base.view);
846 if ((it->group_item) && (it->group_item->realized))
847 evas_object_raise(it->group_item->base.view);
849 it->highlighted = EINA_TRUE;
853 _item_unhighlight(Elm_Genlist_Item *it)
855 const char *stacking, *selectraise;
856 if ((it->delete_me) || (!it->highlighted)) return;
857 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
858 stacking = edje_object_data_get(it->base.view, "stacking");
859 selectraise = edje_object_data_get(it->base.view, "selectraise");
862 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
863 else evas_object_raise(it->base.view);
865 it->highlighted = EINA_FALSE;
869 _item_block_del(Elm_Genlist_Item *it)
872 Item_Block *itb = it->block;
874 itb->items = eina_list_remove(itb->items, it);
876 itb->changed = EINA_TRUE;
877 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
878 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
881 il = EINA_INLIST_GET(itb);
882 Item_Block *itbn = (Item_Block *)(il->next);
884 it->parent->items = eina_list_remove(it->parent->items, it);
886 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
888 if (itbn) itbn->changed = EINA_TRUE;
894 il = EINA_INLIST_GET(itb);
895 Item_Block *itbp = (Item_Block *)(il->prev);
896 Item_Block *itbn = (Item_Block *)(il->next);
897 if ((itbp) && ((itbp->count + itb->count) < 48))
899 Elm_Genlist_Item *it2;
901 EINA_LIST_FREE(itb->items, it2)
904 itbp->items = eina_list_append(itbp->items, it2);
906 itbp->changed = EINA_TRUE;
908 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
909 EINA_INLIST_GET(itb));
912 else if ((itbn) && ((itbn->count + itb->count) < 48))
916 Eina_List *last = eina_list_last(itb->items);
917 Elm_Genlist_Item *it2 = last->data;
920 itb->items = eina_list_remove_list(itb->items, last);
921 itbn->items = eina_list_prepend(itbn->items, it2);
923 itbn->changed = EINA_TRUE;
926 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
934 _item_del(Elm_Genlist_Item *it)
936 elm_widget_item_pre_notify_del(it);
937 elm_genlist_item_subitems_clear(it);
938 it->wd->walking -= it->walking;
939 if (it->wd->show_item == it) it->wd->show_item = NULL;
940 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
941 if (it->realized) _item_unrealize(it, EINA_FALSE);
942 if (it->block) _item_block_del(it);
943 if ((!it->delete_me) && (it->itc->func.del))
944 it->itc->func.del((void *)it->base.data, it->base.widget);
945 it->delete_me = EINA_TRUE;
947 it->wd->queue = eina_list_remove(it->wd->queue, it);
948 if (it->wd->anchor_item == it)
950 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
951 if (!it->wd->anchor_item)
952 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
954 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
956 it->parent->items = eina_list_remove(it->parent->items, it);
957 if (it->flags & ELM_GENLIST_ITEM_GROUP)
958 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
959 if (it->long_timer) ecore_timer_del(it->long_timer);
960 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
962 if (it->tooltip.del_cb)
963 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
965 elm_widget_item_del(it);
969 _item_select(Elm_Genlist_Item *it)
971 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
974 if (it->wd->always_select) goto call;
977 it->selected = EINA_TRUE;
978 it->wd->selected = eina_list_append(it->wd->selected, it);
982 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
984 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
987 if ((it->wd->clear_me) && (!it->wd->walking))
988 elm_genlist_clear(it->base.widget);
991 if ((!it->walking) && (it->delete_me))
993 if (!it->relcount) _item_del(it);
996 it->wd->last_selected_item = it;
1000 _item_unselect(Elm_Genlist_Item *it)
1002 if ((it->delete_me) || (!it->selected)) return;
1003 it->selected = EINA_FALSE;
1004 it->wd->selected = eina_list_remove(it->wd->selected, it);
1005 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1009 _mouse_move(void *data,
1010 Evas *evas __UNUSED__,
1014 Elm_Genlist_Item *it = data;
1015 Evas_Event_Mouse_Move *ev = event_info;
1016 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1018 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1020 if (!it->wd->on_hold)
1022 it->wd->on_hold = EINA_TRUE;
1023 if (!it->wd->wasselected)
1025 _item_unhighlight(it);
1030 if (it->wd->multitouched)
1032 it->wd->cur_x = ev->cur.canvas.x;
1033 it->wd->cur_y = ev->cur.canvas.y;
1036 if ((it->dragging) && (it->down))
1038 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1041 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1042 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1043 if (abs((it->wd->history[it->wd->movements].x -
1044 it->wd->history[0].x)) > 40)
1045 it->wd->swipe = EINA_TRUE;
1047 it->wd->movements++;
1051 ecore_timer_del(it->long_timer);
1052 it->long_timer = NULL;
1054 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1057 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1061 ecore_timer_del(it->long_timer);
1062 it->long_timer = NULL;
1066 if (!it->display_only)
1067 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1068 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1069 x = ev->cur.canvas.x - x;
1070 y = ev->cur.canvas.y - y;
1073 if (adx < 0) adx = -dx;
1076 if (ady < 0) ady = -dy;
1079 if ((adx > minw) || (ady > minh))
1081 it->dragging = EINA_TRUE;
1084 ecore_timer_del(it->long_timer);
1085 it->long_timer = NULL;
1087 if (!it->wd->wasselected)
1089 _item_unhighlight(it);
1095 evas_object_smart_callback_call(it->base.widget,
1096 SIG_DRAG_START_UP, it);
1100 evas_object_smart_callback_call(it->base.widget,
1101 SIG_DRAG_START_LEFT, it);
1103 evas_object_smart_callback_call(it->base.widget,
1104 SIG_DRAG_START_RIGHT, it);
1110 evas_object_smart_callback_call(it->base.widget,
1111 SIG_DRAG_START_DOWN, it);
1115 evas_object_smart_callback_call(it->base.widget,
1116 SIG_DRAG_START_LEFT, it);
1118 evas_object_smart_callback_call(it->base.widget,
1119 SIG_DRAG_START_RIGHT, it);
1126 _long_press(void *data)
1128 Elm_Genlist_Item *it = data;
1130 it->long_timer = NULL;
1131 if ((it->disabled) || (it->dragging) || (it->display_only))
1132 return ECORE_CALLBACK_CANCEL;
1133 it->wd->longpressed = EINA_TRUE;
1134 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1135 return ECORE_CALLBACK_CANCEL;
1139 _swipe(Elm_Genlist_Item *it)
1144 if ((it->display_only) || (it->disabled)) return;
1145 it->wd->swipe = EINA_FALSE;
1146 for (i = 0; i < it->wd->movements; i++)
1148 sum += it->wd->history[i].x;
1149 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1152 sum /= it->wd->movements;
1153 if (abs(sum - it->wd->history[0].x) <= 10) return;
1154 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1158 _swipe_cancel(void *data)
1160 Elm_Genlist_Item *it = data;
1162 if (!it) return ECORE_CALLBACK_CANCEL;
1163 it->wd->swipe = EINA_FALSE;
1164 it->wd->movements = 0;
1165 return ECORE_CALLBACK_RENEW;
1169 _multi_cancel(void *data)
1171 Widget_Data *wd = data;
1173 if (!wd) return ECORE_CALLBACK_CANCEL;
1174 wd->multi_timeout = EINA_TRUE;
1175 return ECORE_CALLBACK_RENEW;
1179 _multi_touch_gesture_eval(void *data)
1181 Elm_Genlist_Item *it = data;
1183 it->wd->multitouched = EINA_FALSE;
1184 if (it->wd->multi_timer)
1186 ecore_timer_del(it->wd->multi_timer);
1187 it->wd->multi_timer = NULL;
1189 if (it->wd->multi_timeout)
1191 it->wd->multi_timeout = EINA_FALSE;
1195 Evas_Coord minw = 0, minh = 0;
1196 Evas_Coord off_x, off_y, off_mx, off_my;
1198 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1199 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1200 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1201 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1202 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1204 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1206 if ((off_x + off_mx) > (off_y + off_my))
1208 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1209 evas_object_smart_callback_call(it->base.widget,
1210 SIG_MULTI_SWIPE_RIGHT, it);
1211 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1212 evas_object_smart_callback_call(it->base.widget,
1213 SIG_MULTI_SWIPE_LEFT, it);
1214 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1215 evas_object_smart_callback_call(it->base.widget,
1216 SIG_MULTI_PINCH_OUT, it);
1218 evas_object_smart_callback_call(it->base.widget,
1219 SIG_MULTI_PINCH_IN, it);
1223 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1224 evas_object_smart_callback_call(it->base.widget,
1225 SIG_MULTI_SWIPE_DOWN, it);
1226 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1227 evas_object_smart_callback_call(it->base.widget,
1228 SIG_MULTI_SWIPE_UP, it);
1229 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1230 evas_object_smart_callback_call(it->base.widget,
1231 SIG_MULTI_PINCH_OUT, it);
1233 evas_object_smart_callback_call(it->base.widget,
1234 SIG_MULTI_PINCH_IN, it);
1237 it->wd->multi_timeout = EINA_FALSE;
1241 _multi_down(void *data,
1242 Evas *evas __UNUSED__,
1243 Evas_Object *obj __UNUSED__,
1246 Elm_Genlist_Item *it = data;
1247 Evas_Event_Multi_Down *ev = event_info;
1249 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1250 it->wd->multi_device = ev->device;
1251 it->wd->multi_down = EINA_TRUE;
1252 it->wd->multitouched = EINA_TRUE;
1253 it->wd->prev_mx = ev->canvas.x;
1254 it->wd->prev_my = ev->canvas.y;
1255 if (!it->wd->wasselected)
1257 _item_unhighlight(it);
1260 it->wd->wasselected = EINA_FALSE;
1261 it->wd->longpressed = EINA_FALSE;
1264 ecore_timer_del(it->long_timer);
1265 it->long_timer = NULL;
1269 it->dragging = EINA_FALSE;
1270 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1272 if (it->swipe_timer)
1274 ecore_timer_del(it->swipe_timer);
1275 it->swipe_timer = NULL;
1277 if (it->wd->on_hold)
1279 it->wd->swipe = EINA_FALSE;
1280 it->wd->movements = 0;
1281 it->wd->on_hold = EINA_FALSE;
1286 _multi_up(void *data,
1287 Evas *evas __UNUSED__,
1288 Evas_Object *obj __UNUSED__,
1291 Elm_Genlist_Item *it = data;
1292 Evas_Event_Multi_Up *ev = event_info;
1294 if (it->wd->multi_device != ev->device) return;
1295 it->wd->multi_device = 0;
1296 it->wd->multi_down = EINA_FALSE;
1297 if (it->wd->mouse_down) return;
1298 _multi_touch_gesture_eval(data);
1302 _multi_move(void *data,
1303 Evas *evas __UNUSED__,
1304 Evas_Object *obj __UNUSED__,
1307 Elm_Genlist_Item *it = data;
1308 Evas_Event_Multi_Move *ev = event_info;
1310 if (it->wd->multi_device != ev->device) return;
1311 it->wd->cur_mx = ev->cur.canvas.x;
1312 it->wd->cur_my = ev->cur.canvas.y;
1316 _mouse_down(void *data,
1317 Evas *evas __UNUSED__,
1321 Elm_Genlist_Item *it = data;
1322 Evas_Event_Mouse_Down *ev = event_info;
1325 if (ev->button != 1) return;
1326 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1328 it->wd->on_hold = EINA_TRUE;
1331 it->down = EINA_TRUE;
1332 it->dragging = EINA_FALSE;
1333 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1334 it->dx = ev->canvas.x - x;
1335 it->dy = ev->canvas.y - y;
1336 it->wd->mouse_down = EINA_TRUE;
1337 if (!it->wd->multitouched)
1339 it->wd->prev_x = ev->canvas.x;
1340 it->wd->prev_y = ev->canvas.y;
1341 it->wd->multi_timeout = EINA_FALSE;
1342 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1343 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1345 it->wd->longpressed = EINA_FALSE;
1346 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1347 else it->wd->on_hold = EINA_FALSE;
1348 if (it->wd->on_hold) return;
1349 it->wd->wasselected = it->selected;
1350 _item_highlight(it);
1351 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1352 if ((!it->disabled) && (!it->display_only))
1354 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1355 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1357 if (it->long_timer) ecore_timer_del(it->long_timer);
1358 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1359 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1361 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1364 it->long_timer = NULL;
1365 it->wd->swipe = EINA_FALSE;
1366 it->wd->movements = 0;
1370 _mouse_up(void *data,
1371 Evas *evas __UNUSED__,
1372 Evas_Object *obj __UNUSED__,
1375 Elm_Genlist_Item *it = data;
1376 Evas_Event_Mouse_Up *ev = event_info;
1377 Eina_Bool dragged = EINA_FALSE;
1379 if (ev->button != 1) return;
1380 it->down = EINA_FALSE;
1381 it->wd->mouse_down = EINA_FALSE;
1382 if (it->wd->multitouched)
1384 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1385 if (it->wd->multi_down) return;
1386 _multi_touch_gesture_eval(data);
1389 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1390 else it->wd->on_hold = EINA_FALSE;
1393 ecore_timer_del(it->long_timer);
1394 it->long_timer = NULL;
1398 it->dragging = EINA_FALSE;
1399 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1402 if (it->swipe_timer)
1404 ecore_timer_del(it->swipe_timer);
1405 it->swipe_timer = NULL;
1407 if (it->wd->multi_timer)
1409 ecore_timer_del(it->wd->multi_timer);
1410 it->wd->multi_timer = NULL;
1411 it->wd->multi_timeout = EINA_FALSE;
1413 if (it->wd->on_hold)
1415 if (it->wd->swipe) _swipe(data);
1416 it->wd->longpressed = EINA_FALSE;
1417 it->wd->on_hold = EINA_FALSE;
1420 if (it->wd->longpressed)
1422 it->wd->longpressed = EINA_FALSE;
1423 if (!it->wd->wasselected)
1425 _item_unhighlight(it);
1428 it->wd->wasselected = EINA_FALSE;
1433 if (it->want_unrealize)
1435 _item_unrealize(it, EINA_FALSE);
1436 if (it->block->want_unrealize)
1437 _item_block_unrealize(it->block);
1440 if ((it->disabled) || (dragged) || (it->display_only)) return;
1441 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1446 _item_highlight(it);
1451 _item_unhighlight(it);
1459 Widget_Data *wd = it->wd;
1462 while (wd->selected)
1464 _item_unhighlight(wd->selected->data);
1465 _item_unselect(wd->selected->data);
1471 const Eina_List *l, *l_next;
1472 Elm_Genlist_Item *it2;
1474 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1477 _item_unhighlight(it2);
1478 _item_unselect(it2);
1480 //_item_highlight(it);
1483 _item_highlight(it);
1489 _signal_expand_toggle(void *data,
1490 Evas_Object *obj __UNUSED__,
1491 const char *emission __UNUSED__,
1492 const char *source __UNUSED__)
1494 Elm_Genlist_Item *it = data;
1497 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1499 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1503 _signal_expand(void *data,
1504 Evas_Object *obj __UNUSED__,
1505 const char *emission __UNUSED__,
1506 const char *source __UNUSED__)
1508 Elm_Genlist_Item *it = data;
1511 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1515 _signal_contract(void *data,
1516 Evas_Object *obj __UNUSED__,
1517 const char *emission __UNUSED__,
1518 const char *source __UNUSED__)
1520 Elm_Genlist_Item *it = data;
1523 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1527 _scr_hold_timer_cb(void *data)
1529 if (!data) return ECORE_CALLBACK_CANCEL;
1530 Widget_Data *wd = data;
1531 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1532 wd->scr_hold_timer = NULL;
1533 return ECORE_CALLBACK_CANCEL;
1537 _mode_finished_signal_cb(void *data,
1539 const char *emission __UNUSED__,
1540 const char *source __UNUSED__)
1544 Elm_Genlist_Item *it = data;
1545 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1548 it->nocache = EINA_FALSE;
1549 _mode_item_unrealize(it);
1550 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1551 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1555 _item_cache_clean(Widget_Data *wd)
1557 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1561 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1562 wd->item_cache = eina_inlist_remove(wd->item_cache,
1563 wd->item_cache->last);
1564 wd->item_cache_count--;
1565 if (itc->spacer) evas_object_del(itc->spacer);
1566 if (itc->base_view) evas_object_del(itc->base_view);
1567 if (itc->item_style) eina_stringshare_del(itc->item_style);
1573 _item_cache_zero(Widget_Data *wd)
1575 int pmax = wd->item_cache_max;
1576 wd->item_cache_max = 0;
1577 _item_cache_clean(wd);
1578 wd->item_cache_max = pmax;
1582 _item_cache_add(Elm_Genlist_Item *it)
1586 if (it->wd->item_cache_max <= 0)
1588 evas_object_del(it->base.view);
1589 it->base.view = NULL;
1590 evas_object_del(it->spacer);
1595 it->wd->item_cache_count++;
1596 itc = calloc(1, sizeof(Item_Cache));
1597 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1598 EINA_INLIST_GET(itc));
1599 itc->spacer = it->spacer;
1601 itc->base_view = it->base.view;
1602 it->base.view = NULL;
1603 evas_object_hide(itc->base_view);
1604 evas_object_move(itc->base_view, -9999, -9999);
1605 itc->item_style = eina_stringshare_add(it->itc->item_style);
1606 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1607 itc->compress = (it->wd->compress);
1608 itc->selected = it->selected;
1609 itc->disabled = it->disabled;
1610 itc->expanded = it->expanded;
1613 ecore_timer_del(it->long_timer);
1614 it->long_timer = NULL;
1616 if (it->swipe_timer)
1618 ecore_timer_del(it->swipe_timer);
1619 it->swipe_timer = NULL;
1621 // FIXME: other callbacks?
1622 edje_object_signal_callback_del_full(itc->base_view,
1623 "elm,action,expand,toggle",
1624 "elm", _signal_expand_toggle, it);
1625 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1627 _signal_expand, it);
1628 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1629 "elm", _signal_contract, it);
1630 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1632 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1634 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1636 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1638 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1640 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1642 _item_cache_clean(it->wd);
1646 _item_cache_find(Elm_Genlist_Item *it)
1651 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1652 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1654 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1656 if ((itc->tree == tree) &&
1657 (itc->compress == it->wd->compress) &&
1658 (!strcmp(it->itc->item_style, itc->item_style)))
1660 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1661 EINA_INLIST_GET(itc));
1662 it->wd->item_cache_count--;
1670 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1672 if (!it->nostacking)
1674 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1675 evas_object_lower(it->base.view);
1677 evas_object_raise(it->base.view);
1680 if (it->order_num_in & 0x1)
1681 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1683 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1687 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1691 if (it->selected != itc->selected)
1694 edje_object_signal_emit(it->base.view,
1695 "elm,state,selected", "elm");
1697 if (it->disabled != itc->disabled)
1700 edje_object_signal_emit(it->base.view,
1701 "elm,state,disabled", "elm");
1703 if (it->expanded != itc->expanded)
1706 edje_object_signal_emit(it->base.view,
1707 "elm,state,expanded", "elm");
1713 edje_object_signal_emit(it->base.view,
1714 "elm,state,selected", "elm");
1716 edje_object_signal_emit(it->base.view,
1717 "elm,state,disabled", "elm");
1719 edje_object_signal_emit(it->base.view,
1720 "elm,state,expanded", "elm");
1725 _item_cache_free(Item_Cache *itc)
1727 if (itc->spacer) evas_object_del(itc->spacer);
1728 if (itc->base_view) evas_object_del(itc->base_view);
1729 if (itc->item_style) eina_stringshare_del(itc->item_style);
1734 _item_label_realize(Elm_Genlist_Item *it,
1735 Evas_Object *target,
1738 if (it->itc->func.label_get)
1743 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1744 EINA_LIST_FOREACH(*source, l, key)
1746 char *s = it->itc->func.label_get
1747 ((void *)it->base.data, it->base.widget, key);
1751 edje_object_part_text_set(target, key, s);
1756 edje_object_part_text_set(target, key, "");
1763 _item_icon_realize(Elm_Genlist_Item *it,
1764 Evas_Object *target,
1767 Eina_List *res = NULL;
1769 if (it->itc->func.icon_get)
1774 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1775 EINA_LIST_FOREACH(*source, l, key)
1777 Evas_Object *ic = it->itc->func.icon_get
1778 ((void *)it->base.data, it->base.widget, key);
1782 res = eina_list_append(res, ic);
1783 edje_object_part_swallow(target, key, ic);
1784 evas_object_show(ic);
1785 elm_widget_sub_object_add(it->base.widget, ic);
1787 elm_widget_disabled_set(ic, EINA_TRUE);
1796 _item_state_realize(Elm_Genlist_Item *it,
1797 Evas_Object *target,
1800 if (it->itc->func.state_get)
1806 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1807 EINA_LIST_FOREACH(*source, l, key)
1809 Eina_Bool on = it->itc->func.state_get
1810 ((void *)it->base.data, it->base.widget, key);
1814 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1815 edje_object_signal_emit(target, buf, "elm");
1819 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1820 edje_object_signal_emit(target, buf, "elm");
1827 _item_realize(Elm_Genlist_Item *it,
1831 Elm_Genlist_Item *it2;
1832 const char *treesize;
1834 int depth, tsize = 20;
1835 Item_Cache *itc = NULL;
1837 if (it->delete_me) return ;
1840 if (it->order_num_in != in)
1842 it->order_num_in = in;
1843 _elm_genlist_item_odd_even_update(it);
1844 _elm_genlist_item_state_update(it, NULL);
1848 it->order_num_in = in;
1851 it->nocache = EINA_FALSE;
1853 itc = _item_cache_find(it);
1856 it->base.view = itc->base_view;
1857 itc->base_view = NULL;
1858 it->spacer = itc->spacer;
1863 const char *stacking_even;
1864 const char *stacking;
1866 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1867 edje_object_scale_set(it->base.view,
1868 elm_widget_scale_get(it->base.widget) *
1869 _elm_config->scale);
1870 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1871 elm_widget_sub_object_add(it->base.widget, it->base.view);
1873 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1874 strncpy(buf, "tree", sizeof(buf));
1875 else strncpy(buf, "item", sizeof(buf));
1876 if (it->wd->compress)
1877 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1879 strncat(buf, "/", sizeof(buf) - strlen(buf));
1880 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1882 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1883 elm_widget_style_get(it->base.widget));
1885 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1886 if (!stacking_even) stacking_even = "above";
1887 it->stacking_even = !!strcmp("above", stacking_even);
1889 stacking = edje_object_data_get(it->base.view, "stacking");
1890 if (!stacking) stacking = "yes";
1891 it->nostacking = !!strcmp("yes", stacking);
1893 edje_object_mirrored_set(it->base.view,
1894 elm_widget_mirrored_get(it->base.widget));
1896 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1897 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1898 elm_widget_sub_object_add(it->base.widget, it->spacer);
1901 _elm_genlist_item_odd_even_update(it);
1903 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1905 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1907 it->expanded_depth = depth;
1908 treesize = edje_object_data_get(it->base.view, "treesize");
1909 if (treesize) tsize = atoi(treesize);
1910 evas_object_size_hint_min_set(it->spacer,
1911 (depth * tsize) * _elm_config->scale, 1);
1912 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1915 edje_object_signal_callback_add(it->base.view,
1916 "elm,action,expand,toggle",
1917 "elm", _signal_expand_toggle, it);
1918 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1919 "elm", _signal_expand, it);
1920 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1921 "elm", _signal_contract, it);
1922 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1924 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1926 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1928 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1930 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1932 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1935 _elm_genlist_item_state_update(it, itc);
1938 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1940 /* homogenous genlist shortcut */
1943 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1945 it->w = it->minw = it->wd->group_item_width;
1946 it->h = it->minh = it->wd->group_item_height;
1950 it->w = it->minw = it->wd->item_width;
1951 it->h = it->minh = it->wd->item_height;
1953 it->mincalcd = EINA_TRUE;
1958 /* FIXME: If you see that assert, please notify us and we
1959 will clean our mess */
1960 assert(eina_list_count(it->icon_objs) == 0);
1962 _item_label_realize(it, it->base.view, &it->labels);
1963 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1964 _item_state_realize(it, it->base.view, &it->states);
1968 Evas_Coord mw = -1, mh = -1;
1970 if (!it->display_only)
1971 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1972 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1973 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1975 if (!it->display_only)
1976 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1977 it->w = it->minw = mw;
1978 it->h = it->minh = mh;
1979 it->mincalcd = EINA_TRUE;
1981 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1983 it->wd->group_item_width = mw;
1984 it->wd->group_item_height = mh;
1986 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1988 it->wd->item_width = mw;
1989 it->wd->item_height = mh;
1992 if (!calc) evas_object_show(it->base.view);
1995 if (it->tooltip.content_cb)
1997 elm_widget_item_tooltip_content_cb_set(it,
1998 it->tooltip.content_cb,
1999 it->tooltip.data, NULL);
2000 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2003 if (it->mouse_cursor)
2004 elm_widget_item_cursor_set(it, it->mouse_cursor);
2006 it->realized = EINA_TRUE;
2007 it->want_unrealize = EINA_FALSE;
2009 if (itc) _item_cache_free(itc);
2010 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2014 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2018 if (!it->realized) return;
2019 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2022 ecore_timer_del(it->long_timer);
2023 it->long_timer = NULL;
2027 evas_object_del(it->base.view);
2028 it->base.view = NULL;
2029 evas_object_del(it->spacer);
2034 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2035 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2036 _item_cache_add(it);
2038 elm_widget_stringlist_free(it->labels);
2040 elm_widget_stringlist_free(it->icons);
2042 elm_widget_stringlist_free(it->states);
2044 EINA_LIST_FREE(it->icon_objs, icon)
2045 evas_object_del(icon);
2047 _mode_item_unrealize(it);
2049 it->realized = EINA_FALSE;
2050 it->want_unrealize = EINA_FALSE;
2054 _item_block_recalc(Item_Block *itb,
2059 Elm_Genlist_Item *it;
2060 Evas_Coord minw = 0, minh = 0;
2061 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2065 EINA_LIST_FOREACH(itb->items, l, it)
2067 if (it->delete_me) continue;
2068 showme |= it->showme;
2073 if (!it->mincalcd) changed = EINA_TRUE;
2076 _item_realize(it, in, EINA_TRUE);
2077 _item_unrealize(it, EINA_TRUE);
2082 _item_realize(it, in, EINA_TRUE);
2083 _item_unrealize(it, EINA_TRUE);
2087 _item_realize(it, in, EINA_FALSE);
2089 if (minw < it->minw) minw = it->minw;
2097 itb->changed = EINA_FALSE;
2102 _item_block_realize(Item_Block *itb,
2107 Elm_Genlist_Item *it;
2109 if (itb->realized) return;
2110 EINA_LIST_FOREACH(itb->items, l, it)
2112 if (it->delete_me) continue;
2113 if (full) _item_realize(it, in, EINA_FALSE);
2116 itb->realized = EINA_TRUE;
2117 itb->want_unrealize = EINA_FALSE;
2121 _item_block_unrealize(Item_Block *itb)
2124 Elm_Genlist_Item *it;
2125 Eina_Bool dragging = EINA_FALSE;
2127 if (!itb->realized) return;
2128 EINA_LIST_FOREACH(itb->items, l, it)
2130 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2134 dragging = EINA_TRUE;
2135 it->want_unrealize = EINA_TRUE;
2138 _item_unrealize(it, EINA_FALSE);
2143 itb->realized = EINA_FALSE;
2144 itb->want_unrealize = EINA_TRUE;
2147 itb->want_unrealize = EINA_FALSE;
2151 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2156 evas_object_resize(view, it->w, it->h);
2157 evas_object_move(view, it->scrl_x, it->scrl_y);
2158 evas_object_show(view);
2162 _item_block_position(Item_Block *itb,
2166 Elm_Genlist_Item *it;
2167 Elm_Genlist_Item *git;
2168 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2171 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2172 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2174 EINA_LIST_FOREACH(itb->items, l, it)
2176 if (it->delete_me) continue;
2180 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2181 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2183 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2184 cvx, cvy, cvw, cvh));
2185 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2187 if ((itb->realized) && (!it->realized))
2189 if (vis) _item_realize(it, in, EINA_FALSE);
2195 git = it->group_item;
2198 if (git->scrl_y < oy)
2200 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2201 git->scrl_y = (it->scrl_y + it->h) - git->h;
2202 git->want_realize = EINA_TRUE;
2205 _item_position(it, it->mode_view);
2207 _item_position(it, it->base.view);
2211 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2218 if (vis) it->want_realize = EINA_TRUE;
2225 _group_items_recalc(void *data)
2227 Widget_Data *wd = data;
2229 Elm_Genlist_Item *git;
2231 EINA_LIST_FOREACH(wd->group_items, l, git)
2233 if (git->want_realize)
2236 _item_realize(git, 0, EINA_FALSE);
2237 evas_object_resize(git->base.view, wd->minw, git->h);
2238 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2239 evas_object_show(git->base.view);
2240 evas_object_raise(git->base.view);
2242 else if (!git->want_realize && git->realized)
2245 _item_unrealize(git, EINA_FALSE);
2251 _must_recalc_idler(void *data)
2253 Widget_Data *wd = data;
2254 if (wd->calc_job) ecore_job_del(wd->calc_job);
2255 wd->calc_job = ecore_job_add(_calc_job, wd);
2256 wd->must_recalc_idler = NULL;
2257 return ECORE_CALLBACK_CANCEL;
2261 _calc_job(void *data)
2263 Widget_Data *wd = data;
2265 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2266 Item_Block *chb = NULL;
2267 int in = 0, minw_change = 0;
2268 Eina_Bool changed = EINA_FALSE;
2270 Eina_Bool did_must_recalc = EINA_FALSE;
2273 t0 = ecore_time_get();
2274 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2278 EINA_INLIST_FOREACH(wd->blocks, itb)
2280 Eina_Bool showme = EINA_FALSE;
2283 showme = itb->showme;
2284 itb->showme = EINA_FALSE;
2287 if (itb->realized) _item_block_unrealize(itb);
2289 if ((itb->changed) || (changed) ||
2290 ((itb->must_recalc) && (!did_must_recalc)))
2292 if ((changed) || (itb->must_recalc))
2295 Elm_Genlist_Item *it;
2296 EINA_LIST_FOREACH(itb->items, l, it)
2297 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2298 itb->changed = EINA_TRUE;
2299 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2300 itb->must_recalc = EINA_FALSE;
2302 if (itb->realized) _item_block_unrealize(itb);
2303 showme = _item_block_recalc(itb, in, 0);
2309 if (minw == -1) minw = itb->minw;
2310 else if ((!itb->must_recalc) && (minw < itb->minw))
2319 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2321 wd->show_item->showme = EINA_FALSE;
2323 elm_smart_scroller_region_bring_in(wd->scr,
2325 wd->show_item->block->x,
2327 wd->show_item->block->y,
2328 wd->show_item->block->w,
2331 elm_smart_scroller_child_region_show(wd->scr,
2333 wd->show_item->block->x,
2335 wd->show_item->block->y,
2336 wd->show_item->block->w,
2338 wd->show_item = NULL;
2343 EINA_INLIST_FOREACH(wd->blocks, itb)
2349 if ((chb) && (EINA_INLIST_GET(chb)->next))
2351 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2353 if (itb->realized) _item_block_unrealize(itb);
2356 wd->realminw = minw;
2357 if (minw < wd->w) minw = wd->w;
2358 if ((minw != wd->minw) || (minh != wd->minh))
2362 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2363 _sizing_eval(wd->obj);
2364 if ((wd->anchor_item) && (wd->anchor_item->block))
2366 Elm_Genlist_Item *it;
2369 it = wd->anchor_item;
2370 it_y = wd->anchor_y;
2371 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2372 it->block->y + it->y + it_y);
2373 wd->anchor_item = it;
2374 wd->anchor_y = it_y;
2377 t = ecore_time_get();
2378 if (did_must_recalc)
2380 if (!wd->must_recalc_idler)
2381 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2383 wd->calc_job = NULL;
2384 evas_object_smart_changed(wd->pan_smart);
2388 _update_job(void *data)
2390 Widget_Data *wd = data;
2393 int num, num0, position = 0, recalc = 0;
2395 wd->update_job = NULL;
2397 EINA_INLIST_FOREACH(wd->blocks, itb)
2399 Evas_Coord itminw, itminh;
2400 Elm_Genlist_Item *it;
2406 _item_block_position(itb, num);
2411 EINA_LIST_FOREACH(itb->items, l2, it)
2418 it->updateme = EINA_FALSE;
2421 _item_unrealize(it, EINA_FALSE);
2422 _item_realize(it, num, EINA_FALSE);
2427 _item_realize(it, num, EINA_TRUE);
2428 _item_unrealize(it, EINA_TRUE);
2430 if ((it->minw != itminw) || (it->minh != itminh))
2435 itb->updateme = EINA_FALSE;
2439 itb->changed = EINA_TRUE;
2440 _item_block_recalc(itb, num0, 0);
2441 _item_block_position(itb, num0);
2446 if (wd->calc_job) ecore_job_del(wd->calc_job);
2447 wd->calc_job = ecore_job_add(_calc_job, wd);
2452 _pan_set(Evas_Object *obj,
2456 Pan *sd = evas_object_smart_data_get(obj);
2459 // Evas_Coord ow, oh;
2460 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2461 // ow = sd->wd->minw - ow;
2462 // if (ow < 0) ow = 0;
2463 // oh = sd->wd->minh - oh;
2464 // if (oh < 0) oh = 0;
2465 // if (x < 0) x = 0;
2466 // if (y < 0) y = 0;
2467 // if (x > ow) x = ow;
2468 // if (y > oh) y = oh;
2469 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2473 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2475 if ((itb->y + itb->h) > y)
2477 Elm_Genlist_Item *it;
2480 EINA_LIST_FOREACH(itb->items, l2, it)
2482 if ((itb->y + it->y) >= y)
2484 sd->wd->anchor_item = it;
2485 sd->wd->anchor_y = -(itb->y + it->y - y);
2492 evas_object_smart_changed(obj);
2496 _pan_get(Evas_Object *obj,
2500 Pan *sd = evas_object_smart_data_get(obj);
2502 if (x) *x = sd->wd->pan_x;
2503 if (y) *y = sd->wd->pan_y;
2507 _pan_max_get(Evas_Object *obj,
2511 Pan *sd = evas_object_smart_data_get(obj);
2514 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2515 ow = sd->wd->minw - ow;
2517 oh = sd->wd->minh - oh;
2524 _pan_min_get(Evas_Object *obj __UNUSED__,
2533 _pan_child_size_get(Evas_Object *obj,
2537 Pan *sd = evas_object_smart_data_get(obj);
2539 if (w) *w = sd->wd->minw;
2540 if (h) *h = sd->wd->minh;
2544 _pan_add(Evas_Object *obj)
2547 Evas_Object_Smart_Clipped_Data *cd;
2550 cd = evas_object_smart_data_get(obj);
2553 sd->__clipped_data = *cd;
2555 evas_object_smart_data_set(obj, sd);
2559 _pan_del(Evas_Object *obj)
2561 Pan *sd = evas_object_smart_data_get(obj);
2566 ecore_job_del(sd->resize_job);
2567 sd->resize_job = NULL;
2573 _pan_resize_job(void *data)
2576 _sizing_eval(sd->wd->obj);
2577 sd->resize_job = NULL;
2581 _pan_resize(Evas_Object *obj,
2585 Pan *sd = evas_object_smart_data_get(obj);
2588 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2589 if ((ow == w) && (oh == h)) return;
2590 if ((sd->wd->height_for_width) && (ow != w))
2592 if (sd->resize_job) ecore_job_del(sd->resize_job);
2593 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2595 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2596 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2600 _pan_calculate(Evas_Object *obj)
2602 Pan *sd = evas_object_smart_data_get(obj);
2604 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2606 Elm_Genlist_Item *git;
2609 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2610 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2611 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2613 git->want_realize = EINA_FALSE;
2615 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2617 itb->w = sd->wd->minw;
2618 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2619 itb->y - sd->wd->pan_y + oy,
2621 cvx, cvy, cvw, cvh))
2623 if ((!itb->realized) || (itb->changed))
2624 _item_block_realize(itb, in, 0);
2625 _item_block_position(itb, in);
2629 if (itb->realized) _item_block_unrealize(itb);
2633 _group_items_recalc(sd->wd);
2637 _pan_move(Evas_Object *obj,
2638 Evas_Coord x __UNUSED__,
2639 Evas_Coord y __UNUSED__)
2641 Pan *sd = evas_object_smart_data_get(obj);
2643 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2644 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2648 _hold_on(void *data __UNUSED__,
2650 void *event_info __UNUSED__)
2652 Widget_Data *wd = elm_widget_data_get(obj);
2654 elm_smart_scroller_hold_set(wd->scr, 1);
2658 _hold_off(void *data __UNUSED__,
2660 void *event_info __UNUSED__)
2662 Widget_Data *wd = elm_widget_data_get(obj);
2664 elm_smart_scroller_hold_set(wd->scr, 0);
2668 _freeze_on(void *data __UNUSED__,
2670 void *event_info __UNUSED__)
2672 Widget_Data *wd = elm_widget_data_get(obj);
2674 elm_smart_scroller_freeze_set(wd->scr, 1);
2678 _freeze_off(void *data __UNUSED__,
2680 void *event_info __UNUSED__)
2682 Widget_Data *wd = elm_widget_data_get(obj);
2684 elm_smart_scroller_freeze_set(wd->scr, 0);
2688 _scroll_edge_left(void *data,
2689 Evas_Object *scr __UNUSED__,
2690 void *event_info __UNUSED__)
2692 Evas_Object *obj = data;
2693 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2697 _scroll_edge_right(void *data,
2698 Evas_Object *scr __UNUSED__,
2699 void *event_info __UNUSED__)
2701 Evas_Object *obj = data;
2702 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2706 _scroll_edge_top(void *data,
2707 Evas_Object *scr __UNUSED__,
2708 void *event_info __UNUSED__)
2710 Evas_Object *obj = data;
2711 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2715 _scroll_edge_bottom(void *data,
2716 Evas_Object *scr __UNUSED__,
2717 void *event_info __UNUSED__)
2719 Evas_Object *obj = data;
2720 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2724 _mode_item_realize(Elm_Genlist_Item *it)
2728 if ((it->mode_view) || (it->delete_me)) return;
2730 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2731 edje_object_scale_set(it->mode_view,
2732 elm_widget_scale_get(it->base.widget) *
2733 _elm_config->scale);
2734 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2735 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2737 strncpy(buf, "item", sizeof(buf));
2738 if (it->wd->compress)
2739 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2741 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2742 strncat(buf, "/", sizeof(buf) - strlen(buf));
2743 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2745 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2746 elm_widget_style_get(it->base.widget));
2747 edje_object_mirrored_set(it->mode_view,
2748 elm_widget_mirrored_get(it->base.widget));
2750 /* signal callback add */
2751 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2753 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2755 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2758 /* label_get, icon_get, state_get */
2759 /* FIXME: If you see that assert, please notify us and we
2760 will clean our mess */
2761 assert(eina_list_count(it->mode_icon_objs) == 0);
2763 _item_label_realize(it, it->mode_view, &it->mode_labels);
2764 it->mode_icon_objs = _item_icon_realize(it,
2767 _item_state_realize(it, it->mode_view, &it->mode_states);
2769 edje_object_part_swallow(it->mode_view,
2770 edje_object_data_get(it->mode_view, "mode_part"),
2773 it->want_unrealize = EINA_FALSE;
2777 _mode_item_unrealize(Elm_Genlist_Item *it)
2779 Widget_Data *wd = it->wd;
2781 if (!it->mode_view) return;
2783 elm_widget_stringlist_free(it->mode_labels);
2784 it->mode_labels = NULL;
2785 elm_widget_stringlist_free(it->mode_icons);
2786 it->mode_icons = NULL;
2787 elm_widget_stringlist_free(it->mode_states);
2789 EINA_LIST_FREE(it->mode_icon_objs, icon)
2790 evas_object_del(icon);
2792 edje_object_part_unswallow(it->mode_view, it->base.view);
2793 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2794 evas_object_del(it->mode_view);
2795 it->mode_view = NULL;
2797 if (wd->mode_item == it)
2798 wd->mode_item = NULL;
2802 _item_mode_set(Elm_Genlist_Item *it)
2805 Widget_Data *wd = it->wd;
2810 it->nocache = EINA_TRUE;
2812 if (wd->scr_hold_timer)
2814 ecore_timer_del(wd->scr_hold_timer);
2815 wd->scr_hold_timer = NULL;
2817 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2818 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2820 _mode_item_realize(it);
2821 _item_position(it, it->mode_view);
2823 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2824 edje_object_signal_emit(it->mode_view, buf, "elm");
2828 _item_mode_unset(Widget_Data *wd)
2831 if (!wd->mode_item) return;
2832 char buf[1024], buf2[1024];
2833 Elm_Genlist_Item *it;
2836 it->nocache = EINA_TRUE;
2838 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2839 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2841 edje_object_signal_emit(it->mode_view, buf, "elm");
2842 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2844 wd->mode_item = NULL;
2848 * Add a new Genlist object
2850 * @param parent The parent object
2851 * @return The new object or NULL if it cannot be created
2856 elm_genlist_add(Evas_Object *parent)
2861 Evas_Coord minw, minh;
2862 static Evas_Smart *smart = NULL;
2866 static Evas_Smart_Class sc;
2868 evas_object_smart_clipped_smart_set(&_pan_sc);
2870 sc.name = "elm_genlist_pan";
2871 sc.version = EVAS_SMART_CLASS_VERSION;
2874 sc.resize = _pan_resize;
2875 sc.move = _pan_move;
2876 sc.calculate = _pan_calculate;
2877 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2880 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2882 ELM_SET_WIDTYPE(widtype, "genlist");
2883 elm_widget_type_set(obj, "genlist");
2884 elm_widget_sub_object_add(parent, obj);
2885 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2886 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2887 elm_widget_data_set(obj, wd);
2888 elm_widget_del_hook_set(obj, _del_hook);
2889 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2890 elm_widget_theme_hook_set(obj, _theme_hook);
2891 elm_widget_can_focus_set(obj, EINA_TRUE);
2892 elm_widget_event_hook_set(obj, _event_hook);
2893 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2895 wd->scr = elm_smart_scroller_add(e);
2896 elm_smart_scroller_widget_set(wd->scr, obj);
2897 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2898 elm_widget_style_get(obj));
2899 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2900 _elm_config->thumbscroll_bounce_enable);
2901 elm_widget_resize_object_set(obj, wd->scr);
2903 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2904 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2906 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2907 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2911 wd->mode = ELM_LIST_SCROLL;
2912 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2913 wd->item_cache_max = wd->max_items_per_block * 2;
2914 wd->longpress_timeout = _elm_config->longpress_timeout;
2916 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2917 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2918 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2919 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2921 wd->pan_smart = evas_object_smart_add(e, smart);
2922 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2925 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2926 _pan_set, _pan_get, _pan_max_get,
2927 _pan_min_get, _pan_child_size_get);
2929 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2931 evas_object_size_hint_min_set(obj, minw, minh);
2933 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2935 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2940 static Elm_Genlist_Item *
2941 _item_new(Widget_Data *wd,
2942 const Elm_Genlist_Item_Class *itc,
2944 Elm_Genlist_Item *parent,
2945 Elm_Genlist_Item_Flags flags,
2947 const void *func_data)
2949 Elm_Genlist_Item *it;
2951 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2952 if (!it) return NULL;
2955 it->base.data = data;
2956 it->parent = parent;
2958 it->func.func = func;
2959 it->func.data = func_data;
2960 it->mouse_cursor = NULL;
2961 it->expanded_depth = 0;
2966 _item_block_add(Widget_Data *wd,
2967 Elm_Genlist_Item *it)
2969 Item_Block *itb = NULL;
2976 itb = calloc(1, sizeof(Item_Block));
2979 if (!it->rel->block)
2982 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2983 itb->items = eina_list_append(itb->items, it);
2989 wd->blocks = eina_inlist_prepend_relative
2990 (wd->blocks, EINA_INLIST_GET(itb),
2991 EINA_INLIST_GET(it->rel->block));
2993 eina_list_prepend_relative(itb->items, it, it->rel);
2997 wd->blocks = eina_inlist_append_relative
2998 (wd->blocks, EINA_INLIST_GET(itb),
2999 EINA_INLIST_GET(it->rel->block));
3001 eina_list_append_relative(itb->items, it, it->rel);
3011 itb = (Item_Block *)(wd->blocks);
3012 if (itb->count >= wd->max_items_per_block)
3014 itb = calloc(1, sizeof(Item_Block));
3018 eina_inlist_prepend(wd->blocks,
3019 EINA_INLIST_GET(itb));
3024 itb = calloc(1, sizeof(Item_Block));
3028 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3030 itb->items = eina_list_prepend(itb->items, it);
3036 itb = (Item_Block *)(wd->blocks->last);
3037 if (itb->count >= wd->max_items_per_block)
3039 itb = calloc(1, sizeof(Item_Block));
3043 eina_inlist_append(wd->blocks,
3044 EINA_INLIST_GET(itb));
3049 itb = calloc(1, sizeof(Item_Block));
3053 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3055 itb->items = eina_list_append(itb->items, it);
3061 itb = it->rel->block;
3062 if (!itb) goto newblock;
3064 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3066 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3069 itb->changed = EINA_TRUE;
3071 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3072 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3075 it->rel->relcount--;
3076 if ((it->rel->delete_me) && (!it->rel->relcount))
3080 if (itb->count > itb->wd->max_items_per_block)
3084 Elm_Genlist_Item *it2;
3086 newc = itb->count / 2;
3087 itb2 = calloc(1, sizeof(Item_Block));
3091 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3092 EINA_INLIST_GET(itb));
3093 itb2->changed = EINA_TRUE;
3094 while ((itb->count > newc) && (itb->items))
3098 l = eina_list_last(itb->items);
3100 itb->items = eina_list_remove_list(itb->items, l);
3103 itb2->items = eina_list_prepend(itb2->items, it2);
3111 _queue_process(Widget_Data *wd)
3114 Eina_Bool showme = EINA_FALSE;
3117 t0 = ecore_time_get();
3118 for (n = 0; (wd->queue) && (n < 128); n++)
3120 Elm_Genlist_Item *it;
3122 it = wd->queue->data;
3123 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3124 it->queued = EINA_FALSE;
3125 _item_block_add(wd, it);
3126 t = ecore_time_get();
3127 if (it->block->changed)
3129 showme = _item_block_recalc(it->block, it->block->num, 1);
3130 it->block->changed = 0;
3132 if (showme) it->block->showme = EINA_TRUE;
3133 if (eina_inlist_count(wd->blocks) > 1)
3135 if ((t - t0) > (ecore_animator_frametime_get())) break;
3142 _idle_process(void *data, Eina_Bool *wakeup)
3144 Widget_Data *wd = data;
3147 //static double q_start = 0.0;
3148 //if (q_start == 0.0) q_start = ecore_time_get();
3150 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3154 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3156 return ECORE_CALLBACK_CANCEL;
3158 return ECORE_CALLBACK_RENEW;
3162 _item_idle_enterer(void *data)
3164 Widget_Data *wd = data;
3165 Eina_Bool wakeup = EINA_FALSE;
3166 Eina_Bool ok = _idle_process(data, &wakeup);
3171 if (wd->calc_job) ecore_job_del(wd->calc_job);
3172 wd->calc_job = ecore_job_add(_calc_job, wd);
3174 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3179 _item_queue(Widget_Data *wd,
3180 Elm_Genlist_Item *it)
3182 if (it->queued) return;
3183 it->queued = EINA_TRUE;
3184 wd->queue = eina_list_append(wd->queue, it);
3185 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3187 if (wd->queue_idle_enterer)
3189 ecore_idle_enterer_del(wd->queue_idle_enterer);
3190 wd->queue_idle_enterer = NULL;
3194 if (!wd->queue_idle_enterer)
3195 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3199 _elm_genlist_item_compare(const void *data, const void *data1)
3201 Elm_Genlist_Item *item, *item1;
3202 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3203 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3204 return _elm_genlist_item_compare_cb(item->base.data, item1->base.data);
3208 * Append item to the end of the genlist
3210 * This appends the given item to the end of the list or the end of
3211 * the children if the parent is given.
3213 * @param obj The genlist object
3214 * @param itc The item class for the item
3215 * @param data The item data
3216 * @param parent The parent item, or NULL if none
3217 * @param flags Item flags
3218 * @param func Convenience function called when item selected
3219 * @param func_data Data passed to @p func above.
3220 * @return A handle to the item added or NULL if not possible
3224 EAPI Elm_Genlist_Item *
3225 elm_genlist_item_append(Evas_Object *obj,
3226 const Elm_Genlist_Item_Class *itc,
3228 Elm_Genlist_Item *parent,
3229 Elm_Genlist_Item_Flags flags,
3231 const void *func_data)
3233 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3234 Widget_Data *wd = elm_widget_data_get(obj);
3235 if (!wd) return NULL;
3236 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3238 if (!it) return NULL;
3241 if (flags & ELM_GENLIST_ITEM_GROUP)
3242 wd->group_items = eina_list_append(wd->group_items, it);
3243 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3248 Elm_Genlist_Item *it2 = NULL;
3249 Eina_List *ll = eina_list_last(it->parent->items);
3250 if (ll) it2 = ll->data;
3251 it->parent->items = eina_list_append(it->parent->items, it);
3252 if (!it2) it2 = it->parent;
3254 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3255 EINA_INLIST_GET(it2));
3257 it->rel->relcount++;
3259 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3260 it->group_item = parent;
3261 else if (it->parent->group_item)
3262 it->group_item = it->parent->group_item;
3264 it->before = EINA_FALSE;
3265 _item_queue(wd, it);
3270 * Prepend item at start of the genlist
3272 * This adds an item to the beginning of the list or beginning of the
3273 * children of the parent if given.
3275 * @param obj The genlist object
3276 * @param itc The item class for the item
3277 * @param data The item data
3278 * @param parent The parent item, or NULL if none
3279 * @param flags Item flags
3280 * @param func Convenience function called when item selected
3281 * @param func_data Data passed to @p func above.
3282 * @return A handle to the item added or NULL if not possible
3286 EAPI Elm_Genlist_Item *
3287 elm_genlist_item_prepend(Evas_Object *obj,
3288 const Elm_Genlist_Item_Class *itc,
3290 Elm_Genlist_Item *parent,
3291 Elm_Genlist_Item_Flags flags,
3293 const void *func_data)
3295 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3296 Widget_Data *wd = elm_widget_data_get(obj);
3297 if (!wd) return NULL;
3298 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3300 if (!it) return NULL;
3303 if (flags & ELM_GENLIST_ITEM_GROUP)
3304 wd->group_items = eina_list_prepend(wd->group_items, it);
3305 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3310 Elm_Genlist_Item *it2 = NULL;
3311 Eina_List *ll = it->parent->items;
3312 if (ll) it2 = ll->data;
3313 it->parent->items = eina_list_prepend(it->parent->items, it);
3314 if (!it2) it2 = it->parent;
3316 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3317 EINA_INLIST_GET(it2));
3319 it->rel->relcount++;
3321 it->before = EINA_TRUE;
3322 _item_queue(wd, it);
3327 * Insert item before another in the genlist
3329 * This inserts an item before another in the list. It will be in the
3330 * same tree level or group as the item it is inseted before.
3332 * @param obj The genlist object
3333 * @param itc The item class for the item
3334 * @param data The item data
3335 * @param before The item to insert before
3336 * @param flags Item flags
3337 * @param func Convenience function called when item selected
3338 * @param func_data Data passed to @p func above.
3339 * @return A handle to the item added or NULL if not possible
3343 EAPI Elm_Genlist_Item *
3344 elm_genlist_item_insert_before(Evas_Object *obj,
3345 const Elm_Genlist_Item_Class *itc,
3347 Elm_Genlist_Item *parent,
3348 Elm_Genlist_Item *before,
3349 Elm_Genlist_Item_Flags flags,
3351 const void *func_data)
3353 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3354 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3355 Widget_Data *wd = elm_widget_data_get(obj);
3356 if (!wd) return NULL;
3357 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3359 if (!it) return NULL;
3362 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3365 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3366 EINA_INLIST_GET(before));
3368 it->rel->relcount++;
3369 it->before = EINA_TRUE;
3370 _item_queue(wd, it);
3375 * Insert a new item into the sorted genlist object
3377 * @param obj The genlist object
3378 * @param itc The item class for the item
3379 * @param data The item data
3380 * @param parent The parent item, or NULL if none
3381 * @param flags Item flags
3382 * @param comp The function called for the sort
3383 * @param func Convenience function called when item selected
3384 * @param func_data Data passed to @p func above.
3385 * @return A handle to the item added or NULL if not possible
3389 EAPI Elm_Genlist_Item *
3390 elm_genlist_item_sorted_insert(Evas_Object *obj,
3391 const Elm_Genlist_Item_Class *itc,
3393 Elm_Genlist_Item *parent,
3394 Elm_Genlist_Item_Flags flags,
3395 Eina_Compare_Cb comp,
3397 const void *func_data)
3399 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3400 Widget_Data *wd = elm_widget_data_get(obj);
3401 if (!wd) return NULL;
3402 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3404 if (!it) return NULL;
3406 _elm_genlist_item_compare_cb = comp;
3410 eina_list_sorted_insert(it->parent->items, comp, it);
3412 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3413 _elm_genlist_item_compare);
3414 if (EINA_INLIST_GET(it)->next)
3416 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3417 it->rel->relcount++;
3418 it->before = EINA_TRUE;
3420 else if (EINA_INLIST_GET(it)->prev)
3422 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3423 it->rel->relcount++;
3424 it->before = EINA_FALSE;
3426 _item_queue(wd, it);
3432 * Insert an item after another in the genlst
3434 * This inserts an item after another in the list. It will be in the
3435 * same tree level or group as the item it is inseted after.
3437 * @param obj The genlist object
3438 * @param itc The item class for the item
3439 * @param data The item data
3440 * @param after The item to insert after
3441 * @param flags Item flags
3442 * @param func Convenience function called when item selected
3443 * @param func_data Data passed to @p func above.
3444 * @return A handle to the item added or NULL if not possible
3448 EAPI Elm_Genlist_Item *
3449 elm_genlist_item_insert_after(Evas_Object *obj,
3450 const Elm_Genlist_Item_Class *itc,
3452 Elm_Genlist_Item *parent,
3453 Elm_Genlist_Item *after,
3454 Elm_Genlist_Item_Flags flags,
3456 const void *func_data)
3458 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3459 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3460 Widget_Data *wd = elm_widget_data_get(obj);
3461 if (!wd) return NULL;
3462 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3464 if (!it) return NULL;
3465 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3466 EINA_INLIST_GET(after));
3469 it->parent->items = eina_list_append_relative(it->parent->items, it,
3473 it->rel->relcount++;
3474 it->before = EINA_FALSE;
3475 _item_queue(wd, it);
3482 * This clears all items in the list, leaving it empty.
3484 * @param obj The genlist object
3489 elm_genlist_clear(Evas_Object *obj)
3491 ELM_CHECK_WIDTYPE(obj, widtype);
3492 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (wd->walking > 0)
3496 Elm_Genlist_Item *it;
3498 wd->clear_me = EINA_TRUE;
3499 EINA_INLIST_FOREACH(wd->items, it)
3501 it->delete_me = EINA_TRUE;
3507 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3509 if (wd->anchor_item == it)
3511 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3512 if (!wd->anchor_item)
3514 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3516 wd->items = eina_inlist_remove(wd->items, wd->items);
3517 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3518 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3519 elm_widget_item_pre_notify_del(it);
3520 if (it->realized) _item_unrealize(it, EINA_FALSE);
3521 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3522 it->itc->func.del((void *)it->base.data, it->base.widget);
3523 if (it->long_timer) ecore_timer_del(it->long_timer);
3524 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3525 elm_widget_item_del(it);
3527 wd->clear_me = EINA_FALSE;
3528 wd->anchor_item = NULL;
3531 Item_Block *itb = (Item_Block *)(wd->blocks);
3533 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3534 if (itb->items) eina_list_free(itb->items);
3539 ecore_job_del(wd->calc_job);
3540 wd->calc_job = NULL;
3542 if (wd->queue_idle_enterer)
3544 ecore_idle_enterer_del(wd->queue_idle_enterer);
3545 wd->queue_idle_enterer = NULL;
3547 if (wd->must_recalc_idler)
3549 ecore_idler_del(wd->must_recalc_idler);
3550 wd->must_recalc_idler = NULL;
3554 eina_list_free(wd->queue);
3559 eina_list_free(wd->selected);
3560 wd->selected = NULL;
3562 wd->show_item = NULL;
3569 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3570 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3576 * Enable or disable multi-select in the genlist
3578 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3579 * the list. This allows more than 1 item to be selected.
3581 * @param obj The genlist object
3582 * @param multi Multi-select enable/disable
3587 elm_genlist_multi_select_set(Evas_Object *obj,
3590 ELM_CHECK_WIDTYPE(obj, widtype);
3591 Widget_Data *wd = elm_widget_data_get(obj);
3597 * Gets if multi-select in genlist is enable or disable
3599 * @param obj The genlist object
3600 * @return Multi-select enable/disable
3601 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3606 elm_genlist_multi_select_get(const Evas_Object *obj)
3608 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3609 Widget_Data *wd = elm_widget_data_get(obj);
3610 if (!wd) return EINA_FALSE;
3615 * Get the selectd item in the genlist
3617 * This gets the selected item in the list (if multi-select is enabled
3618 * only the first item in the list is selected - which is not very
3619 * useful, so see elm_genlist_selected_items_get() for when
3620 * multi-select is used).
3622 * If no item is selected, NULL is returned.
3624 * @param obj The genlist object
3625 * @return The selected item, or NULL if none.
3629 EAPI Elm_Genlist_Item *
3630 elm_genlist_selected_item_get(const Evas_Object *obj)
3632 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3633 Widget_Data *wd = elm_widget_data_get(obj);
3634 if (!wd) return NULL;
3635 if (wd->selected) return wd->selected->data;
3640 * Get a list of selected items in the genlist
3642 * This returns a list of the selected items. This list pointer is
3643 * only valid so long as no items are selected or unselected (or
3644 * unselected implicitly by deletion). The list contains
3645 * Elm_Genlist_Item pointers.
3647 * @param obj The genlist object
3648 * @return The list of selected items, nor NULL if none are selected.
3652 EAPI const Eina_List *
3653 elm_genlist_selected_items_get(const Evas_Object *obj)
3655 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3656 Widget_Data *wd = elm_widget_data_get(obj);
3657 if (!wd) return NULL;
3658 return wd->selected;
3662 * Get a list of realized items in genlist
3664 * This returns a list of the realized items in the genlist. The list
3665 * contains Elm_Genlist_Item pointers. The list must be freed by the
3666 * caller when done with eina_list_free(). The item pointers in the
3667 * list are only valid so long as those items are not deleted or the
3668 * genlist is not deleted.
3670 * @param obj The genlist object
3671 * @return The list of realized items, nor NULL if none are realized.
3676 elm_genlist_realized_items_get(const Evas_Object *obj)
3678 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3679 Widget_Data *wd = elm_widget_data_get(obj);
3680 Eina_List *list = NULL;
3682 Eina_Bool done = EINA_FALSE;
3683 if (!wd) return NULL;
3684 EINA_INLIST_FOREACH(wd->blocks, itb)
3689 Elm_Genlist_Item *it;
3692 EINA_LIST_FOREACH(itb->items, l, it)
3694 if (it->realized) list = eina_list_append(list, it);
3706 * Get the item that is at the x, y canvas coords
3708 * This returns the item at the given coordinates (which are canvas
3709 * relative not object-relative). If an item is at that coordinate,
3710 * that item handle is returned, and if @p posret is not NULL, the
3711 * integer pointed to is set to a value of -1, 0 or 1, depending if
3712 * the coordinate is on the upper portion of that item (-1), on the
3713 * middle section (0) or on the lower part (1). If NULL is returned as
3714 * an item (no item found there), then posret may indicate -1 or 1
3715 * based if the coordinate is above or below all items respectively in
3718 * @param it The item
3719 * @param x The input x coordinate
3720 * @param y The input y coordinate
3721 * @param posret The position relative to the item returned here
3722 * @return The item at the coordinates or NULL if none
3726 EAPI Elm_Genlist_Item *
3727 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3732 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3733 Widget_Data *wd = elm_widget_data_get(obj);
3734 Evas_Coord ox, oy, ow, oh;
3737 if (!wd) return NULL;
3738 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3740 EINA_INLIST_FOREACH(wd->blocks, itb)
3743 Elm_Genlist_Item *it;
3745 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3746 oy + itb->y - itb->wd->pan_y,
3747 itb->w, itb->h, x, y, 1, 1))
3749 EINA_LIST_FOREACH(itb->items, l, it)
3751 Evas_Coord itx, ity;
3753 itx = ox + itb->x + it->x - itb->wd->pan_x;
3754 ity = oy + itb->y + it->y - itb->wd->pan_y;
3755 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3759 if (y <= (ity + (it->h / 4))) *posret = -1;
3760 else if (y >= (ity + it->h - (it->h / 4)))
3766 lasty = ity + it->h;
3771 if (y > lasty) *posret = 1;
3778 * Get the first item in the genlist
3780 * This returns the first item in the list.
3782 * @param obj The genlist object
3783 * @return The first item, or NULL if none
3787 EAPI Elm_Genlist_Item *
3788 elm_genlist_first_item_get(const Evas_Object *obj)
3790 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3791 Widget_Data *wd = elm_widget_data_get(obj);
3792 if (!wd) return NULL;
3793 if (!wd->items) return NULL;
3794 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3795 while ((it) && (it->delete_me))
3796 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3801 * Get the last item in the genlist
3803 * This returns the last item in the list.
3805 * @return The last item, or NULL if none
3809 EAPI Elm_Genlist_Item *
3810 elm_genlist_last_item_get(const Evas_Object *obj)
3812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3813 Widget_Data *wd = elm_widget_data_get(obj);
3814 if (!wd) return NULL;
3815 if (!wd->items) return NULL;
3816 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3817 while ((it) && (it->delete_me))
3818 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3823 * Get the next item in the genlist
3825 * This returns the item after the item @p it.
3827 * @param it The item
3828 * @return The item after @p it, or NULL if none
3832 EAPI Elm_Genlist_Item *
3833 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3835 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3838 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3839 if ((it) && (!it->delete_me)) break;
3841 return (Elm_Genlist_Item *)it;
3845 * Get the previous item in the genlist
3847 * This returns the item before the item @p it.
3849 * @param it The item
3850 * @return The item before @p it, or NULL if none
3854 EAPI Elm_Genlist_Item *
3855 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3857 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3860 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3861 if ((it) && (!it->delete_me)) break;
3863 return (Elm_Genlist_Item *)it;
3867 * Get the genlist object from an item
3869 * This returns the genlist object itself that an item belongs to.
3871 * @param it The item
3872 * @return The genlist object
3877 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3879 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3880 return it->base.widget;
3884 * Get the parent item of the given item
3886 * This returns the parent item of the item @p it given.
3888 * @param it The item
3889 * @return The parent of the item or NULL if none
3893 EAPI Elm_Genlist_Item *
3894 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3896 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3901 * Clear all sub-items (children) of the given item
3903 * This clears all items that are children (or their descendants) of the
3906 * @param it The item
3911 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3913 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3914 Eina_List *tl = NULL, *l;
3915 Elm_Genlist_Item *it2;
3917 EINA_LIST_FOREACH(it->items, l, it2)
3918 tl = eina_list_append(tl, it2);
3919 EINA_LIST_FREE(tl, it2)
3920 elm_genlist_item_del(it2);
3924 * Set the selected state of an item
3926 * This sets the selected state (1 selected, 0 not selected) of the given
3929 * @param it The item
3930 * @param selected The selected state
3935 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3938 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3939 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3941 if ((it->delete_me) || (it->disabled)) return;
3942 selected = !!selected;
3943 if (it->selected == selected) return;
3949 while (wd->selected)
3951 _item_unhighlight(wd->selected->data);
3952 _item_unselect(wd->selected->data);
3955 _item_highlight(it);
3960 _item_unhighlight(it);
3966 * Get the selected state of an item
3968 * This gets the selected state of an item (1 selected, 0 not selected).
3970 * @param it The item
3971 * @return The selected state
3976 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3978 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3979 return it->selected;
3983 * Sets the expanded state of an item (if it's a parent)
3985 * This expands or contracts a parent item (thus showing or hiding the
3988 * @param it The item
3989 * @param expanded The expanded state (1 expanded, 0 not expanded).
3994 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3997 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3998 if (it->expanded == expanded) return;
3999 it->expanded = expanded;
4003 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4004 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
4009 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4010 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
4015 * Get the expanded state of an item
4017 * This gets the expanded state of an item
4019 * @param it The item
4020 * @return Thre expanded state
4025 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4027 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4028 return it->expanded;
4032 * Get the depth of expanded item
4034 * @param it The genlist item object
4035 * @return The depth of expanded item
4040 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4042 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4043 return it->expanded_depth;
4047 * Sets the disabled state of an item.
4049 * A disabled item cannot be selected or unselected. It will also
4050 * change appearance to appear disabled. This sets the disabled state
4051 * (1 disabled, 0 not disabled).
4053 * @param it The item
4054 * @param disabled The disabled state
4059 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4062 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4065 if (it->disabled == disabled) return;
4066 if (it->delete_me) return;
4067 it->disabled = !!disabled;
4069 elm_genlist_item_selected_set(it, EINA_FALSE);
4073 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4075 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4076 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4077 elm_widget_disabled_set(obj, disabled);
4082 * Get the disabled state of an item
4084 * This gets the disabled state of the given item.
4086 * @param it The item
4087 * @return The disabled state
4092 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4094 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4095 if (it->delete_me) return EINA_FALSE;
4096 return it->disabled;
4100 * Sets the display only state of an item.
4102 * A display only item cannot be selected or unselected. It is for
4103 * display only and not selecting or otherwise clicking, dragging
4104 * etc. by the user, thus finger size rules will not be applied to
4107 * @param it The item
4108 * @param display_only The display only state
4113 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4114 Eina_Bool display_only)
4116 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4117 if (it->display_only == display_only) return;
4118 if (it->delete_me) return;
4119 it->display_only = display_only;
4120 it->mincalcd = EINA_FALSE;
4121 it->updateme = EINA_TRUE;
4122 if (it->block) it->block->updateme = EINA_TRUE;
4123 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4124 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4128 * Get the display only state of an item
4130 * This gets the display only state of the given item.
4132 * @param it The item
4133 * @return The display only state
4138 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4140 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4141 if (it->delete_me) return EINA_FALSE;
4142 return it->display_only;
4146 * Show the given item
4148 * This causes genlist to jump to the given item @p it and show it (by
4149 * scrolling), if it is not fully visible.
4151 * @param it The item
4156 elm_genlist_item_show(Elm_Genlist_Item *it)
4158 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4159 Evas_Coord gith = 0;
4160 if (it->delete_me) return;
4161 if ((it->queued) || (!it->mincalcd))
4163 it->wd->show_item = it;
4164 it->wd->bring_in = EINA_TRUE;
4165 it->showme = EINA_TRUE;
4168 if (it->wd->show_item)
4170 it->wd->show_item->showme = EINA_FALSE;
4171 it->wd->show_item = NULL;
4173 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4174 gith = it->group_item->h;
4175 elm_smart_scroller_child_region_show(it->wd->scr,
4176 it->x + it->block->x,
4177 it->y + it->block->y - gith,
4178 it->block->w, it->h);
4182 * Bring in the given item
4184 * This causes genlist to jump to the given item @p it and show it (by
4185 * scrolling), if it is not fully visible. This may use animation to
4186 * do so and take a period of time
4188 * @param it The item
4193 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4195 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4196 Evas_Coord gith = 0;
4197 if (it->delete_me) return;
4198 if ((it->queued) || (!it->mincalcd))
4200 it->wd->show_item = it;
4201 it->wd->bring_in = EINA_TRUE;
4202 it->showme = EINA_TRUE;
4205 if (it->wd->show_item)
4207 it->wd->show_item->showme = EINA_FALSE;
4208 it->wd->show_item = NULL;
4210 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4211 gith = it->group_item->h;
4212 elm_smart_scroller_region_bring_in(it->wd->scr,
4213 it->x + it->block->x,
4214 it->y + it->block->y - gith,
4215 it->block->w, it->h);
4219 * Show the given item at the top
4221 * This causes genlist to jump to the given item @p it and show it (by
4222 * scrolling), if it is not fully visible.
4224 * @param it The item
4229 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4233 Evas_Coord gith = 0;
4235 if (it->delete_me) return;
4236 if ((it->queued) || (!it->mincalcd))
4238 it->wd->show_item = it;
4239 it->wd->bring_in = EINA_TRUE;
4240 it->showme = EINA_TRUE;
4243 if (it->wd->show_item)
4245 it->wd->show_item->showme = EINA_FALSE;
4246 it->wd->show_item = NULL;
4248 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4249 if (it->group_item) gith = it->group_item->h;
4250 elm_smart_scroller_child_region_show(it->wd->scr,
4251 it->x + it->block->x,
4252 it->y + it->block->y - gith,
4257 * Bring in the given item at the top
4259 * This causes genlist to jump to the given item @p it and show it (by
4260 * scrolling), if it is not fully visible. This may use animation to
4261 * do so and take a period of time
4263 * @param it The item
4268 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4272 Evas_Coord gith = 0;
4274 if (it->delete_me) return;
4275 if ((it->queued) || (!it->mincalcd))
4277 it->wd->show_item = it;
4278 it->wd->bring_in = EINA_TRUE;
4279 it->showme = EINA_TRUE;
4282 if (it->wd->show_item)
4284 it->wd->show_item->showme = EINA_FALSE;
4285 it->wd->show_item = NULL;
4287 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4288 if (it->group_item) gith = it->group_item->h;
4289 elm_smart_scroller_region_bring_in(it->wd->scr,
4290 it->x + it->block->x,
4291 it->y + it->block->y - gith,
4296 * Show the given item at the middle
4298 * This causes genlist to jump to the given item @p it and show it (by
4299 * scrolling), if it is not fully visible.
4301 * @param it The item
4306 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4308 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4311 if (it->delete_me) return;
4312 if ((it->queued) || (!it->mincalcd))
4314 it->wd->show_item = it;
4315 it->wd->bring_in = EINA_TRUE;
4316 it->showme = EINA_TRUE;
4319 if (it->wd->show_item)
4321 it->wd->show_item->showme = EINA_FALSE;
4322 it->wd->show_item = NULL;
4324 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4325 elm_smart_scroller_child_region_show(it->wd->scr,
4326 it->x + it->block->x,
4327 it->y + it->block->y - oh / 2 +
4328 it->h / 2, it->block->w, oh);
4332 * Bring in the given item at the middle
4334 * This causes genlist to jump to the given item @p it and show it (by
4335 * scrolling), if it is not fully visible. This may use animation to
4336 * do so and take a period of time
4338 * @param it The item
4343 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4345 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4348 if (it->delete_me) return;
4349 if ((it->queued) || (!it->mincalcd))
4351 it->wd->show_item = it;
4352 it->wd->bring_in = EINA_TRUE;
4353 it->showme = EINA_TRUE;
4356 if (it->wd->show_item)
4358 it->wd->show_item->showme = EINA_FALSE;
4359 it->wd->show_item = NULL;
4361 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4362 elm_smart_scroller_region_bring_in(it->wd->scr,
4363 it->x + it->block->x,
4364 it->y + it->block->y - oh / 2 + it->h / 2,
4369 * Delete a given item
4371 * This deletes the item from genlist and calls the genlist item del
4372 * class callback defined in the item class, if it is set. This clears all
4373 * subitems if it is a tree.
4375 * @param it The item
4380 elm_genlist_item_del(Elm_Genlist_Item *it)
4382 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4383 if ((it->relcount > 0) || (it->walking > 0))
4385 elm_widget_item_pre_notify_del(it);
4386 elm_genlist_item_subitems_clear(it);
4387 it->delete_me = EINA_TRUE;
4388 if (it->wd->show_item == it) it->wd->show_item = NULL;
4390 it->wd->selected = eina_list_remove(it->wd->selected,
4394 if (it->realized) _item_unrealize(it, EINA_FALSE);
4395 it->block->changed = EINA_TRUE;
4396 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4397 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4399 if (it->itc->func.del)
4400 it->itc->func.del((void *)it->base.data, it->base.widget);
4407 * Set the data item from the genlist item
4409 * This set the data value passed on the elm_genlist_item_append() and
4410 * related item addition calls. This function will also call
4411 * elm_genlist_item_update() so the item will be updated to reflect the
4414 * @param it The item
4415 * @param data The new data pointer to set
4420 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4423 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4424 elm_widget_item_data_set(it, data);
4425 elm_genlist_item_update(it);
4429 * Get the data item from the genlist item
4431 * This returns the data value passed on the elm_genlist_item_append()
4432 * and related item addition calls and elm_genlist_item_data_set().
4434 * @param it The item
4435 * @return The data pointer provided when created
4440 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4442 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4443 return elm_widget_item_data_get(it);
4447 * Tells genlist to "orphan" icons fetchs by the item class
4449 * This instructs genlist to release references to icons in the item,
4450 * meaning that they will no longer be managed by genlist and are
4451 * floating "orphans" that can be re-used elsewhere if the user wants
4454 * @param it The item
4459 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4462 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4463 EINA_LIST_FREE(it->icon_objs, icon)
4465 elm_widget_sub_object_del(it->base.widget, icon);
4466 evas_object_smart_member_del(icon);
4467 evas_object_hide(icon);
4472 * Get the real evas object of the genlist item
4474 * This returns the actual evas object used for the specified genlist
4475 * item. This may be NULL as it may not be created, and may be deleted
4476 * at any time by genlist. Do not modify this object (move, resize,
4477 * show, hide etc.) as genlist is controlling it. This function is for
4478 * querying, emitting custom signals or hooking lower level callbacks
4479 * for events. Do not delete this object under any circumstances.
4481 * @param it The item
4482 * @return The object pointer
4486 EAPI const Evas_Object *
4487 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4489 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4490 return it->base.view;
4494 * Update the contents of an item
4496 * This updates an item by calling all the item class functions again
4497 * to get the icons, labels and states. Use this when the original
4498 * item data has changed and the changes are desired to be reflected.
4500 * @param it The item
4505 elm_genlist_item_update(Elm_Genlist_Item *it)
4507 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4508 if (!it->block) return;
4509 if (it->delete_me) return;
4510 it->mincalcd = EINA_FALSE;
4511 it->updateme = EINA_TRUE;
4512 it->block->updateme = EINA_TRUE;
4513 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4514 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4518 * Update the item class of an item
4520 * @param it The item
4521 * @parem itc The item class for the item
4526 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4527 const Elm_Genlist_Item_Class *itc)
4529 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4530 if (!it->block) return;
4531 EINA_SAFETY_ON_NULL_RETURN(itc);
4532 if (it->delete_me) return;
4534 it->nocache = EINA_TRUE;
4535 elm_genlist_item_update(it);
4538 static Evas_Object *
4539 _elm_genlist_item_label_create(void *data,
4541 void *item __UNUSED__)
4543 Evas_Object *label = elm_label_add(obj);
4546 elm_object_style_set(label, "tooltip");
4547 elm_label_label_set(label, data);
4552 _elm_genlist_item_label_del_cb(void *data,
4553 Evas_Object *obj __UNUSED__,
4554 void *event_info __UNUSED__)
4556 eina_stringshare_del(data);
4560 * Set the text to be shown in the genlist item.
4562 * @param item Target item
4563 * @param text The text to set in the content
4565 * Setup the text as tooltip to object. The item can have only one
4566 * tooltip, so any previous tooltip data is removed.
4571 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4574 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4575 text = eina_stringshare_add(text);
4576 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4578 _elm_genlist_item_label_del_cb);
4582 * Set the content to be shown in the tooltip item
4584 * Setup the tooltip to item. The item can have only one tooltip, so
4585 * any previous tooltip data is removed. @p func(with @p data) will be
4586 * called every time that need to show the tooltip and it should return a
4587 * valid Evas_Object. This object is then managed fully by tooltip
4588 * system and is deleted when the tooltip is gone.
4590 * @param item the genlist item being attached by a tooltip.
4591 * @param func the function used to create the tooltip contents.
4592 * @param data what to provide to @a func as callback data/context.
4593 * @param del_cb called when data is not needed anymore, either when
4594 * another callback replaces @func, the tooltip is unset with
4595 * elm_genlist_item_tooltip_unset() or the owner @a item
4596 * dies. This callback receives as the first parameter the
4597 * given @a data, and @c event_info is the item.
4602 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4603 Elm_Tooltip_Item_Content_Cb func,
4605 Evas_Smart_Cb del_cb)
4607 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4609 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4612 if (item->tooltip.del_cb)
4613 item->tooltip.del_cb((void *)item->tooltip.data,
4614 item->base.widget, item);
4616 item->tooltip.content_cb = func;
4617 item->tooltip.data = data;
4618 item->tooltip.del_cb = del_cb;
4620 if (item->base.view)
4622 elm_widget_item_tooltip_content_cb_set(item,
4623 item->tooltip.content_cb,
4624 item->tooltip.data, NULL);
4625 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4631 if (del_cb) del_cb((void *)data, NULL, NULL);
4635 * Unset tooltip from item
4637 * @param item genlist item to remove previously set tooltip.
4639 * Remove tooltip from item. The callback provided as del_cb to
4640 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4641 * it is not used anymore.
4643 * @see elm_genlist_item_tooltip_content_cb_set()
4648 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4650 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4651 if ((item->base.view) && (item->tooltip.content_cb))
4652 elm_widget_item_tooltip_unset(item);
4654 if (item->tooltip.del_cb)
4655 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4656 item->tooltip.del_cb = NULL;
4657 item->tooltip.content_cb = NULL;
4658 item->tooltip.data = NULL;
4659 if (item->tooltip.style)
4660 elm_genlist_item_tooltip_style_set(item, NULL);
4664 * Sets a different style for this item tooltip.
4666 * @note before you set a style you should define a tooltip with
4667 * elm_genlist_item_tooltip_content_cb_set() or
4668 * elm_genlist_item_tooltip_text_set()
4670 * @param item genlist item with tooltip already set.
4671 * @param style the theme style to use (default, transparent, ...)
4676 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4679 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4680 eina_stringshare_replace(&item->tooltip.style, style);
4681 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4685 * Get the style for this item tooltip.
4687 * @param item genlist item with tooltip already set.
4688 * @return style the theme style in use, defaults to "default". If the
4689 * object does not have a tooltip set, then NULL is returned.
4694 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4696 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4697 return item->tooltip.style;
4701 * Set the cursor to be shown when mouse is over the genlist item
4703 * @param item Target item
4704 * @param cursor the cursor name to be used.
4706 * @see elm_object_cursor_set()
4710 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4713 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4714 eina_stringshare_replace(&item->mouse_cursor, cursor);
4715 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4719 * Get the cursor to be shown when mouse is over the genlist item
4721 * @param item genlist item with cursor already set.
4722 * @return the cursor name.
4727 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4729 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4730 return elm_widget_item_cursor_get(item);
4734 * Unset the cursor to be shown when mouse is over the genlist item
4736 * @param item Target item
4738 * @see elm_object_cursor_unset()
4742 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4744 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4745 if (!item->mouse_cursor)
4748 if (item->base.view)
4749 elm_widget_item_cursor_unset(item);
4751 eina_stringshare_del(item->mouse_cursor);
4752 item->mouse_cursor = NULL;
4756 * Sets a different style for this item cursor.
4758 * @note before you set a style you should define a cursor with
4759 * elm_genlist_item_cursor_set()
4761 * @param item genlist item with cursor already set.
4762 * @param style the theme style to use (default, transparent, ...)
4767 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4770 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4771 elm_widget_item_cursor_style_set(item, style);
4775 * Get the style for this item cursor.
4777 * @param item genlist item with cursor already set.
4778 * @return style the theme style in use, defaults to "default". If the
4779 * object does not have a cursor set, then NULL is returned.
4784 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4786 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4787 return elm_widget_item_cursor_style_get(item);
4791 * Set if the cursor set should be searched on the theme or should use
4792 * the provided by the engine, only.
4794 * @note before you set if should look on theme you should define a
4795 * cursor with elm_object_cursor_set(). By default it will only look
4796 * for cursors provided by the engine.
4798 * @param item widget item with cursor already set.
4799 * @param engine_only boolean to define it cursors should be looked
4800 * only between the provided by the engine or searched on widget's
4806 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4807 Eina_Bool engine_only)
4809 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4810 elm_widget_item_cursor_engine_only_set(item, engine_only);
4814 * Get the cursor engine only usage for this item cursor.
4816 * @param item widget item with cursor already set.
4817 * @return engine_only boolean to define it cursors should be looked
4818 * only between the provided by the engine or searched on widget's
4819 * theme as well. If the object does not have a cursor set, then
4820 * EINA_FALSE is returned.
4825 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4827 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4828 return elm_widget_item_cursor_engine_only_get(item);
4832 * This sets the horizontal stretching mode
4834 * This sets the mode used for sizing items horizontally. Valid modes
4835 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4836 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4837 * the scroller will scroll horizontally. Otherwise items are expanded
4838 * to fill the width of the viewport of the scroller. If it is
4839 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4840 * limited to that size.
4842 * @param obj The genlist object
4843 * @param mode The mode to use
4848 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4851 ELM_CHECK_WIDTYPE(obj, widtype);
4852 Widget_Data *wd = elm_widget_data_get(obj);
4854 if (wd->mode == mode) return;
4860 * Gets the horizontal stretching mode
4862 * @param obj The genlist object
4863 * @return The mode to use
4864 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4869 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4871 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4872 Widget_Data *wd = elm_widget_data_get(obj);
4873 if (!wd) return ELM_LIST_LAST;
4878 * Set the always select mode.
4880 * Items will only call their selection func and callback when first
4881 * becoming selected. Any further clicks will do nothing, unless you
4882 * enable always select with elm_genlist_always_select_mode_set().
4883 * This means even if selected, every click will make the selected
4884 * callbacks be called.
4886 * @param obj The genlist object
4887 * @param always_select The always select mode
4888 * (EINA_TRUE = on, EINA_FALSE = off)
4893 elm_genlist_always_select_mode_set(Evas_Object *obj,
4894 Eina_Bool always_select)
4896 ELM_CHECK_WIDTYPE(obj, widtype);
4897 Widget_Data *wd = elm_widget_data_get(obj);
4899 wd->always_select = always_select;
4903 * Get the always select mode.
4905 * @param obj The genlist object
4906 * @return The always select mode
4907 * (EINA_TRUE = on, EINA_FALSE = off)
4912 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4914 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4915 Widget_Data *wd = elm_widget_data_get(obj);
4916 if (!wd) return EINA_FALSE;
4917 return wd->always_select;
4921 * Set no select mode
4923 * This will turn off the ability to select items entirely and they
4924 * will neither appear selected nor call selected callback functions.
4926 * @param obj The genlist object
4927 * @param no_select The no select mode
4928 * (EINA_TRUE = on, EINA_FALSE = off)
4933 elm_genlist_no_select_mode_set(Evas_Object *obj,
4934 Eina_Bool no_select)
4936 ELM_CHECK_WIDTYPE(obj, widtype);
4937 Widget_Data *wd = elm_widget_data_get(obj);
4939 wd->no_select = no_select;
4943 * Gets no select mode
4945 * @param obj The genlist object
4946 * @return The no select mode
4947 * (EINA_TRUE = on, EINA_FALSE = off)
4952 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4954 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4955 Widget_Data *wd = elm_widget_data_get(obj);
4956 if (!wd) return EINA_FALSE;
4957 return wd->no_select;
4963 * This will enable the compress mode where items are "compressed"
4964 * horizontally to fit the genlist scrollable viewport width. This is
4965 * special for genlist. Do not rely on
4966 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4967 * work as genlist needs to handle it specially.
4969 * @param obj The genlist object
4970 * @param compress The compress mode
4971 * (EINA_TRUE = on, EINA_FALSE = off)
4976 elm_genlist_compress_mode_set(Evas_Object *obj,
4979 ELM_CHECK_WIDTYPE(obj, widtype);
4980 Widget_Data *wd = elm_widget_data_get(obj);
4982 wd->compress = compress;
4983 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4987 * Get the compress mode
4989 * @param obj The genlist object
4990 * @return The compress mode
4991 * (EINA_TRUE = on, EINA_FALSE = off)
4996 elm_genlist_compress_mode_get(const Evas_Object *obj)
4998 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4999 Widget_Data *wd = elm_widget_data_get(obj);
5000 if (!wd) return EINA_FALSE;
5001 return wd->compress;
5005 * Set height-for-width mode
5007 * With height-for-width mode the item width will be fixed (restricted
5008 * to a minimum of) to the list width when calculating its size in
5009 * order to allow the height to be calculated based on it. This allows,
5010 * for instance, text block to wrap lines if the Edje part is
5011 * configured with "text.min: 0 1".
5013 * @note This mode will make list resize slower as it will have to
5014 * recalculate every item height again whenever the list width
5017 * @note When height-for-width mode is enabled, it also enables
5018 * compress mode (see elm_genlist_compress_mode_set()) and
5019 * disables homogeneous (see elm_genlist_homogeneous_set()).
5021 * @param obj The genlist object
5022 * @param setting The height-for-width mode (EINA_TRUE = on,
5028 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5029 Eina_Bool height_for_width)
5031 ELM_CHECK_WIDTYPE(obj, widtype);
5032 Widget_Data *wd = elm_widget_data_get(obj);
5034 wd->height_for_width = !!height_for_width;
5035 if (wd->height_for_width)
5037 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5038 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5043 * Get the height-for-width mode
5045 * @param obj The genlist object
5046 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5052 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5054 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5055 Widget_Data *wd = elm_widget_data_get(obj);
5056 if (!wd) return EINA_FALSE;
5057 return wd->height_for_width;
5063 * This will enable or disable the scroller bounce mode for the
5064 * genlist. See elm_scroller_bounce_set() for details
5066 * @param obj The genlist object
5067 * @param h_bounce Allow bounce horizontally
5068 * @param v_bounce Allow bounce vertically
5073 elm_genlist_bounce_set(Evas_Object *obj,
5077 ELM_CHECK_WIDTYPE(obj, widtype);
5078 Widget_Data *wd = elm_widget_data_get(obj);
5080 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5084 * Get the bounce mode
5086 * @param obj The genlist object
5087 * @param h_bounce Allow bounce horizontally
5088 * @param v_bounce Allow bounce vertically
5093 elm_genlist_bounce_get(const Evas_Object *obj,
5094 Eina_Bool *h_bounce,
5095 Eina_Bool *v_bounce)
5097 ELM_CHECK_WIDTYPE(obj, widtype);
5098 Widget_Data *wd = elm_widget_data_get(obj);
5100 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5104 * Set homogenous mode
5106 * This will enable the homogeneous mode where items are of the same
5107 * height and width so that genlist may do the lazy-loading at its
5108 * maximum. This implies 'compressed' mode.
5110 * @param obj The genlist object
5111 * @param homogeneous Assume the items within the genlist are of the
5112 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5117 elm_genlist_homogeneous_set(Evas_Object *obj,
5118 Eina_Bool homogeneous)
5120 ELM_CHECK_WIDTYPE(obj, widtype);
5121 Widget_Data *wd = elm_widget_data_get(obj);
5123 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5124 wd->homogeneous = homogeneous;
5128 * Get the homogenous mode
5130 * @param obj The genlist object
5131 * @return Assume the items within the genlist are of the same height
5132 * and width (EINA_TRUE = on, EINA_FALSE = off)
5137 elm_genlist_homogeneous_get(const Evas_Object *obj)
5139 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5140 Widget_Data *wd = elm_widget_data_get(obj);
5141 if (!wd) return EINA_FALSE;
5142 return wd->homogeneous;
5146 * Set the maximum number of items within an item block
5148 * This will configure the block count to tune to the target with
5149 * particular performance matrix.
5151 * @param obj The genlist object
5152 * @param n Maximum number of items within an item block
5157 elm_genlist_block_count_set(Evas_Object *obj,
5160 ELM_CHECK_WIDTYPE(obj, widtype);
5161 Widget_Data *wd = elm_widget_data_get(obj);
5163 wd->max_items_per_block = n;
5164 wd->item_cache_max = wd->max_items_per_block * 2;
5165 _item_cache_clean(wd);
5169 * Get the maximum number of items within an item block
5171 * @param obj The genlist object
5172 * @return Maximum number of items within an item block
5177 elm_genlist_block_count_get(const Evas_Object *obj)
5179 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5180 Widget_Data *wd = elm_widget_data_get(obj);
5182 return wd->max_items_per_block;
5186 * Set the timeout in seconds for the longpress event
5188 * @param obj The genlist object
5189 * @param timeout timeout in seconds
5194 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5197 ELM_CHECK_WIDTYPE(obj, widtype);
5198 Widget_Data *wd = elm_widget_data_get(obj);
5200 wd->longpress_timeout = timeout;
5204 * Get the timeout in seconds for the longpress event
5206 * @param obj The genlist object
5207 * @return timeout in seconds
5212 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5214 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5215 Widget_Data *wd = elm_widget_data_get(obj);
5217 return wd->longpress_timeout;
5221 * Set the scrollbar policy
5223 * This sets the scrollbar visibility policy for the given genlist
5224 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5225 * made visible if it is needed, and otherwise kept hidden.
5226 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5227 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5228 * respectively for the horizontal and vertical scrollbars.
5230 * @param obj The genlist object
5231 * @param policy_h Horizontal scrollbar policy
5232 * @param policy_v Vertical scrollbar policy
5237 elm_genlist_scroller_policy_set(Evas_Object *obj,
5238 Elm_Scroller_Policy policy_h,
5239 Elm_Scroller_Policy policy_v)
5241 ELM_CHECK_WIDTYPE(obj, widtype);
5242 Widget_Data *wd = elm_widget_data_get(obj);
5244 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5245 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5248 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5252 * Get the scrollbar policy
5254 * @param obj The genlist object
5255 * @param policy_h Horizontal scrollbar policy
5256 * @param policy_v Vertical scrollbar policy
5261 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5262 Elm_Scroller_Policy *policy_h,
5263 Elm_Scroller_Policy *policy_v)
5265 ELM_CHECK_WIDTYPE(obj, widtype);
5266 Widget_Data *wd = elm_widget_data_get(obj);
5267 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5268 if ((!wd) || (!wd->scr)) return;
5269 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5270 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5271 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5275 * Update the contents of all realized items
5277 * This updates all realized items by calling all the item class functions again
5278 * to get the icons, labels and states. Use this when the original
5279 * item data has changed and the changes are desired to be reflected.
5281 * @param it The item
5286 elm_genlist_realized_items_update(Evas_Object *obj)
5288 ELM_CHECK_WIDTYPE(obj, widtype);
5290 Eina_List *list, *l;
5291 Elm_Genlist_Item *it;
5293 list = elm_genlist_realized_items_get(obj);
5294 EINA_LIST_FOREACH(list, l, it)
5295 elm_genlist_item_update(it);
5299 * Set genlist item mode
5301 * @param item The genlist item
5302 * @param mode Mode name
5303 * @param mode_set Boolean to define set or unset mode.
5308 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5309 const char *mode_type,
5312 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5313 Widget_Data *wd = it->wd;
5315 Elm_Genlist_Item *it2;
5318 if (!mode_type) return;
5319 if ((it->delete_me) || (it->disabled)) return;
5321 if ((wd->mode_item == it) &&
5322 (!strcmp(mode_type, wd->mode_type)) &&
5325 if (!it->itc->mode_item_style) return;
5329 EINA_LIST_FOREACH(wd->selected, l, it2)
5331 elm_genlist_item_selected_set(it2, EINA_FALSE);
5335 it2 = elm_genlist_selected_item_get(wd->obj);
5336 if ((it2) && (it2->realized))
5337 elm_genlist_item_selected_set(it2, EINA_FALSE);
5340 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5342 ((it == wd->mode_item) && (!mode_set)))
5343 _item_mode_unset(wd);
5345 eina_stringshare_replace(&wd->mode_type, mode_type);
5346 if (mode_set) _item_mode_set(it);
5350 * Get active genlist mode type
5352 * @param obj The genlist object
5357 elm_genlist_mode_get(const Evas_Object *obj)
5359 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5360 Widget_Data *wd = elm_widget_data_get(obj);
5361 if (!wd) return NULL;
5362 return wd->mode_type;
5366 * Get active genlist mode item
5368 * @param obj The genlist object
5372 EAPI const Elm_Genlist_Item *
5373 elm_genlist_mode_item_get(const Evas_Object *obj)
5375 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5376 Widget_Data *wd = elm_widget_data_get(obj);
5377 if (!wd) return NULL;
5378 return wd->mode_item;