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_unhighlight(Elm_Genlist_Item *it)
853 const char *stacking, *selectraise;
854 if ((it->delete_me) || (!it->highlighted)) return;
855 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
856 stacking = edje_object_data_get(it->base.view, "stacking");
857 selectraise = edje_object_data_get(it->base.view, "selectraise");
860 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
861 else evas_object_raise(it->base.view);
863 it->highlighted = EINA_FALSE;
867 _item_block_del(Elm_Genlist_Item *it)
870 Item_Block *itb = it->block;
872 itb->items = eina_list_remove(itb->items, it);
874 itb->changed = EINA_TRUE;
875 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
876 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
879 il = EINA_INLIST_GET(itb);
880 Item_Block *itbn = (Item_Block *)(il->next);
882 it->parent->items = eina_list_remove(it->parent->items, it);
884 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
886 if (itbn) itbn->changed = EINA_TRUE;
892 il = EINA_INLIST_GET(itb);
893 Item_Block *itbp = (Item_Block *)(il->prev);
894 Item_Block *itbn = (Item_Block *)(il->next);
895 if ((itbp) && ((itbp->count + itb->count) < 48))
897 Elm_Genlist_Item *it2;
899 EINA_LIST_FREE(itb->items, it2)
902 itbp->items = eina_list_append(itbp->items, it2);
904 itbp->changed = EINA_TRUE;
906 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
907 EINA_INLIST_GET(itb));
910 else if ((itbn) && ((itbn->count + itb->count) < 48))
914 Eina_List *last = eina_list_last(itb->items);
915 Elm_Genlist_Item *it2 = last->data;
918 itb->items = eina_list_remove_list(itb->items, last);
919 itbn->items = eina_list_prepend(itbn->items, it2);
921 itbn->changed = EINA_TRUE;
924 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
932 _item_del(Elm_Genlist_Item *it)
934 elm_widget_item_pre_notify_del(it);
935 elm_genlist_item_subitems_clear(it);
936 it->wd->walking -= it->walking;
937 if (it->wd->show_item == it) it->wd->show_item = NULL;
938 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
939 if (it->realized) _item_unrealize(it, EINA_FALSE);
940 if (it->block) _item_block_del(it);
941 if ((!it->delete_me) && (it->itc->func.del))
942 it->itc->func.del((void *)it->base.data, it->base.widget);
943 it->delete_me = EINA_TRUE;
945 it->wd->queue = eina_list_remove(it->wd->queue, it);
946 if (it->wd->anchor_item == it)
948 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
949 if (!it->wd->anchor_item)
950 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
952 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
954 it->parent->items = eina_list_remove(it->parent->items, it);
955 if (it->flags & ELM_GENLIST_ITEM_GROUP)
956 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
957 if (it->long_timer) ecore_timer_del(it->long_timer);
958 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
960 if (it->tooltip.del_cb)
961 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
963 elm_widget_item_del(it);
967 _item_select(Elm_Genlist_Item *it)
969 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
972 if (it->wd->always_select) goto call;
975 it->selected = EINA_TRUE;
976 it->wd->selected = eina_list_append(it->wd->selected, it);
980 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
982 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
985 if ((it->wd->clear_me) && (!it->wd->walking))
986 elm_genlist_clear(it->base.widget);
989 if ((!it->walking) && (it->delete_me))
991 if (!it->relcount) _item_del(it);
994 it->wd->last_selected_item = it;
998 _item_unselect(Elm_Genlist_Item *it)
1000 if ((it->delete_me) || (!it->selected)) return;
1001 it->selected = EINA_FALSE;
1002 it->wd->selected = eina_list_remove(it->wd->selected, it);
1003 evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
1007 _mouse_move(void *data,
1008 Evas *evas __UNUSED__,
1012 Elm_Genlist_Item *it = data;
1013 Evas_Event_Mouse_Move *ev = event_info;
1014 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1016 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1018 if (!it->wd->on_hold)
1020 it->wd->on_hold = EINA_TRUE;
1021 if (!it->wd->wasselected)
1023 _item_unhighlight(it);
1028 if (it->wd->multitouched)
1030 it->wd->cur_x = ev->cur.canvas.x;
1031 it->wd->cur_y = ev->cur.canvas.y;
1034 if ((it->dragging) && (it->down))
1036 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1039 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1040 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1041 if (abs((it->wd->history[it->wd->movements].x -
1042 it->wd->history[0].x)) > 40)
1043 it->wd->swipe = EINA_TRUE;
1045 it->wd->movements++;
1049 ecore_timer_del(it->long_timer);
1050 it->long_timer = NULL;
1052 evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
1055 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1059 ecore_timer_del(it->long_timer);
1060 it->long_timer = NULL;
1064 if (!it->display_only)
1065 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1066 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1067 x = ev->cur.canvas.x - x;
1068 y = ev->cur.canvas.y - y;
1071 if (adx < 0) adx = -dx;
1074 if (ady < 0) ady = -dy;
1077 if ((adx > minw) || (ady > minh))
1079 it->dragging = EINA_TRUE;
1082 ecore_timer_del(it->long_timer);
1083 it->long_timer = NULL;
1085 if (!it->wd->wasselected)
1087 _item_unhighlight(it);
1093 evas_object_smart_callback_call(it->base.widget,
1094 SIG_DRAG_START_UP, it);
1098 evas_object_smart_callback_call(it->base.widget,
1099 SIG_DRAG_START_LEFT, it);
1101 evas_object_smart_callback_call(it->base.widget,
1102 SIG_DRAG_START_RIGHT, it);
1108 evas_object_smart_callback_call(it->base.widget,
1109 SIG_DRAG_START_DOWN, it);
1113 evas_object_smart_callback_call(it->base.widget,
1114 SIG_DRAG_START_LEFT, it);
1116 evas_object_smart_callback_call(it->base.widget,
1117 SIG_DRAG_START_RIGHT, it);
1124 _long_press(void *data)
1126 Elm_Genlist_Item *it = data;
1128 it->long_timer = NULL;
1129 if ((it->disabled) || (it->dragging) || (it->display_only))
1130 return ECORE_CALLBACK_CANCEL;
1131 it->wd->longpressed = EINA_TRUE;
1132 evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
1133 return ECORE_CALLBACK_CANCEL;
1137 _swipe(Elm_Genlist_Item *it)
1142 if ((it->display_only) || (it->disabled)) return;
1143 it->wd->swipe = EINA_FALSE;
1144 for (i = 0; i < it->wd->movements; i++)
1146 sum += it->wd->history[i].x;
1147 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1150 sum /= it->wd->movements;
1151 if (abs(sum - it->wd->history[0].x) <= 10) return;
1152 evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
1156 _swipe_cancel(void *data)
1158 Elm_Genlist_Item *it = data;
1160 if (!it) return ECORE_CALLBACK_CANCEL;
1161 it->wd->swipe = EINA_FALSE;
1162 it->wd->movements = 0;
1163 return ECORE_CALLBACK_RENEW;
1167 _multi_cancel(void *data)
1169 Widget_Data *wd = data;
1171 if (!wd) return ECORE_CALLBACK_CANCEL;
1172 wd->multi_timeout = EINA_TRUE;
1173 return ECORE_CALLBACK_RENEW;
1177 _multi_touch_gesture_eval(void *data)
1179 Elm_Genlist_Item *it = data;
1181 it->wd->multitouched = EINA_FALSE;
1182 if (it->wd->multi_timer)
1184 ecore_timer_del(it->wd->multi_timer);
1185 it->wd->multi_timer = NULL;
1187 if (it->wd->multi_timeout)
1189 it->wd->multi_timeout = EINA_FALSE;
1193 Evas_Coord minw = 0, minh = 0;
1194 Evas_Coord off_x, off_y, off_mx, off_my;
1196 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1197 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1198 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1199 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1200 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1202 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1204 if ((off_x + off_mx) > (off_y + off_my))
1206 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1207 evas_object_smart_callback_call(it->base.widget,
1208 SIG_MULTI_SWIPE_RIGHT, it);
1209 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1210 evas_object_smart_callback_call(it->base.widget,
1211 SIG_MULTI_SWIPE_LEFT, it);
1212 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1213 evas_object_smart_callback_call(it->base.widget,
1214 SIG_MULTI_PINCH_OUT, it);
1216 evas_object_smart_callback_call(it->base.widget,
1217 SIG_MULTI_PINCH_IN, it);
1221 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1222 evas_object_smart_callback_call(it->base.widget,
1223 SIG_MULTI_SWIPE_DOWN, it);
1224 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1225 evas_object_smart_callback_call(it->base.widget,
1226 SIG_MULTI_SWIPE_UP, it);
1227 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1228 evas_object_smart_callback_call(it->base.widget,
1229 SIG_MULTI_PINCH_OUT, it);
1231 evas_object_smart_callback_call(it->base.widget,
1232 SIG_MULTI_PINCH_IN, it);
1235 it->wd->multi_timeout = EINA_FALSE;
1239 _multi_down(void *data,
1240 Evas *evas __UNUSED__,
1241 Evas_Object *obj __UNUSED__,
1244 Elm_Genlist_Item *it = data;
1245 Evas_Event_Multi_Down *ev = event_info;
1247 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1248 it->wd->multi_device = ev->device;
1249 it->wd->multi_down = EINA_TRUE;
1250 it->wd->multitouched = EINA_TRUE;
1251 it->wd->prev_mx = ev->canvas.x;
1252 it->wd->prev_my = ev->canvas.y;
1253 if (!it->wd->wasselected)
1255 _item_unhighlight(it);
1258 it->wd->wasselected = EINA_FALSE;
1259 it->wd->longpressed = EINA_FALSE;
1262 ecore_timer_del(it->long_timer);
1263 it->long_timer = NULL;
1267 it->dragging = EINA_FALSE;
1268 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1270 if (it->swipe_timer)
1272 ecore_timer_del(it->swipe_timer);
1273 it->swipe_timer = NULL;
1275 if (it->wd->on_hold)
1277 it->wd->swipe = EINA_FALSE;
1278 it->wd->movements = 0;
1279 it->wd->on_hold = EINA_FALSE;
1284 _multi_up(void *data,
1285 Evas *evas __UNUSED__,
1286 Evas_Object *obj __UNUSED__,
1289 Elm_Genlist_Item *it = data;
1290 Evas_Event_Multi_Up *ev = event_info;
1292 if (it->wd->multi_device != ev->device) return;
1293 it->wd->multi_device = 0;
1294 it->wd->multi_down = EINA_FALSE;
1295 if (it->wd->mouse_down) return;
1296 _multi_touch_gesture_eval(data);
1300 _multi_move(void *data,
1301 Evas *evas __UNUSED__,
1302 Evas_Object *obj __UNUSED__,
1305 Elm_Genlist_Item *it = data;
1306 Evas_Event_Multi_Move *ev = event_info;
1308 if (it->wd->multi_device != ev->device) return;
1309 it->wd->cur_mx = ev->cur.canvas.x;
1310 it->wd->cur_my = ev->cur.canvas.y;
1314 _mouse_down(void *data,
1315 Evas *evas __UNUSED__,
1319 Elm_Genlist_Item *it = data;
1320 Evas_Event_Mouse_Down *ev = event_info;
1323 if (ev->button != 1) return;
1324 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1326 it->wd->on_hold = EINA_TRUE;
1329 it->down = EINA_TRUE;
1330 it->dragging = EINA_FALSE;
1331 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1332 it->dx = ev->canvas.x - x;
1333 it->dy = ev->canvas.y - y;
1334 it->wd->mouse_down = EINA_TRUE;
1335 if (!it->wd->multitouched)
1337 it->wd->prev_x = ev->canvas.x;
1338 it->wd->prev_y = ev->canvas.y;
1339 it->wd->multi_timeout = EINA_FALSE;
1340 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1341 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1343 it->wd->longpressed = EINA_FALSE;
1344 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1345 else it->wd->on_hold = EINA_FALSE;
1346 if (it->wd->on_hold) return;
1347 it->wd->wasselected = it->selected;
1348 _item_highlight(it);
1349 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1350 if ((!it->disabled) && (!it->display_only))
1352 evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
1353 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1355 if (it->long_timer) ecore_timer_del(it->long_timer);
1356 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1357 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1359 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1362 it->long_timer = NULL;
1363 it->wd->swipe = EINA_FALSE;
1364 it->wd->movements = 0;
1368 _mouse_up(void *data,
1369 Evas *evas __UNUSED__,
1370 Evas_Object *obj __UNUSED__,
1373 Elm_Genlist_Item *it = data;
1374 Evas_Event_Mouse_Up *ev = event_info;
1375 Eina_Bool dragged = EINA_FALSE;
1377 if (ev->button != 1) return;
1378 it->down = EINA_FALSE;
1379 it->wd->mouse_down = EINA_FALSE;
1380 if (it->wd->multitouched)
1382 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
1383 if (it->wd->multi_down) return;
1384 _multi_touch_gesture_eval(data);
1387 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1388 else it->wd->on_hold = EINA_FALSE;
1391 ecore_timer_del(it->long_timer);
1392 it->long_timer = NULL;
1396 it->dragging = EINA_FALSE;
1397 evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
1400 if (it->swipe_timer)
1402 ecore_timer_del(it->swipe_timer);
1403 it->swipe_timer = NULL;
1405 if (it->wd->multi_timer)
1407 ecore_timer_del(it->wd->multi_timer);
1408 it->wd->multi_timer = NULL;
1409 it->wd->multi_timeout = EINA_FALSE;
1411 if (it->wd->on_hold)
1413 if (it->wd->swipe) _swipe(data);
1414 it->wd->longpressed = EINA_FALSE;
1415 it->wd->on_hold = EINA_FALSE;
1418 if (it->wd->longpressed)
1420 it->wd->longpressed = EINA_FALSE;
1421 if (!it->wd->wasselected)
1423 _item_unhighlight(it);
1426 it->wd->wasselected = EINA_FALSE;
1431 if (it->want_unrealize)
1433 _item_unrealize(it, EINA_FALSE);
1434 if (it->block->want_unrealize)
1435 _item_block_unrealize(it->block);
1438 if ((it->disabled) || (dragged) || (it->display_only)) return;
1439 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1444 _item_highlight(it);
1449 _item_unhighlight(it);
1457 Widget_Data *wd = it->wd;
1460 while (wd->selected)
1462 _item_unhighlight(wd->selected->data);
1463 _item_unselect(wd->selected->data);
1469 const Eina_List *l, *l_next;
1470 Elm_Genlist_Item *it2;
1472 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1475 _item_unhighlight(it2);
1476 _item_unselect(it2);
1478 //_item_highlight(it);
1481 _item_highlight(it);
1487 _signal_expand_toggle(void *data,
1488 Evas_Object *obj __UNUSED__,
1489 const char *emission __UNUSED__,
1490 const char *source __UNUSED__)
1492 Elm_Genlist_Item *it = data;
1495 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1497 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1501 _signal_expand(void *data,
1502 Evas_Object *obj __UNUSED__,
1503 const char *emission __UNUSED__,
1504 const char *source __UNUSED__)
1506 Elm_Genlist_Item *it = data;
1509 evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
1513 _signal_contract(void *data,
1514 Evas_Object *obj __UNUSED__,
1515 const char *emission __UNUSED__,
1516 const char *source __UNUSED__)
1518 Elm_Genlist_Item *it = data;
1521 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
1525 _scr_hold_timer_cb(void *data)
1527 if (!data) return ECORE_CALLBACK_CANCEL;
1528 Widget_Data *wd = data;
1529 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1530 wd->scr_hold_timer = NULL;
1531 return ECORE_CALLBACK_CANCEL;
1535 _mode_finished_signal_cb(void *data,
1537 const char *emission __UNUSED__,
1538 const char *source __UNUSED__)
1542 Elm_Genlist_Item *it = data;
1543 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1546 it->nocache = EINA_FALSE;
1547 _mode_item_unrealize(it);
1548 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1549 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1553 _item_cache_clean(Widget_Data *wd)
1555 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1559 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1560 wd->item_cache = eina_inlist_remove(wd->item_cache,
1561 wd->item_cache->last);
1562 wd->item_cache_count--;
1563 if (itc->spacer) evas_object_del(itc->spacer);
1564 if (itc->base_view) evas_object_del(itc->base_view);
1565 if (itc->item_style) eina_stringshare_del(itc->item_style);
1571 _item_cache_zero(Widget_Data *wd)
1573 int pmax = wd->item_cache_max;
1574 wd->item_cache_max = 0;
1575 _item_cache_clean(wd);
1576 wd->item_cache_max = pmax;
1580 _item_cache_add(Elm_Genlist_Item *it)
1584 if (it->wd->item_cache_max <= 0)
1586 evas_object_del(it->base.view);
1587 it->base.view = NULL;
1588 evas_object_del(it->spacer);
1593 it->wd->item_cache_count++;
1594 itc = calloc(1, sizeof(Item_Cache));
1595 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1596 EINA_INLIST_GET(itc));
1597 itc->spacer = it->spacer;
1599 itc->base_view = it->base.view;
1600 it->base.view = NULL;
1601 evas_object_hide(itc->base_view);
1602 evas_object_move(itc->base_view, -9999, -9999);
1603 itc->item_style = eina_stringshare_add(it->itc->item_style);
1604 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1605 itc->compress = (it->wd->compress);
1606 itc->selected = it->selected;
1607 itc->disabled = it->disabled;
1608 itc->expanded = it->expanded;
1611 ecore_timer_del(it->long_timer);
1612 it->long_timer = NULL;
1614 if (it->swipe_timer)
1616 ecore_timer_del(it->swipe_timer);
1617 it->swipe_timer = NULL;
1619 // FIXME: other callbacks?
1620 edje_object_signal_callback_del_full(itc->base_view,
1621 "elm,action,expand,toggle",
1622 "elm", _signal_expand_toggle, it);
1623 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1625 _signal_expand, it);
1626 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1627 "elm", _signal_contract, it);
1628 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1630 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1632 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1634 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1636 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1638 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1640 _item_cache_clean(it->wd);
1644 _item_cache_find(Elm_Genlist_Item *it)
1649 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1650 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1652 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1654 if ((itc->tree == tree) &&
1655 (itc->compress == it->wd->compress) &&
1656 (!strcmp(it->itc->item_style, itc->item_style)))
1658 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1659 EINA_INLIST_GET(itc));
1660 it->wd->item_cache_count--;
1668 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1670 if (!it->nostacking)
1672 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1673 evas_object_lower(it->base.view);
1675 evas_object_raise(it->base.view);
1678 if (it->order_num_in & 0x1)
1679 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1681 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1685 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1689 if (it->selected != itc->selected)
1692 edje_object_signal_emit(it->base.view,
1693 "elm,state,selected", "elm");
1695 if (it->disabled != itc->disabled)
1698 edje_object_signal_emit(it->base.view,
1699 "elm,state,disabled", "elm");
1701 if (it->expanded != itc->expanded)
1704 edje_object_signal_emit(it->base.view,
1705 "elm,state,expanded", "elm");
1711 edje_object_signal_emit(it->base.view,
1712 "elm,state,selected", "elm");
1714 edje_object_signal_emit(it->base.view,
1715 "elm,state,disabled", "elm");
1717 edje_object_signal_emit(it->base.view,
1718 "elm,state,expanded", "elm");
1723 _item_cache_free(Item_Cache *itc)
1725 if (itc->spacer) evas_object_del(itc->spacer);
1726 if (itc->base_view) evas_object_del(itc->base_view);
1727 if (itc->item_style) eina_stringshare_del(itc->item_style);
1732 _item_label_realize(Elm_Genlist_Item *it,
1733 Evas_Object *target,
1736 if (it->itc->func.label_get)
1741 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1742 EINA_LIST_FOREACH(*source, l, key)
1744 char *s = it->itc->func.label_get
1745 ((void *)it->base.data, it->base.widget, key);
1749 edje_object_part_text_set(target, key, s);
1754 edje_object_part_text_set(target, key, "");
1761 _item_icon_realize(Elm_Genlist_Item *it,
1762 Evas_Object *target,
1765 Eina_List *res = NULL;
1767 if (it->itc->func.icon_get)
1772 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1773 EINA_LIST_FOREACH(*source, l, key)
1775 Evas_Object *ic = it->itc->func.icon_get
1776 ((void *)it->base.data, it->base.widget, key);
1780 res = eina_list_append(res, ic);
1781 edje_object_part_swallow(target, key, ic);
1782 evas_object_show(ic);
1783 elm_widget_sub_object_add(it->base.widget, ic);
1785 elm_widget_disabled_set(ic, EINA_TRUE);
1794 _item_state_realize(Elm_Genlist_Item *it,
1795 Evas_Object *target,
1798 if (it->itc->func.state_get)
1804 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1805 EINA_LIST_FOREACH(*source, l, key)
1807 Eina_Bool on = it->itc->func.state_get
1808 ((void *)it->base.data, it->base.widget, key);
1812 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1813 edje_object_signal_emit(target, buf, "elm");
1817 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1818 edje_object_signal_emit(target, buf, "elm");
1825 _item_realize(Elm_Genlist_Item *it,
1829 Elm_Genlist_Item *it2;
1830 const char *treesize;
1832 int depth, tsize = 20;
1833 Item_Cache *itc = NULL;
1835 if (it->delete_me) return ;
1838 if (it->order_num_in != in)
1840 it->order_num_in = in;
1841 _elm_genlist_item_odd_even_update(it);
1842 _elm_genlist_item_state_update(it, NULL);
1846 it->order_num_in = in;
1849 it->nocache = EINA_FALSE;
1851 itc = _item_cache_find(it);
1854 it->base.view = itc->base_view;
1855 itc->base_view = NULL;
1856 it->spacer = itc->spacer;
1861 const char *stacking_even;
1862 const char *stacking;
1864 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1865 edje_object_scale_set(it->base.view,
1866 elm_widget_scale_get(it->base.widget) *
1867 _elm_config->scale);
1868 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1869 elm_widget_sub_object_add(it->base.widget, it->base.view);
1871 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1872 strncpy(buf, "tree", sizeof(buf));
1873 else strncpy(buf, "item", sizeof(buf));
1874 if (it->wd->compress)
1875 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1877 strncat(buf, "/", sizeof(buf) - strlen(buf));
1878 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1880 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1881 elm_widget_style_get(it->base.widget));
1883 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1884 if (!stacking_even) stacking_even = "above";
1885 it->stacking_even = !!strcmp("above", stacking_even);
1887 stacking = edje_object_data_get(it->base.view, "stacking");
1888 if (!stacking) stacking = "yes";
1889 it->nostacking = !!strcmp("yes", stacking);
1891 edje_object_mirrored_set(it->base.view,
1892 elm_widget_mirrored_get(it->base.widget));
1894 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1895 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1896 elm_widget_sub_object_add(it->base.widget, it->spacer);
1899 _elm_genlist_item_odd_even_update(it);
1901 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1903 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1905 it->expanded_depth = depth;
1906 treesize = edje_object_data_get(it->base.view, "treesize");
1907 if (treesize) tsize = atoi(treesize);
1908 evas_object_size_hint_min_set(it->spacer,
1909 (depth * tsize) * _elm_config->scale, 1);
1910 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1913 edje_object_signal_callback_add(it->base.view,
1914 "elm,action,expand,toggle",
1915 "elm", _signal_expand_toggle, it);
1916 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1917 "elm", _signal_expand, it);
1918 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1919 "elm", _signal_contract, it);
1920 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1922 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1924 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1926 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1928 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1930 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1933 _elm_genlist_item_state_update(it, itc);
1936 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1938 /* homogenous genlist shortcut */
1941 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1943 it->w = it->minw = it->wd->group_item_width;
1944 it->h = it->minh = it->wd->group_item_height;
1948 it->w = it->minw = it->wd->item_width;
1949 it->h = it->minh = it->wd->item_height;
1951 it->mincalcd = EINA_TRUE;
1956 /* FIXME: If you see that assert, please notify us and we
1957 will clean our mess */
1958 assert(eina_list_count(it->icon_objs) == 0);
1960 _item_label_realize(it, it->base.view, &it->labels);
1961 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1962 _item_state_realize(it, it->base.view, &it->states);
1966 Evas_Coord mw = -1, mh = -1;
1968 if (!it->display_only)
1969 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1970 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1971 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1973 if (!it->display_only)
1974 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1975 it->w = it->minw = mw;
1976 it->h = it->minh = mh;
1977 it->mincalcd = EINA_TRUE;
1979 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1981 it->wd->group_item_width = mw;
1982 it->wd->group_item_height = mh;
1984 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1986 it->wd->item_width = mw;
1987 it->wd->item_height = mh;
1990 if (!calc) evas_object_show(it->base.view);
1993 if (it->tooltip.content_cb)
1995 elm_widget_item_tooltip_content_cb_set(it,
1996 it->tooltip.content_cb,
1997 it->tooltip.data, NULL);
1998 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2001 if (it->mouse_cursor)
2002 elm_widget_item_cursor_set(it, it->mouse_cursor);
2004 it->realized = EINA_TRUE;
2005 it->want_unrealize = EINA_FALSE;
2007 if (itc) _item_cache_free(itc);
2008 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
2012 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2016 if (!it->realized) return;
2017 if (!calc) evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
2020 ecore_timer_del(it->long_timer);
2021 it->long_timer = NULL;
2025 evas_object_del(it->base.view);
2026 it->base.view = NULL;
2027 evas_object_del(it->spacer);
2032 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2033 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2034 _item_cache_add(it);
2036 elm_widget_stringlist_free(it->labels);
2038 elm_widget_stringlist_free(it->icons);
2040 elm_widget_stringlist_free(it->states);
2042 EINA_LIST_FREE(it->icon_objs, icon)
2043 evas_object_del(icon);
2045 _mode_item_unrealize(it);
2047 it->realized = EINA_FALSE;
2048 it->want_unrealize = EINA_FALSE;
2052 _item_block_recalc(Item_Block *itb,
2057 Elm_Genlist_Item *it;
2058 Evas_Coord minw = 0, minh = 0;
2059 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2063 EINA_LIST_FOREACH(itb->items, l, it)
2065 if (it->delete_me) continue;
2066 showme |= it->showme;
2071 if (!it->mincalcd) changed = EINA_TRUE;
2074 _item_realize(it, in, EINA_TRUE);
2075 _item_unrealize(it, EINA_TRUE);
2080 _item_realize(it, in, EINA_TRUE);
2081 _item_unrealize(it, EINA_TRUE);
2085 _item_realize(it, in, EINA_FALSE);
2087 if (minw < it->minw) minw = it->minw;
2095 itb->changed = EINA_FALSE;
2100 _item_block_realize(Item_Block *itb,
2105 Elm_Genlist_Item *it;
2107 if (itb->realized) return;
2108 EINA_LIST_FOREACH(itb->items, l, it)
2110 if (it->delete_me) continue;
2111 if (full) _item_realize(it, in, EINA_FALSE);
2114 itb->realized = EINA_TRUE;
2115 itb->want_unrealize = EINA_FALSE;
2119 _item_block_unrealize(Item_Block *itb)
2122 Elm_Genlist_Item *it;
2123 Eina_Bool dragging = EINA_FALSE;
2125 if (!itb->realized) return;
2126 EINA_LIST_FOREACH(itb->items, l, it)
2128 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2132 dragging = EINA_TRUE;
2133 it->want_unrealize = EINA_TRUE;
2136 _item_unrealize(it, EINA_FALSE);
2141 itb->realized = EINA_FALSE;
2142 itb->want_unrealize = EINA_TRUE;
2145 itb->want_unrealize = EINA_FALSE;
2149 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2154 evas_object_resize(view, it->w, it->h);
2155 evas_object_move(view, it->scrl_x, it->scrl_y);
2156 evas_object_show(view);
2160 _item_block_position(Item_Block *itb,
2164 Elm_Genlist_Item *it;
2165 Elm_Genlist_Item *git;
2166 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2169 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2170 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2172 EINA_LIST_FOREACH(itb->items, l, it)
2174 if (it->delete_me) continue;
2178 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2179 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2181 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2182 cvx, cvy, cvw, cvh));
2183 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2185 if ((itb->realized) && (!it->realized))
2187 if (vis) _item_realize(it, in, EINA_FALSE);
2193 git = it->group_item;
2196 if (git->scrl_y < oy)
2198 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2199 git->scrl_y = (it->scrl_y + it->h) - git->h;
2200 git->want_realize = EINA_TRUE;
2203 _item_position(it, it->mode_view);
2205 _item_position(it, it->base.view);
2209 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2216 if (vis) it->want_realize = EINA_TRUE;
2223 _group_items_recalc(void *data)
2225 Widget_Data *wd = data;
2227 Elm_Genlist_Item *git;
2229 EINA_LIST_FOREACH(wd->group_items, l, git)
2231 if (git->want_realize)
2234 _item_realize(git, 0, EINA_FALSE);
2235 evas_object_resize(git->base.view, wd->minw, git->h);
2236 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2237 evas_object_show(git->base.view);
2238 evas_object_raise(git->base.view);
2240 else if (!git->want_realize && git->realized)
2243 _item_unrealize(git, EINA_FALSE);
2249 _must_recalc_idler(void *data)
2251 Widget_Data *wd = data;
2252 if (wd->calc_job) ecore_job_del(wd->calc_job);
2253 wd->calc_job = ecore_job_add(_calc_job, wd);
2254 wd->must_recalc_idler = NULL;
2255 return ECORE_CALLBACK_CANCEL;
2259 _calc_job(void *data)
2261 Widget_Data *wd = data;
2263 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2264 Item_Block *chb = NULL;
2265 int in = 0, minw_change = 0;
2266 Eina_Bool changed = EINA_FALSE;
2268 Eina_Bool did_must_recalc = EINA_FALSE;
2271 t0 = ecore_time_get();
2272 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2276 EINA_INLIST_FOREACH(wd->blocks, itb)
2278 Eina_Bool showme = EINA_FALSE;
2281 showme = itb->showme;
2282 itb->showme = EINA_FALSE;
2285 if (itb->realized) _item_block_unrealize(itb);
2287 if ((itb->changed) || (changed) ||
2288 ((itb->must_recalc) && (!did_must_recalc)))
2290 if ((changed) || (itb->must_recalc))
2293 Elm_Genlist_Item *it;
2294 EINA_LIST_FOREACH(itb->items, l, it)
2295 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2296 itb->changed = EINA_TRUE;
2297 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2298 itb->must_recalc = EINA_FALSE;
2300 if (itb->realized) _item_block_unrealize(itb);
2301 showme = _item_block_recalc(itb, in, 0);
2307 if (minw == -1) minw = itb->minw;
2308 else if ((!itb->must_recalc) && (minw < itb->minw))
2317 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2319 wd->show_item->showme = EINA_FALSE;
2321 elm_smart_scroller_region_bring_in(wd->scr,
2323 wd->show_item->block->x,
2325 wd->show_item->block->y,
2326 wd->show_item->block->w,
2329 elm_smart_scroller_child_region_show(wd->scr,
2331 wd->show_item->block->x,
2333 wd->show_item->block->y,
2334 wd->show_item->block->w,
2336 wd->show_item = NULL;
2341 EINA_INLIST_FOREACH(wd->blocks, itb)
2347 if ((chb) && (EINA_INLIST_GET(chb)->next))
2349 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2351 if (itb->realized) _item_block_unrealize(itb);
2354 wd->realminw = minw;
2355 if (minw < wd->w) minw = wd->w;
2356 if ((minw != wd->minw) || (minh != wd->minh))
2360 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2361 _sizing_eval(wd->obj);
2362 if ((wd->anchor_item) && (wd->anchor_item->block))
2364 Elm_Genlist_Item *it;
2367 it = wd->anchor_item;
2368 it_y = wd->anchor_y;
2369 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2370 it->block->y + it->y + it_y);
2371 wd->anchor_item = it;
2372 wd->anchor_y = it_y;
2375 t = ecore_time_get();
2376 if (did_must_recalc)
2378 if (!wd->must_recalc_idler)
2379 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2381 wd->calc_job = NULL;
2382 evas_object_smart_changed(wd->pan_smart);
2386 _update_job(void *data)
2388 Widget_Data *wd = data;
2391 int num, num0, position = 0, recalc = 0;
2393 wd->update_job = NULL;
2395 EINA_INLIST_FOREACH(wd->blocks, itb)
2397 Evas_Coord itminw, itminh;
2398 Elm_Genlist_Item *it;
2404 _item_block_position(itb, num);
2409 EINA_LIST_FOREACH(itb->items, l2, it)
2416 it->updateme = EINA_FALSE;
2419 _item_unrealize(it, EINA_FALSE);
2420 _item_realize(it, num, EINA_FALSE);
2425 _item_realize(it, num, EINA_TRUE);
2426 _item_unrealize(it, EINA_TRUE);
2428 if ((it->minw != itminw) || (it->minh != itminh))
2433 itb->updateme = EINA_FALSE;
2437 itb->changed = EINA_TRUE;
2438 _item_block_recalc(itb, num0, 0);
2439 _item_block_position(itb, num0);
2444 if (wd->calc_job) ecore_job_del(wd->calc_job);
2445 wd->calc_job = ecore_job_add(_calc_job, wd);
2450 _pan_set(Evas_Object *obj,
2454 Pan *sd = evas_object_smart_data_get(obj);
2457 // Evas_Coord ow, oh;
2458 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2459 // ow = sd->wd->minw - ow;
2460 // if (ow < 0) ow = 0;
2461 // oh = sd->wd->minh - oh;
2462 // if (oh < 0) oh = 0;
2463 // if (x < 0) x = 0;
2464 // if (y < 0) y = 0;
2465 // if (x > ow) x = ow;
2466 // if (y > oh) y = oh;
2467 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2471 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2473 if ((itb->y + itb->h) > y)
2475 Elm_Genlist_Item *it;
2478 EINA_LIST_FOREACH(itb->items, l2, it)
2480 if ((itb->y + it->y) >= y)
2482 sd->wd->anchor_item = it;
2483 sd->wd->anchor_y = -(itb->y + it->y - y);
2490 evas_object_smart_changed(obj);
2494 _pan_get(Evas_Object *obj,
2498 Pan *sd = evas_object_smart_data_get(obj);
2500 if (x) *x = sd->wd->pan_x;
2501 if (y) *y = sd->wd->pan_y;
2505 _pan_max_get(Evas_Object *obj,
2509 Pan *sd = evas_object_smart_data_get(obj);
2512 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2513 ow = sd->wd->minw - ow;
2515 oh = sd->wd->minh - oh;
2522 _pan_min_get(Evas_Object *obj __UNUSED__,
2531 _pan_child_size_get(Evas_Object *obj,
2535 Pan *sd = evas_object_smart_data_get(obj);
2537 if (w) *w = sd->wd->minw;
2538 if (h) *h = sd->wd->minh;
2542 _pan_add(Evas_Object *obj)
2545 Evas_Object_Smart_Clipped_Data *cd;
2548 cd = evas_object_smart_data_get(obj);
2551 sd->__clipped_data = *cd;
2553 evas_object_smart_data_set(obj, sd);
2557 _pan_del(Evas_Object *obj)
2559 Pan *sd = evas_object_smart_data_get(obj);
2564 ecore_job_del(sd->resize_job);
2565 sd->resize_job = NULL;
2571 _pan_resize_job(void *data)
2574 _sizing_eval(sd->wd->obj);
2575 sd->resize_job = NULL;
2579 _pan_resize(Evas_Object *obj,
2583 Pan *sd = evas_object_smart_data_get(obj);
2586 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2587 if ((ow == w) && (oh == h)) return;
2588 if ((sd->wd->height_for_width) && (ow != w))
2590 if (sd->resize_job) ecore_job_del(sd->resize_job);
2591 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2593 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2594 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2598 _pan_calculate(Evas_Object *obj)
2600 Pan *sd = evas_object_smart_data_get(obj);
2602 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2604 Elm_Genlist_Item *git;
2607 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2608 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2609 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2611 git->want_realize = EINA_FALSE;
2613 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2615 itb->w = sd->wd->minw;
2616 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2617 itb->y - sd->wd->pan_y + oy,
2619 cvx, cvy, cvw, cvh))
2621 if ((!itb->realized) || (itb->changed))
2622 _item_block_realize(itb, in, 0);
2623 _item_block_position(itb, in);
2627 if (itb->realized) _item_block_unrealize(itb);
2631 _group_items_recalc(sd->wd);
2635 _pan_move(Evas_Object *obj,
2636 Evas_Coord x __UNUSED__,
2637 Evas_Coord y __UNUSED__)
2639 Pan *sd = evas_object_smart_data_get(obj);
2641 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2642 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2646 _hold_on(void *data __UNUSED__,
2648 void *event_info __UNUSED__)
2650 Widget_Data *wd = elm_widget_data_get(obj);
2652 elm_smart_scroller_hold_set(wd->scr, 1);
2656 _hold_off(void *data __UNUSED__,
2658 void *event_info __UNUSED__)
2660 Widget_Data *wd = elm_widget_data_get(obj);
2662 elm_smart_scroller_hold_set(wd->scr, 0);
2666 _freeze_on(void *data __UNUSED__,
2668 void *event_info __UNUSED__)
2670 Widget_Data *wd = elm_widget_data_get(obj);
2672 elm_smart_scroller_freeze_set(wd->scr, 1);
2676 _freeze_off(void *data __UNUSED__,
2678 void *event_info __UNUSED__)
2680 Widget_Data *wd = elm_widget_data_get(obj);
2682 elm_smart_scroller_freeze_set(wd->scr, 0);
2686 _scroll_edge_left(void *data,
2687 Evas_Object *scr __UNUSED__,
2688 void *event_info __UNUSED__)
2690 Evas_Object *obj = data;
2691 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
2695 _scroll_edge_right(void *data,
2696 Evas_Object *scr __UNUSED__,
2697 void *event_info __UNUSED__)
2699 Evas_Object *obj = data;
2700 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
2704 _scroll_edge_top(void *data,
2705 Evas_Object *scr __UNUSED__,
2706 void *event_info __UNUSED__)
2708 Evas_Object *obj = data;
2709 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
2713 _scroll_edge_bottom(void *data,
2714 Evas_Object *scr __UNUSED__,
2715 void *event_info __UNUSED__)
2717 Evas_Object *obj = data;
2718 evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
2722 _mode_item_realize(Elm_Genlist_Item *it)
2726 if ((it->mode_view) || (it->delete_me)) return;
2728 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2729 edje_object_scale_set(it->mode_view,
2730 elm_widget_scale_get(it->base.widget) *
2731 _elm_config->scale);
2732 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2733 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2735 strncpy(buf, "item", sizeof(buf));
2736 if (it->wd->compress)
2737 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2739 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2740 strncat(buf, "/", sizeof(buf) - strlen(buf));
2741 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2743 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2744 elm_widget_style_get(it->base.widget));
2745 edje_object_mirrored_set(it->mode_view,
2746 elm_widget_mirrored_get(it->base.widget));
2748 /* signal callback add */
2749 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2751 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2753 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2756 /* label_get, icon_get, state_get */
2757 /* FIXME: If you see that assert, please notify us and we
2758 will clean our mess */
2759 assert(eina_list_count(it->mode_icon_objs) == 0);
2761 _item_label_realize(it, it->mode_view, &it->mode_labels);
2762 it->mode_icon_objs = _item_icon_realize(it,
2765 _item_state_realize(it, it->mode_view, &it->mode_states);
2767 edje_object_part_swallow(it->mode_view,
2768 edje_object_data_get(it->mode_view, "mode_part"),
2771 it->want_unrealize = EINA_FALSE;
2775 _mode_item_unrealize(Elm_Genlist_Item *it)
2777 Widget_Data *wd = it->wd;
2779 if (!it->mode_view) return;
2781 elm_widget_stringlist_free(it->mode_labels);
2782 it->mode_labels = NULL;
2783 elm_widget_stringlist_free(it->mode_icons);
2784 it->mode_icons = NULL;
2785 elm_widget_stringlist_free(it->mode_states);
2787 EINA_LIST_FREE(it->mode_icon_objs, icon)
2788 evas_object_del(icon);
2790 edje_object_part_unswallow(it->mode_view, it->base.view);
2791 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2792 evas_object_del(it->mode_view);
2793 it->mode_view = NULL;
2795 if (wd->mode_item == it)
2796 wd->mode_item = NULL;
2800 _item_mode_set(Elm_Genlist_Item *it)
2803 Widget_Data *wd = it->wd;
2808 it->nocache = EINA_TRUE;
2810 if (wd->scr_hold_timer)
2812 ecore_timer_del(wd->scr_hold_timer);
2813 wd->scr_hold_timer = NULL;
2815 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2816 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2818 _mode_item_realize(it);
2819 _item_position(it, it->mode_view);
2821 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2822 edje_object_signal_emit(it->mode_view, buf, "elm");
2826 _item_mode_unset(Widget_Data *wd)
2829 if (!wd->mode_item) return;
2830 char buf[1024], buf2[1024];
2831 Elm_Genlist_Item *it;
2834 it->nocache = EINA_TRUE;
2836 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2837 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2839 edje_object_signal_emit(it->mode_view, buf, "elm");
2840 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2842 wd->mode_item = NULL;
2846 * Add a new Genlist object
2848 * @param parent The parent object
2849 * @return The new object or NULL if it cannot be created
2854 elm_genlist_add(Evas_Object *parent)
2859 Evas_Coord minw, minh;
2860 static Evas_Smart *smart = NULL;
2864 static Evas_Smart_Class sc;
2866 evas_object_smart_clipped_smart_set(&_pan_sc);
2868 sc.name = "elm_genlist_pan";
2869 sc.version = EVAS_SMART_CLASS_VERSION;
2872 sc.resize = _pan_resize;
2873 sc.move = _pan_move;
2874 sc.calculate = _pan_calculate;
2875 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2878 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2880 ELM_SET_WIDTYPE(widtype, "genlist");
2881 elm_widget_type_set(obj, "genlist");
2882 elm_widget_sub_object_add(parent, obj);
2883 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2884 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2885 elm_widget_data_set(obj, wd);
2886 elm_widget_del_hook_set(obj, _del_hook);
2887 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2888 elm_widget_theme_hook_set(obj, _theme_hook);
2889 elm_widget_can_focus_set(obj, EINA_TRUE);
2890 elm_widget_event_hook_set(obj, _event_hook);
2891 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2893 wd->scr = elm_smart_scroller_add(e);
2894 elm_smart_scroller_widget_set(wd->scr, obj);
2895 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2896 elm_widget_style_get(obj));
2897 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2898 _elm_config->thumbscroll_bounce_enable);
2899 elm_widget_resize_object_set(obj, wd->scr);
2901 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2902 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2904 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2905 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2909 wd->mode = ELM_LIST_SCROLL;
2910 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2911 wd->item_cache_max = wd->max_items_per_block * 2;
2912 wd->longpress_timeout = _elm_config->longpress_timeout;
2914 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2915 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2916 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2917 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2919 wd->pan_smart = evas_object_smart_add(e, smart);
2920 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2923 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2924 _pan_set, _pan_get, _pan_max_get,
2925 _pan_min_get, _pan_child_size_get);
2927 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2929 evas_object_size_hint_min_set(obj, minw, minh);
2931 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2933 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2938 static Elm_Genlist_Item *
2939 _item_new(Widget_Data *wd,
2940 const Elm_Genlist_Item_Class *itc,
2942 Elm_Genlist_Item *parent,
2943 Elm_Genlist_Item_Flags flags,
2945 const void *func_data)
2947 Elm_Genlist_Item *it;
2949 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2950 if (!it) return NULL;
2953 it->base.data = data;
2954 it->parent = parent;
2956 it->func.func = func;
2957 it->func.data = func_data;
2958 it->mouse_cursor = NULL;
2959 it->expanded_depth = 0;
2964 _item_block_add(Widget_Data *wd,
2965 Elm_Genlist_Item *it)
2967 Item_Block *itb = NULL;
2974 itb = calloc(1, sizeof(Item_Block));
2977 if (!it->rel->block)
2980 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2981 itb->items = eina_list_append(itb->items, it);
2987 wd->blocks = eina_inlist_prepend_relative
2988 (wd->blocks, EINA_INLIST_GET(itb),
2989 EINA_INLIST_GET(it->rel->block));
2991 eina_list_prepend_relative(itb->items, it, it->rel);
2995 wd->blocks = eina_inlist_append_relative
2996 (wd->blocks, EINA_INLIST_GET(itb),
2997 EINA_INLIST_GET(it->rel->block));
2999 eina_list_append_relative(itb->items, it, it->rel);
3009 itb = (Item_Block *)(wd->blocks);
3010 if (itb->count >= wd->max_items_per_block)
3012 itb = calloc(1, sizeof(Item_Block));
3016 eina_inlist_prepend(wd->blocks,
3017 EINA_INLIST_GET(itb));
3022 itb = calloc(1, sizeof(Item_Block));
3026 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3028 itb->items = eina_list_prepend(itb->items, it);
3034 itb = (Item_Block *)(wd->blocks->last);
3035 if (itb->count >= wd->max_items_per_block)
3037 itb = calloc(1, sizeof(Item_Block));
3041 eina_inlist_append(wd->blocks,
3042 EINA_INLIST_GET(itb));
3047 itb = calloc(1, sizeof(Item_Block));
3051 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3053 itb->items = eina_list_append(itb->items, it);
3059 itb = it->rel->block;
3060 if (!itb) goto newblock;
3062 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3064 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3067 itb->changed = EINA_TRUE;
3069 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3070 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3073 it->rel->relcount--;
3074 if ((it->rel->delete_me) && (!it->rel->relcount))
3078 if (itb->count > itb->wd->max_items_per_block)
3082 Elm_Genlist_Item *it2;
3084 newc = itb->count / 2;
3085 itb2 = calloc(1, sizeof(Item_Block));
3089 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3090 EINA_INLIST_GET(itb));
3091 itb2->changed = EINA_TRUE;
3092 while ((itb->count > newc) && (itb->items))
3096 l = eina_list_last(itb->items);
3098 itb->items = eina_list_remove_list(itb->items, l);
3101 itb2->items = eina_list_prepend(itb2->items, it2);
3109 _queue_process(Widget_Data *wd)
3112 Eina_Bool showme = EINA_FALSE;
3115 t0 = ecore_time_get();
3116 for (n = 0; (wd->queue) && (n < 128); n++)
3118 Elm_Genlist_Item *it;
3120 it = wd->queue->data;
3121 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3122 it->queued = EINA_FALSE;
3123 _item_block_add(wd, it);
3124 t = ecore_time_get();
3125 if (it->block->changed)
3127 showme = _item_block_recalc(it->block, it->block->num, 1);
3128 it->block->changed = 0;
3130 if (showme) it->block->showme = EINA_TRUE;
3131 if (eina_inlist_count(wd->blocks) > 1)
3133 if ((t - t0) > (ecore_animator_frametime_get())) break;
3140 _idle_process(void *data, Eina_Bool *wakeup)
3142 Widget_Data *wd = data;
3145 //static double q_start = 0.0;
3146 //if (q_start == 0.0) q_start = ecore_time_get();
3148 if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
3152 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3154 return ECORE_CALLBACK_CANCEL;
3156 return ECORE_CALLBACK_RENEW;
3160 _item_idle_enterer(void *data)
3162 Widget_Data *wd = data;
3163 Eina_Bool wakeup = EINA_FALSE;
3164 Eina_Bool ok = _idle_process(data, &wakeup);
3169 if (wd->calc_job) ecore_job_del(wd->calc_job);
3170 wd->calc_job = ecore_job_add(_calc_job, wd);
3172 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3177 _item_queue(Widget_Data *wd,
3178 Elm_Genlist_Item *it)
3180 if (it->queued) return;
3181 it->queued = EINA_TRUE;
3182 wd->queue = eina_list_append(wd->queue, it);
3183 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3185 if (wd->queue_idle_enterer)
3187 ecore_idle_enterer_del(wd->queue_idle_enterer);
3188 wd->queue_idle_enterer = NULL;
3192 if (!wd->queue_idle_enterer)
3193 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3197 * Append item to the end of the genlist
3199 * This appends the given item to the end of the list or the end of
3200 * the children if the parent is given.
3202 * @param obj The genlist object
3203 * @param itc The item class for the item
3204 * @param data The item data
3205 * @param parent The parent item, or NULL if none
3206 * @param flags Item flags
3207 * @param func Convenience function called when item selected
3208 * @param func_data Data passed to @p func above.
3209 * @return A handle to the item added or NULL if not possible
3213 EAPI Elm_Genlist_Item *
3214 elm_genlist_item_append(Evas_Object *obj,
3215 const Elm_Genlist_Item_Class *itc,
3217 Elm_Genlist_Item *parent,
3218 Elm_Genlist_Item_Flags flags,
3220 const void *func_data)
3222 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3223 Widget_Data *wd = elm_widget_data_get(obj);
3224 if (!wd) return NULL;
3225 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3227 if (!it) return NULL;
3230 if (flags & ELM_GENLIST_ITEM_GROUP)
3231 wd->group_items = eina_list_append(wd->group_items, it);
3232 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3237 Elm_Genlist_Item *it2 = NULL;
3238 Eina_List *ll = eina_list_last(it->parent->items);
3239 if (ll) it2 = ll->data;
3240 it->parent->items = eina_list_append(it->parent->items, it);
3241 if (!it2) it2 = it->parent;
3243 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3244 EINA_INLIST_GET(it2));
3246 it->rel->relcount++;
3248 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3249 it->group_item = parent;
3250 else if (it->parent->group_item)
3251 it->group_item = it->parent->group_item;
3253 it->before = EINA_FALSE;
3254 _item_queue(wd, it);
3259 * Prepend item at start of the genlist
3261 * This adds an item to the beginning of the list or beginning of the
3262 * children of the parent if given.
3264 * @param obj The genlist object
3265 * @param itc The item class for the item
3266 * @param data The item data
3267 * @param parent The parent item, or NULL if none
3268 * @param flags Item flags
3269 * @param func Convenience function called when item selected
3270 * @param func_data Data passed to @p func above.
3271 * @return A handle to the item added or NULL if not possible
3275 EAPI Elm_Genlist_Item *
3276 elm_genlist_item_prepend(Evas_Object *obj,
3277 const Elm_Genlist_Item_Class *itc,
3279 Elm_Genlist_Item *parent,
3280 Elm_Genlist_Item_Flags flags,
3282 const void *func_data)
3284 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3285 Widget_Data *wd = elm_widget_data_get(obj);
3286 if (!wd) return NULL;
3287 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3289 if (!it) return NULL;
3292 if (flags & ELM_GENLIST_ITEM_GROUP)
3293 wd->group_items = eina_list_prepend(wd->group_items, it);
3294 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3299 Elm_Genlist_Item *it2 = NULL;
3300 Eina_List *ll = it->parent->items;
3301 if (ll) it2 = ll->data;
3302 it->parent->items = eina_list_prepend(it->parent->items, it);
3303 if (!it2) it2 = it->parent;
3305 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3306 EINA_INLIST_GET(it2));
3308 it->rel->relcount++;
3310 it->before = EINA_TRUE;
3311 _item_queue(wd, it);
3316 * Insert item before another in the genlist
3318 * This inserts an item before another in the list. It will be in the
3319 * same tree level or group as the item it is inseted before.
3321 * @param obj The genlist object
3322 * @param itc The item class for the item
3323 * @param data The item data
3324 * @param before The item to insert before
3325 * @param flags Item flags
3326 * @param func Convenience function called when item selected
3327 * @param func_data Data passed to @p func above.
3328 * @return A handle to the item added or NULL if not possible
3332 EAPI Elm_Genlist_Item *
3333 elm_genlist_item_insert_before(Evas_Object *obj,
3334 const Elm_Genlist_Item_Class *itc,
3336 Elm_Genlist_Item *parent,
3337 Elm_Genlist_Item *before,
3338 Elm_Genlist_Item_Flags flags,
3340 const void *func_data)
3342 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3343 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3344 Widget_Data *wd = elm_widget_data_get(obj);
3345 if (!wd) return NULL;
3346 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3348 if (!it) return NULL;
3351 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3354 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3355 EINA_INLIST_GET(before));
3357 it->rel->relcount++;
3358 it->before = EINA_TRUE;
3359 _item_queue(wd, it);
3364 * Insert an item after another in the genlst
3366 * This inserts an item after another in the list. It will be in the
3367 * same tree level or group as the item it is inseted after.
3369 * @param obj The genlist object
3370 * @param itc The item class for the item
3371 * @param data The item data
3372 * @param after The item to insert after
3373 * @param flags Item flags
3374 * @param func Convenience function called when item selected
3375 * @param func_data Data passed to @p func above.
3376 * @return A handle to the item added or NULL if not possible
3380 EAPI Elm_Genlist_Item *
3381 elm_genlist_item_insert_after(Evas_Object *obj,
3382 const Elm_Genlist_Item_Class *itc,
3384 Elm_Genlist_Item *parent,
3385 Elm_Genlist_Item *after,
3386 Elm_Genlist_Item_Flags flags,
3388 const void *func_data)
3390 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3391 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3392 Widget_Data *wd = elm_widget_data_get(obj);
3393 if (!wd) return NULL;
3394 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3396 if (!it) return NULL;
3397 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3398 EINA_INLIST_GET(after));
3401 it->parent->items = eina_list_append_relative(it->parent->items, it,
3405 it->rel->relcount++;
3406 it->before = EINA_FALSE;
3407 _item_queue(wd, it);
3414 * This clears all items in the list, leaving it empty.
3416 * @param obj The genlist object
3421 elm_genlist_clear(Evas_Object *obj)
3423 ELM_CHECK_WIDTYPE(obj, widtype);
3424 Widget_Data *wd = elm_widget_data_get(obj);
3426 if (wd->walking > 0)
3428 Elm_Genlist_Item *it;
3430 wd->clear_me = EINA_TRUE;
3431 EINA_INLIST_FOREACH(wd->items, it)
3433 it->delete_me = EINA_TRUE;
3439 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3441 if (wd->anchor_item == it)
3443 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3444 if (!wd->anchor_item)
3446 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3448 wd->items = eina_inlist_remove(wd->items, wd->items);
3449 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3450 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3451 elm_widget_item_pre_notify_del(it);
3452 if (it->realized) _item_unrealize(it, EINA_FALSE);
3453 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3454 it->itc->func.del((void *)it->base.data, it->base.widget);
3455 if (it->long_timer) ecore_timer_del(it->long_timer);
3456 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3457 elm_widget_item_del(it);
3459 wd->clear_me = EINA_FALSE;
3460 wd->anchor_item = NULL;
3463 Item_Block *itb = (Item_Block *)(wd->blocks);
3465 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3466 if (itb->items) eina_list_free(itb->items);
3471 ecore_job_del(wd->calc_job);
3472 wd->calc_job = NULL;
3474 if (wd->queue_idle_enterer)
3476 ecore_idle_enterer_del(wd->queue_idle_enterer);
3477 wd->queue_idle_enterer = NULL;
3479 if (wd->must_recalc_idler)
3481 ecore_idler_del(wd->must_recalc_idler);
3482 wd->must_recalc_idler = NULL;
3486 eina_list_free(wd->queue);
3491 eina_list_free(wd->selected);
3492 wd->selected = NULL;
3494 wd->show_item = NULL;
3501 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3502 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3508 * Enable or disable multi-select in the genlist
3510 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3511 * the list. This allows more than 1 item to be selected.
3513 * @param obj The genlist object
3514 * @param multi Multi-select enable/disable
3519 elm_genlist_multi_select_set(Evas_Object *obj,
3522 ELM_CHECK_WIDTYPE(obj, widtype);
3523 Widget_Data *wd = elm_widget_data_get(obj);
3529 * Gets if multi-select in genlist is enable or disable
3531 * @param obj The genlist object
3532 * @return Multi-select enable/disable
3533 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3538 elm_genlist_multi_select_get(const Evas_Object *obj)
3540 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3541 Widget_Data *wd = elm_widget_data_get(obj);
3542 if (!wd) return EINA_FALSE;
3547 * Get the selectd item in the genlist
3549 * This gets the selected item in the list (if multi-select is enabled
3550 * only the first item in the list is selected - which is not very
3551 * useful, so see elm_genlist_selected_items_get() for when
3552 * multi-select is used).
3554 * If no item is selected, NULL is returned.
3556 * @param obj The genlist object
3557 * @return The selected item, or NULL if none.
3561 EAPI Elm_Genlist_Item *
3562 elm_genlist_selected_item_get(const Evas_Object *obj)
3564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3565 Widget_Data *wd = elm_widget_data_get(obj);
3566 if (!wd) return NULL;
3567 if (wd->selected) return wd->selected->data;
3572 * Get a list of selected items in the genlist
3574 * This returns a list of the selected items. This list pointer is
3575 * only valid so long as no items are selected or unselected (or
3576 * unselected implicitly by deletion). The list contains
3577 * Elm_Genlist_Item pointers.
3579 * @param obj The genlist object
3580 * @return The list of selected items, nor NULL if none are selected.
3584 EAPI const Eina_List *
3585 elm_genlist_selected_items_get(const Evas_Object *obj)
3587 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3588 Widget_Data *wd = elm_widget_data_get(obj);
3589 if (!wd) return NULL;
3590 return wd->selected;
3594 * Get a list of realized items in genlist
3596 * This returns a list of the realized items in the genlist. The list
3597 * contains Elm_Genlist_Item pointers. The list must be freed by the
3598 * caller when done with eina_list_free(). The item pointers in the
3599 * list are only valid so long as those items are not deleted or the
3600 * genlist is not deleted.
3602 * @param obj The genlist object
3603 * @return The list of realized items, nor NULL if none are realized.
3608 elm_genlist_realized_items_get(const Evas_Object *obj)
3610 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3611 Widget_Data *wd = elm_widget_data_get(obj);
3612 Eina_List *list = NULL;
3614 Eina_Bool done = EINA_FALSE;
3615 if (!wd) return NULL;
3616 EINA_INLIST_FOREACH(wd->blocks, itb)
3621 Elm_Genlist_Item *it;
3624 EINA_LIST_FOREACH(itb->items, l, it)
3626 if (it->realized) list = eina_list_append(list, it);
3638 * Get the item that is at the x, y canvas coords
3640 * This returns the item at the given coordinates (which are canvas
3641 * relative not object-relative). If an item is at that coordinate,
3642 * that item handle is returned, and if @p posret is not NULL, the
3643 * integer pointed to is set to a value of -1, 0 or 1, depending if
3644 * the coordinate is on the upper portion of that item (-1), on the
3645 * middle section (0) or on the lower part (1). If NULL is returned as
3646 * an item (no item found there), then posret may indicate -1 or 1
3647 * based if the coordinate is above or below all items respectively in
3650 * @param it The item
3651 * @param x The input x coordinate
3652 * @param y The input y coordinate
3653 * @param posret The position relative to the item returned here
3654 * @return The item at the coordinates or NULL if none
3658 EAPI Elm_Genlist_Item *
3659 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3664 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3665 Widget_Data *wd = elm_widget_data_get(obj);
3666 Evas_Coord ox, oy, ow, oh;
3669 if (!wd) return NULL;
3670 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3672 EINA_INLIST_FOREACH(wd->blocks, itb)
3675 Elm_Genlist_Item *it;
3677 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3678 oy + itb->y - itb->wd->pan_y,
3679 itb->w, itb->h, x, y, 1, 1))
3681 EINA_LIST_FOREACH(itb->items, l, it)
3683 Evas_Coord itx, ity;
3685 itx = ox + itb->x + it->x - itb->wd->pan_x;
3686 ity = oy + itb->y + it->y - itb->wd->pan_y;
3687 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3691 if (y <= (ity + (it->h / 4))) *posret = -1;
3692 else if (y >= (ity + it->h - (it->h / 4)))
3698 lasty = ity + it->h;
3703 if (y > lasty) *posret = 1;
3710 * Get the first item in the genlist
3712 * This returns the first item in the list.
3714 * @param obj The genlist object
3715 * @return The first item, or NULL if none
3719 EAPI Elm_Genlist_Item *
3720 elm_genlist_first_item_get(const Evas_Object *obj)
3722 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3723 Widget_Data *wd = elm_widget_data_get(obj);
3724 if (!wd) return NULL;
3725 if (!wd->items) return NULL;
3726 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3727 while ((it) && (it->delete_me))
3728 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3733 * Get the last item in the genlist
3735 * This returns the last item in the list.
3737 * @return The last item, or NULL if none
3741 EAPI Elm_Genlist_Item *
3742 elm_genlist_last_item_get(const Evas_Object *obj)
3744 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3745 Widget_Data *wd = elm_widget_data_get(obj);
3746 if (!wd) return NULL;
3747 if (!wd->items) return NULL;
3748 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3749 while ((it) && (it->delete_me))
3750 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3755 * Get the next item in the genlist
3757 * This returns the item after the item @p it.
3759 * @param it The item
3760 * @return The item after @p it, or NULL if none
3764 EAPI Elm_Genlist_Item *
3765 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3767 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3770 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3771 if ((it) && (!it->delete_me)) break;
3773 return (Elm_Genlist_Item *)it;
3777 * Get the previous item in the genlist
3779 * This returns the item before the item @p it.
3781 * @param it The item
3782 * @return The item before @p it, or NULL if none
3786 EAPI Elm_Genlist_Item *
3787 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3789 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3792 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3793 if ((it) && (!it->delete_me)) break;
3795 return (Elm_Genlist_Item *)it;
3799 * Get the genlist object from an item
3801 * This returns the genlist object itself that an item belongs to.
3803 * @param it The item
3804 * @return The genlist object
3809 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3811 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3812 return it->base.widget;
3816 * Get the parent item of the given item
3818 * This returns the parent item of the item @p it given.
3820 * @param it The item
3821 * @return The parent of the item or NULL if none
3825 EAPI Elm_Genlist_Item *
3826 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3828 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3833 * Clear all sub-items (children) of the given item
3835 * This clears all items that are children (or their descendants) of the
3838 * @param it The item
3843 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3845 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3846 Eina_List *tl = NULL, *l;
3847 Elm_Genlist_Item *it2;
3849 EINA_LIST_FOREACH(it->items, l, it2)
3850 tl = eina_list_append(tl, it2);
3851 EINA_LIST_FREE(tl, it2)
3852 elm_genlist_item_del(it2);
3856 * Set the selected state of an item
3858 * This sets the selected state (1 selected, 0 not selected) of the given
3861 * @param it The item
3862 * @param selected The selected state
3867 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3870 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3871 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3873 if ((it->delete_me) || (it->disabled)) return;
3874 selected = !!selected;
3875 if (it->selected == selected) return;
3881 while (wd->selected)
3883 _item_unhighlight(wd->selected->data);
3884 _item_unselect(wd->selected->data);
3887 _item_highlight(it);
3892 _item_unhighlight(it);
3898 * Get the selected state of an item
3900 * This gets the selected state of an item (1 selected, 0 not selected).
3902 * @param it The item
3903 * @return The selected state
3908 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3910 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3911 return it->selected;
3915 * Sets the expanded state of an item (if it's a parent)
3917 * This expands or contracts a parent item (thus showing or hiding the
3920 * @param it The item
3921 * @param expanded The expanded state (1 expanded, 0 not expanded).
3926 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3929 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3930 if (it->expanded == expanded) return;
3931 it->expanded = expanded;
3935 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3936 evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
3941 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3942 evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
3947 * Get the expanded state of an item
3949 * This gets the expanded state of an item
3951 * @param it The item
3952 * @return Thre expanded state
3957 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3959 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3960 return it->expanded;
3964 * Get the depth of expanded item
3966 * @param it The genlist item object
3967 * @return The depth of expanded item
3972 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3974 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3975 return it->expanded_depth;
3979 * Sets the disabled state of an item.
3981 * A disabled item cannot be selected or unselected. It will also
3982 * change appearance to appear disabled. This sets the disabled state
3983 * (1 disabled, 0 not disabled).
3985 * @param it The item
3986 * @param disabled The disabled state
3991 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3994 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3997 if (it->disabled == disabled) return;
3998 if (it->delete_me) return;
3999 it->disabled = !!disabled;
4001 elm_genlist_item_selected_set(it, EINA_FALSE);
4005 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4007 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4008 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4009 elm_widget_disabled_set(obj, disabled);
4014 * Get the disabled state of an item
4016 * This gets the disabled state of the given item.
4018 * @param it The item
4019 * @return The disabled state
4024 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4026 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4027 if (it->delete_me) return EINA_FALSE;
4028 return it->disabled;
4032 * Sets the display only state of an item.
4034 * A display only item cannot be selected or unselected. It is for
4035 * display only and not selecting or otherwise clicking, dragging
4036 * etc. by the user, thus finger size rules will not be applied to
4039 * @param it The item
4040 * @param display_only The display only state
4045 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4046 Eina_Bool display_only)
4048 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4049 if (it->display_only == display_only) return;
4050 if (it->delete_me) return;
4051 it->display_only = display_only;
4052 it->mincalcd = EINA_FALSE;
4053 it->updateme = EINA_TRUE;
4054 if (it->block) it->block->updateme = EINA_TRUE;
4055 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4056 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4060 * Get the display only state of an item
4062 * This gets the display only state of the given item.
4064 * @param it The item
4065 * @return The display only state
4070 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4072 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4073 if (it->delete_me) return EINA_FALSE;
4074 return it->display_only;
4078 * Show the given item
4080 * This causes genlist to jump to the given item @p it and show it (by
4081 * scrolling), if it is not fully visible.
4083 * @param it The item
4088 elm_genlist_item_show(Elm_Genlist_Item *it)
4090 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4091 Evas_Coord gith = 0;
4092 if (it->delete_me) return;
4093 if ((it->queued) || (!it->mincalcd))
4095 it->wd->show_item = it;
4096 it->wd->bring_in = EINA_TRUE;
4097 it->showme = EINA_TRUE;
4100 if (it->wd->show_item)
4102 it->wd->show_item->showme = EINA_FALSE;
4103 it->wd->show_item = NULL;
4105 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4106 gith = it->group_item->h;
4107 elm_smart_scroller_child_region_show(it->wd->scr,
4108 it->x + it->block->x,
4109 it->y + it->block->y - gith,
4110 it->block->w, it->h);
4114 * Bring in the given item
4116 * This causes genlist to jump to the given item @p it and show it (by
4117 * scrolling), if it is not fully visible. This may use animation to
4118 * do so and take a period of time
4120 * @param it The item
4125 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4127 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4128 Evas_Coord gith = 0;
4129 if (it->delete_me) return;
4130 if ((it->queued) || (!it->mincalcd))
4132 it->wd->show_item = it;
4133 it->wd->bring_in = EINA_TRUE;
4134 it->showme = EINA_TRUE;
4137 if (it->wd->show_item)
4139 it->wd->show_item->showme = EINA_FALSE;
4140 it->wd->show_item = NULL;
4142 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4143 gith = it->group_item->h;
4144 elm_smart_scroller_region_bring_in(it->wd->scr,
4145 it->x + it->block->x,
4146 it->y + it->block->y - gith,
4147 it->block->w, it->h);
4151 * Show the given item at the top
4153 * This causes genlist to jump to the given item @p it and show it (by
4154 * scrolling), if it is not fully visible.
4156 * @param it The item
4161 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4163 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4165 Evas_Coord gith = 0;
4167 if (it->delete_me) return;
4168 if ((it->queued) || (!it->mincalcd))
4170 it->wd->show_item = it;
4171 it->wd->bring_in = EINA_TRUE;
4172 it->showme = EINA_TRUE;
4175 if (it->wd->show_item)
4177 it->wd->show_item->showme = EINA_FALSE;
4178 it->wd->show_item = NULL;
4180 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4181 if (it->group_item) gith = it->group_item->h;
4182 elm_smart_scroller_child_region_show(it->wd->scr,
4183 it->x + it->block->x,
4184 it->y + it->block->y - gith,
4189 * Bring in the given item at the top
4191 * This causes genlist to jump to the given item @p it and show it (by
4192 * scrolling), if it is not fully visible. This may use animation to
4193 * do so and take a period of time
4195 * @param it The item
4200 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4202 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4204 Evas_Coord gith = 0;
4206 if (it->delete_me) return;
4207 if ((it->queued) || (!it->mincalcd))
4209 it->wd->show_item = it;
4210 it->wd->bring_in = EINA_TRUE;
4211 it->showme = EINA_TRUE;
4214 if (it->wd->show_item)
4216 it->wd->show_item->showme = EINA_FALSE;
4217 it->wd->show_item = NULL;
4219 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4220 if (it->group_item) gith = it->group_item->h;
4221 elm_smart_scroller_region_bring_in(it->wd->scr,
4222 it->x + it->block->x,
4223 it->y + it->block->y - gith,
4228 * Show the given item at the middle
4230 * This causes genlist to jump to the given item @p it and show it (by
4231 * scrolling), if it is not fully visible.
4233 * @param it The item
4238 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4240 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4243 if (it->delete_me) return;
4244 if ((it->queued) || (!it->mincalcd))
4246 it->wd->show_item = it;
4247 it->wd->bring_in = EINA_TRUE;
4248 it->showme = EINA_TRUE;
4251 if (it->wd->show_item)
4253 it->wd->show_item->showme = EINA_FALSE;
4254 it->wd->show_item = NULL;
4256 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4257 elm_smart_scroller_child_region_show(it->wd->scr,
4258 it->x + it->block->x,
4259 it->y + it->block->y - oh / 2 +
4260 it->h / 2, it->block->w, oh);
4264 * Bring in the given item at the middle
4266 * This causes genlist to jump to the given item @p it and show it (by
4267 * scrolling), if it is not fully visible. This may use animation to
4268 * do so and take a period of time
4270 * @param it The item
4275 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4277 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4280 if (it->delete_me) return;
4281 if ((it->queued) || (!it->mincalcd))
4283 it->wd->show_item = it;
4284 it->wd->bring_in = EINA_TRUE;
4285 it->showme = EINA_TRUE;
4288 if (it->wd->show_item)
4290 it->wd->show_item->showme = EINA_FALSE;
4291 it->wd->show_item = NULL;
4293 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4294 elm_smart_scroller_region_bring_in(it->wd->scr,
4295 it->x + it->block->x,
4296 it->y + it->block->y - oh / 2 + it->h / 2,
4301 * Delete a given item
4303 * This deletes the item from genlist and calls the genlist item del
4304 * class callback defined in the item class, if it is set. This clears all
4305 * subitems if it is a tree.
4307 * @param it The item
4312 elm_genlist_item_del(Elm_Genlist_Item *it)
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4315 if ((it->relcount > 0) || (it->walking > 0))
4317 elm_widget_item_pre_notify_del(it);
4318 elm_genlist_item_subitems_clear(it);
4319 it->delete_me = EINA_TRUE;
4320 if (it->wd->show_item == it) it->wd->show_item = NULL;
4322 it->wd->selected = eina_list_remove(it->wd->selected,
4326 if (it->realized) _item_unrealize(it, EINA_FALSE);
4327 it->block->changed = EINA_TRUE;
4328 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4329 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4331 if (it->itc->func.del)
4332 it->itc->func.del((void *)it->base.data, it->base.widget);
4339 * Set the data item from the genlist item
4341 * This set the data value passed on the elm_genlist_item_append() and
4342 * related item addition calls. This function will also call
4343 * elm_genlist_item_update() so the item will be updated to reflect the
4346 * @param it The item
4347 * @param data The new data pointer to set
4352 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4355 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4356 elm_widget_item_data_set(it, data);
4357 elm_genlist_item_update(it);
4361 * Get the data item from the genlist item
4363 * This returns the data value passed on the elm_genlist_item_append()
4364 * and related item addition calls and elm_genlist_item_data_set().
4366 * @param it The item
4367 * @return The data pointer provided when created
4372 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4374 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4375 return elm_widget_item_data_get(it);
4379 * Tells genlist to "orphan" icons fetchs by the item class
4381 * This instructs genlist to release references to icons in the item,
4382 * meaning that they will no longer be managed by genlist and are
4383 * floating "orphans" that can be re-used elsewhere if the user wants
4386 * @param it The item
4391 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4394 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4395 EINA_LIST_FREE(it->icon_objs, icon)
4397 elm_widget_sub_object_del(it->base.widget, icon);
4398 evas_object_smart_member_del(icon);
4399 evas_object_hide(icon);
4404 * Get the real evas object of the genlist item
4406 * This returns the actual evas object used for the specified genlist
4407 * item. This may be NULL as it may not be created, and may be deleted
4408 * at any time by genlist. Do not modify this object (move, resize,
4409 * show, hide etc.) as genlist is controlling it. This function is for
4410 * querying, emitting custom signals or hooking lower level callbacks
4411 * for events. Do not delete this object under any circumstances.
4413 * @param it The item
4414 * @return The object pointer
4418 EAPI const Evas_Object *
4419 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4421 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4422 return it->base.view;
4426 * Update the contents of an item
4428 * This updates an item by calling all the item class functions again
4429 * to get the icons, labels and states. Use this when the original
4430 * item data has changed and the changes are desired to be reflected.
4432 * @param it The item
4437 elm_genlist_item_update(Elm_Genlist_Item *it)
4439 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4440 if (!it->block) return;
4441 if (it->delete_me) return;
4442 it->mincalcd = EINA_FALSE;
4443 it->updateme = EINA_TRUE;
4444 it->block->updateme = EINA_TRUE;
4445 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4446 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4450 * Update the item class of an item
4452 * @param it The item
4453 * @parem itc The item class for the item
4458 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4459 const Elm_Genlist_Item_Class *itc)
4461 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4462 if (!it->block) return;
4463 EINA_SAFETY_ON_NULL_RETURN(itc);
4464 if (it->delete_me) return;
4466 it->nocache = EINA_TRUE;
4467 elm_genlist_item_update(it);
4470 static Evas_Object *
4471 _elm_genlist_item_label_create(void *data,
4473 void *item __UNUSED__)
4475 Evas_Object *label = elm_label_add(obj);
4478 elm_object_style_set(label, "tooltip");
4479 elm_label_label_set(label, data);
4484 _elm_genlist_item_label_del_cb(void *data,
4485 Evas_Object *obj __UNUSED__,
4486 void *event_info __UNUSED__)
4488 eina_stringshare_del(data);
4492 * Set the text to be shown in the genlist item.
4494 * @param item Target item
4495 * @param text The text to set in the content
4497 * Setup the text as tooltip to object. The item can have only one
4498 * tooltip, so any previous tooltip data is removed.
4503 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4506 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4507 text = eina_stringshare_add(text);
4508 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4510 _elm_genlist_item_label_del_cb);
4514 * Set the content to be shown in the tooltip item
4516 * Setup the tooltip to item. The item can have only one tooltip, so
4517 * any previous tooltip data is removed. @p func(with @p data) will be
4518 * called every time that need to show the tooltip and it should return a
4519 * valid Evas_Object. This object is then managed fully by tooltip
4520 * system and is deleted when the tooltip is gone.
4522 * @param item the genlist item being attached by a tooltip.
4523 * @param func the function used to create the tooltip contents.
4524 * @param data what to provide to @a func as callback data/context.
4525 * @param del_cb called when data is not needed anymore, either when
4526 * another callback replaces @func, the tooltip is unset with
4527 * elm_genlist_item_tooltip_unset() or the owner @a item
4528 * dies. This callback receives as the first parameter the
4529 * given @a data, and @c event_info is the item.
4534 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4535 Elm_Tooltip_Item_Content_Cb func,
4537 Evas_Smart_Cb del_cb)
4539 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4541 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4544 if (item->tooltip.del_cb)
4545 item->tooltip.del_cb((void *)item->tooltip.data,
4546 item->base.widget, item);
4548 item->tooltip.content_cb = func;
4549 item->tooltip.data = data;
4550 item->tooltip.del_cb = del_cb;
4552 if (item->base.view)
4554 elm_widget_item_tooltip_content_cb_set(item,
4555 item->tooltip.content_cb,
4556 item->tooltip.data, NULL);
4557 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4563 if (del_cb) del_cb((void *)data, NULL, NULL);
4567 * Unset tooltip from item
4569 * @param item genlist item to remove previously set tooltip.
4571 * Remove tooltip from item. The callback provided as del_cb to
4572 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4573 * it is not used anymore.
4575 * @see elm_genlist_item_tooltip_content_cb_set()
4580 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4582 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4583 if ((item->base.view) && (item->tooltip.content_cb))
4584 elm_widget_item_tooltip_unset(item);
4586 if (item->tooltip.del_cb)
4587 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4588 item->tooltip.del_cb = NULL;
4589 item->tooltip.content_cb = NULL;
4590 item->tooltip.data = NULL;
4591 if (item->tooltip.style)
4592 elm_genlist_item_tooltip_style_set(item, NULL);
4596 * Sets a different style for this item tooltip.
4598 * @note before you set a style you should define a tooltip with
4599 * elm_genlist_item_tooltip_content_cb_set() or
4600 * elm_genlist_item_tooltip_text_set()
4602 * @param item genlist item with tooltip already set.
4603 * @param style the theme style to use (default, transparent, ...)
4608 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4612 eina_stringshare_replace(&item->tooltip.style, style);
4613 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4617 * Get the style for this item tooltip.
4619 * @param item genlist item with tooltip already set.
4620 * @return style the theme style in use, defaults to "default". If the
4621 * object does not have a tooltip set, then NULL is returned.
4626 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4628 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4629 return item->tooltip.style;
4633 * Set the cursor to be shown when mouse is over the genlist item
4635 * @param item Target item
4636 * @param cursor the cursor name to be used.
4638 * @see elm_object_cursor_set()
4642 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4645 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4646 eina_stringshare_replace(&item->mouse_cursor, cursor);
4647 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4651 * Get the cursor to be shown when mouse is over the genlist item
4653 * @param item genlist item with cursor already set.
4654 * @return the cursor name.
4659 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4661 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4662 return elm_widget_item_cursor_get(item);
4666 * Unset the cursor to be shown when mouse is over the genlist item
4668 * @param item Target item
4670 * @see elm_object_cursor_unset()
4674 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4676 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4677 if (!item->mouse_cursor)
4680 if (item->base.view)
4681 elm_widget_item_cursor_unset(item);
4683 eina_stringshare_del(item->mouse_cursor);
4684 item->mouse_cursor = NULL;
4688 * Sets a different style for this item cursor.
4690 * @note before you set a style you should define a cursor with
4691 * elm_genlist_item_cursor_set()
4693 * @param item genlist item with cursor already set.
4694 * @param style the theme style to use (default, transparent, ...)
4699 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4702 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4703 elm_widget_item_cursor_style_set(item, style);
4707 * Get the style for this item cursor.
4709 * @param item genlist item with cursor already set.
4710 * @return style the theme style in use, defaults to "default". If the
4711 * object does not have a cursor set, then NULL is returned.
4716 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4718 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4719 return elm_widget_item_cursor_style_get(item);
4723 * Set if the cursor set should be searched on the theme or should use
4724 * the provided by the engine, only.
4726 * @note before you set if should look on theme you should define a
4727 * cursor with elm_object_cursor_set(). By default it will only look
4728 * for cursors provided by the engine.
4730 * @param item widget item with cursor already set.
4731 * @param engine_only boolean to define it cursors should be looked
4732 * only between the provided by the engine or searched on widget's
4738 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4739 Eina_Bool engine_only)
4741 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4742 elm_widget_item_cursor_engine_only_set(item, engine_only);
4746 * Get the cursor engine only usage for this item cursor.
4748 * @param item widget item with cursor already set.
4749 * @return engine_only boolean to define it cursors should be looked
4750 * only between the provided by the engine or searched on widget's
4751 * theme as well. If the object does not have a cursor set, then
4752 * EINA_FALSE is returned.
4757 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4759 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4760 return elm_widget_item_cursor_engine_only_get(item);
4764 * This sets the horizontal stretching mode
4766 * This sets the mode used for sizing items horizontally. Valid modes
4767 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4768 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4769 * the scroller will scroll horizontally. Otherwise items are expanded
4770 * to fill the width of the viewport of the scroller. If it is
4771 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4772 * limited to that size.
4774 * @param obj The genlist object
4775 * @param mode The mode to use
4780 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4783 ELM_CHECK_WIDTYPE(obj, widtype);
4784 Widget_Data *wd = elm_widget_data_get(obj);
4786 if (wd->mode == mode) return;
4792 * Gets the horizontal stretching mode
4794 * @param obj The genlist object
4795 * @return The mode to use
4796 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4801 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4803 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4804 Widget_Data *wd = elm_widget_data_get(obj);
4805 if (!wd) return ELM_LIST_LAST;
4810 * Set the always select mode.
4812 * Items will only call their selection func and callback when first
4813 * becoming selected. Any further clicks will do nothing, unless you
4814 * enable always select with elm_genlist_always_select_mode_set().
4815 * This means even if selected, every click will make the selected
4816 * callbacks be called.
4818 * @param obj The genlist object
4819 * @param always_select The always select mode
4820 * (EINA_TRUE = on, EINA_FALSE = off)
4825 elm_genlist_always_select_mode_set(Evas_Object *obj,
4826 Eina_Bool always_select)
4828 ELM_CHECK_WIDTYPE(obj, widtype);
4829 Widget_Data *wd = elm_widget_data_get(obj);
4831 wd->always_select = always_select;
4835 * Get the always select mode.
4837 * @param obj The genlist object
4838 * @return The always select mode
4839 * (EINA_TRUE = on, EINA_FALSE = off)
4844 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4846 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4847 Widget_Data *wd = elm_widget_data_get(obj);
4848 if (!wd) return EINA_FALSE;
4849 return wd->always_select;
4853 * Set no select mode
4855 * This will turn off the ability to select items entirely and they
4856 * will neither appear selected nor call selected callback functions.
4858 * @param obj The genlist object
4859 * @param no_select The no select mode
4860 * (EINA_TRUE = on, EINA_FALSE = off)
4865 elm_genlist_no_select_mode_set(Evas_Object *obj,
4866 Eina_Bool no_select)
4868 ELM_CHECK_WIDTYPE(obj, widtype);
4869 Widget_Data *wd = elm_widget_data_get(obj);
4871 wd->no_select = no_select;
4875 * Gets no select mode
4877 * @param obj The genlist object
4878 * @return The no select mode
4879 * (EINA_TRUE = on, EINA_FALSE = off)
4884 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4886 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4887 Widget_Data *wd = elm_widget_data_get(obj);
4888 if (!wd) return EINA_FALSE;
4889 return wd->no_select;
4895 * This will enable the compress mode where items are "compressed"
4896 * horizontally to fit the genlist scrollable viewport width. This is
4897 * special for genlist. Do not rely on
4898 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4899 * work as genlist needs to handle it specially.
4901 * @param obj The genlist object
4902 * @param compress The compress mode
4903 * (EINA_TRUE = on, EINA_FALSE = off)
4908 elm_genlist_compress_mode_set(Evas_Object *obj,
4911 ELM_CHECK_WIDTYPE(obj, widtype);
4912 Widget_Data *wd = elm_widget_data_get(obj);
4914 wd->compress = compress;
4915 if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
4919 * Get the compress mode
4921 * @param obj The genlist object
4922 * @return The compress mode
4923 * (EINA_TRUE = on, EINA_FALSE = off)
4928 elm_genlist_compress_mode_get(const Evas_Object *obj)
4930 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4931 Widget_Data *wd = elm_widget_data_get(obj);
4932 if (!wd) return EINA_FALSE;
4933 return wd->compress;
4937 * Set height-for-width mode
4939 * With height-for-width mode the item width will be fixed (restricted
4940 * to a minimum of) to the list width when calculating its size in
4941 * order to allow the height to be calculated based on it. This allows,
4942 * for instance, text block to wrap lines if the Edje part is
4943 * configured with "text.min: 0 1".
4945 * @note This mode will make list resize slower as it will have to
4946 * recalculate every item height again whenever the list width
4949 * @note When height-for-width mode is enabled, it also enables
4950 * compress mode (see elm_genlist_compress_mode_set()) and
4951 * disables homogeneous (see elm_genlist_homogeneous_set()).
4953 * @param obj The genlist object
4954 * @param setting The height-for-width mode (EINA_TRUE = on,
4960 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4961 Eina_Bool height_for_width)
4963 ELM_CHECK_WIDTYPE(obj, widtype);
4964 Widget_Data *wd = elm_widget_data_get(obj);
4966 wd->height_for_width = !!height_for_width;
4967 if (wd->height_for_width)
4969 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4970 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4975 * Get the height-for-width mode
4977 * @param obj The genlist object
4978 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4984 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4986 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4987 Widget_Data *wd = elm_widget_data_get(obj);
4988 if (!wd) return EINA_FALSE;
4989 return wd->height_for_width;
4995 * This will enable or disable the scroller bounce mode for the
4996 * genlist. See elm_scroller_bounce_set() for details
4998 * @param obj The genlist object
4999 * @param h_bounce Allow bounce horizontally
5000 * @param v_bounce Allow bounce vertically
5005 elm_genlist_bounce_set(Evas_Object *obj,
5009 ELM_CHECK_WIDTYPE(obj, widtype);
5010 Widget_Data *wd = elm_widget_data_get(obj);
5012 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5016 * Get the bounce mode
5018 * @param obj The genlist object
5019 * @param h_bounce Allow bounce horizontally
5020 * @param v_bounce Allow bounce vertically
5025 elm_genlist_bounce_get(const Evas_Object *obj,
5026 Eina_Bool *h_bounce,
5027 Eina_Bool *v_bounce)
5029 ELM_CHECK_WIDTYPE(obj, widtype);
5030 Widget_Data *wd = elm_widget_data_get(obj);
5032 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5036 * Set homogenous mode
5038 * This will enable the homogeneous mode where items are of the same
5039 * height and width so that genlist may do the lazy-loading at its
5040 * maximum. This implies 'compressed' mode.
5042 * @param obj The genlist object
5043 * @param homogeneous Assume the items within the genlist are of the
5044 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5049 elm_genlist_homogeneous_set(Evas_Object *obj,
5050 Eina_Bool homogeneous)
5052 ELM_CHECK_WIDTYPE(obj, widtype);
5053 Widget_Data *wd = elm_widget_data_get(obj);
5055 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5056 wd->homogeneous = homogeneous;
5060 * Get the homogenous mode
5062 * @param obj The genlist object
5063 * @return Assume the items within the genlist are of the same height
5064 * and width (EINA_TRUE = on, EINA_FALSE = off)
5069 elm_genlist_homogeneous_get(const Evas_Object *obj)
5071 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5072 Widget_Data *wd = elm_widget_data_get(obj);
5073 if (!wd) return EINA_FALSE;
5074 return wd->homogeneous;
5078 * Set the maximum number of items within an item block
5080 * This will configure the block count to tune to the target with
5081 * particular performance matrix.
5083 * @param obj The genlist object
5084 * @param n Maximum number of items within an item block
5089 elm_genlist_block_count_set(Evas_Object *obj,
5092 ELM_CHECK_WIDTYPE(obj, widtype);
5093 Widget_Data *wd = elm_widget_data_get(obj);
5095 wd->max_items_per_block = n;
5096 wd->item_cache_max = wd->max_items_per_block * 2;
5097 _item_cache_clean(wd);
5101 * Get the maximum number of items within an item block
5103 * @param obj The genlist object
5104 * @return Maximum number of items within an item block
5109 elm_genlist_block_count_get(const Evas_Object *obj)
5111 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5112 Widget_Data *wd = elm_widget_data_get(obj);
5114 return wd->max_items_per_block;
5118 * Set the timeout in seconds for the longpress event
5120 * @param obj The genlist object
5121 * @param timeout timeout in seconds
5126 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5129 ELM_CHECK_WIDTYPE(obj, widtype);
5130 Widget_Data *wd = elm_widget_data_get(obj);
5132 wd->longpress_timeout = timeout;
5136 * Get the timeout in seconds for the longpress event
5138 * @param obj The genlist object
5139 * @return timeout in seconds
5144 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5146 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5147 Widget_Data *wd = elm_widget_data_get(obj);
5149 return wd->longpress_timeout;
5153 * Set the scrollbar policy
5155 * This sets the scrollbar visibility policy for the given genlist
5156 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5157 * made visible if it is needed, and otherwise kept hidden.
5158 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5159 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5160 * respectively for the horizontal and vertical scrollbars.
5162 * @param obj The genlist object
5163 * @param policy_h Horizontal scrollbar policy
5164 * @param policy_v Vertical scrollbar policy
5169 elm_genlist_scroller_policy_set(Evas_Object *obj,
5170 Elm_Scroller_Policy policy_h,
5171 Elm_Scroller_Policy policy_v)
5173 ELM_CHECK_WIDTYPE(obj, widtype);
5174 Widget_Data *wd = elm_widget_data_get(obj);
5176 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5177 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5180 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5184 * Get the scrollbar policy
5186 * @param obj The genlist object
5187 * @param policy_h Horizontal scrollbar policy
5188 * @param policy_v Vertical scrollbar policy
5193 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5194 Elm_Scroller_Policy *policy_h,
5195 Elm_Scroller_Policy *policy_v)
5197 ELM_CHECK_WIDTYPE(obj, widtype);
5198 Widget_Data *wd = elm_widget_data_get(obj);
5199 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5200 if ((!wd) || (!wd->scr)) return;
5201 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5202 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5203 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5207 * Update the contents of all realized items
5209 * This updates all realized items by calling all the item class functions again
5210 * to get the icons, labels and states. Use this when the original
5211 * item data has changed and the changes are desired to be reflected.
5213 * @param it The item
5218 elm_genlist_realized_items_update(Evas_Object *obj)
5220 ELM_CHECK_WIDTYPE(obj, widtype);
5222 Eina_List *list, *l;
5223 Elm_Genlist_Item *it;
5225 list = elm_genlist_realized_items_get(obj);
5226 EINA_LIST_FOREACH(list, l, it)
5227 elm_genlist_item_update(it);
5231 * Set genlist item mode
5233 * @param item The genlist item
5234 * @param mode Mode name
5235 * @param mode_set Boolean to define set or unset mode.
5240 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5241 const char *mode_type,
5244 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5245 Widget_Data *wd = it->wd;
5247 Elm_Genlist_Item *it2;
5250 if (!mode_type) return;
5251 if ((it->delete_me) || (it->disabled)) return;
5253 if ((wd->mode_item == it) &&
5254 (!strcmp(mode_type, wd->mode_type)) &&
5257 if (!it->itc->mode_item_style) return;
5261 EINA_LIST_FOREACH(wd->selected, l, it2)
5263 elm_genlist_item_selected_set(it2, EINA_FALSE);
5267 it2 = elm_genlist_selected_item_get(wd->obj);
5268 if ((it2) && (it2->realized))
5269 elm_genlist_item_selected_set(it2, EINA_FALSE);
5272 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5274 ((it == wd->mode_item) && (!mode_set)))
5275 _item_mode_unset(wd);
5277 eina_stringshare_replace(&wd->mode_type, mode_type);
5278 if (mode_set) _item_mode_set(it);
5282 * Get active genlist mode type
5284 * @param obj The genlist object
5289 elm_genlist_mode_get(const Evas_Object *obj)
5291 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5292 Widget_Data *wd = elm_widget_data_get(obj);
5293 if (!wd) return NULL;
5294 return wd->mode_type;
5298 * Get active genlist mode item
5300 * @param obj The genlist object
5304 EAPI const Elm_Genlist_Item *
5305 elm_genlist_mode_item_get(const Evas_Object *obj)
5307 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5308 Widget_Data *wd = elm_widget_data_get(obj);
5309 if (!wd) return NULL;
5310 return wd->mode_item;