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, ""},
454 _event_hook(Evas_Object *obj,
455 Evas_Object *src __UNUSED__,
456 Evas_Callback_Type type,
459 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
460 Evas_Event_Key_Down *ev = event_info;
461 Widget_Data *wd = elm_widget_data_get(obj);
462 if (!wd) return EINA_FALSE;
463 if (!wd->items) return EINA_FALSE;
464 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
465 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
467 Elm_Genlist_Item *it = NULL;
470 Evas_Coord step_x = 0;
471 Evas_Coord step_y = 0;
474 Evas_Coord page_x = 0;
475 Evas_Coord page_y = 0;
477 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
478 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
479 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
480 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
482 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
486 else if ((!strcmp(ev->keyname, "Right")) ||
487 (!strcmp(ev->keyname, "KP_Right")))
491 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
493 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
494 (_item_multi_select_up(wd)))
495 || (_item_single_select_up(wd)))
497 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
503 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
505 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
506 (_item_multi_select_down(wd)))
507 || (_item_single_select_down(wd)))
509 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
515 else if ((!strcmp(ev->keyname, "Home")) ||
516 (!strcmp(ev->keyname, "KP_Home")))
518 it = elm_genlist_first_item_get(obj);
519 elm_genlist_item_bring_in(it);
520 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
523 else if ((!strcmp(ev->keyname, "End")) ||
524 (!strcmp(ev->keyname, "KP_End")))
526 it = elm_genlist_last_item_get(obj);
527 elm_genlist_item_bring_in(it);
528 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
531 else if ((!strcmp(ev->keyname, "Prior")) ||
532 (!strcmp(ev->keyname, "KP_Prior")))
535 y -= -(page_y * v_h) / 100;
539 else if ((!strcmp(ev->keyname, "Next")) ||
540 (!strcmp(ev->keyname, "KP_Next")))
543 y += -(page_y * v_h) / 100;
547 else if(((!strcmp(ev->keyname, "Return")) ||
548 (!strcmp(ev->keyname, "KP_Enter")) ||
549 (!strcmp(ev->keyname, "space")))
550 && (!wd->multi) && (wd->selected))
552 it = elm_genlist_selected_item_get(obj);
553 elm_genlist_item_expanded_set(it,
554 !elm_genlist_item_expanded_get(it));
556 else if (!strcmp(ev->keyname, "Escape"))
558 if (!_deselect_all_items(wd)) return EINA_FALSE;
559 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
562 else return EINA_FALSE;
564 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
565 elm_smart_scroller_child_pos_set(wd->scr, x, y);
570 _deselect_all_items(Widget_Data *wd)
572 if (!wd->selected) return EINA_FALSE;
574 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
580 _item_multi_select_up(Widget_Data *wd)
582 if (!wd->selected) return EINA_FALSE;
583 if (!wd->multi) return EINA_FALSE;
585 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
586 if (!prev) return EINA_TRUE;
588 if (elm_genlist_item_selected_get(prev))
590 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
591 wd->last_selected_item = prev;
592 elm_genlist_item_show(wd->last_selected_item);
596 elm_genlist_item_selected_set(prev, EINA_TRUE);
597 elm_genlist_item_show(prev);
603 _item_multi_select_down(Widget_Data *wd)
605 if (!wd->selected) return EINA_FALSE;
606 if (!wd->multi) return EINA_FALSE;
608 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
609 if (!next) return EINA_TRUE;
611 if (elm_genlist_item_selected_get(next))
613 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
614 wd->last_selected_item = next;
615 elm_genlist_item_show(wd->last_selected_item);
619 elm_genlist_item_selected_set(next, EINA_TRUE);
620 elm_genlist_item_show(next);
626 _item_single_select_up(Widget_Data *wd)
628 Elm_Genlist_Item *prev;
631 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
632 while ((prev) && (prev->delete_me))
633 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
635 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
637 if (!prev) return EINA_FALSE;
639 _deselect_all_items(wd);
641 elm_genlist_item_selected_set(prev, EINA_TRUE);
642 elm_genlist_item_show(prev);
647 _item_single_select_down(Widget_Data *wd)
649 Elm_Genlist_Item *next;
652 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
653 while ((next) && (next->delete_me))
654 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
656 else next = elm_genlist_item_next_get(wd->last_selected_item);
658 if (!next) return EINA_FALSE;
660 _deselect_all_items(wd);
662 elm_genlist_item_selected_set(next, EINA_TRUE);
663 elm_genlist_item_show(next);
668 _on_focus_hook(void *data __UNUSED__,
671 Widget_Data *wd = elm_widget_data_get(obj);
673 if (elm_widget_focus_get(obj))
675 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
676 evas_object_focus_set(wd->obj, EINA_TRUE);
677 if ((wd->selected) && (!wd->last_selected_item))
678 wd->last_selected_item = eina_list_data_get(wd->selected);
682 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
683 evas_object_focus_set(wd->obj, EINA_FALSE);
688 _del_hook(Evas_Object *obj)
690 Widget_Data *wd = elm_widget_data_get(obj);
692 _item_cache_zero(wd);
693 if (wd->calc_job) ecore_job_del(wd->calc_job);
694 if (wd->update_job) ecore_job_del(wd->update_job);
695 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
696 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
697 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
698 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
699 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
704 _del_pre_hook(Evas_Object *obj)
706 Widget_Data *wd = elm_widget_data_get(obj);
708 evas_object_del(wd->pan_smart);
709 wd->pan_smart = NULL;
710 elm_genlist_clear(obj);
714 _mirrored_set(Evas_Object *obj,
717 Widget_Data *wd = elm_widget_data_get(obj);
719 _item_cache_zero(wd);
720 elm_smart_scroller_mirrored_set(wd->scr, rtl);
724 _theme_hook(Evas_Object *obj)
726 Widget_Data *wd = elm_widget_data_get(obj);
729 _item_cache_zero(wd);
730 _elm_widget_mirrored_reload(obj);
731 _mirrored_set(obj, elm_widget_mirrored_get(obj));
732 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
733 elm_widget_style_get(obj));
734 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
735 wd->item_width = wd->item_height = 0;
736 wd->group_item_width = wd->group_item_height = 0;
737 wd->minw = wd->minh = wd->realminw = 0;
738 EINA_INLIST_FOREACH(wd->blocks, itb)
741 Elm_Genlist_Item *it;
743 if (itb->realized) _item_block_unrealize(itb);
744 EINA_LIST_FOREACH(itb->items, l, it)
745 it->mincalcd = EINA_FALSE;
747 itb->changed = EINA_TRUE;
749 if (wd->calc_job) ecore_job_del(wd->calc_job);
750 wd->calc_job = ecore_job_add(_calc_job, wd);
755 _show_region_hook(void *data,
758 Widget_Data *wd = elm_widget_data_get(data);
759 Evas_Coord x, y, w, h;
761 elm_widget_show_region_get(obj, &x, &y, &w, &h);
762 //x & y are screen coordinates, Add with pan coordinates
765 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
769 _sizing_eval(Evas_Object *obj)
771 Widget_Data *wd = elm_widget_data_get(obj);
772 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
774 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
775 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
777 if (wd->height_for_width)
781 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
782 if ((vw != 0) && (vw != wd->prev_viewport_w))
786 wd->prev_viewport_w = vw;
787 EINA_INLIST_FOREACH(wd->blocks, itb)
789 itb->must_recalc = EINA_TRUE;
791 if (wd->calc_job) ecore_job_del(wd->calc_job);
792 wd->calc_job = ecore_job_add(_calc_job, wd);
795 if (wd->mode == ELM_LIST_LIMIT)
797 Evas_Coord vmw, vmh, vw, vh;
801 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
802 if ((minw > 0) && (vw < minw)) vw = minw;
803 else if ((maxw > 0) && (vw > maxw))
805 edje_object_size_min_calc
806 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
813 edje_object_size_min_calc
814 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
818 evas_object_size_hint_min_set(obj, minw, minh);
819 evas_object_size_hint_max_set(obj, maxw, maxh);
823 _signal_emit_hook(Evas_Object *obj,
824 const char *emission,
827 Widget_Data *wd = elm_widget_data_get(obj);
828 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
833 _item_highlight(Elm_Genlist_Item *it)
835 const char *selectraise;
836 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
837 (it->disabled) || (it->display_only) || (it->mode_view))
839 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
840 selectraise = edje_object_data_get(it->base.view, "selectraise");
841 if ((selectraise) && (!strcmp(selectraise, "on")))
843 evas_object_raise(it->base.view);
844 if ((it->group_item) && (it->group_item->realized))
845 evas_object_raise(it->group_item->base.view);
847 it->highlighted = EINA_TRUE;
851 _item_block_del(Elm_Genlist_Item *it)
854 Item_Block *itb = it->block;
856 itb->items = eina_list_remove(itb->items, it);
858 itb->changed = EINA_TRUE;
859 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
860 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
863 il = EINA_INLIST_GET(itb);
864 Item_Block *itbn = (Item_Block *)(il->next);
866 it->parent->items = eina_list_remove(it->parent->items, it);
868 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
870 if (itbn) itbn->changed = EINA_TRUE;
876 il = EINA_INLIST_GET(itb);
877 Item_Block *itbp = (Item_Block *)(il->prev);
878 Item_Block *itbn = (Item_Block *)(il->next);
879 if ((itbp) && ((itbp->count + itb->count) < 48))
881 Elm_Genlist_Item *it2;
883 EINA_LIST_FREE(itb->items, it2)
886 itbp->items = eina_list_append(itbp->items, it2);
888 itbp->changed = EINA_TRUE;
890 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
891 EINA_INLIST_GET(itb));
894 else if ((itbn) && ((itbn->count + itb->count) < 48))
898 Eina_List *last = eina_list_last(itb->items);
899 Elm_Genlist_Item *it2 = last->data;
902 itb->items = eina_list_remove_list(itb->items, last);
903 itbn->items = eina_list_prepend(itbn->items, it2);
905 itbn->changed = EINA_TRUE;
908 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
916 _item_del(Elm_Genlist_Item *it)
918 elm_widget_item_pre_notify_del(it);
919 elm_genlist_item_subitems_clear(it);
920 it->wd->walking -= it->walking;
921 if (it->wd->show_item == it) it->wd->show_item = NULL;
922 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
923 if (it->realized) _item_unrealize(it, EINA_FALSE);
924 if (it->block) _item_block_del(it);
925 if ((!it->delete_me) && (it->itc->func.del))
926 it->itc->func.del((void *)it->base.data, it->base.widget);
927 it->delete_me = EINA_TRUE;
929 it->wd->queue = eina_list_remove(it->wd->queue, it);
930 if (it->wd->anchor_item == it)
932 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
933 if (!it->wd->anchor_item)
934 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
936 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
938 it->parent->items = eina_list_remove(it->parent->items, it);
939 if (it->flags & ELM_GENLIST_ITEM_GROUP)
940 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
941 if (it->long_timer) ecore_timer_del(it->long_timer);
942 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
944 if (it->tooltip.del_cb)
945 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
947 elm_widget_item_del(it);
951 _item_select(Elm_Genlist_Item *it)
953 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
956 if (it->wd->always_select) goto call;
959 it->selected = EINA_TRUE;
960 it->wd->selected = eina_list_append(it->wd->selected, it);
964 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
966 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
969 if ((it->wd->clear_me) && (!it->wd->walking))
970 elm_genlist_clear(it->base.widget);
973 if ((!it->walking) && (it->delete_me))
975 if (!it->relcount) _item_del(it);
978 it->wd->last_selected_item = it;
982 _item_unselect(Elm_Genlist_Item *it)
984 const char *stacking, *selectraise;
986 if ((it->delete_me) || (!it->highlighted)) return;
987 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
988 stacking = edje_object_data_get(it->base.view, "stacking");
989 selectraise = edje_object_data_get(it->base.view, "selectraise");
992 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
993 else evas_object_raise(it->base.view);
995 it->highlighted = EINA_FALSE;
998 it->selected = EINA_FALSE;
999 it->wd->selected = eina_list_remove(it->wd->selected, it);
1000 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1005 _mouse_move(void *data,
1006 Evas *evas __UNUSED__,
1010 Elm_Genlist_Item *it = data;
1011 Evas_Event_Mouse_Move *ev = event_info;
1012 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1014 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1016 if (!it->wd->on_hold)
1018 it->wd->on_hold = EINA_TRUE;
1019 if (!it->wd->wasselected)
1023 if (it->wd->multitouched)
1025 it->wd->cur_x = ev->cur.canvas.x;
1026 it->wd->cur_y = ev->cur.canvas.y;
1029 if ((it->dragging) && (it->down))
1031 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1034 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1035 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1036 if (abs((it->wd->history[it->wd->movements].x -
1037 it->wd->history[0].x)) > 40)
1038 it->wd->swipe = EINA_TRUE;
1040 it->wd->movements++;
1044 ecore_timer_del(it->long_timer);
1045 it->long_timer = NULL;
1047 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1050 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1054 ecore_timer_del(it->long_timer);
1055 it->long_timer = NULL;
1059 if (!it->display_only)
1060 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1061 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1062 x = ev->cur.canvas.x - x;
1063 y = ev->cur.canvas.y - y;
1066 if (adx < 0) adx = -dx;
1069 if (ady < 0) ady = -dy;
1072 if ((adx > minw) || (ady > minh))
1074 it->dragging = EINA_TRUE;
1077 ecore_timer_del(it->long_timer);
1078 it->long_timer = NULL;
1080 if (!it->wd->wasselected)
1085 evas_object_smart_callback_call(it->base.widget,
1086 SIG_DRAG_START_UP, it);
1090 evas_object_smart_callback_call(it->base.widget,
1091 SIG_DRAG_START_LEFT, it);
1093 evas_object_smart_callback_call(it->base.widget,
1094 SIG_DRAG_START_RIGHT, it);
1100 evas_object_smart_callback_call(it->base.widget,
1101 SIG_DRAG_START_DOWN, it);
1105 evas_object_smart_callback_call(it->base.widget,
1106 SIG_DRAG_START_LEFT, it);
1108 evas_object_smart_callback_call(it->base.widget,
1109 SIG_DRAG_START_RIGHT, it);
1116 _long_press(void *data)
1118 Elm_Genlist_Item *it = data;
1120 it->long_timer = NULL;
1121 if ((it->disabled) || (it->dragging) || (it->display_only))
1122 return ECORE_CALLBACK_CANCEL;
1123 it->wd->longpressed = EINA_TRUE;
1124 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1125 return ECORE_CALLBACK_CANCEL;
1129 _swipe(Elm_Genlist_Item *it)
1134 if ((it->display_only) || (it->disabled)) return;
1135 it->wd->swipe = EINA_FALSE;
1136 for (i = 0; i < it->wd->movements; i++)
1138 sum += it->wd->history[i].x;
1139 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1142 sum /= it->wd->movements;
1143 if (abs(sum - it->wd->history[0].x) <= 10) return;
1144 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1148 _swipe_cancel(void *data)
1150 Elm_Genlist_Item *it = data;
1152 if (!it) return ECORE_CALLBACK_CANCEL;
1153 it->wd->swipe = EINA_FALSE;
1154 it->wd->movements = 0;
1155 return ECORE_CALLBACK_RENEW;
1159 _multi_cancel(void *data)
1161 Widget_Data *wd = data;
1163 if (!wd) return ECORE_CALLBACK_CANCEL;
1164 wd->multi_timeout = EINA_TRUE;
1165 return ECORE_CALLBACK_RENEW;
1169 _multi_touch_gesture_eval(void *data)
1171 Elm_Genlist_Item *it = data;
1173 it->wd->multitouched = EINA_FALSE;
1174 if (it->wd->multi_timer)
1176 ecore_timer_del(it->wd->multi_timer);
1177 it->wd->multi_timer = NULL;
1179 if (it->wd->multi_timeout)
1181 it->wd->multi_timeout = EINA_FALSE;
1185 Evas_Coord minw = 0, minh = 0;
1186 Evas_Coord off_x, off_y, off_mx, off_my;
1188 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1189 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1190 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1191 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1192 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1194 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1196 if ((off_x + off_mx) > (off_y + off_my))
1198 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1199 evas_object_smart_callback_call(it->base.widget,
1200 SIG_MULTI_SWIPE_RIGHT, it);
1201 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1202 evas_object_smart_callback_call(it->base.widget,
1203 SIG_MULTI_SWIPE_LEFT, it);
1204 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1205 evas_object_smart_callback_call(it->base.widget,
1206 SIG_MULTI_PINCH_OUT, it);
1208 evas_object_smart_callback_call(it->base.widget,
1209 SIG_MULTI_PINCH_IN, it);
1213 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1214 evas_object_smart_callback_call(it->base.widget,
1215 SIG_MULTI_SWIPE_DOWN, it);
1216 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1217 evas_object_smart_callback_call(it->base.widget,
1218 SIG_MULTI_SWIPE_UP, it);
1219 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1220 evas_object_smart_callback_call(it->base.widget,
1221 SIG_MULTI_PINCH_OUT, it);
1223 evas_object_smart_callback_call(it->base.widget,
1224 SIG_MULTI_PINCH_IN, it);
1227 it->wd->multi_timeout = EINA_FALSE;
1231 _multi_down(void *data,
1232 Evas *evas __UNUSED__,
1233 Evas_Object *obj __UNUSED__,
1236 Elm_Genlist_Item *it = data;
1237 Evas_Event_Multi_Down *ev = event_info;
1239 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1240 it->wd->multi_device = ev->device;
1241 it->wd->multi_down = EINA_TRUE;
1242 it->wd->multitouched = EINA_TRUE;
1243 it->wd->prev_mx = ev->canvas.x;
1244 it->wd->prev_my = ev->canvas.y;
1245 if (!it->wd->wasselected) _item_unselect(it);
1246 it->wd->wasselected = EINA_FALSE;
1247 it->wd->longpressed = EINA_FALSE;
1250 ecore_timer_del(it->long_timer);
1251 it->long_timer = NULL;
1255 it->dragging = EINA_FALSE;
1256 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1258 if (it->swipe_timer)
1260 ecore_timer_del(it->swipe_timer);
1261 it->swipe_timer = NULL;
1263 if (it->wd->on_hold)
1265 it->wd->swipe = EINA_FALSE;
1266 it->wd->movements = 0;
1267 it->wd->on_hold = EINA_FALSE;
1272 _multi_up(void *data,
1273 Evas *evas __UNUSED__,
1274 Evas_Object *obj __UNUSED__,
1277 Elm_Genlist_Item *it = data;
1278 Evas_Event_Multi_Up *ev = event_info;
1280 if (it->wd->multi_device != ev->device) return;
1281 it->wd->multi_device = 0;
1282 it->wd->multi_down = EINA_FALSE;
1283 if (it->wd->mouse_down) return;
1284 _multi_touch_gesture_eval(data);
1288 _multi_move(void *data,
1289 Evas *evas __UNUSED__,
1290 Evas_Object *obj __UNUSED__,
1293 Elm_Genlist_Item *it = data;
1294 Evas_Event_Multi_Move *ev = event_info;
1296 if (it->wd->multi_device != ev->device) return;
1297 it->wd->cur_mx = ev->cur.canvas.x;
1298 it->wd->cur_my = ev->cur.canvas.y;
1302 _mouse_down(void *data,
1303 Evas *evas __UNUSED__,
1307 Elm_Genlist_Item *it = data;
1308 Evas_Event_Mouse_Down *ev = event_info;
1311 if (ev->button != 1) return;
1312 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1314 it->wd->on_hold = EINA_TRUE;
1317 it->down = EINA_TRUE;
1318 it->dragging = EINA_FALSE;
1319 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1320 it->dx = ev->canvas.x - x;
1321 it->dy = ev->canvas.y - y;
1322 it->wd->mouse_down = EINA_TRUE;
1323 if (!it->wd->multitouched)
1325 it->wd->prev_x = ev->canvas.x;
1326 it->wd->prev_y = ev->canvas.y;
1327 it->wd->multi_timeout = EINA_FALSE;
1328 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1329 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1331 it->wd->longpressed = EINA_FALSE;
1332 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1333 else it->wd->on_hold = EINA_FALSE;
1334 if (it->wd->on_hold) return;
1335 it->wd->wasselected = it->selected;
1336 _item_highlight(it);
1337 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1338 if ((!it->disabled) && (!it->display_only))
1340 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1341 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1343 if (it->long_timer) ecore_timer_del(it->long_timer);
1344 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1345 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1347 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1350 it->long_timer = NULL;
1351 it->wd->swipe = EINA_FALSE;
1352 it->wd->movements = 0;
1356 _mouse_up(void *data,
1357 Evas *evas __UNUSED__,
1358 Evas_Object *obj __UNUSED__,
1361 Elm_Genlist_Item *it = data;
1362 Evas_Event_Mouse_Up *ev = event_info;
1363 Eina_Bool dragged = EINA_FALSE;
1365 if (ev->button != 1) return;
1366 it->down = EINA_FALSE;
1367 it->wd->mouse_down = EINA_FALSE;
1368 if (it->wd->multitouched)
1370 if (it->wd->multi_down) return;
1371 _multi_touch_gesture_eval(data);
1374 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1375 else it->wd->on_hold = EINA_FALSE;
1378 ecore_timer_del(it->long_timer);
1379 it->long_timer = NULL;
1383 it->dragging = EINA_FALSE;
1384 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1387 if (it->swipe_timer)
1389 ecore_timer_del(it->swipe_timer);
1390 it->swipe_timer = NULL;
1392 if (it->wd->multi_timer)
1394 ecore_timer_del(it->wd->multi_timer);
1395 it->wd->multi_timer = NULL;
1396 it->wd->multi_timeout = EINA_FALSE;
1398 if (it->wd->on_hold)
1400 if (it->wd->swipe) _swipe(data);
1401 it->wd->longpressed = EINA_FALSE;
1402 it->wd->on_hold = EINA_FALSE;
1405 if (it->wd->longpressed)
1407 it->wd->longpressed = EINA_FALSE;
1408 if (!it->wd->wasselected)
1410 it->wd->wasselected = EINA_FALSE;
1415 if (it->want_unrealize)
1417 _item_unrealize(it, EINA_FALSE);
1418 if (it->block->want_unrealize)
1419 _item_block_unrealize(it->block);
1422 if ((it->disabled) || (dragged) || (it->display_only)) return;
1423 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1428 _item_highlight(it);
1431 else _item_unselect(it);
1437 Widget_Data *wd = it->wd;
1440 while (wd->selected) _item_unselect(wd->selected->data);
1445 const Eina_List *l, *l_next;
1446 Elm_Genlist_Item *it2;
1448 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1449 if (it2 != it) _item_unselect(it2);
1450 //_item_highlight(it);
1453 _item_highlight(it);
1459 _signal_expand_toggle(void *data,
1460 Evas_Object *obj __UNUSED__,
1461 const char *emission __UNUSED__,
1462 const char *source __UNUSED__)
1464 Elm_Genlist_Item *it = data;
1467 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1469 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1473 _signal_expand(void *data,
1474 Evas_Object *obj __UNUSED__,
1475 const char *emission __UNUSED__,
1476 const char *source __UNUSED__)
1478 Elm_Genlist_Item *it = data;
1481 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1485 _signal_contract(void *data,
1486 Evas_Object *obj __UNUSED__,
1487 const char *emission __UNUSED__,
1488 const char *source __UNUSED__)
1490 Elm_Genlist_Item *it = data;
1493 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1497 _scr_hold_timer_cb(void *data)
1499 if (!data) return ECORE_CALLBACK_CANCEL;
1500 Widget_Data *wd = data;
1501 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1502 wd->scr_hold_timer = NULL;
1503 return ECORE_CALLBACK_CANCEL;
1507 _mode_finished_signal_cb(void *data,
1509 const char *emission __UNUSED__,
1510 const char *source __UNUSED__)
1514 Elm_Genlist_Item *it = data;
1515 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1518 it->nocache = EINA_FALSE;
1519 _mode_item_unrealize(it);
1520 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1521 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1525 _item_cache_clean(Widget_Data *wd)
1527 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1531 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1532 wd->item_cache = eina_inlist_remove(wd->item_cache,
1533 wd->item_cache->last);
1534 wd->item_cache_count--;
1535 if (itc->spacer) evas_object_del(itc->spacer);
1536 if (itc->base_view) evas_object_del(itc->base_view);
1537 if (itc->item_style) eina_stringshare_del(itc->item_style);
1543 _item_cache_zero(Widget_Data *wd)
1545 int pmax = wd->item_cache_max;
1546 wd->item_cache_max = 0;
1547 _item_cache_clean(wd);
1548 wd->item_cache_max = pmax;
1552 _item_cache_add(Elm_Genlist_Item *it)
1556 if (it->wd->item_cache_max <= 0)
1558 evas_object_del(it->base.view);
1559 it->base.view = NULL;
1560 evas_object_del(it->spacer);
1565 it->wd->item_cache_count++;
1566 itc = calloc(1, sizeof(Item_Cache));
1567 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1568 EINA_INLIST_GET(itc));
1569 itc->spacer = it->spacer;
1571 itc->base_view = it->base.view;
1572 it->base.view = NULL;
1573 evas_object_hide(itc->base_view);
1574 evas_object_move(itc->base_view, -9999, -9999);
1575 itc->item_style = eina_stringshare_add(it->itc->item_style);
1576 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1577 itc->compress = (it->wd->compress);
1578 itc->selected = it->selected;
1579 itc->disabled = it->disabled;
1580 itc->expanded = it->expanded;
1583 ecore_timer_del(it->long_timer);
1584 it->long_timer = NULL;
1586 if (it->swipe_timer)
1588 ecore_timer_del(it->swipe_timer);
1589 it->swipe_timer = NULL;
1591 // FIXME: other callbacks?
1592 edje_object_signal_callback_del_full(itc->base_view,
1593 "elm,action,expand,toggle",
1594 "elm", _signal_expand_toggle, it);
1595 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1597 _signal_expand, it);
1598 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1599 "elm", _signal_contract, it);
1600 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1602 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1604 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1606 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1608 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1610 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1612 _item_cache_clean(it->wd);
1616 _item_cache_find(Elm_Genlist_Item *it)
1621 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1622 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1624 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1626 if ((itc->tree == tree) &&
1627 (itc->compress == it->wd->compress) &&
1628 (!strcmp(it->itc->item_style, itc->item_style)))
1630 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1631 EINA_INLIST_GET(itc));
1632 it->wd->item_cache_count--;
1640 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1642 if (!it->nostacking)
1644 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1645 evas_object_lower(it->base.view);
1647 evas_object_raise(it->base.view);
1650 if (it->order_num_in & 0x1)
1651 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1653 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1657 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1661 if (it->selected != itc->selected)
1664 edje_object_signal_emit(it->base.view,
1665 "elm,state,selected", "elm");
1667 if (it->disabled != itc->disabled)
1670 edje_object_signal_emit(it->base.view,
1671 "elm,state,disabled", "elm");
1673 if (it->expanded != itc->expanded)
1676 edje_object_signal_emit(it->base.view,
1677 "elm,state,expanded", "elm");
1683 edje_object_signal_emit(it->base.view,
1684 "elm,state,selected", "elm");
1686 edje_object_signal_emit(it->base.view,
1687 "elm,state,disabled", "elm");
1689 edje_object_signal_emit(it->base.view,
1690 "elm,state,expanded", "elm");
1695 _item_cache_free(Item_Cache *itc)
1697 if (itc->spacer) evas_object_del(itc->spacer);
1698 if (itc->base_view) evas_object_del(itc->base_view);
1699 if (itc->item_style) eina_stringshare_del(itc->item_style);
1704 _item_label_realize(Elm_Genlist_Item *it,
1705 Evas_Object *target,
1708 if (it->itc->func.label_get)
1713 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1714 EINA_LIST_FOREACH(*source, l, key)
1716 char *s = it->itc->func.label_get
1717 ((void *)it->base.data, it->base.widget, key);
1721 edje_object_part_text_set(target, key, s);
1726 edje_object_part_text_set(target, key, "");
1733 _item_icon_realize(Elm_Genlist_Item *it,
1734 Evas_Object *target,
1737 Eina_List *res = NULL;
1739 if (it->itc->func.icon_get)
1744 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1745 EINA_LIST_FOREACH(*source, l, key)
1747 Evas_Object *ic = it->itc->func.icon_get
1748 ((void *)it->base.data, it->base.widget, key);
1752 res = eina_list_append(res, ic);
1753 edje_object_part_swallow(target, key, ic);
1754 evas_object_show(ic);
1755 elm_widget_sub_object_add(it->base.widget, ic);
1757 elm_widget_disabled_set(ic, EINA_TRUE);
1766 _item_state_realize(Elm_Genlist_Item *it,
1767 Evas_Object *target,
1770 if (it->itc->func.state_get)
1776 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1777 EINA_LIST_FOREACH(*source, l, key)
1779 Eina_Bool on = it->itc->func.state_get
1780 ((void *)it->base.data, it->base.widget, key);
1784 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1785 edje_object_signal_emit(target, buf, "elm");
1789 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1790 edje_object_signal_emit(target, buf, "elm");
1797 _item_realize(Elm_Genlist_Item *it,
1801 Elm_Genlist_Item *it2;
1802 const char *treesize;
1804 int depth, tsize = 20;
1805 Item_Cache *itc = NULL;
1807 if (it->delete_me) return ;
1810 if (it->order_num_in != in)
1812 it->order_num_in = in;
1813 _elm_genlist_item_odd_even_update(it);
1814 _elm_genlist_item_state_update(it, NULL);
1818 it->order_num_in = in;
1821 it->nocache = EINA_FALSE;
1823 itc = _item_cache_find(it);
1826 it->base.view = itc->base_view;
1827 itc->base_view = NULL;
1828 it->spacer = itc->spacer;
1833 const char *stacking_even;
1834 const char *stacking;
1836 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1837 edje_object_scale_set(it->base.view,
1838 elm_widget_scale_get(it->base.widget) *
1839 _elm_config->scale);
1840 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1841 elm_widget_sub_object_add(it->base.widget, it->base.view);
1843 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1844 strncpy(buf, "tree", sizeof(buf));
1845 else strncpy(buf, "item", sizeof(buf));
1846 if (it->wd->compress)
1847 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1849 strncat(buf, "/", sizeof(buf) - strlen(buf));
1850 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1852 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1853 elm_widget_style_get(it->base.widget));
1855 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1856 if (!stacking_even) stacking_even = "above";
1857 it->stacking_even = !!strcmp("above", stacking_even);
1859 stacking = edje_object_data_get(it->base.view, "stacking");
1860 if (!stacking) stacking = "yes";
1861 it->nostacking = !!strcmp("yes", stacking);
1863 edje_object_mirrored_set(it->base.view,
1864 elm_widget_mirrored_get(it->base.widget));
1866 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1867 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1868 elm_widget_sub_object_add(it->base.widget, it->spacer);
1871 _elm_genlist_item_odd_even_update(it);
1873 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1875 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1877 it->expanded_depth = depth;
1878 treesize = edje_object_data_get(it->base.view, "treesize");
1879 if (treesize) tsize = atoi(treesize);
1880 evas_object_size_hint_min_set(it->spacer,
1881 (depth * tsize) * _elm_config->scale, 1);
1882 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1885 edje_object_signal_callback_add(it->base.view,
1886 "elm,action,expand,toggle",
1887 "elm", _signal_expand_toggle, it);
1888 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1889 "elm", _signal_expand, it);
1890 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1891 "elm", _signal_contract, it);
1892 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1894 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1896 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1898 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1900 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1902 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1905 _elm_genlist_item_state_update(it, itc);
1908 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1910 /* homogenous genlist shortcut */
1913 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1915 it->w = it->minw = it->wd->group_item_width;
1916 it->h = it->minh = it->wd->group_item_height;
1920 it->w = it->minw = it->wd->item_width;
1921 it->h = it->minh = it->wd->item_height;
1923 it->mincalcd = EINA_TRUE;
1928 /* FIXME: If you see that assert, please notify us and we
1929 will clean our mess */
1930 assert(eina_list_count(it->icon_objs) == 0);
1932 _item_label_realize(it, it->base.view, &it->labels);
1933 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1934 _item_state_realize(it, it->base.view, &it->states);
1938 Evas_Coord mw = -1, mh = -1;
1940 if (!it->display_only)
1941 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1942 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1943 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1945 if (!it->display_only)
1946 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1947 it->w = it->minw = mw;
1948 it->h = it->minh = mh;
1949 it->mincalcd = EINA_TRUE;
1951 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1953 it->wd->group_item_width = mw;
1954 it->wd->group_item_height = mh;
1956 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1958 it->wd->item_width = mw;
1959 it->wd->item_height = mh;
1962 if (!calc) evas_object_show(it->base.view);
1965 if (it->tooltip.content_cb)
1967 elm_widget_item_tooltip_content_cb_set(it,
1968 it->tooltip.content_cb,
1969 it->tooltip.data, NULL);
1970 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1973 if (it->mouse_cursor)
1974 elm_widget_item_cursor_set(it, it->mouse_cursor);
1976 it->realized = EINA_TRUE;
1977 it->want_unrealize = EINA_FALSE;
1979 if (itc) _item_cache_free(itc);
1980 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
1984 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1988 if (!it->realized) return;
1989 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
1992 ecore_timer_del(it->long_timer);
1993 it->long_timer = NULL;
1997 evas_object_del(it->base.view);
1998 it->base.view = NULL;
1999 evas_object_del(it->spacer);
2004 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2005 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2006 _item_cache_add(it);
2008 elm_widget_stringlist_free(it->labels);
2010 elm_widget_stringlist_free(it->icons);
2012 elm_widget_stringlist_free(it->states);
2014 EINA_LIST_FREE(it->icon_objs, icon)
2015 evas_object_del(icon);
2017 _mode_item_unrealize(it);
2019 it->realized = EINA_FALSE;
2020 it->want_unrealize = EINA_FALSE;
2024 _item_block_recalc(Item_Block *itb,
2029 Elm_Genlist_Item *it;
2030 Evas_Coord minw = 0, minh = 0;
2031 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2035 EINA_LIST_FOREACH(itb->items, l, it)
2037 if (it->delete_me) continue;
2038 showme |= it->showme;
2043 if (!it->mincalcd) changed = EINA_TRUE;
2046 _item_realize(it, in, EINA_TRUE);
2047 _item_unrealize(it, EINA_TRUE);
2052 _item_realize(it, in, EINA_TRUE);
2053 _item_unrealize(it, EINA_TRUE);
2057 _item_realize(it, in, EINA_FALSE);
2059 if (minw < it->minw) minw = it->minw;
2067 itb->changed = EINA_FALSE;
2072 _item_block_realize(Item_Block *itb,
2077 Elm_Genlist_Item *it;
2079 if (itb->realized) return;
2080 EINA_LIST_FOREACH(itb->items, l, it)
2082 if (it->delete_me) continue;
2083 if (full) _item_realize(it, in, EINA_FALSE);
2086 itb->realized = EINA_TRUE;
2087 itb->want_unrealize = EINA_FALSE;
2091 _item_block_unrealize(Item_Block *itb)
2094 Elm_Genlist_Item *it;
2095 Eina_Bool dragging = EINA_FALSE;
2097 if (!itb->realized) return;
2098 EINA_LIST_FOREACH(itb->items, l, it)
2100 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2104 dragging = EINA_TRUE;
2105 it->want_unrealize = EINA_TRUE;
2108 _item_unrealize(it, EINA_FALSE);
2113 itb->realized = EINA_FALSE;
2114 itb->want_unrealize = EINA_TRUE;
2117 itb->want_unrealize = EINA_FALSE;
2121 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2126 evas_object_resize(view, it->w, it->h);
2127 evas_object_move(view, it->scrl_x, it->scrl_y);
2128 evas_object_show(view);
2132 _item_block_position(Item_Block *itb,
2136 Elm_Genlist_Item *it;
2137 Elm_Genlist_Item *git;
2138 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2141 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2142 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2144 EINA_LIST_FOREACH(itb->items, l, it)
2146 if (it->delete_me) continue;
2150 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2151 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2153 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2154 cvx, cvy, cvw, cvh));
2155 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2157 if ((itb->realized) && (!it->realized))
2159 if (vis) _item_realize(it, in, EINA_FALSE);
2165 git = it->group_item;
2168 if (git->scrl_y < oy)
2170 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2171 git->scrl_y = (it->scrl_y + it->h) - git->h;
2172 git->want_realize = EINA_TRUE;
2175 _item_position(it, it->mode_view);
2177 _item_position(it, it->base.view);
2181 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2188 if (vis) it->want_realize = EINA_TRUE;
2195 _group_items_recalc(void *data)
2197 Widget_Data *wd = data;
2199 Elm_Genlist_Item *git;
2201 EINA_LIST_FOREACH(wd->group_items, l, git)
2203 if (git->want_realize)
2206 _item_realize(git, 0, EINA_FALSE);
2207 evas_object_resize(git->base.view, wd->minw, git->h);
2208 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2209 evas_object_show(git->base.view);
2210 evas_object_raise(git->base.view);
2212 else if (!git->want_realize && git->realized)
2215 _item_unrealize(git, EINA_FALSE);
2221 _must_recalc_idler(void *data)
2223 Widget_Data *wd = data;
2224 if (wd->calc_job) ecore_job_del(wd->calc_job);
2225 wd->calc_job = ecore_job_add(_calc_job, wd);
2226 wd->must_recalc_idler = NULL;
2227 return ECORE_CALLBACK_CANCEL;
2231 _calc_job(void *data)
2233 Widget_Data *wd = data;
2235 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2236 Item_Block *chb = NULL;
2237 int in = 0, minw_change = 0;
2238 Eina_Bool changed = EINA_FALSE;
2240 Eina_Bool did_must_recalc = EINA_FALSE;
2243 t0 = ecore_time_get();
2244 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2248 EINA_INLIST_FOREACH(wd->blocks, itb)
2250 Eina_Bool showme = EINA_FALSE;
2253 showme = itb->showme;
2254 itb->showme = EINA_FALSE;
2257 if (itb->realized) _item_block_unrealize(itb);
2259 if ((itb->changed) || (changed) ||
2260 ((itb->must_recalc) && (!did_must_recalc)))
2262 if ((changed) || (itb->must_recalc))
2265 Elm_Genlist_Item *it;
2266 EINA_LIST_FOREACH(itb->items, l, it)
2267 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2268 itb->changed = EINA_TRUE;
2269 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2270 itb->must_recalc = EINA_FALSE;
2272 if (itb->realized) _item_block_unrealize(itb);
2273 showme = _item_block_recalc(itb, in, 0);
2279 if (minw == -1) minw = itb->minw;
2280 else if ((!itb->must_recalc) && (minw < itb->minw))
2289 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2291 wd->show_item->showme = EINA_FALSE;
2293 elm_smart_scroller_region_bring_in(wd->scr,
2295 wd->show_item->block->x,
2297 wd->show_item->block->y,
2298 wd->show_item->block->w,
2301 elm_smart_scroller_child_region_show(wd->scr,
2303 wd->show_item->block->x,
2305 wd->show_item->block->y,
2306 wd->show_item->block->w,
2308 wd->show_item = NULL;
2313 EINA_INLIST_FOREACH(wd->blocks, itb)
2319 if ((chb) && (EINA_INLIST_GET(chb)->next))
2321 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2323 if (itb->realized) _item_block_unrealize(itb);
2326 wd->realminw = minw;
2327 if (minw < wd->w) minw = wd->w;
2328 if ((minw != wd->minw) || (minh != wd->minh))
2332 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2333 _sizing_eval(wd->obj);
2334 if ((wd->anchor_item) && (wd->anchor_item->block))
2336 Elm_Genlist_Item *it;
2339 it = wd->anchor_item;
2340 it_y = wd->anchor_y;
2341 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2342 it->block->y + it->y + it_y);
2343 wd->anchor_item = it;
2344 wd->anchor_y = it_y;
2347 t = ecore_time_get();
2348 if (did_must_recalc)
2350 if (!wd->must_recalc_idler)
2351 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2353 wd->calc_job = NULL;
2354 evas_object_smart_changed(wd->pan_smart);
2358 _update_job(void *data)
2360 Widget_Data *wd = data;
2363 int num, num0, position = 0, recalc = 0;
2365 wd->update_job = NULL;
2367 EINA_INLIST_FOREACH(wd->blocks, itb)
2369 Evas_Coord itminw, itminh;
2370 Elm_Genlist_Item *it;
2376 _item_block_position(itb, num);
2381 EINA_LIST_FOREACH(itb->items, l2, it)
2388 it->updateme = EINA_FALSE;
2391 _item_unrealize(it, EINA_FALSE);
2392 _item_realize(it, num, EINA_FALSE);
2397 _item_realize(it, num, EINA_TRUE);
2398 _item_unrealize(it, EINA_TRUE);
2400 if ((it->minw != itminw) || (it->minh != itminh))
2405 itb->updateme = EINA_FALSE;
2409 itb->changed = EINA_TRUE;
2410 _item_block_recalc(itb, num0, 0);
2411 _item_block_position(itb, num0);
2416 if (wd->calc_job) ecore_job_del(wd->calc_job);
2417 wd->calc_job = ecore_job_add(_calc_job, wd);
2422 _pan_set(Evas_Object *obj,
2426 Pan *sd = evas_object_smart_data_get(obj);
2429 // Evas_Coord ow, oh;
2430 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2431 // ow = sd->wd->minw - ow;
2432 // if (ow < 0) ow = 0;
2433 // oh = sd->wd->minh - oh;
2434 // if (oh < 0) oh = 0;
2435 // if (x < 0) x = 0;
2436 // if (y < 0) y = 0;
2437 // if (x > ow) x = ow;
2438 // if (y > oh) y = oh;
2439 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2443 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2445 if ((itb->y + itb->h) > y)
2447 Elm_Genlist_Item *it;
2450 EINA_LIST_FOREACH(itb->items, l2, it)
2452 if ((itb->y + it->y) >= y)
2454 sd->wd->anchor_item = it;
2455 sd->wd->anchor_y = -(itb->y + it->y - y);
2462 evas_object_smart_changed(obj);
2466 _pan_get(Evas_Object *obj,
2470 Pan *sd = evas_object_smart_data_get(obj);
2472 if (x) *x = sd->wd->pan_x;
2473 if (y) *y = sd->wd->pan_y;
2477 _pan_max_get(Evas_Object *obj,
2481 Pan *sd = evas_object_smart_data_get(obj);
2484 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2485 ow = sd->wd->minw - ow;
2487 oh = sd->wd->minh - oh;
2494 _pan_min_get(Evas_Object *obj __UNUSED__,
2503 _pan_child_size_get(Evas_Object *obj,
2507 Pan *sd = evas_object_smart_data_get(obj);
2509 if (w) *w = sd->wd->minw;
2510 if (h) *h = sd->wd->minh;
2514 _pan_add(Evas_Object *obj)
2517 Evas_Object_Smart_Clipped_Data *cd;
2520 cd = evas_object_smart_data_get(obj);
2523 sd->__clipped_data = *cd;
2525 evas_object_smart_data_set(obj, sd);
2529 _pan_del(Evas_Object *obj)
2531 Pan *sd = evas_object_smart_data_get(obj);
2536 ecore_job_del(sd->resize_job);
2537 sd->resize_job = NULL;
2543 _pan_resize_job(void *data)
2546 _sizing_eval(sd->wd->obj);
2547 sd->resize_job = NULL;
2551 _pan_resize(Evas_Object *obj,
2555 Pan *sd = evas_object_smart_data_get(obj);
2558 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2559 if ((ow == w) && (oh == h)) return;
2560 if ((sd->wd->height_for_width) && (ow != w))
2562 if (sd->resize_job) ecore_job_del(sd->resize_job);
2563 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2565 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2566 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2570 _pan_calculate(Evas_Object *obj)
2572 Pan *sd = evas_object_smart_data_get(obj);
2574 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2576 Elm_Genlist_Item *git;
2579 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2580 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2581 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2583 git->want_realize = EINA_FALSE;
2585 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2587 itb->w = sd->wd->minw;
2588 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2589 itb->y - sd->wd->pan_y + oy,
2591 cvx, cvy, cvw, cvh))
2593 if ((!itb->realized) || (itb->changed))
2594 _item_block_realize(itb, in, 0);
2595 _item_block_position(itb, in);
2599 if (itb->realized) _item_block_unrealize(itb);
2603 _group_items_recalc(sd->wd);
2607 _pan_move(Evas_Object *obj,
2608 Evas_Coord x __UNUSED__,
2609 Evas_Coord y __UNUSED__)
2611 Pan *sd = evas_object_smart_data_get(obj);
2613 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2614 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2618 _hold_on(void *data __UNUSED__,
2620 void *event_info __UNUSED__)
2622 Widget_Data *wd = elm_widget_data_get(obj);
2624 elm_smart_scroller_hold_set(wd->scr, 1);
2628 _hold_off(void *data __UNUSED__,
2630 void *event_info __UNUSED__)
2632 Widget_Data *wd = elm_widget_data_get(obj);
2634 elm_smart_scroller_hold_set(wd->scr, 0);
2638 _freeze_on(void *data __UNUSED__,
2640 void *event_info __UNUSED__)
2642 Widget_Data *wd = elm_widget_data_get(obj);
2644 elm_smart_scroller_freeze_set(wd->scr, 1);
2648 _freeze_off(void *data __UNUSED__,
2650 void *event_info __UNUSED__)
2652 Widget_Data *wd = elm_widget_data_get(obj);
2654 elm_smart_scroller_freeze_set(wd->scr, 0);
2658 _scroll_edge_left(void *data,
2659 Evas_Object *scr __UNUSED__,
2660 void *event_info __UNUSED__)
2662 Evas_Object *obj = data;
2663 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2667 _scroll_edge_right(void *data,
2668 Evas_Object *scr __UNUSED__,
2669 void *event_info __UNUSED__)
2671 Evas_Object *obj = data;
2672 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2676 _scroll_edge_top(void *data,
2677 Evas_Object *scr __UNUSED__,
2678 void *event_info __UNUSED__)
2680 Evas_Object *obj = data;
2681 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2685 _scroll_edge_bottom(void *data,
2686 Evas_Object *scr __UNUSED__,
2687 void *event_info __UNUSED__)
2689 Evas_Object *obj = data;
2690 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2694 _mode_item_realize(Elm_Genlist_Item *it)
2698 if ((it->mode_view) || (it->delete_me)) return;
2700 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2701 edje_object_scale_set(it->mode_view,
2702 elm_widget_scale_get(it->base.widget) *
2703 _elm_config->scale);
2704 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2705 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2707 strncpy(buf, "item", sizeof(buf));
2708 if (it->wd->compress)
2709 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2711 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2712 strncat(buf, "/", sizeof(buf) - strlen(buf));
2713 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2715 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2716 elm_widget_style_get(it->base.widget));
2717 edje_object_mirrored_set(it->mode_view,
2718 elm_widget_mirrored_get(it->base.widget));
2720 /* signal callback add */
2721 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2723 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2725 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2728 /* label_get, icon_get, state_get */
2729 /* FIXME: If you see that assert, please notify us and we
2730 will clean our mess */
2731 assert(eina_list_count(it->mode_icon_objs) == 0);
2733 _item_label_realize(it, it->mode_view, &it->mode_labels);
2734 it->mode_icon_objs = _item_icon_realize(it,
2737 _item_state_realize(it, it->mode_view, &it->mode_states);
2739 edje_object_part_swallow(it->mode_view,
2740 edje_object_data_get(it->mode_view, "mode_part"),
2743 it->want_unrealize = EINA_FALSE;
2747 _mode_item_unrealize(Elm_Genlist_Item *it)
2749 Widget_Data *wd = it->wd;
2751 if (!it->mode_view) return;
2753 elm_widget_stringlist_free(it->mode_labels);
2754 it->mode_labels = NULL;
2755 elm_widget_stringlist_free(it->mode_icons);
2756 it->mode_icons = NULL;
2757 elm_widget_stringlist_free(it->mode_states);
2759 EINA_LIST_FREE(it->mode_icon_objs, icon)
2760 evas_object_del(icon);
2762 edje_object_part_unswallow(it->mode_view, it->base.view);
2763 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2764 evas_object_del(it->mode_view);
2765 it->mode_view = NULL;
2767 if (wd->mode_item == it)
2768 wd->mode_item = NULL;
2772 _item_mode_set(Elm_Genlist_Item *it)
2775 Widget_Data *wd = it->wd;
2780 it->nocache = EINA_TRUE;
2782 if (wd->scr_hold_timer)
2784 ecore_timer_del(wd->scr_hold_timer);
2785 wd->scr_hold_timer = NULL;
2787 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2788 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2790 _mode_item_realize(it);
2791 _item_position(it, it->mode_view);
2793 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2794 edje_object_signal_emit(it->mode_view, buf, "elm");
2798 _item_mode_unset(Widget_Data *wd)
2801 if (!wd->mode_item) return;
2802 char buf[1024], buf2[1024];
2803 Elm_Genlist_Item *it;
2806 it->nocache = EINA_TRUE;
2808 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2809 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2811 edje_object_signal_emit(it->mode_view, buf, "elm");
2812 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2814 wd->mode_item = NULL;
2818 * Add a new Genlist object
2820 * @param parent The parent object
2821 * @return The new object or NULL if it cannot be created
2826 elm_genlist_add(Evas_Object *parent)
2831 Evas_Coord minw, minh;
2832 static Evas_Smart *smart = NULL;
2836 static Evas_Smart_Class sc;
2838 evas_object_smart_clipped_smart_set(&_pan_sc);
2840 sc.name = "elm_genlist_pan";
2841 sc.version = EVAS_SMART_CLASS_VERSION;
2844 sc.resize = _pan_resize;
2845 sc.move = _pan_move;
2846 sc.calculate = _pan_calculate;
2847 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2850 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2852 ELM_SET_WIDTYPE(widtype, "genlist");
2853 elm_widget_type_set(obj, "genlist");
2854 elm_widget_sub_object_add(parent, obj);
2855 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2856 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2857 elm_widget_data_set(obj, wd);
2858 elm_widget_del_hook_set(obj, _del_hook);
2859 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2860 elm_widget_theme_hook_set(obj, _theme_hook);
2861 elm_widget_can_focus_set(obj, EINA_TRUE);
2862 elm_widget_event_hook_set(obj, _event_hook);
2863 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2865 wd->scr = elm_smart_scroller_add(e);
2866 elm_smart_scroller_widget_set(wd->scr, obj);
2867 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2868 elm_widget_style_get(obj));
2869 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2870 _elm_config->thumbscroll_bounce_enable);
2871 elm_widget_resize_object_set(obj, wd->scr);
2873 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2874 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2876 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2877 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2881 wd->mode = ELM_LIST_SCROLL;
2882 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2883 wd->item_cache_max = wd->max_items_per_block * 2;
2884 wd->longpress_timeout = _elm_config->longpress_timeout;
2886 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2887 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2888 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2889 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2891 wd->pan_smart = evas_object_smart_add(e, smart);
2892 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2895 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2896 _pan_set, _pan_get, _pan_max_get,
2897 _pan_min_get, _pan_child_size_get);
2899 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2901 evas_object_size_hint_min_set(obj, minw, minh);
2903 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2905 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2910 static Elm_Genlist_Item *
2911 _item_new(Widget_Data *wd,
2912 const Elm_Genlist_Item_Class *itc,
2914 Elm_Genlist_Item *parent,
2915 Elm_Genlist_Item_Flags flags,
2917 const void *func_data)
2919 Elm_Genlist_Item *it;
2921 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2922 if (!it) return NULL;
2925 it->base.data = data;
2926 it->parent = parent;
2928 it->func.func = func;
2929 it->func.data = func_data;
2930 it->mouse_cursor = NULL;
2931 it->expanded_depth = 0;
2936 _item_block_add(Widget_Data *wd,
2937 Elm_Genlist_Item *it)
2939 Item_Block *itb = NULL;
2946 itb = calloc(1, sizeof(Item_Block));
2949 if (!it->rel->block)
2952 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2953 itb->items = eina_list_append(itb->items, it);
2959 wd->blocks = eina_inlist_prepend_relative
2960 (wd->blocks, EINA_INLIST_GET(itb),
2961 EINA_INLIST_GET(it->rel->block));
2963 eina_list_prepend_relative(itb->items, it, it->rel);
2967 wd->blocks = eina_inlist_append_relative
2968 (wd->blocks, EINA_INLIST_GET(itb),
2969 EINA_INLIST_GET(it->rel->block));
2971 eina_list_append_relative(itb->items, it, it->rel);
2981 itb = (Item_Block *)(wd->blocks);
2982 if (itb->count >= wd->max_items_per_block)
2984 itb = calloc(1, sizeof(Item_Block));
2988 eina_inlist_prepend(wd->blocks,
2989 EINA_INLIST_GET(itb));
2994 itb = calloc(1, sizeof(Item_Block));
2998 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3000 itb->items = eina_list_prepend(itb->items, it);
3006 itb = (Item_Block *)(wd->blocks->last);
3007 if (itb->count >= wd->max_items_per_block)
3009 itb = calloc(1, sizeof(Item_Block));
3013 eina_inlist_append(wd->blocks,
3014 EINA_INLIST_GET(itb));
3019 itb = calloc(1, sizeof(Item_Block));
3023 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3025 itb->items = eina_list_append(itb->items, it);
3031 itb = it->rel->block;
3032 if (!itb) goto newblock;
3034 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3036 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3039 itb->changed = EINA_TRUE;
3041 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3042 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3045 it->rel->relcount--;
3046 if ((it->rel->delete_me) && (!it->rel->relcount))
3050 if (itb->count > itb->wd->max_items_per_block)
3054 Elm_Genlist_Item *it2;
3056 newc = itb->count / 2;
3057 itb2 = calloc(1, sizeof(Item_Block));
3061 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3062 EINA_INLIST_GET(itb));
3063 itb2->changed = EINA_TRUE;
3064 while ((itb->count > newc) && (itb->items))
3068 l = eina_list_last(itb->items);
3070 itb->items = eina_list_remove_list(itb->items, l);
3073 itb2->items = eina_list_prepend(itb2->items, it2);
3081 _queue_process(Widget_Data *wd)
3084 Eina_Bool showme = EINA_FALSE;
3087 t0 = ecore_time_get();
3088 for (n = 0; (wd->queue) && (n < 128); n++)
3090 Elm_Genlist_Item *it;
3092 it = wd->queue->data;
3093 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3094 it->queued = EINA_FALSE;
3095 _item_block_add(wd, it);
3096 t = ecore_time_get();
3097 if (it->block->changed)
3099 showme = _item_block_recalc(it->block, it->block->num, 1);
3100 it->block->changed = 0;
3102 if (showme) it->block->showme = EINA_TRUE;
3103 if (eina_inlist_count(wd->blocks) > 1)
3105 if ((t - t0) > (ecore_animator_frametime_get())) break;
3112 _idle_process(void *data, Eina_Bool *wakeup)
3114 Widget_Data *wd = data;
3117 //static double q_start = 0.0;
3118 //if (q_start == 0.0) q_start = ecore_time_get();
3120 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3124 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3126 return ECORE_CALLBACK_CANCEL;
3128 return ECORE_CALLBACK_RENEW;
3132 _item_idle_enterer(void *data)
3134 Widget_Data *wd = data;
3135 Eina_Bool wakeup = EINA_FALSE;
3136 Eina_Bool ok = _idle_process(data, &wakeup);
3141 if (wd->calc_job) ecore_job_del(wd->calc_job);
3142 wd->calc_job = ecore_job_add(_calc_job, wd);
3144 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3149 _item_queue(Widget_Data *wd,
3150 Elm_Genlist_Item *it)
3152 if (it->queued) return;
3153 it->queued = EINA_TRUE;
3154 wd->queue = eina_list_append(wd->queue, it);
3155 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3157 if (wd->queue_idle_enterer)
3159 ecore_idle_enterer_del(wd->queue_idle_enterer);
3160 wd->queue_idle_enterer = NULL;
3164 if (!wd->queue_idle_enterer)
3165 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3169 * Append item to the end of the genlist
3171 * This appends the given item to the end of the list or the end of
3172 * the children if the parent is given.
3174 * @param obj The genlist object
3175 * @param itc The item class for the item
3176 * @param data The item data
3177 * @param parent The parent item, or NULL if none
3178 * @param flags Item flags
3179 * @param func Convenience function called when item selected
3180 * @param func_data Data passed to @p func above.
3181 * @return A handle to the item added or NULL if not possible
3185 EAPI Elm_Genlist_Item *
3186 elm_genlist_item_append(Evas_Object *obj,
3187 const Elm_Genlist_Item_Class *itc,
3189 Elm_Genlist_Item *parent,
3190 Elm_Genlist_Item_Flags flags,
3192 const void *func_data)
3194 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3195 Widget_Data *wd = elm_widget_data_get(obj);
3196 if (!wd) return NULL;
3197 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3199 if (!it) return NULL;
3202 if (flags & ELM_GENLIST_ITEM_GROUP)
3203 wd->group_items = eina_list_append(wd->group_items, it);
3204 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3209 Elm_Genlist_Item *it2 = NULL;
3210 Eina_List *ll = eina_list_last(it->parent->items);
3211 if (ll) it2 = ll->data;
3212 it->parent->items = eina_list_append(it->parent->items, it);
3213 if (!it2) it2 = it->parent;
3215 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3216 EINA_INLIST_GET(it2));
3218 it->rel->relcount++;
3220 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3221 it->group_item = parent;
3222 else if (it->parent->group_item)
3223 it->group_item = it->parent->group_item;
3225 it->before = EINA_FALSE;
3226 _item_queue(wd, it);
3231 * Prepend item at start of the genlist
3233 * This adds an item to the beginning of the list or beginning of the
3234 * children of the parent if given.
3236 * @param obj The genlist object
3237 * @param itc The item class for the item
3238 * @param data The item data
3239 * @param parent The parent item, or NULL if none
3240 * @param flags Item flags
3241 * @param func Convenience function called when item selected
3242 * @param func_data Data passed to @p func above.
3243 * @return A handle to the item added or NULL if not possible
3247 EAPI Elm_Genlist_Item *
3248 elm_genlist_item_prepend(Evas_Object *obj,
3249 const Elm_Genlist_Item_Class *itc,
3251 Elm_Genlist_Item *parent,
3252 Elm_Genlist_Item_Flags flags,
3254 const void *func_data)
3256 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3257 Widget_Data *wd = elm_widget_data_get(obj);
3258 if (!wd) return NULL;
3259 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3261 if (!it) return NULL;
3264 if (flags & ELM_GENLIST_ITEM_GROUP)
3265 wd->group_items = eina_list_prepend(wd->group_items, it);
3266 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3271 Elm_Genlist_Item *it2 = NULL;
3272 Eina_List *ll = it->parent->items;
3273 if (ll) it2 = ll->data;
3274 it->parent->items = eina_list_prepend(it->parent->items, it);
3275 if (!it2) it2 = it->parent;
3277 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3278 EINA_INLIST_GET(it2));
3280 it->rel->relcount++;
3282 it->before = EINA_TRUE;
3283 _item_queue(wd, it);
3288 * Insert item before another in the genlist
3290 * This inserts an item before another in the list. It will be in the
3291 * same tree level or group as the item it is inseted before.
3293 * @param obj The genlist object
3294 * @param itc The item class for the item
3295 * @param data The item data
3296 * @param before The item to insert before
3297 * @param flags Item flags
3298 * @param func Convenience function called when item selected
3299 * @param func_data Data passed to @p func above.
3300 * @return A handle to the item added or NULL if not possible
3304 EAPI Elm_Genlist_Item *
3305 elm_genlist_item_insert_before(Evas_Object *obj,
3306 const Elm_Genlist_Item_Class *itc,
3308 Elm_Genlist_Item *parent,
3309 Elm_Genlist_Item *before,
3310 Elm_Genlist_Item_Flags flags,
3312 const void *func_data)
3314 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3315 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3316 Widget_Data *wd = elm_widget_data_get(obj);
3317 if (!wd) return NULL;
3318 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3320 if (!it) return NULL;
3323 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3326 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3327 EINA_INLIST_GET(before));
3329 it->rel->relcount++;
3330 it->before = EINA_TRUE;
3331 _item_queue(wd, it);
3336 * Insert an item after another in the genlst
3338 * This inserts an item after another in the list. It will be in the
3339 * same tree level or group as the item it is inseted after.
3341 * @param obj The genlist object
3342 * @param itc The item class for the item
3343 * @param data The item data
3344 * @param after The item to insert after
3345 * @param flags Item flags
3346 * @param func Convenience function called when item selected
3347 * @param func_data Data passed to @p func above.
3348 * @return A handle to the item added or NULL if not possible
3352 EAPI Elm_Genlist_Item *
3353 elm_genlist_item_insert_after(Evas_Object *obj,
3354 const Elm_Genlist_Item_Class *itc,
3356 Elm_Genlist_Item *parent,
3357 Elm_Genlist_Item *after,
3358 Elm_Genlist_Item_Flags flags,
3360 const void *func_data)
3362 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3363 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3364 Widget_Data *wd = elm_widget_data_get(obj);
3365 if (!wd) return NULL;
3366 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3368 if (!it) return NULL;
3369 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3370 EINA_INLIST_GET(after));
3373 it->parent->items = eina_list_append_relative(it->parent->items, it,
3377 it->rel->relcount++;
3378 it->before = EINA_FALSE;
3379 _item_queue(wd, it);
3386 * This clears all items in the list, leaving it empty.
3388 * @param obj The genlist object
3393 elm_genlist_clear(Evas_Object *obj)
3395 ELM_CHECK_WIDTYPE(obj, widtype);
3396 Widget_Data *wd = elm_widget_data_get(obj);
3398 if (wd->walking > 0)
3400 Elm_Genlist_Item *it;
3402 wd->clear_me = EINA_TRUE;
3403 EINA_INLIST_FOREACH(wd->items, it)
3405 it->delete_me = EINA_TRUE;
3411 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3413 if (wd->anchor_item == it)
3415 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3416 if (!wd->anchor_item)
3418 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3420 wd->items = eina_inlist_remove(wd->items, wd->items);
3421 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3422 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3423 elm_widget_item_pre_notify_del(it);
3424 if (it->realized) _item_unrealize(it, EINA_FALSE);
3425 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3426 it->itc->func.del((void *)it->base.data, it->base.widget);
3427 if (it->long_timer) ecore_timer_del(it->long_timer);
3428 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3429 elm_widget_item_del(it);
3431 wd->clear_me = EINA_FALSE;
3432 wd->anchor_item = NULL;
3435 Item_Block *itb = (Item_Block *)(wd->blocks);
3437 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3438 if (itb->items) eina_list_free(itb->items);
3443 ecore_job_del(wd->calc_job);
3444 wd->calc_job = NULL;
3446 if (wd->queue_idle_enterer)
3448 ecore_idle_enterer_del(wd->queue_idle_enterer);
3449 wd->queue_idle_enterer = NULL;
3451 if (wd->must_recalc_idler)
3453 ecore_idler_del(wd->must_recalc_idler);
3454 wd->must_recalc_idler = NULL;
3458 eina_list_free(wd->queue);
3463 eina_list_free(wd->selected);
3464 wd->selected = NULL;
3466 wd->show_item = NULL;
3473 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3474 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3480 * Enable or disable multi-select in the genlist
3482 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3483 * the list. This allows more than 1 item to be selected.
3485 * @param obj The genlist object
3486 * @param multi Multi-select enable/disable
3491 elm_genlist_multi_select_set(Evas_Object *obj,
3494 ELM_CHECK_WIDTYPE(obj, widtype);
3495 Widget_Data *wd = elm_widget_data_get(obj);
3501 * Gets if multi-select in genlist is enable or disable
3503 * @param obj The genlist object
3504 * @return Multi-select enable/disable
3505 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3510 elm_genlist_multi_select_get(const Evas_Object *obj)
3512 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3513 Widget_Data *wd = elm_widget_data_get(obj);
3514 if (!wd) return EINA_FALSE;
3519 * Get the selectd item in the genlist
3521 * This gets the selected item in the list (if multi-select is enabled
3522 * only the first item in the list is selected - which is not very
3523 * useful, so see elm_genlist_selected_items_get() for when
3524 * multi-select is used).
3526 * If no item is selected, NULL is returned.
3528 * @param obj The genlist object
3529 * @return The selected item, or NULL if none.
3533 EAPI Elm_Genlist_Item *
3534 elm_genlist_selected_item_get(const Evas_Object *obj)
3536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3537 Widget_Data *wd = elm_widget_data_get(obj);
3538 if (!wd) return NULL;
3539 if (wd->selected) return wd->selected->data;
3544 * Get a list of selected items in the genlist
3546 * This returns a list of the selected items. This list pointer is
3547 * only valid so long as no items are selected or unselected (or
3548 * unselected implicitly by deletion). The list contains
3549 * Elm_Genlist_Item pointers.
3551 * @param obj The genlist object
3552 * @return The list of selected items, nor NULL if none are selected.
3556 EAPI const Eina_List *
3557 elm_genlist_selected_items_get(const Evas_Object *obj)
3559 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3560 Widget_Data *wd = elm_widget_data_get(obj);
3561 if (!wd) return NULL;
3562 return wd->selected;
3566 * Get a list of realized items in genlist
3568 * This returns a list of the realized items in the genlist. The list
3569 * contains Elm_Genlist_Item pointers. The list must be freed by the
3570 * caller when done with eina_list_free(). The item pointers in the
3571 * list are only valid so long as those items are not deleted or the
3572 * genlist is not deleted.
3574 * @param obj The genlist object
3575 * @return The list of realized items, nor NULL if none are realized.
3580 elm_genlist_realized_items_get(const Evas_Object *obj)
3582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3583 Widget_Data *wd = elm_widget_data_get(obj);
3584 Eina_List *list = NULL;
3586 Eina_Bool done = EINA_FALSE;
3587 if (!wd) return NULL;
3588 EINA_INLIST_FOREACH(wd->blocks, itb)
3593 Elm_Genlist_Item *it;
3596 EINA_LIST_FOREACH(itb->items, l, it)
3598 if (it->realized) list = eina_list_append(list, it);
3610 * Get the item that is at the x, y canvas coords
3612 * This returns the item at the given coordinates (which are canvas
3613 * relative not object-relative). If an item is at that coordinate,
3614 * that item handle is returned, and if @p posret is not NULL, the
3615 * integer pointed to is set to a value of -1, 0 or 1, depending if
3616 * the coordinate is on the upper portion of that item (-1), on the
3617 * middle section (0) or on the lower part (1). If NULL is returned as
3618 * an item (no item found there), then posret may indicate -1 or 1
3619 * based if the coordinate is above or below all items respectively in
3622 * @param it The item
3623 * @param x The input x coordinate
3624 * @param y The input y coordinate
3625 * @param posret The position relative to the item returned here
3626 * @return The item at the coordinates or NULL if none
3630 EAPI Elm_Genlist_Item *
3631 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3636 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3637 Widget_Data *wd = elm_widget_data_get(obj);
3638 Evas_Coord ox, oy, ow, oh;
3641 if (!wd) return NULL;
3642 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3644 EINA_INLIST_FOREACH(wd->blocks, itb)
3647 Elm_Genlist_Item *it;
3649 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3650 oy + itb->y - itb->wd->pan_y,
3651 itb->w, itb->h, x, y, 1, 1))
3653 EINA_LIST_FOREACH(itb->items, l, it)
3655 Evas_Coord itx, ity;
3657 itx = ox + itb->x + it->x - itb->wd->pan_x;
3658 ity = oy + itb->y + it->y - itb->wd->pan_y;
3659 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3663 if (y <= (ity + (it->h / 4))) *posret = -1;
3664 else if (y >= (ity + it->h - (it->h / 4)))
3670 lasty = ity + it->h;
3675 if (y > lasty) *posret = 1;
3682 * Get the first item in the genlist
3684 * This returns the first item in the list.
3686 * @param obj The genlist object
3687 * @return The first item, or NULL if none
3691 EAPI Elm_Genlist_Item *
3692 elm_genlist_first_item_get(const Evas_Object *obj)
3694 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3695 Widget_Data *wd = elm_widget_data_get(obj);
3696 if (!wd) return NULL;
3697 if (!wd->items) return NULL;
3698 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3699 while ((it) && (it->delete_me))
3700 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3705 * Get the last item in the genlist
3707 * This returns the last item in the list.
3709 * @return The last item, or NULL if none
3713 EAPI Elm_Genlist_Item *
3714 elm_genlist_last_item_get(const Evas_Object *obj)
3716 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3717 Widget_Data *wd = elm_widget_data_get(obj);
3718 if (!wd) return NULL;
3719 if (!wd->items) return NULL;
3720 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3721 while ((it) && (it->delete_me))
3722 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3727 * Get the next item in the genlist
3729 * This returns the item after the item @p it.
3731 * @param it The item
3732 * @return The item after @p it, or NULL if none
3736 EAPI Elm_Genlist_Item *
3737 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3739 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3742 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3743 if ((it) && (!it->delete_me)) break;
3745 return (Elm_Genlist_Item *)it;
3749 * Get the previous item in the genlist
3751 * This returns the item before the item @p it.
3753 * @param it The item
3754 * @return The item before @p it, or NULL if none
3758 EAPI Elm_Genlist_Item *
3759 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3761 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3764 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3765 if ((it) && (!it->delete_me)) break;
3767 return (Elm_Genlist_Item *)it;
3771 * Get the genlist object from an item
3773 * This returns the genlist object itself that an item belongs to.
3775 * @param it The item
3776 * @return The genlist object
3781 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3783 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3784 return it->base.widget;
3788 * Get the parent item of the given item
3790 * This returns the parent item of the item @p it given.
3792 * @param it The item
3793 * @return The parent of the item or NULL if none
3797 EAPI Elm_Genlist_Item *
3798 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3800 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3805 * Clear all sub-items (children) of the given item
3807 * This clears all items that are children (or their descendants) of the
3810 * @param it The item
3815 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3818 Eina_List *tl = NULL, *l;
3819 Elm_Genlist_Item *it2;
3821 EINA_LIST_FOREACH(it->items, l, it2)
3822 tl = eina_list_append(tl, it2);
3823 EINA_LIST_FREE(tl, it2)
3824 elm_genlist_item_del(it2);
3828 * Set the selected state of an item
3830 * This sets the selected state (1 selected, 0 not selected) of the given
3833 * @param it The item
3834 * @param selected The selected state
3839 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3842 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3843 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3845 if ((it->delete_me) || (it->disabled)) return;
3846 selected = !!selected;
3847 if (it->selected == selected) return;
3853 while (wd->selected)
3854 _item_unselect(wd->selected->data);
3856 _item_highlight(it);
3864 * Get the selected state of an item
3866 * This gets the selected state of an item (1 selected, 0 not selected).
3868 * @param it The item
3869 * @return The selected state
3874 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3876 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3877 return it->selected;
3881 * Sets the expanded state of an item (if it's a parent)
3883 * This expands or contracts a parent item (thus showing or hiding the
3886 * @param it The item
3887 * @param expanded The expanded state (1 expanded, 0 not expanded).
3892 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3895 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3896 if (it->expanded == expanded) return;
3897 it->expanded = expanded;
3901 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3902 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
3907 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3908 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
3913 * Get the expanded state of an item
3915 * This gets the expanded state of an item
3917 * @param it The item
3918 * @return Thre expanded state
3923 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3926 return it->expanded;
3930 * Get the depth of expanded item
3932 * @param it The genlist item object
3933 * @return The depth of expanded item
3938 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3940 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3941 return it->expanded_depth;
3945 * Sets the disabled state of an item.
3947 * A disabled item cannot be selected or unselected. It will also
3948 * change appearance to appear disabled. This sets the disabled state
3949 * (1 disabled, 0 not disabled).
3951 * @param it The item
3952 * @param disabled The disabled state
3957 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3960 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3963 if (it->disabled == disabled) return;
3964 if (it->delete_me) return;
3965 it->disabled = !!disabled;
3967 elm_genlist_item_selected_set(it, EINA_FALSE);
3971 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3973 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3974 EINA_LIST_FOREACH(it->icon_objs, l, obj)
3975 elm_widget_disabled_set(obj, disabled);
3980 * Get the disabled state of an item
3982 * This gets the disabled state of the given item.
3984 * @param it The item
3985 * @return The disabled state
3990 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3992 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3993 if (it->delete_me) return EINA_FALSE;
3994 return it->disabled;
3998 * Sets the display only state of an item.
4000 * A display only item cannot be selected or unselected. It is for
4001 * display only and not selecting or otherwise clicking, dragging
4002 * etc. by the user, thus finger size rules will not be applied to
4005 * @param it The item
4006 * @param display_only The display only state
4011 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4012 Eina_Bool display_only)
4014 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4015 if (it->display_only == display_only) return;
4016 if (it->delete_me) return;
4017 it->display_only = display_only;
4018 it->mincalcd = EINA_FALSE;
4019 it->updateme = EINA_TRUE;
4020 if (it->block) it->block->updateme = EINA_TRUE;
4021 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4022 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4026 * Get the display only state of an item
4028 * This gets the display only state of the given item.
4030 * @param it The item
4031 * @return The display only state
4036 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4038 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4039 if (it->delete_me) return EINA_FALSE;
4040 return it->display_only;
4044 * Show the given item
4046 * This causes genlist to jump to the given item @p it and show it (by
4047 * scrolling), if it is not fully visible.
4049 * @param it The item
4054 elm_genlist_item_show(Elm_Genlist_Item *it)
4056 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4057 Evas_Coord gith = 0;
4058 if (it->delete_me) return;
4059 if ((it->queued) || (!it->mincalcd))
4061 it->wd->show_item = it;
4062 it->wd->bring_in = EINA_TRUE;
4063 it->showme = EINA_TRUE;
4066 if (it->wd->show_item)
4068 it->wd->show_item->showme = EINA_FALSE;
4069 it->wd->show_item = NULL;
4071 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4072 gith = it->group_item->h;
4073 elm_smart_scroller_child_region_show(it->wd->scr,
4074 it->x + it->block->x,
4075 it->y + it->block->y - gith,
4076 it->block->w, it->h);
4080 * Bring in the given item
4082 * This causes genlist to jump to the given item @p it and show it (by
4083 * scrolling), if it is not fully visible. This may use animation to
4084 * do so and take a period of time
4086 * @param it The item
4091 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4093 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4094 Evas_Coord gith = 0;
4095 if (it->delete_me) return;
4096 if ((it->queued) || (!it->mincalcd))
4098 it->wd->show_item = it;
4099 it->wd->bring_in = EINA_TRUE;
4100 it->showme = EINA_TRUE;
4103 if (it->wd->show_item)
4105 it->wd->show_item->showme = EINA_FALSE;
4106 it->wd->show_item = NULL;
4108 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4109 gith = it->group_item->h;
4110 elm_smart_scroller_region_bring_in(it->wd->scr,
4111 it->x + it->block->x,
4112 it->y + it->block->y - gith,
4113 it->block->w, it->h);
4117 * Show the given item at the top
4119 * This causes genlist to jump to the given item @p it and show it (by
4120 * scrolling), if it is not fully visible.
4122 * @param it The item
4127 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4129 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4131 Evas_Coord gith = 0;
4133 if (it->delete_me) return;
4134 if ((it->queued) || (!it->mincalcd))
4136 it->wd->show_item = it;
4137 it->wd->bring_in = EINA_TRUE;
4138 it->showme = EINA_TRUE;
4141 if (it->wd->show_item)
4143 it->wd->show_item->showme = EINA_FALSE;
4144 it->wd->show_item = NULL;
4146 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4147 if (it->group_item) gith = it->group_item->h;
4148 elm_smart_scroller_child_region_show(it->wd->scr,
4149 it->x + it->block->x,
4150 it->y + it->block->y - gith,
4155 * Bring in the given item at the top
4157 * This causes genlist to jump to the given item @p it and show it (by
4158 * scrolling), if it is not fully visible. This may use animation to
4159 * do so and take a period of time
4161 * @param it The item
4166 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4168 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4170 Evas_Coord gith = 0;
4172 if (it->delete_me) return;
4173 if ((it->queued) || (!it->mincalcd))
4175 it->wd->show_item = it;
4176 it->wd->bring_in = EINA_TRUE;
4177 it->showme = EINA_TRUE;
4180 if (it->wd->show_item)
4182 it->wd->show_item->showme = EINA_FALSE;
4183 it->wd->show_item = NULL;
4185 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4186 if (it->group_item) gith = it->group_item->h;
4187 elm_smart_scroller_region_bring_in(it->wd->scr,
4188 it->x + it->block->x,
4189 it->y + it->block->y - gith,
4194 * Show the given item at the middle
4196 * This causes genlist to jump to the given item @p it and show it (by
4197 * scrolling), if it is not fully visible.
4199 * @param it The item
4204 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4206 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4209 if (it->delete_me) return;
4210 if ((it->queued) || (!it->mincalcd))
4212 it->wd->show_item = it;
4213 it->wd->bring_in = EINA_TRUE;
4214 it->showme = EINA_TRUE;
4217 if (it->wd->show_item)
4219 it->wd->show_item->showme = EINA_FALSE;
4220 it->wd->show_item = NULL;
4222 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4223 elm_smart_scroller_child_region_show(it->wd->scr,
4224 it->x + it->block->x,
4225 it->y + it->block->y - oh / 2 +
4226 it->h / 2, it->block->w, oh);
4230 * Bring in the given item at the middle
4232 * This causes genlist to jump to the given item @p it and show it (by
4233 * scrolling), if it is not fully visible. This may use animation to
4234 * do so and take a period of time
4236 * @param it The item
4241 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4243 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4246 if (it->delete_me) return;
4247 if ((it->queued) || (!it->mincalcd))
4249 it->wd->show_item = it;
4250 it->wd->bring_in = EINA_TRUE;
4251 it->showme = EINA_TRUE;
4254 if (it->wd->show_item)
4256 it->wd->show_item->showme = EINA_FALSE;
4257 it->wd->show_item = NULL;
4259 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4260 elm_smart_scroller_region_bring_in(it->wd->scr,
4261 it->x + it->block->x,
4262 it->y + it->block->y - oh / 2 + it->h / 2,
4267 * Delete a given item
4269 * This deletes the item from genlist and calls the genlist item del
4270 * class callback defined in the item class, if it is set. This clears all
4271 * subitems if it is a tree.
4273 * @param it The item
4278 elm_genlist_item_del(Elm_Genlist_Item *it)
4280 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4281 if ((it->relcount > 0) || (it->walking > 0))
4283 elm_widget_item_pre_notify_del(it);
4284 elm_genlist_item_subitems_clear(it);
4285 it->delete_me = EINA_TRUE;
4286 if (it->wd->show_item == it) it->wd->show_item = NULL;
4288 it->wd->selected = eina_list_remove(it->wd->selected,
4292 if (it->realized) _item_unrealize(it, EINA_FALSE);
4293 it->block->changed = EINA_TRUE;
4294 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4295 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4297 if (it->itc->func.del)
4298 it->itc->func.del((void *)it->base.data, it->base.widget);
4305 * Set the data item from the genlist item
4307 * This set the data value passed on the elm_genlist_item_append() and
4308 * related item addition calls. This function will also call
4309 * elm_genlist_item_update() so the item will be updated to reflect the
4312 * @param it The item
4313 * @param data The new data pointer to set
4318 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4321 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4322 elm_widget_item_data_set(it, data);
4323 elm_genlist_item_update(it);
4327 * Get the data item from the genlist item
4329 * This returns the data value passed on the elm_genlist_item_append()
4330 * and related item addition calls and elm_genlist_item_data_set().
4332 * @param it The item
4333 * @return The data pointer provided when created
4338 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4340 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4341 return elm_widget_item_data_get(it);
4345 * Tells genlist to "orphan" icons fetchs by the item class
4347 * This instructs genlist to release references to icons in the item,
4348 * meaning that they will no longer be managed by genlist and are
4349 * floating "orphans" that can be re-used elsewhere if the user wants
4352 * @param it The item
4357 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4360 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4361 EINA_LIST_FREE(it->icon_objs, icon)
4363 elm_widget_sub_object_del(it->base.widget, icon);
4364 evas_object_smart_member_del(icon);
4365 evas_object_hide(icon);
4370 * Get the real evas object of the genlist item
4372 * This returns the actual evas object used for the specified genlist
4373 * item. This may be NULL as it may not be created, and may be deleted
4374 * at any time by genlist. Do not modify this object (move, resize,
4375 * show, hide etc.) as genlist is controlling it. This function is for
4376 * querying, emitting custom signals or hooking lower level callbacks
4377 * for events. Do not delete this object under any circumstances.
4379 * @param it The item
4380 * @return The object pointer
4384 EAPI const Evas_Object *
4385 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4387 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4388 return it->base.view;
4392 * Update the contents of an item
4394 * This updates an item by calling all the item class functions again
4395 * to get the icons, labels and states. Use this when the original
4396 * item data has changed and the changes are desired to be reflected.
4398 * @param it The item
4403 elm_genlist_item_update(Elm_Genlist_Item *it)
4405 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4406 if (!it->block) return;
4407 if (it->delete_me) return;
4408 it->mincalcd = EINA_FALSE;
4409 it->updateme = EINA_TRUE;
4410 it->block->updateme = EINA_TRUE;
4411 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4412 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4416 * Update the item class of an item
4418 * @param it The item
4419 * @parem itc The item class for the item
4424 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4425 const Elm_Genlist_Item_Class *itc)
4427 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4428 if (!it->block) return;
4429 EINA_SAFETY_ON_NULL_RETURN(itc);
4430 if (it->delete_me) return;
4432 it->nocache = EINA_TRUE;
4433 elm_genlist_item_update(it);
4436 static Evas_Object *
4437 _elm_genlist_item_label_create(void *data,
4439 void *item __UNUSED__)
4441 Evas_Object *label = elm_label_add(obj);
4444 elm_object_style_set(label, "tooltip");
4445 elm_label_label_set(label, data);
4450 _elm_genlist_item_label_del_cb(void *data,
4451 Evas_Object *obj __UNUSED__,
4452 void *event_info __UNUSED__)
4454 eina_stringshare_del(data);
4458 * Set the text to be shown in the genlist item.
4460 * @param item Target item
4461 * @param text The text to set in the content
4463 * Setup the text as tooltip to object. The item can have only one
4464 * tooltip, so any previous tooltip data is removed.
4469 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4472 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4473 text = eina_stringshare_add(text);
4474 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4476 _elm_genlist_item_label_del_cb);
4480 * Set the content to be shown in the tooltip item
4482 * Setup the tooltip to item. The item can have only one tooltip, so
4483 * any previous tooltip data is removed. @p func(with @p data) will be
4484 * called every time that need to show the tooltip and it should return a
4485 * valid Evas_Object. This object is then managed fully by tooltip
4486 * system and is deleted when the tooltip is gone.
4488 * @param item the genlist item being attached by a tooltip.
4489 * @param func the function used to create the tooltip contents.
4490 * @param data what to provide to @a func as callback data/context.
4491 * @param del_cb called when data is not needed anymore, either when
4492 * another callback replaces @func, the tooltip is unset with
4493 * elm_genlist_item_tooltip_unset() or the owner @a item
4494 * dies. This callback receives as the first parameter the
4495 * given @a data, and @c event_info is the item.
4500 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4501 Elm_Tooltip_Item_Content_Cb func,
4503 Evas_Smart_Cb del_cb)
4505 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4507 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4510 if (item->tooltip.del_cb)
4511 item->tooltip.del_cb((void *)item->tooltip.data,
4512 item->base.widget, item);
4514 item->tooltip.content_cb = func;
4515 item->tooltip.data = data;
4516 item->tooltip.del_cb = del_cb;
4518 if (item->base.view)
4520 elm_widget_item_tooltip_content_cb_set(item,
4521 item->tooltip.content_cb,
4522 item->tooltip.data, NULL);
4523 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4529 if (del_cb) del_cb((void *)data, NULL, NULL);
4533 * Unset tooltip from item
4535 * @param item genlist item to remove previously set tooltip.
4537 * Remove tooltip from item. The callback provided as del_cb to
4538 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4539 * it is not used anymore.
4541 * @see elm_genlist_item_tooltip_content_cb_set()
4546 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4548 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4549 if ((item->base.view) && (item->tooltip.content_cb))
4550 elm_widget_item_tooltip_unset(item);
4552 if (item->tooltip.del_cb)
4553 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4554 item->tooltip.del_cb = NULL;
4555 item->tooltip.content_cb = NULL;
4556 item->tooltip.data = NULL;
4557 if (item->tooltip.style)
4558 elm_genlist_item_tooltip_style_set(item, NULL);
4562 * Sets a different style for this item tooltip.
4564 * @note before you set a style you should define a tooltip with
4565 * elm_genlist_item_tooltip_content_cb_set() or
4566 * elm_genlist_item_tooltip_text_set()
4568 * @param item genlist item with tooltip already set.
4569 * @param style the theme style to use (default, transparent, ...)
4574 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4577 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4578 eina_stringshare_replace(&item->tooltip.style, style);
4579 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4583 * Get the style for this item tooltip.
4585 * @param item genlist item with tooltip already set.
4586 * @return style the theme style in use, defaults to "default". If the
4587 * object does not have a tooltip set, then NULL is returned.
4592 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4594 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4595 return item->tooltip.style;
4599 * Set the cursor to be shown when mouse is over the genlist item
4601 * @param item Target item
4602 * @param cursor the cursor name to be used.
4604 * @see elm_object_cursor_set()
4608 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4612 eina_stringshare_replace(&item->mouse_cursor, cursor);
4613 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4617 * Get the cursor to be shown when mouse is over the genlist item
4619 * @param item genlist item with cursor already set.
4620 * @return the cursor name.
4625 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4627 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4628 return elm_widget_item_cursor_get(item);
4632 * Unset the cursor to be shown when mouse is over the genlist item
4634 * @param item Target item
4636 * @see elm_object_cursor_unset()
4640 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4642 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4643 if (!item->mouse_cursor)
4646 if (item->base.view)
4647 elm_widget_item_cursor_unset(item);
4649 eina_stringshare_del(item->mouse_cursor);
4650 item->mouse_cursor = NULL;
4654 * Sets a different style for this item cursor.
4656 * @note before you set a style you should define a cursor with
4657 * elm_genlist_item_cursor_set()
4659 * @param item genlist item with cursor already set.
4660 * @param style the theme style to use (default, transparent, ...)
4665 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4668 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4669 elm_widget_item_cursor_style_set(item, style);
4673 * Get the style for this item cursor.
4675 * @param item genlist item with cursor already set.
4676 * @return style the theme style in use, defaults to "default". If the
4677 * object does not have a cursor set, then NULL is returned.
4682 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4684 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4685 return elm_widget_item_cursor_style_get(item);
4689 * Set if the cursor set should be searched on the theme or should use
4690 * the provided by the engine, only.
4692 * @note before you set if should look on theme you should define a
4693 * cursor with elm_object_cursor_set(). By default it will only look
4694 * for cursors provided by the engine.
4696 * @param item widget item with cursor already set.
4697 * @param engine_only boolean to define it cursors should be looked
4698 * only between the provided by the engine or searched on widget's
4704 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4705 Eina_Bool engine_only)
4707 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4708 elm_widget_item_cursor_engine_only_set(item, engine_only);
4712 * Get the cursor engine only usage for this item cursor.
4714 * @param item widget item with cursor already set.
4715 * @return engine_only boolean to define it cursors should be looked
4716 * only between the provided by the engine or searched on widget's
4717 * theme as well. If the object does not have a cursor set, then
4718 * EINA_FALSE is returned.
4723 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4725 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4726 return elm_widget_item_cursor_engine_only_get(item);
4730 * This sets the horizontal stretching mode
4732 * This sets the mode used for sizing items horizontally. Valid modes
4733 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4734 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4735 * the scroller will scroll horizontally. Otherwise items are expanded
4736 * to fill the width of the viewport of the scroller. If it is
4737 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4738 * limited to that size.
4740 * @param obj The genlist object
4741 * @param mode The mode to use
4746 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4749 ELM_CHECK_WIDTYPE(obj, widtype);
4750 Widget_Data *wd = elm_widget_data_get(obj);
4752 if (wd->mode == mode) return;
4758 * Gets the horizontal stretching mode
4760 * @param obj The genlist object
4761 * @return The mode to use
4762 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4767 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4769 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4770 Widget_Data *wd = elm_widget_data_get(obj);
4771 if (!wd) return ELM_LIST_LAST;
4776 * Set the always select mode.
4778 * Items will only call their selection func and callback when first
4779 * becoming selected. Any further clicks will do nothing, unless you
4780 * enable always select with elm_genlist_always_select_mode_set().
4781 * This means even if selected, every click will make the selected
4782 * callbacks be called.
4784 * @param obj The genlist object
4785 * @param always_select The always select mode
4786 * (EINA_TRUE = on, EINA_FALSE = off)
4791 elm_genlist_always_select_mode_set(Evas_Object *obj,
4792 Eina_Bool always_select)
4794 ELM_CHECK_WIDTYPE(obj, widtype);
4795 Widget_Data *wd = elm_widget_data_get(obj);
4797 wd->always_select = always_select;
4801 * Get the always select mode.
4803 * @param obj The genlist object
4804 * @return The always select mode
4805 * (EINA_TRUE = on, EINA_FALSE = off)
4810 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4812 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4813 Widget_Data *wd = elm_widget_data_get(obj);
4814 if (!wd) return EINA_FALSE;
4815 return wd->always_select;
4819 * Set no select mode
4821 * This will turn off the ability to select items entirely and they
4822 * will neither appear selected nor call selected callback functions.
4824 * @param obj The genlist object
4825 * @param no_select The no select mode
4826 * (EINA_TRUE = on, EINA_FALSE = off)
4831 elm_genlist_no_select_mode_set(Evas_Object *obj,
4832 Eina_Bool no_select)
4834 ELM_CHECK_WIDTYPE(obj, widtype);
4835 Widget_Data *wd = elm_widget_data_get(obj);
4837 wd->no_select = no_select;
4841 * Gets no select mode
4843 * @param obj The genlist object
4844 * @return The no select mode
4845 * (EINA_TRUE = on, EINA_FALSE = off)
4850 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4852 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4853 Widget_Data *wd = elm_widget_data_get(obj);
4854 if (!wd) return EINA_FALSE;
4855 return wd->no_select;
4861 * This will enable the compress mode where items are "compressed"
4862 * horizontally to fit the genlist scrollable viewport width. This is
4863 * special for genlist. Do not rely on
4864 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4865 * work as genlist needs to handle it specially.
4867 * @param obj The genlist object
4868 * @param compress The compress mode
4869 * (EINA_TRUE = on, EINA_FALSE = off)
4874 elm_genlist_compress_mode_set(Evas_Object *obj,
4877 ELM_CHECK_WIDTYPE(obj, widtype);
4878 Widget_Data *wd = elm_widget_data_get(obj);
4880 wd->compress = compress;
4881 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4885 * Get the compress mode
4887 * @param obj The genlist object
4888 * @return The compress mode
4889 * (EINA_TRUE = on, EINA_FALSE = off)
4894 elm_genlist_compress_mode_get(const Evas_Object *obj)
4896 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4897 Widget_Data *wd = elm_widget_data_get(obj);
4898 if (!wd) return EINA_FALSE;
4899 return wd->compress;
4903 * Set height-for-width mode
4905 * With height-for-width mode the item width will be fixed (restricted
4906 * to a minimum of) to the list width when calculating its size in
4907 * order to allow the height to be calculated based on it. This allows,
4908 * for instance, text block to wrap lines if the Edje part is
4909 * configured with "text.min: 0 1".
4911 * @note This mode will make list resize slower as it will have to
4912 * recalculate every item height again whenever the list width
4915 * @note When height-for-width mode is enabled, it also enables
4916 * compress mode (see elm_genlist_compress_mode_set()) and
4917 * disables homogeneous (see elm_genlist_homogeneous_set()).
4919 * @param obj The genlist object
4920 * @param setting The height-for-width mode (EINA_TRUE = on,
4926 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4927 Eina_Bool height_for_width)
4929 ELM_CHECK_WIDTYPE(obj, widtype);
4930 Widget_Data *wd = elm_widget_data_get(obj);
4932 wd->height_for_width = !!height_for_width;
4933 if (wd->height_for_width)
4935 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4936 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4941 * Get the height-for-width mode
4943 * @param obj The genlist object
4944 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4950 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4952 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4953 Widget_Data *wd = elm_widget_data_get(obj);
4954 if (!wd) return EINA_FALSE;
4955 return wd->height_for_width;
4961 * This will enable or disable the scroller bounce mode for the
4962 * genlist. See elm_scroller_bounce_set() for details
4964 * @param obj The genlist object
4965 * @param h_bounce Allow bounce horizontally
4966 * @param v_bounce Allow bounce vertically
4971 elm_genlist_bounce_set(Evas_Object *obj,
4975 ELM_CHECK_WIDTYPE(obj, widtype);
4976 Widget_Data *wd = elm_widget_data_get(obj);
4978 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4982 * Get the bounce mode
4984 * @param obj The genlist object
4985 * @param h_bounce Allow bounce horizontally
4986 * @param v_bounce Allow bounce vertically
4991 elm_genlist_bounce_get(const Evas_Object *obj,
4992 Eina_Bool *h_bounce,
4993 Eina_Bool *v_bounce)
4995 ELM_CHECK_WIDTYPE(obj, widtype);
4996 Widget_Data *wd = elm_widget_data_get(obj);
4998 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5002 * Set homogenous mode
5004 * This will enable the homogeneous mode where items are of the same
5005 * height and width so that genlist may do the lazy-loading at its
5006 * maximum. This implies 'compressed' mode.
5008 * @param obj The genlist object
5009 * @param homogeneous Assume the items within the genlist are of the
5010 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5015 elm_genlist_homogeneous_set(Evas_Object *obj,
5016 Eina_Bool homogeneous)
5018 ELM_CHECK_WIDTYPE(obj, widtype);
5019 Widget_Data *wd = elm_widget_data_get(obj);
5021 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5022 wd->homogeneous = homogeneous;
5026 * Get the homogenous mode
5028 * @param obj The genlist object
5029 * @return Assume the items within the genlist are of the same height
5030 * and width (EINA_TRUE = on, EINA_FALSE = off)
5035 elm_genlist_homogeneous_get(const Evas_Object *obj)
5037 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5038 Widget_Data *wd = elm_widget_data_get(obj);
5039 if (!wd) return EINA_FALSE;
5040 return wd->homogeneous;
5044 * Set the maximum number of items within an item block
5046 * This will configure the block count to tune to the target with
5047 * particular performance matrix.
5049 * @param obj The genlist object
5050 * @param n Maximum number of items within an item block
5055 elm_genlist_block_count_set(Evas_Object *obj,
5058 ELM_CHECK_WIDTYPE(obj, widtype);
5059 Widget_Data *wd = elm_widget_data_get(obj);
5061 wd->max_items_per_block = n;
5062 wd->item_cache_max = wd->max_items_per_block * 2;
5063 _item_cache_clean(wd);
5067 * Get the maximum number of items within an item block
5069 * @param obj The genlist object
5070 * @return Maximum number of items within an item block
5075 elm_genlist_block_count_get(const Evas_Object *obj)
5077 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5078 Widget_Data *wd = elm_widget_data_get(obj);
5080 return wd->max_items_per_block;
5084 * Set the timeout in seconds for the longpress event
5086 * @param obj The genlist object
5087 * @param timeout timeout in seconds
5092 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5095 ELM_CHECK_WIDTYPE(obj, widtype);
5096 Widget_Data *wd = elm_widget_data_get(obj);
5098 wd->longpress_timeout = timeout;
5102 * Get the timeout in seconds for the longpress event
5104 * @param obj The genlist object
5105 * @return timeout in seconds
5110 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5112 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5113 Widget_Data *wd = elm_widget_data_get(obj);
5115 return wd->longpress_timeout;
5119 * Set the scrollbar policy
5121 * This sets the scrollbar visibility policy for the given genlist
5122 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5123 * made visible if it is needed, and otherwise kept hidden.
5124 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5125 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5126 * respectively for the horizontal and vertical scrollbars.
5128 * @param obj The genlist object
5129 * @param policy_h Horizontal scrollbar policy
5130 * @param policy_v Vertical scrollbar policy
5135 elm_genlist_scroller_policy_set(Evas_Object *obj,
5136 Elm_Scroller_Policy policy_h,
5137 Elm_Scroller_Policy policy_v)
5139 ELM_CHECK_WIDTYPE(obj, widtype);
5140 Widget_Data *wd = elm_widget_data_get(obj);
5142 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5143 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5146 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5150 * Get the scrollbar policy
5152 * @param obj The genlist object
5153 * @param policy_h Horizontal scrollbar policy
5154 * @param policy_v Vertical scrollbar policy
5159 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5160 Elm_Scroller_Policy *policy_h,
5161 Elm_Scroller_Policy *policy_v)
5163 ELM_CHECK_WIDTYPE(obj, widtype);
5164 Widget_Data *wd = elm_widget_data_get(obj);
5165 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5166 if ((!wd) || (!wd->scr)) return;
5167 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5168 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5169 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5173 * Update the contents of all realized items
5175 * This updates all realized items by calling all the item class functions again
5176 * to get the icons, labels and states. Use this when the original
5177 * item data has changed and the changes are desired to be reflected.
5179 * @param it The item
5184 elm_genlist_realized_items_update(Evas_Object *obj)
5186 ELM_CHECK_WIDTYPE(obj, widtype);
5188 Eina_List *list, *l;
5189 Elm_Genlist_Item *it;
5191 list = elm_genlist_realized_items_get(obj);
5192 EINA_LIST_FOREACH(list, l, it)
5193 elm_genlist_item_update(it);
5197 * Set genlist item mode
5199 * @param item The genlist item
5200 * @param mode Mode name
5201 * @param mode_set Boolean to define set or unset mode.
5206 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5207 const char *mode_type,
5210 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5211 Widget_Data *wd = it->wd;
5213 Elm_Genlist_Item *it2;
5216 if (!mode_type) return;
5217 if ((it->delete_me) || (it->disabled)) return;
5219 if ((wd->mode_item == it) &&
5220 (!strcmp(mode_type, wd->mode_type)) &&
5223 if (!it->itc->mode_item_style) return;
5227 EINA_LIST_FOREACH(wd->selected, l, it2)
5229 elm_genlist_item_selected_set(it2, EINA_FALSE);
5233 it2 = elm_genlist_selected_item_get(wd->obj);
5234 if ((it2) && (it2->realized))
5235 elm_genlist_item_selected_set(it2, EINA_FALSE);
5238 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5240 ((it == wd->mode_item) && (!mode_set)))
5241 _item_mode_unset(wd);
5243 eina_stringshare_replace(&wd->mode_type, mode_type);
5244 if (mode_set) _item_mode_set(it);
5248 * Get active genlist mode type
5250 * @param obj The genlist object
5255 elm_genlist_mode_get(const Evas_Object *obj)
5257 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5258 Widget_Data *wd = elm_widget_data_get(obj);
5259 if (!wd) return NULL;
5260 return wd->mode_type;
5264 * Get active genlist mode item
5266 * @param obj The genlist object
5270 EAPI const Elm_Genlist_Item *
5271 elm_genlist_mode_item_get(const Evas_Object *obj)
5273 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5274 Widget_Data *wd = elm_widget_data_get(obj);
5275 if (!wd) return NULL;
5276 return wd->mode_item;