1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Genlist has a fairly large API, mostly because it's relatively complex,
19 * trying to be both expansive, powerful and efficient. First we will begin
20 * an overview on the theory behind genlist.
22 * Evas tracks every object you create. Every time it processes an event
23 * (mouse move, down, up etc.) it needs to walk through objects and find out
24 * what event that affects. Even worse every time it renders display updates,
25 * in order to just calculate what to re-draw, it needs to walk through many
26 * many many objects. Thus, the more objects you keep active, the more
27 * overhead Evas has in just doing its work. It is advisable to keep your
28 * active objects to the minimum working set you need. Also remember that
29 * object creation and deletion carries an overhead, so there is a
30 * middle-ground, which is not easily determined. But don't keep massive lists
31 * of objects you can't see or use. Genlist does this with list objects. It
32 * creates and destroys them dynamically as you scroll around. It groups them
33 * into blocks so it can determine the visibility etc. of a whole block at
34 * once as opposed to having to walk the whole list. This 2-level list allows
35 * for very large numbers of items to be in the list (tests have used up to
36 * 2,000,000 items). Also genlist employs a queue for adding items. As items
37 * may be different sizes, every item added needs to be calculated as to its
38 * size and thus this presents a lot of overhead on populating the list, this
39 * genlist employs a queue. Any item added is queued and spooled off over
40 * time, actually appearing some time later, so if your list has many members
41 * you may find it takes a while for them to all appear, with your process
42 * consuming a lot of CPU while it is busy spooling.
44 * Genlist also implements a tree structure, but it does so with callbacks to
45 * the application, with the application filling in tree structures when
46 * requested (allowing for efficient building of a very deep tree that could
47 * even be used for file-management). See the above smart signal callbacks for
50 * An item in the genlist world can have 0 or more text labels (they can be
51 * regular text or textblock - that's up to the style to determine), 0 or
52 * more icons (which are simply objects swallowed into the genlist item) and
53 * 0 or more boolean states that can be used for check, radio or other
54 * indicators by the edje theme style. An item may be one of several styles
55 * (Elementary provides 4 by default - "default", "double_label", "group_index"
56 * and "icon_top_text_bottom", but this can be extended by system or
57 * application custom themes/overlays/extensions).
59 * In order to implement the ability to add and delete items on the fly,
60 * Genlist implements a class/callback system where the application provides
61 * a structure with information about that type of item (genlist may contain
62 * multiple different items with different classes, states and styles).
63 * Genlist will call the functions in this struct (methods) when an item is
64 * "realized" (that is created dynamically while scrolling). All objects will
65 * simply be deleted when no longer needed with evas_object_del(). The
66 * Elm_Genlist_Item_Class structure contains the following members:
68 * item_style - This is a constant string and simply defines the name of the
69 * item style. It must be specified and the default should be "default".
71 * func.label_get - This function is called when an actual item object is
72 * created. The data parameter is the data parameter passed to
73 * elm_genlist_item_append() and related item creation functions. The obj
74 * parameter is the genlist object and the part parameter is the string name
75 * of the text part in the edje design that is listed as one of the possible
76 * labels that can be set. This function must return a strudup()'ed string as
77 * the caller will free() it when done.
79 * func.icon_get - This function is called when an actual item object is
80 * created. The data parameter is the data parameter passed to
81 * elm_genlist_item_append() and related item creation functions. The obj
82 * parameter is the genlist object and the part parameter is the string name
83 * of the icon part in the edje design that is listed as one of the possible
84 * icons that can be set. This must return NULL for no object or a valid
85 * object. The object will be deleted by genlist on shutdown or when the item
88 * func.state_get - This function is called when an actual item object is
89 * created. The data parameter is the data parameter passed to
90 * elm_genlist_item_append() and related item creation functions. The obj
91 * parameter is the genlist object and the part parameter is the string name
92 * of the state part in the edje design that is listed as one of the possible
93 * states that can be set. Return 0 for false or 1 for true. Genlist will
94 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95 * true (the default is false), where XXX is the name of the part.
97 * func.del - This is called when elm_genlist_item_del() is called on an
98 * item, elm_genlist_clear() is called on the genlist, or
99 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100 * intended for use when actual genlist items are deleted, so any backing
101 * data attached to the item (e.g. its data parameter on creation) can be
104 * Items can be added by several calls. All of them return a Elm_Genlist_Item
105 * handle that is an internal member inside the genlist. They all take a data
106 * parameter that is meant to be used for a handle to the applications
107 * internal data (eg the struct with the original item data). The parent
108 * parameter is the parent genlist item this belongs to if it is a tree or
109 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112 * is displayed as an item that is able to expand and have child items.
113 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114 * displayed at the top until the next group comes. The func parameter is a
115 * convenience callback that is called when the item is selected and the data
116 * parameter will be the func_data parameter, obj be the genlist object and
117 * event_info will be the genlist item.
119 * elm_genlist_item_append() appends an item to the end of the list, or if
120 * there is a parent, to the end of all the child items of the parent.
121 * elm_genlist_item_prepend() is the same but prepends to the beginning of
122 * the list or children list. elm_genlist_item_insert_before() inserts at
123 * item before another item and elm_genlist_item_insert_after() inserts after
124 * the indicated item.
126 * The application can clear the list with elm_genlist_clear() which deletes
127 * all the items in the list and elm_genlist_item_del() will delete a specific
128 * item. elm_genlist_item_subitems_clear() will clear all items that are
129 * children of the indicated parent item.
131 * If the application wants multiple items to be able to be selected,
132 * elm_genlist_multi_select_set() can enable this. If the list is
133 * single-selection only (the default), then elm_genlist_selected_item_get()
134 * will return the selected item, if any, or NULL I none is selected. If the
135 * list is multi-select then elm_genlist_selected_items_get() will return a
136 * list (that is only valid as long as no items are modified (added, deleted,
137 * selected or unselected)).
139 * To help inspect list items you can jump to the item at the top of the list
140 * with elm_genlist_first_item_get() which will return the item pointer, and
141 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143 * and previous items respectively relative to the indicated item. Using
144 * these calls you can walk the entire item list/tree. Note that as a tree
145 * the items are flattened in the list, so elm_genlist_item_parent_get() will
146 * let you know which item is the parent (and thus know how to skip them if
149 * There are also convenience functions. elm_genlist_item_genlist_get() will
150 * return the genlist object the item belongs to. elm_genlist_item_show()
151 * will make the scroller scroll to show that specific item so its visible.
152 * elm_genlist_item_data_get() returns the data pointer set by the item
153 * creation functions.
155 * If an item changes (state of boolean changes, label or icons change),
156 * then use elm_genlist_item_update() to have genlist update the item with
157 * the new state. Genlist will re-realize the item thus call the functions
158 * in the _Elm_Genlist_Item_Class for that item.
160 * To programmatically (un)select an item use elm_genlist_item_selected_set().
161 * To get its selected state use elm_genlist_item_selected_get(). Similarly
162 * to expand/contract an item and get its expanded state, use
163 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164 * again to make an item disabled (unable to be selected and appear
165 * differently) use elm_genlist_item_disabled_set() to set this and
166 * elm_genlist_item_disabled_get() to get the disabled state.
168 * In general to indicate how the genlist should expand items horizontally to
169 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171 * mode means that if items are too wide to fit, the scroller will scroll
172 * horizontally. Otherwise items are expanded to fill the width of the
173 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174 * to the viewport width and limited to that size. This can be combined with
175 * a different style that uses edjes' ellipsis feature (cutting text off like
178 * Items will only call their selection func and callback when first becoming
179 * selected. Any further clicks will do nothing, unless you enable always
180 * select with elm_genlist_always_select_mode_set(). This means even if
181 * selected, every click will make the selected callbacks be called.
182 * elm_genlist_no_select_mode_set() will turn off the ability to select
183 * items entirely and they will neither appear selected nor call selected
184 * callback functions.
186 * Remember that you can create new styles and add your own theme augmentation
187 * per application with elm_theme_extension_add(). If you absolutely must
188 * have a specific style that overrides any theme the user or system sets up
189 * you can use elm_theme_overlay_add() to add such a file.
191 * Signals that you can add callbacks for are:
193 * "clicked,double" - This is called when a user has double-clicked an item. The
194 * event_info parameter is the genlist item that was double-c
196 * "selected" - This is called when a user has made an item selected. The
197 * event_info parameter is the genlist item that was selected.
198 * "unselected" - This is called when a user has made an item unselected. The
199 * event_info parameter is the genlist item that was unselected.
200 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201 * and the item is now meant to be expanded. The event_info
202 * parameter is the genlist item that was indicated to expand. It
203 * is the job of this callback to then fill in the child items.
204 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205 * and the item is now meant to be contracted. The event_info
206 * parameter is the genlist item that was indicated to contract.
207 * It is the job of this callback to then delete the child items.
208 * "expand,request" - This is called when a user has indicated they want to
209 * expand a tree branch item. The callback should decide if
210 * the item can expand (has any children) and then call
211 * elm_genlist_item_expanded_set() appropriately to set the
212 * state. The event_info parameter is the genlist item that
213 * was indicated to expand.
214 * "contract,request" - This is called when a user has indicated they want to
215 * contract a tree branch item. The callback should decide
216 * if the item can contract (has any children) and then
217 * call elm_genlist_item_expanded_set() appropriately to
218 * set the state. The event_info parameter is the genlist
219 * item that was indicated to contract.
220 * "realized" - This is called when the item in the list is created as a real
221 * evas object. event_info parameter is the genlist item that was
222 * created. The object may be deleted at any time, so it is up to
223 * the caller to not use the object pointer from
224 * elm_genlist_item_object_get() in a way where it may point to
226 * "unrealized" - This is called just before an item is unrealized. After this
227 * call icon objects provided will be deleted and the item object
228 * itself delete or be put into a floating cache.
229 * "drag,start,up" - This is called when the item in the list has been dragged
231 * "drag,start,down" - This is called when the item in the list has been dragged
232 * (not scrolled) down.
233 * "drag,start,left" - This is called when the item in the list has been dragged
234 * (not scrolled) left.
235 * "drag,start,right" - This is called when the item in the list has been
236 * dragged (not scrolled) right.
237 * "drag,stop" - This is called when the item in the list has stopped being
239 * "drag" - This is called when the item in the list is being dragged.
240 * "longpressed" - This is called when the item is pressed for a certain amount
241 * of time. By default it's 1 second.
242 * "scroll,edge,top" - This is called when the genlist is scrolled until the
244 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
246 * "scroll,edge,left" - This is called when the genlist is scrolled until the
248 * "scroll,edge,right" - This is called when the genlist is scrolled until the
250 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
252 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
254 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
257 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
259 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block Item_Block;
264 typedef struct _Pan Pan;
265 typedef struct _Item_Cache Item_Cache;
269 Evas_Object *obj, *scr, *pan_smart;
270 Eina_Inlist *items, *blocks;
271 Eina_List *group_items;
273 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
274 Ecore_Job *calc_job, *update_job;
275 Ecore_Idler *queue_idler;
276 Ecore_Idler *must_recalc_idler;
277 Eina_List *queue, *selected;
278 Elm_Genlist_Item *show_item;
279 Elm_Genlist_Item *last_selected_item;
280 Eina_Inlist *item_cache;
281 Elm_Genlist_Item *anchor_item;
284 Ecore_Timer *multi_timer;
285 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
286 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
287 Eina_Bool mouse_down : 1;
288 Eina_Bool multi_down : 1;
289 Eina_Bool multi_timeout : 1;
290 Eina_Bool multitouched : 1;
291 Eina_Bool on_hold : 1;
293 Eina_Bool always_select : 1;
294 Eina_Bool longpressed : 1;
295 Eina_Bool wasselected : 1;
296 Eina_Bool no_select : 1;
297 Eina_Bool bring_in : 1;
298 Eina_Bool compress : 1;
299 Eina_Bool height_for_width : 1;
300 Eina_Bool homogeneous : 1;
301 Eina_Bool clear_me : 1;
306 } history[SWIPE_MOVES];
308 int item_cache_count;
314 int group_item_width;
315 int group_item_height;
316 int max_items_per_block;
317 double longpress_timeout;
318 const char *mode_type;
319 Elm_Genlist_Item *mode_item;
320 Ecore_Timer *scr_hold_timer;
330 Evas_Coord x, y, w, h, minw, minh;
331 Eina_Bool want_unrealize : 1;
332 Eina_Bool realized : 1;
333 Eina_Bool changed : 1;
334 Eina_Bool updateme : 1;
335 Eina_Bool showme : 1;
336 Eina_Bool must_recalc : 1;
339 struct _Elm_Genlist_Item
341 Elm_Widget_Item base;
346 Evas_Coord x, y, w, h, minw, minh;
347 const Elm_Genlist_Item_Class *itc;
348 Elm_Genlist_Item *parent;
349 Elm_Genlist_Item *group_item;
350 Elm_Genlist_Item_Flags flags;
358 Eina_List *labels, *icons, *states, *icon_objs;
359 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
360 Ecore_Timer *long_timer;
361 Ecore_Timer *swipe_timer;
363 Evas_Coord scrl_x, scrl_y;
365 Elm_Genlist_Item *rel;
366 Evas_Object *mode_view;
371 Elm_Tooltip_Item_Content_Cb content_cb;
372 Evas_Smart_Cb del_cb;
376 const char *mouse_cursor;
383 Eina_Bool before : 1;
385 Eina_Bool want_unrealize : 1;
386 Eina_Bool want_realize : 1;
387 Eina_Bool realized : 1;
388 Eina_Bool selected : 1;
389 Eina_Bool highlighted : 1;
390 Eina_Bool expanded : 1;
391 Eina_Bool disabled : 1;
392 Eina_Bool display_only : 1;
393 Eina_Bool mincalcd : 1;
394 Eina_Bool queued : 1;
395 Eina_Bool showme : 1;
396 Eina_Bool delete_me : 1;
398 Eina_Bool dragging : 1;
399 Eina_Bool updateme : 1;
400 Eina_Bool nocache : 1;
407 Evas_Object *base_view, *spacer;
409 const char *item_style; // it->itc->item_style
410 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
411 Eina_Bool compress : 1; // it->wd->compress
412 Eina_Bool odd : 1; // in & 0x1
414 Eina_Bool selected : 1; // it->selected
415 Eina_Bool disabled : 1; // it->disabled
416 Eina_Bool expanded : 1; // it->expanded
419 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
420 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
424 Evas_Object_Smart_Clipped_Data __clipped_data;
426 Ecore_Job *resize_job;
429 static const char *widtype = NULL;
430 static void _item_cache_zero(Widget_Data *wd);
431 static void _del_hook(Evas_Object *obj);
432 static void _mirrored_set(Evas_Object *obj,
434 static void _theme_hook(Evas_Object *obj);
435 static void _show_region_hook(void *data,
437 static void _sizing_eval(Evas_Object *obj);
438 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
439 static void _item_block_unrealize(Item_Block *itb);
440 static void _calc_job(void *data);
441 static void _on_focus_hook(void *data,
443 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
444 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
445 static Eina_Bool _item_single_select_up(Widget_Data *wd);
446 static Eina_Bool _item_single_select_down(Widget_Data *wd);
447 static Eina_Bool _event_hook(Evas_Object *obj,
449 Evas_Callback_Type type,
451 static void _signal_emit_hook(Evas_Object *obj,
452 const char *emission,
454 static Eina_Bool _deselect_all_items(Widget_Data *wd);
455 static void _pan_calculate(Evas_Object *obj);
456 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
457 static void _mode_item_realize(Elm_Genlist_Item *it);
458 static void _mode_item_unrealize(Elm_Genlist_Item *it);
459 static void _item_mode_set(Elm_Genlist_Item *it);
460 static void _item_mode_unset(Widget_Data *wd);
462 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
465 _event_hook(Evas_Object *obj,
466 Evas_Object *src __UNUSED__,
467 Evas_Callback_Type type,
470 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
471 Evas_Event_Key_Down *ev = event_info;
472 Widget_Data *wd = elm_widget_data_get(obj);
473 if (!wd) return EINA_FALSE;
474 if (!wd->items) return EINA_FALSE;
475 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
476 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
478 Elm_Genlist_Item *it = NULL;
481 Evas_Coord step_x = 0;
482 Evas_Coord step_y = 0;
485 Evas_Coord page_x = 0;
486 Evas_Coord page_y = 0;
488 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
489 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
490 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
491 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
493 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
497 else if ((!strcmp(ev->keyname, "Right")) ||
498 (!strcmp(ev->keyname, "KP_Right")))
502 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
504 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
505 (_item_multi_select_up(wd)))
506 || (_item_single_select_up(wd)))
508 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
514 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
516 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
517 (_item_multi_select_down(wd)))
518 || (_item_single_select_down(wd)))
520 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
526 else if ((!strcmp(ev->keyname, "Home")) ||
527 (!strcmp(ev->keyname, "KP_Home")))
529 it = elm_genlist_first_item_get(obj);
530 elm_genlist_item_bring_in(it);
531 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
534 else if ((!strcmp(ev->keyname, "End")) ||
535 (!strcmp(ev->keyname, "KP_End")))
537 it = elm_genlist_last_item_get(obj);
538 elm_genlist_item_bring_in(it);
539 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
542 else if ((!strcmp(ev->keyname, "Prior")) ||
543 (!strcmp(ev->keyname, "KP_Prior")))
546 y -= -(page_y * v_h) / 100;
550 else if ((!strcmp(ev->keyname, "Next")) ||
551 (!strcmp(ev->keyname, "KP_Next")))
554 y += -(page_y * v_h) / 100;
558 else if(((!strcmp(ev->keyname, "Return")) ||
559 (!strcmp(ev->keyname, "KP_Enter")) ||
560 (!strcmp(ev->keyname, "space")))
561 && (!wd->multi) && (wd->selected))
563 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
564 elm_genlist_item_expanded_set(it,
565 !elm_genlist_item_expanded_get(it));
567 else if (!strcmp(ev->keyname, "Escape"))
569 if (!_deselect_all_items(wd)) return EINA_FALSE;
570 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
573 else return EINA_FALSE;
575 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
576 elm_smart_scroller_child_pos_set(wd->scr, x, y);
581 _deselect_all_items(Widget_Data *wd)
583 if (!wd->selected) return EINA_FALSE;
585 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
591 _item_multi_select_up(Widget_Data *wd)
593 if (!wd->selected) return EINA_FALSE;
594 if (!wd->multi) return EINA_FALSE;
596 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
597 if (!prev) return EINA_TRUE;
599 if (elm_genlist_item_selected_get(prev))
601 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
602 wd->last_selected_item = prev;
603 elm_genlist_item_show(wd->last_selected_item);
607 elm_genlist_item_selected_set(prev, EINA_TRUE);
608 elm_genlist_item_show(prev);
614 _item_multi_select_down(Widget_Data *wd)
616 if (!wd->selected) return EINA_FALSE;
617 if (!wd->multi) return EINA_FALSE;
619 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
620 if (!next) return EINA_TRUE;
622 if (elm_genlist_item_selected_get(next))
624 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
625 wd->last_selected_item = next;
626 elm_genlist_item_show(wd->last_selected_item);
630 elm_genlist_item_selected_set(next, EINA_TRUE);
631 elm_genlist_item_show(next);
637 _item_single_select_up(Widget_Data *wd)
639 Elm_Genlist_Item *prev;
642 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
643 while ((prev) && (prev->delete_me))
644 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
646 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
648 if (!prev) return EINA_FALSE;
650 _deselect_all_items(wd);
652 elm_genlist_item_selected_set(prev, EINA_TRUE);
653 elm_genlist_item_show(prev);
658 _item_single_select_down(Widget_Data *wd)
660 Elm_Genlist_Item *next;
663 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
664 while ((next) && (next->delete_me))
665 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
667 else next = elm_genlist_item_next_get(wd->last_selected_item);
669 if (!next) return EINA_FALSE;
671 _deselect_all_items(wd);
673 elm_genlist_item_selected_set(next, EINA_TRUE);
674 elm_genlist_item_show(next);
679 _on_focus_hook(void *data __UNUSED__,
682 Widget_Data *wd = elm_widget_data_get(obj);
684 if (elm_widget_focus_get(obj))
686 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
687 evas_object_focus_set(wd->obj, EINA_TRUE);
688 if ((wd->selected) && (!wd->last_selected_item))
689 wd->last_selected_item = eina_list_data_get(wd->selected);
693 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
694 evas_object_focus_set(wd->obj, EINA_FALSE);
699 _del_hook(Evas_Object *obj)
701 Widget_Data *wd = elm_widget_data_get(obj);
703 _item_cache_zero(wd);
704 if (wd->calc_job) ecore_job_del(wd->calc_job);
705 if (wd->update_job) ecore_job_del(wd->update_job);
706 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
707 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
708 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
709 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
714 _del_pre_hook(Evas_Object *obj)
716 Widget_Data *wd = elm_widget_data_get(obj);
718 evas_object_del(wd->pan_smart);
719 wd->pan_smart = NULL;
720 elm_genlist_clear(obj);
724 _mirrored_set(Evas_Object *obj,
727 Widget_Data *wd = elm_widget_data_get(obj);
729 _item_cache_zero(wd);
730 elm_smart_scroller_mirrored_set(wd->scr, rtl);
734 _theme_hook(Evas_Object *obj)
736 Widget_Data *wd = elm_widget_data_get(obj);
739 _item_cache_zero(wd);
740 _elm_widget_mirrored_reload(obj);
741 _mirrored_set(obj, elm_widget_mirrored_get(obj));
742 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
743 elm_widget_style_get(obj));
744 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
745 wd->item_width = wd->item_height = 0;
746 wd->group_item_width = wd->group_item_height = 0;
747 wd->minw = wd->minh = wd->realminw = 0;
748 EINA_INLIST_FOREACH(wd->blocks, itb)
751 Elm_Genlist_Item *it;
753 if (itb->realized) _item_block_unrealize(itb);
754 EINA_LIST_FOREACH(itb->items, l, it)
755 it->mincalcd = EINA_FALSE;
757 itb->changed = EINA_TRUE;
759 if (wd->calc_job) ecore_job_del(wd->calc_job);
760 wd->calc_job = ecore_job_add(_calc_job, wd);
765 _show_region_hook(void *data,
768 Widget_Data *wd = elm_widget_data_get(data);
769 Evas_Coord x, y, w, h;
771 elm_widget_show_region_get(obj, &x, &y, &w, &h);
772 //x & y are screen coordinates, Add with pan coordinates
775 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
779 _sizing_eval(Evas_Object *obj)
781 Widget_Data *wd = elm_widget_data_get(obj);
782 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
784 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
785 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
787 if (wd->height_for_width)
791 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
792 if ((vw != 0) && (vw != wd->prev_viewport_w))
796 wd->prev_viewport_w = vw;
797 EINA_INLIST_FOREACH(wd->blocks, itb)
799 itb->must_recalc = EINA_TRUE;
801 if (wd->calc_job) ecore_job_del(wd->calc_job);
802 wd->calc_job = ecore_job_add(_calc_job, wd);
805 if (wd->mode == ELM_LIST_LIMIT)
807 Evas_Coord vmw, vmh, vw, vh;
811 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
812 if ((minw > 0) && (vw < minw)) vw = minw;
813 else if ((maxw > 0) && (vw > maxw))
815 edje_object_size_min_calc
816 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
823 edje_object_size_min_calc
824 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
828 evas_object_size_hint_min_set(obj, minw, minh);
829 evas_object_size_hint_max_set(obj, maxw, maxh);
833 _signal_emit_hook(Evas_Object *obj,
834 const char *emission,
837 Widget_Data *wd = elm_widget_data_get(obj);
838 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
843 _item_highlight(Elm_Genlist_Item *it)
845 const char *selectraise;
846 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
847 (it->disabled) || (it->display_only) || (it->mode_view))
849 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
850 selectraise = edje_object_data_get(it->base.view, "selectraise");
851 if ((selectraise) && (!strcmp(selectraise, "on")))
853 evas_object_raise(it->base.view);
854 if ((it->group_item) && (it->group_item->realized))
855 evas_object_raise(it->group_item->base.view);
857 it->highlighted = EINA_TRUE;
861 _item_block_del(Elm_Genlist_Item *it)
864 Item_Block *itb = it->block;
866 itb->items = eina_list_remove(itb->items, it);
868 itb->changed = EINA_TRUE;
869 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
870 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
873 il = EINA_INLIST_GET(itb);
874 Item_Block *itbn = (Item_Block *)(il->next);
876 it->parent->items = eina_list_remove(it->parent->items, it);
878 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
880 if (itbn) itbn->changed = EINA_TRUE;
886 il = EINA_INLIST_GET(itb);
887 Item_Block *itbp = (Item_Block *)(il->prev);
888 Item_Block *itbn = (Item_Block *)(il->next);
889 if ((itbp) && ((itbp->count + itb->count) < 48))
891 Elm_Genlist_Item *it2;
893 EINA_LIST_FREE(itb->items, it2)
896 itbp->items = eina_list_append(itbp->items, it2);
898 itbp->changed = EINA_TRUE;
900 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
901 EINA_INLIST_GET(itb));
904 else if ((itbn) && ((itbn->count + itb->count) < 48))
908 Eina_List *last = eina_list_last(itb->items);
909 Elm_Genlist_Item *it2 = last->data;
912 itb->items = eina_list_remove_list(itb->items, last);
913 itbn->items = eina_list_prepend(itbn->items, it2);
915 itbn->changed = EINA_TRUE;
918 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
926 _item_del(Elm_Genlist_Item *it)
928 elm_widget_item_pre_notify_del(it);
929 elm_genlist_item_subitems_clear(it);
930 it->wd->walking -= it->walking;
931 if (it->wd->show_item == it) it->wd->show_item = NULL;
932 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
933 if (it->realized) _item_unrealize(it, EINA_FALSE);
934 if (it->block) _item_block_del(it);
935 if ((!it->delete_me) && (it->itc->func.del))
936 it->itc->func.del((void *)it->base.data, it->base.widget);
937 it->delete_me = EINA_TRUE;
939 it->wd->queue = eina_list_remove(it->wd->queue, it);
940 if (it->wd->anchor_item == it)
942 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
943 if (!it->wd->anchor_item)
944 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
946 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
948 it->parent->items = eina_list_remove(it->parent->items, it);
949 if (it->flags & ELM_GENLIST_ITEM_GROUP)
950 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
951 if (it->long_timer) ecore_timer_del(it->long_timer);
952 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
954 if (it->tooltip.del_cb)
955 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
957 elm_widget_item_del(it);
961 _item_select(Elm_Genlist_Item *it)
963 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
966 if (it->wd->always_select) goto call;
969 it->selected = EINA_TRUE;
970 it->wd->selected = eina_list_append(it->wd->selected, it);
974 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
976 evas_object_smart_callback_call(it->base.widget, "selected", it);
979 if ((it->wd->clear_me) && (!it->wd->walking))
980 elm_genlist_clear(it->base.widget);
983 if ((!it->walking) && (it->delete_me))
985 if (!it->relcount) _item_del(it);
988 it->wd->last_selected_item = it;
992 _item_unselect(Elm_Genlist_Item *it)
994 const char *stacking, *selectraise;
996 if ((it->delete_me) || (!it->highlighted)) return;
997 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
998 stacking = edje_object_data_get(it->base.view, "stacking");
999 selectraise = edje_object_data_get(it->base.view, "selectraise");
1000 if ((selectraise) && (!strcmp(selectraise, "on")))
1002 if ((stacking) && (!strcmp(stacking, "below")))
1003 evas_object_lower(it->base.view);
1005 it->highlighted = EINA_FALSE;
1008 it->selected = EINA_FALSE;
1009 it->wd->selected = eina_list_remove(it->wd->selected, it);
1010 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1015 _mouse_move(void *data,
1016 Evas *evas __UNUSED__,
1020 Elm_Genlist_Item *it = data;
1021 Evas_Event_Mouse_Move *ev = event_info;
1022 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1024 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1026 if (!it->wd->on_hold)
1028 it->wd->on_hold = EINA_TRUE;
1029 if (!it->wd->wasselected)
1033 if (it->wd->multitouched)
1035 it->wd->cur_x = ev->cur.canvas.x;
1036 it->wd->cur_y = ev->cur.canvas.y;
1039 if ((it->dragging) && (it->down))
1041 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1044 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1045 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1046 if (abs((it->wd->history[it->wd->movements].x -
1047 it->wd->history[0].x)) > 40)
1048 it->wd->swipe = EINA_TRUE;
1050 it->wd->movements++;
1054 ecore_timer_del(it->long_timer);
1055 it->long_timer = NULL;
1057 evas_object_smart_callback_call(it->base.widget, "drag", it);
1060 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1064 ecore_timer_del(it->long_timer);
1065 it->long_timer = NULL;
1069 if (!it->display_only)
1070 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1071 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1072 x = ev->cur.canvas.x - x;
1073 y = ev->cur.canvas.y - y;
1076 if (adx < 0) adx = -dx;
1079 if (ady < 0) ady = -dy;
1082 if ((adx > minw) || (ady > minh))
1084 it->dragging = EINA_TRUE;
1087 ecore_timer_del(it->long_timer);
1088 it->long_timer = NULL;
1090 if (!it->wd->wasselected)
1095 evas_object_smart_callback_call(it->base.widget,
1096 "drag,start,up", it);
1100 evas_object_smart_callback_call(it->base.widget,
1101 "drag,start,left", it);
1103 evas_object_smart_callback_call(it->base.widget,
1104 "drag,start,right", it);
1110 evas_object_smart_callback_call(it->base.widget,
1111 "drag,start,down", it);
1115 evas_object_smart_callback_call(it->base.widget,
1116 "drag,start,left", it);
1118 evas_object_smart_callback_call(it->base.widget,
1119 "drag,start,right", it);
1126 _long_press(void *data)
1128 Elm_Genlist_Item *it = data;
1130 it->long_timer = NULL;
1131 if ((it->disabled) || (it->dragging) || (it->display_only))
1132 return ECORE_CALLBACK_CANCEL;
1133 it->wd->longpressed = EINA_TRUE;
1134 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1135 return ECORE_CALLBACK_CANCEL;
1139 _swipe(Elm_Genlist_Item *it)
1144 if ((it->display_only) || (it->disabled)) return;
1145 it->wd->swipe = EINA_FALSE;
1146 for (i = 0; i < it->wd->movements; i++)
1148 sum += it->wd->history[i].x;
1149 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1152 sum /= it->wd->movements;
1153 if (abs(sum - it->wd->history[0].x) <= 10) return;
1154 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1158 _swipe_cancel(void *data)
1160 Elm_Genlist_Item *it = data;
1162 if (!it) return ECORE_CALLBACK_CANCEL;
1163 it->wd->swipe = EINA_FALSE;
1164 it->wd->movements = 0;
1165 return ECORE_CALLBACK_RENEW;
1169 _multi_cancel(void *data)
1171 Widget_Data *wd = data;
1173 if (!wd) return ECORE_CALLBACK_CANCEL;
1174 wd->multi_timeout = EINA_TRUE;
1175 return ECORE_CALLBACK_RENEW;
1179 _multi_touch_gesture_eval(void *data)
1181 Elm_Genlist_Item *it = data;
1183 it->wd->multitouched = EINA_FALSE;
1184 if (it->wd->multi_timer)
1186 ecore_timer_del(it->wd->multi_timer);
1187 it->wd->multi_timer = NULL;
1189 if (it->wd->multi_timeout)
1191 it->wd->multi_timeout = EINA_FALSE;
1195 Evas_Coord minw = 0, minh = 0;
1196 Evas_Coord off_x, off_y, off_mx, off_my;
1198 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1199 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1200 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1201 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1202 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1204 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1206 if ((off_x + off_mx) > (off_y + off_my))
1208 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1209 evas_object_smart_callback_call(it->base.widget,
1210 "multi,swipe,right", it);
1211 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1212 evas_object_smart_callback_call(it->base.widget,
1213 "multi,swipe,left", it);
1214 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1215 evas_object_smart_callback_call(it->base.widget,
1216 "multi,pinch,out", it);
1218 evas_object_smart_callback_call(it->base.widget,
1219 "multi,pinch,in", it);
1223 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1224 evas_object_smart_callback_call(it->base.widget,
1225 "multi,swipe,down", it);
1226 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1227 evas_object_smart_callback_call(it->base.widget,
1228 "multi,swipe,up", it);
1229 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1230 evas_object_smart_callback_call(it->base.widget,
1231 "multi,pinch,out", it);
1233 evas_object_smart_callback_call(it->base.widget,
1234 "multi,pinch,in", it);
1237 it->wd->multi_timeout = EINA_FALSE;
1241 _multi_down(void *data,
1242 Evas *evas __UNUSED__,
1243 Evas_Object *obj __UNUSED__,
1246 Elm_Genlist_Item *it = data;
1247 Evas_Event_Multi_Down *ev = event_info;
1249 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1250 it->wd->multi_device = ev->device;
1251 it->wd->multi_down = EINA_TRUE;
1252 it->wd->multitouched = EINA_TRUE;
1253 it->wd->prev_mx = ev->canvas.x;
1254 it->wd->prev_my = ev->canvas.y;
1255 if (!it->wd->wasselected) _item_unselect(it);
1256 it->wd->wasselected = EINA_FALSE;
1257 it->wd->longpressed = EINA_FALSE;
1260 ecore_timer_del(it->long_timer);
1261 it->long_timer = NULL;
1265 it->dragging = EINA_FALSE;
1266 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1268 if (it->swipe_timer)
1270 ecore_timer_del(it->swipe_timer);
1271 it->swipe_timer = NULL;
1273 if (it->wd->on_hold)
1275 it->wd->swipe = EINA_FALSE;
1276 it->wd->movements = 0;
1277 it->wd->on_hold = EINA_FALSE;
1282 _multi_up(void *data,
1283 Evas *evas __UNUSED__,
1284 Evas_Object *obj __UNUSED__,
1287 Elm_Genlist_Item *it = data;
1288 Evas_Event_Multi_Up *ev = event_info;
1290 if (it->wd->multi_device != ev->device) return;
1291 it->wd->multi_device = 0;
1292 it->wd->multi_down = EINA_FALSE;
1293 if (it->wd->mouse_down) return;
1294 _multi_touch_gesture_eval(data);
1298 _multi_move(void *data,
1299 Evas *evas __UNUSED__,
1300 Evas_Object *obj __UNUSED__,
1303 Elm_Genlist_Item *it = data;
1304 Evas_Event_Multi_Move *ev = event_info;
1306 if (it->wd->multi_device != ev->device) return;
1307 it->wd->cur_mx = ev->cur.canvas.x;
1308 it->wd->cur_my = ev->cur.canvas.y;
1312 _mouse_down(void *data,
1313 Evas *evas __UNUSED__,
1317 Elm_Genlist_Item *it = data;
1318 Evas_Event_Mouse_Down *ev = event_info;
1321 if (ev->button != 1) return;
1322 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1324 it->wd->on_hold = EINA_TRUE;
1327 it->down = EINA_TRUE;
1328 it->dragging = EINA_FALSE;
1329 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1330 it->dx = ev->canvas.x - x;
1331 it->dy = ev->canvas.y - y;
1332 it->wd->mouse_down = EINA_TRUE;
1333 if (!it->wd->multitouched)
1335 it->wd->prev_x = ev->canvas.x;
1336 it->wd->prev_y = ev->canvas.y;
1337 it->wd->multi_timeout = EINA_FALSE;
1338 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1339 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1341 it->wd->longpressed = EINA_FALSE;
1342 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1343 else it->wd->on_hold = EINA_FALSE;
1344 if (it->wd->on_hold) return;
1345 it->wd->wasselected = it->selected;
1346 _item_highlight(it);
1347 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1348 if ((!it->disabled) && (!it->display_only))
1350 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1351 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1353 if (it->long_timer) ecore_timer_del(it->long_timer);
1354 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1355 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1357 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1360 it->long_timer = NULL;
1361 it->wd->swipe = EINA_FALSE;
1362 it->wd->movements = 0;
1366 _mouse_up(void *data,
1367 Evas *evas __UNUSED__,
1368 Evas_Object *obj __UNUSED__,
1371 Elm_Genlist_Item *it = data;
1372 Evas_Event_Mouse_Up *ev = event_info;
1373 Eina_Bool dragged = EINA_FALSE;
1375 if (ev->button != 1) return;
1376 it->down = EINA_FALSE;
1377 it->wd->mouse_down = EINA_FALSE;
1378 if (it->wd->multitouched)
1380 if (it->wd->multi_down) return;
1381 _multi_touch_gesture_eval(data);
1384 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1385 else it->wd->on_hold = EINA_FALSE;
1388 ecore_timer_del(it->long_timer);
1389 it->long_timer = NULL;
1393 it->dragging = EINA_FALSE;
1394 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1397 if (it->swipe_timer)
1399 ecore_timer_del(it->swipe_timer);
1400 it->swipe_timer = NULL;
1402 if (it->wd->multi_timer)
1404 ecore_timer_del(it->wd->multi_timer);
1405 it->wd->multi_timer = NULL;
1406 it->wd->multi_timeout = EINA_FALSE;
1408 if (it->wd->on_hold)
1410 if (it->wd->swipe) _swipe(data);
1411 it->wd->longpressed = EINA_FALSE;
1412 it->wd->on_hold = EINA_FALSE;
1415 if (it->wd->longpressed)
1417 it->wd->longpressed = EINA_FALSE;
1418 if (!it->wd->wasselected)
1420 it->wd->wasselected = EINA_FALSE;
1425 if (it->want_unrealize)
1427 _item_unrealize(it, EINA_FALSE);
1428 if (it->block->want_unrealize)
1429 _item_block_unrealize(it->block);
1432 if ((it->disabled) || (dragged) || (it->display_only)) return;
1433 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1438 _item_highlight(it);
1441 else _item_unselect(it);
1447 Widget_Data *wd = it->wd;
1450 while (wd->selected) _item_unselect(wd->selected->data);
1455 const Eina_List *l, *l_next;
1456 Elm_Genlist_Item *it2;
1458 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1459 if (it2 != it) _item_unselect(it2);
1460 //_item_highlight(it);
1463 _item_highlight(it);
1469 _signal_expand_toggle(void *data,
1470 Evas_Object *obj __UNUSED__,
1471 const char *emission __UNUSED__,
1472 const char *source __UNUSED__)
1474 Elm_Genlist_Item *it = data;
1477 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1479 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1483 _signal_expand(void *data,
1484 Evas_Object *obj __UNUSED__,
1485 const char *emission __UNUSED__,
1486 const char *source __UNUSED__)
1488 Elm_Genlist_Item *it = data;
1491 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1495 _signal_contract(void *data,
1496 Evas_Object *obj __UNUSED__,
1497 const char *emission __UNUSED__,
1498 const char *source __UNUSED__)
1500 Elm_Genlist_Item *it = data;
1503 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1507 _scr_hold_timer_cb(void *data)
1509 if (!data) return ECORE_CALLBACK_CANCEL;
1510 Widget_Data *wd = data;
1511 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1512 wd->scr_hold_timer = NULL;
1513 return ECORE_CALLBACK_CANCEL;
1517 _mode_finished_signal_cb(void *data,
1519 const char *emission __UNUSED__,
1520 const char *source __UNUSED__)
1524 Elm_Genlist_Item *it = data;
1525 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1528 it->nocache = EINA_FALSE;
1529 _mode_item_unrealize(it);
1530 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1531 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1535 _item_cache_clean(Widget_Data *wd)
1537 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1541 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1542 wd->item_cache = eina_inlist_remove(wd->item_cache,
1543 wd->item_cache->last);
1544 wd->item_cache_count--;
1545 if (itc->spacer) evas_object_del(itc->spacer);
1546 if (itc->base_view) evas_object_del(itc->base_view);
1547 if (itc->item_style) eina_stringshare_del(itc->item_style);
1553 _item_cache_zero(Widget_Data *wd)
1555 int pmax = wd->item_cache_max;
1556 wd->item_cache_max = 0;
1557 _item_cache_clean(wd);
1558 wd->item_cache_max = pmax;
1562 _item_cache_add(Elm_Genlist_Item *it)
1566 if (it->wd->item_cache_max <= 0)
1568 evas_object_del(it->base.view);
1569 it->base.view = NULL;
1570 evas_object_del(it->spacer);
1575 it->wd->item_cache_count++;
1576 itc = calloc(1, sizeof(Item_Cache));
1577 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1578 EINA_INLIST_GET(itc));
1579 itc->spacer = it->spacer;
1581 itc->base_view = it->base.view;
1582 it->base.view = NULL;
1583 evas_object_hide(itc->base_view);
1584 evas_object_move(itc->base_view, -9999, -9999);
1585 itc->item_style = eina_stringshare_add(it->itc->item_style);
1586 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1587 itc->compress = (it->wd->compress);
1588 itc->odd = (it->order_num_in & 0x1);
1589 itc->selected = it->selected;
1590 itc->disabled = it->disabled;
1591 itc->expanded = it->expanded;
1594 ecore_timer_del(it->long_timer);
1595 it->long_timer = NULL;
1597 if (it->swipe_timer)
1599 ecore_timer_del(it->swipe_timer);
1600 it->swipe_timer = NULL;
1602 // FIXME: other callbacks?
1603 edje_object_signal_callback_del_full(itc->base_view,
1604 "elm,action,expand,toggle",
1605 "elm", _signal_expand_toggle, it);
1606 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1608 _signal_expand, it);
1609 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1610 "elm", _signal_contract, it);
1611 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1613 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1615 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1617 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1619 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1621 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1623 _item_cache_clean(it->wd);
1627 _item_cache_find(Elm_Genlist_Item *it)
1630 Eina_Bool tree = 0, odd;
1632 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1633 odd = (it->order_num_in & 0x1);
1634 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1636 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1638 if ((itc->tree == tree) &&
1639 (itc->odd == odd) &&
1640 (itc->compress == it->wd->compress) &&
1641 (!strcmp(it->itc->item_style, itc->item_style)))
1643 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1644 EINA_INLIST_GET(itc));
1645 it->wd->item_cache_count--;
1653 _item_cache_free(Item_Cache *itc)
1655 if (itc->spacer) evas_object_del(itc->spacer);
1656 if (itc->base_view) evas_object_del(itc->base_view);
1657 if (itc->item_style) eina_stringshare_del(itc->item_style);
1662 _item_realize(Elm_Genlist_Item *it,
1666 Elm_Genlist_Item *it2;
1667 const char *stacking;
1668 const char *treesize;
1670 int depth, tsize = 20;
1671 Item_Cache *itc = NULL;
1673 if ((it->realized) || (it->delete_me)) return;
1674 it->order_num_in = in;
1677 it->nocache = EINA_FALSE;
1679 itc = _item_cache_find(it);
1682 it->base.view = itc->base_view;
1683 itc->base_view = NULL;
1684 it->spacer = itc->spacer;
1689 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1690 edje_object_scale_set(it->base.view,
1691 elm_widget_scale_get(it->base.widget) *
1692 _elm_config->scale);
1693 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1694 elm_widget_sub_object_add(it->base.widget, it->base.view);
1696 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1697 strncpy(buf, "tree", sizeof(buf));
1698 else strncpy(buf, "item", sizeof(buf));
1699 if (it->wd->compress)
1700 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1702 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1703 strncat(buf, "/", sizeof(buf) - strlen(buf));
1704 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1706 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1707 elm_widget_style_get(it->base.widget));
1708 edje_object_mirrored_set(it->base.view,
1709 elm_widget_mirrored_get(it->base.widget));
1711 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1712 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1713 elm_widget_sub_object_add(it->base.widget, it->spacer);
1715 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1717 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1719 it->expanded_depth = depth;
1720 treesize = edje_object_data_get(it->base.view, "treesize");
1721 if (treesize) tsize = atoi(treesize);
1722 evas_object_size_hint_min_set(it->spacer,
1723 (depth * tsize) * _elm_config->scale, 1);
1724 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1727 edje_object_signal_callback_add(it->base.view,
1728 "elm,action,expand,toggle",
1729 "elm", _signal_expand_toggle, it);
1730 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1731 "elm", _signal_expand, it);
1732 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1733 "elm", _signal_contract, it);
1734 stacking = edje_object_data_get(it->base.view, "stacking");
1737 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1738 else if (!strcmp(stacking, "above"))
1739 evas_object_raise(it->base.view);
1741 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1743 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1745 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1747 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1749 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1751 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1755 if (it->selected != itc->selected)
1758 edje_object_signal_emit(it->base.view,
1759 "elm,state,selected", "elm");
1761 if (it->disabled != itc->disabled)
1764 edje_object_signal_emit(it->base.view,
1765 "elm,state,disabled", "elm");
1767 if (it->expanded != itc->expanded)
1770 edje_object_signal_emit(it->base.view,
1771 "elm,state,expanded", "elm");
1777 edje_object_signal_emit(it->base.view,
1778 "elm,state,selected", "elm");
1780 edje_object_signal_emit(it->base.view,
1781 "elm,state,disabled", "elm");
1783 edje_object_signal_emit(it->base.view,
1784 "elm,state,expanded", "elm");
1788 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1790 /* homogenous genlist shortcut */
1793 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1795 it->w = it->minw = it->wd->group_item_width;
1796 it->h = it->minh = it->wd->group_item_height;
1800 it->w = it->minw = it->wd->item_width;
1801 it->h = it->minh = it->wd->item_height;
1803 it->mincalcd = EINA_TRUE;
1808 if (it->itc->func.label_get)
1814 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1816 EINA_LIST_FOREACH(it->labels, l, key)
1818 char *s = it->itc->func.label_get
1819 ((void *)it->base.data, it->base.widget, l->data);
1823 edje_object_part_text_set(it->base.view, l->data, s);
1827 edje_object_part_text_set(it->base.view, l->data, "");
1830 if (it->itc->func.icon_get)
1836 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1838 EINA_LIST_FOREACH(it->icons, l, key)
1840 Evas_Object *ic = it->itc->func.icon_get
1841 ((void *)it->base.data, it->base.widget, l->data);
1845 it->icon_objs = eina_list_append(it->icon_objs, ic);
1846 edje_object_part_swallow(it->base.view, key, ic);
1847 evas_object_show(ic);
1848 elm_widget_sub_object_add(it->base.widget, ic);
1852 if (it->itc->func.state_get)
1858 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1860 EINA_LIST_FOREACH(it->states, l, key)
1862 Eina_Bool on = it->itc->func.state_get
1863 ((void *)it->base.data, it->base.widget, l->data);
1867 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1868 edje_object_signal_emit(it->base.view, buf, "elm");
1872 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1873 edje_object_signal_emit(it->base.view, buf, "elm");
1879 Evas_Coord mw = -1, mh = -1;
1881 if (it->wd->height_for_width) mw = it->wd->w;
1883 if (!it->display_only)
1884 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1885 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1886 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1888 if (!it->display_only)
1889 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1890 it->w = it->minw = mw;
1891 it->h = it->minh = mh;
1892 it->mincalcd = EINA_TRUE;
1894 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1896 it->wd->group_item_width = mw;
1897 it->wd->group_item_height = mh;
1899 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1901 it->wd->item_width = mw;
1902 it->wd->item_height = mh;
1905 if (!calc) evas_object_show(it->base.view);
1908 if (it->tooltip.content_cb)
1910 elm_widget_item_tooltip_content_cb_set(it,
1911 it->tooltip.content_cb,
1912 it->tooltip.data, NULL);
1913 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1916 if (it->mouse_cursor)
1917 elm_widget_item_cursor_set(it, it->mouse_cursor);
1919 it->realized = EINA_TRUE;
1920 it->want_unrealize = EINA_FALSE;
1922 if (itc) _item_cache_free(itc);
1923 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1927 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1931 if (!it->realized) return;
1932 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1935 ecore_timer_del(it->long_timer);
1936 it->long_timer = NULL;
1940 evas_object_del(it->base.view);
1941 it->base.view = NULL;
1942 evas_object_del(it->spacer);
1947 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1948 _item_cache_add(it);
1950 elm_widget_stringlist_free(it->labels);
1952 elm_widget_stringlist_free(it->icons);
1954 elm_widget_stringlist_free(it->states);
1956 EINA_LIST_FREE(it->icon_objs, icon)
1957 evas_object_del(icon);
1959 _mode_item_unrealize(it);
1961 it->realized = EINA_FALSE;
1962 it->want_unrealize = EINA_FALSE;
1966 _item_block_recalc(Item_Block *itb,
1972 Elm_Genlist_Item *it;
1973 Evas_Coord minw = 0, minh = 0;
1974 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1978 EINA_LIST_FOREACH(itb->items, l, it)
1980 if (it->delete_me) continue;
1981 showme |= it->showme;
1986 if (!it->mincalcd) changed = EINA_TRUE;
1989 _item_realize(it, in, EINA_TRUE);
1990 _item_unrealize(it, EINA_TRUE);
1995 _item_realize(it, in, EINA_TRUE);
1996 _item_unrealize(it, EINA_TRUE);
2000 _item_realize(it, in, EINA_FALSE);
2002 if (minw < it->minw) minw = it->minw;
2010 itb->changed = EINA_FALSE;
2011 /* force an evas norender to garbage collect deleted objects */
2012 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2017 _item_block_realize(Item_Block *itb,
2022 Elm_Genlist_Item *it;
2024 if (itb->realized) return;
2025 EINA_LIST_FOREACH(itb->items, l, it)
2027 if (it->delete_me) continue;
2028 if (full) _item_realize(it, in, EINA_FALSE);
2031 itb->realized = EINA_TRUE;
2032 itb->want_unrealize = EINA_FALSE;
2036 _item_block_unrealize(Item_Block *itb)
2039 Elm_Genlist_Item *it;
2040 Eina_Bool dragging = EINA_FALSE;
2042 if (!itb->realized) return;
2043 EINA_LIST_FOREACH(itb->items, l, it)
2045 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2049 dragging = EINA_TRUE;
2050 it->want_unrealize = EINA_TRUE;
2053 _item_unrealize(it, EINA_FALSE);
2058 itb->realized = EINA_FALSE;
2059 itb->want_unrealize = EINA_TRUE;
2062 itb->want_unrealize = EINA_FALSE;
2066 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2071 evas_object_resize(view, it->w, it->h);
2072 evas_object_move(view, it->scrl_x, it->scrl_y);
2073 evas_object_show(view);
2077 _item_block_position(Item_Block *itb,
2081 Elm_Genlist_Item *it;
2082 Elm_Genlist_Item *git;
2083 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2086 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2087 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2089 EINA_LIST_FOREACH(itb->items, l, it)
2091 if (it->delete_me) continue;
2095 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2096 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2098 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2099 cvx, cvy, cvw, cvh));
2100 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2102 if ((itb->realized) && (!it->realized))
2104 if (vis) _item_realize(it, in, EINA_FALSE);
2110 git = it->group_item;
2113 if (git->scrl_y < oy)
2115 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2116 git->scrl_y = (it->scrl_y + it->h) - git->h;
2117 git->want_realize = EINA_TRUE;
2120 _item_position(it, it->mode_view);
2122 _item_position(it, it->base.view);
2126 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2133 if (vis) it->want_realize = EINA_TRUE;
2140 _group_items_recalc(void *data)
2142 Widget_Data *wd = data;
2144 Elm_Genlist_Item *git;
2146 EINA_LIST_FOREACH(wd->group_items, l, git)
2148 if (git->want_realize)
2151 _item_realize(git, 0, EINA_FALSE);
2152 evas_object_resize(git->base.view, wd->minw, git->h);
2153 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2154 evas_object_show(git->base.view);
2155 evas_object_raise(git->base.view);
2157 else if (!git->want_realize && git->realized)
2160 _item_unrealize(git, EINA_FALSE);
2166 _must_recalc_idler(void *data)
2168 Widget_Data *wd = data;
2169 if (wd->calc_job) ecore_job_del(wd->calc_job);
2170 wd->calc_job = ecore_job_add(_calc_job, wd);
2171 wd->must_recalc_idler = NULL;
2172 return ECORE_CALLBACK_CANCEL;
2176 _calc_job(void *data)
2178 Widget_Data *wd = data;
2180 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2181 Item_Block *chb = NULL;
2182 int in = 0, minw_change = 0;
2183 Eina_Bool changed = EINA_FALSE;
2185 Eina_Bool did_must_recalc = EINA_FALSE;
2188 t0 = ecore_time_get();
2189 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2193 // if (wd->height_for_width) changed = EINA_TRUE;
2196 EINA_INLIST_FOREACH(wd->blocks, itb)
2198 Eina_Bool showme = EINA_FALSE;
2201 showme = itb->showme;
2202 itb->showme = EINA_FALSE;
2205 if (itb->realized) _item_block_unrealize(itb);
2207 if ((itb->changed) || (changed) ||
2208 ((itb->must_recalc) && (!did_must_recalc)))
2210 if ((changed) || (itb->must_recalc))
2213 Elm_Genlist_Item *it;
2214 EINA_LIST_FOREACH(itb->items, l, it)
2215 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2216 itb->changed = EINA_TRUE;
2217 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2218 itb->must_recalc = EINA_FALSE;
2220 if (itb->realized) _item_block_unrealize(itb);
2221 showme = _item_block_recalc(itb, in, 0, 1);
2227 if (minw == -1) minw = itb->minw;
2228 else if ((!itb->must_recalc) && (minw < itb->minw))
2237 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2239 wd->show_item->showme = EINA_FALSE;
2241 elm_smart_scroller_region_bring_in(wd->scr,
2243 wd->show_item->block->x,
2245 wd->show_item->block->y,
2246 wd->show_item->block->w,
2249 elm_smart_scroller_child_region_show(wd->scr,
2251 wd->show_item->block->x,
2253 wd->show_item->block->y,
2254 wd->show_item->block->w,
2256 wd->show_item = NULL;
2261 EINA_INLIST_FOREACH(wd->blocks, itb)
2267 if ((chb) && (EINA_INLIST_GET(chb)->next))
2269 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2271 if (itb->realized) _item_block_unrealize(itb);
2274 wd->realminw = minw;
2275 if (minw < wd->w) minw = wd->w;
2276 if ((minw != wd->minw) || (minh != wd->minh))
2280 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2281 _sizing_eval(wd->obj);
2282 if ((wd->anchor_item) && (wd->anchor_item->block))
2284 Elm_Genlist_Item *it;
2287 it = wd->anchor_item;
2288 it_y = wd->anchor_y;
2289 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2290 it->block->y + it->y + it_y);
2291 wd->anchor_item = it;
2292 wd->anchor_y = it_y;
2295 t = ecore_time_get();
2296 if (did_must_recalc)
2298 if (!wd->must_recalc_idler)
2299 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2301 wd->calc_job = NULL;
2302 evas_object_smart_changed(wd->pan_smart);
2306 _update_job(void *data)
2308 Widget_Data *wd = data;
2311 int num, num0, position = 0, recalc = 0;
2313 wd->update_job = NULL;
2315 EINA_INLIST_FOREACH(wd->blocks, itb)
2317 Evas_Coord itminw, itminh;
2318 Elm_Genlist_Item *it;
2324 _item_block_position(itb, num);
2329 EINA_LIST_FOREACH(itb->items, l2, it)
2336 it->updateme = EINA_FALSE;
2339 _item_unrealize(it, EINA_FALSE);
2340 _item_realize(it, num, EINA_FALSE);
2345 _item_realize(it, num, EINA_TRUE);
2346 _item_unrealize(it, EINA_TRUE);
2348 if ((it->minw != itminw) || (it->minh != itminh))
2353 itb->updateme = EINA_FALSE;
2357 itb->changed = EINA_TRUE;
2358 _item_block_recalc(itb, num0, 0, 1);
2359 _item_block_position(itb, num0);
2364 if (wd->calc_job) ecore_job_del(wd->calc_job);
2365 wd->calc_job = ecore_job_add(_calc_job, wd);
2370 _pan_set(Evas_Object *obj,
2374 Pan *sd = evas_object_smart_data_get(obj);
2377 // Evas_Coord ow, oh;
2378 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2379 // ow = sd->wd->minw - ow;
2380 // if (ow < 0) ow = 0;
2381 // oh = sd->wd->minh - oh;
2382 // if (oh < 0) oh = 0;
2383 // if (x < 0) x = 0;
2384 // if (y < 0) y = 0;
2385 // if (x > ow) x = ow;
2386 // if (y > oh) y = oh;
2387 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2391 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2393 if ((itb->y + itb->h) > y)
2395 Elm_Genlist_Item *it;
2398 EINA_LIST_FOREACH(itb->items, l2, it)
2400 if ((itb->y + it->y) >= y)
2402 sd->wd->anchor_item = it;
2403 sd->wd->anchor_y = -(itb->y + it->y - y);
2410 evas_object_smart_changed(obj);
2414 _pan_get(Evas_Object *obj,
2418 Pan *sd = evas_object_smart_data_get(obj);
2420 if (x) *x = sd->wd->pan_x;
2421 if (y) *y = sd->wd->pan_y;
2425 _pan_max_get(Evas_Object *obj,
2429 Pan *sd = evas_object_smart_data_get(obj);
2432 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2433 ow = sd->wd->minw - ow;
2435 oh = sd->wd->minh - oh;
2442 _pan_min_get(Evas_Object *obj __UNUSED__,
2451 _pan_child_size_get(Evas_Object *obj,
2455 Pan *sd = evas_object_smart_data_get(obj);
2457 if (w) *w = sd->wd->minw;
2458 if (h) *h = sd->wd->minh;
2462 _pan_add(Evas_Object *obj)
2465 Evas_Object_Smart_Clipped_Data *cd;
2468 cd = evas_object_smart_data_get(obj);
2471 sd->__clipped_data = *cd;
2473 evas_object_smart_data_set(obj, sd);
2477 _pan_del(Evas_Object *obj)
2479 Pan *sd = evas_object_smart_data_get(obj);
2484 ecore_job_del(sd->resize_job);
2485 sd->resize_job = NULL;
2491 _pan_resize_job(void *data)
2494 _sizing_eval(sd->wd->obj);
2495 sd->resize_job = NULL;
2499 _pan_resize(Evas_Object *obj,
2503 Pan *sd = evas_object_smart_data_get(obj);
2506 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2507 if ((ow == w) && (oh == h)) return;
2508 if ((sd->wd->height_for_width) && (ow != w))
2510 if (sd->resize_job) ecore_job_del(sd->resize_job);
2511 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2513 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2514 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2518 _pan_calculate(Evas_Object *obj)
2520 Pan *sd = evas_object_smart_data_get(obj);
2522 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2524 Elm_Genlist_Item *git;
2527 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2528 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2529 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2531 git->want_realize = EINA_FALSE;
2533 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2535 itb->w = sd->wd->minw;
2536 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2537 itb->y - sd->wd->pan_y + oy,
2539 cvx, cvy, cvw, cvh))
2541 if ((!itb->realized) || (itb->changed))
2542 _item_block_realize(itb, in, 0);
2543 _item_block_position(itb, in);
2547 if (itb->realized) _item_block_unrealize(itb);
2551 _group_items_recalc(sd->wd);
2555 _pan_move(Evas_Object *obj,
2556 Evas_Coord x __UNUSED__,
2557 Evas_Coord y __UNUSED__)
2559 Pan *sd = evas_object_smart_data_get(obj);
2561 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2562 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2566 _hold_on(void *data __UNUSED__,
2568 void *event_info __UNUSED__)
2570 Widget_Data *wd = elm_widget_data_get(obj);
2572 elm_smart_scroller_hold_set(wd->scr, 1);
2576 _hold_off(void *data __UNUSED__,
2578 void *event_info __UNUSED__)
2580 Widget_Data *wd = elm_widget_data_get(obj);
2582 elm_smart_scroller_hold_set(wd->scr, 0);
2586 _freeze_on(void *data __UNUSED__,
2588 void *event_info __UNUSED__)
2590 Widget_Data *wd = elm_widget_data_get(obj);
2592 elm_smart_scroller_freeze_set(wd->scr, 1);
2596 _freeze_off(void *data __UNUSED__,
2598 void *event_info __UNUSED__)
2600 Widget_Data *wd = elm_widget_data_get(obj);
2602 elm_smart_scroller_freeze_set(wd->scr, 0);
2606 _scroll_edge_left(void *data,
2607 Evas_Object *scr __UNUSED__,
2608 void *event_info __UNUSED__)
2610 Evas_Object *obj = data;
2611 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2615 _scroll_edge_right(void *data,
2616 Evas_Object *scr __UNUSED__,
2617 void *event_info __UNUSED__)
2619 Evas_Object *obj = data;
2620 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2624 _scroll_edge_top(void *data,
2625 Evas_Object *scr __UNUSED__,
2626 void *event_info __UNUSED__)
2628 Evas_Object *obj = data;
2629 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2633 _scroll_edge_bottom(void *data,
2634 Evas_Object *scr __UNUSED__,
2635 void *event_info __UNUSED__)
2637 Evas_Object *obj = data;
2638 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2642 _mode_item_realize(Elm_Genlist_Item *it)
2646 if ((it->mode_view) || (it->delete_me)) return;
2648 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2649 edje_object_scale_set(it->mode_view,
2650 elm_widget_scale_get(it->base.widget) *
2651 _elm_config->scale);
2652 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2653 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2655 strncpy(buf, "item", sizeof(buf));
2656 if (it->wd->compress)
2657 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2659 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2660 strncat(buf, "/", sizeof(buf) - strlen(buf));
2661 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2663 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2664 elm_widget_style_get(it->base.widget));
2665 edje_object_mirrored_set(it->mode_view,
2666 elm_widget_mirrored_get(it->base.widget));
2667 elm_widget_sub_object_add(it->base.widget, it->spacer);
2669 /* signal callback add */
2670 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2672 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2674 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2677 /* label_get, icon_get, state_get */
2678 if (it->itc->func.label_get)
2684 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2686 EINA_LIST_FOREACH(it->mode_labels, l, key)
2688 char *s = it->itc->func.label_get
2689 ((void *)it->base.data, it->base.widget, l->data);
2693 edje_object_part_text_set(it->mode_view, l->data, s);
2698 if (it->itc->func.icon_get)
2704 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2706 EINA_LIST_FOREACH(it->mode_icons, l, key)
2708 Evas_Object *ic = it->itc->func.icon_get
2709 ((void *)it->base.data, it->base.widget, l->data);
2713 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
2714 edje_object_part_swallow(it->mode_view, key, ic);
2715 evas_object_show(ic);
2716 elm_widget_sub_object_add(it->base.widget, ic);
2720 if (it->itc->func.state_get)
2726 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2728 EINA_LIST_FOREACH(it->mode_states, l, key)
2730 Eina_Bool on = it->itc->func.state_get
2731 ((void *)it->base.data, it->base.widget, l->data);
2735 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2736 edje_object_signal_emit(it->mode_view, buf, "elm");
2741 edje_object_part_swallow(it->mode_view,
2742 edje_object_data_get(it->mode_view, "mode_part"),
2745 it->want_unrealize = EINA_FALSE;
2749 _mode_item_unrealize(Elm_Genlist_Item *it)
2751 Widget_Data *wd = it->wd;
2753 if (!it->mode_view) return;
2755 elm_widget_stringlist_free(it->mode_labels);
2756 it->mode_labels = NULL;
2757 elm_widget_stringlist_free(it->mode_icons);
2758 it->mode_icons = NULL;
2759 elm_widget_stringlist_free(it->mode_states);
2761 EINA_LIST_FREE(it->mode_icon_objs, icon)
2762 evas_object_del(icon);
2764 edje_object_part_unswallow(it->mode_view, it->base.view);
2765 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2766 evas_object_del(it->mode_view);
2767 it->mode_view = NULL;
2769 if (wd->mode_item == it)
2770 wd->mode_item = NULL;
2774 _item_mode_set(Elm_Genlist_Item *it)
2777 Widget_Data *wd = it->wd;
2782 it->nocache = EINA_TRUE;
2784 if (wd->scr_hold_timer)
2786 ecore_timer_del(wd->scr_hold_timer);
2787 wd->scr_hold_timer = NULL;
2789 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2790 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2792 _mode_item_realize(it);
2793 _item_position(it, it->mode_view);
2795 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2796 edje_object_signal_emit(it->mode_view, buf, "elm");
2800 _item_mode_unset(Widget_Data *wd)
2803 if (!wd->mode_item) return;
2804 char buf[1024], buf2[1024];
2805 Elm_Genlist_Item *it;
2808 it->nocache = EINA_TRUE;
2810 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2811 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2813 edje_object_signal_emit(it->mode_view, buf, "elm");
2814 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2816 wd->mode_item = NULL;
2820 * Add a new Genlist object
2822 * @param parent The parent object
2823 * @return The new object or NULL if it cannot be created
2828 elm_genlist_add(Evas_Object *parent)
2833 Evas_Coord minw, minh;
2834 static Evas_Smart *smart = NULL;
2838 static Evas_Smart_Class sc;
2840 evas_object_smart_clipped_smart_set(&_pan_sc);
2842 sc.name = "elm_genlist_pan";
2843 sc.version = EVAS_SMART_CLASS_VERSION;
2846 sc.resize = _pan_resize;
2847 sc.move = _pan_move;
2848 sc.calculate = _pan_calculate;
2849 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2852 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2854 ELM_SET_WIDTYPE(widtype, "genlist");
2855 elm_widget_type_set(obj, "genlist");
2856 elm_widget_sub_object_add(parent, obj);
2857 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2858 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2859 elm_widget_data_set(obj, wd);
2860 elm_widget_del_hook_set(obj, _del_hook);
2861 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2862 elm_widget_theme_hook_set(obj, _theme_hook);
2863 elm_widget_can_focus_set(obj, EINA_TRUE);
2864 elm_widget_event_hook_set(obj, _event_hook);
2865 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2867 wd->scr = elm_smart_scroller_add(e);
2868 elm_smart_scroller_widget_set(wd->scr, obj);
2869 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2870 elm_widget_style_get(obj));
2871 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2872 _elm_config->thumbscroll_bounce_enable);
2873 elm_widget_resize_object_set(obj, wd->scr);
2875 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2876 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2878 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2879 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2883 wd->mode = ELM_LIST_SCROLL;
2884 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2885 wd->item_cache_max = wd->max_items_per_block * 2;
2886 wd->longpress_timeout = _elm_config->longpress_timeout;
2888 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2889 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2890 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2891 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2893 wd->pan_smart = evas_object_smart_add(e, smart);
2894 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2897 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2898 _pan_set, _pan_get, _pan_max_get,
2899 _pan_min_get, _pan_child_size_get);
2901 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2903 evas_object_size_hint_min_set(obj, minw, minh);
2905 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2910 static Elm_Genlist_Item *
2911 _item_new(Widget_Data *wd,
2912 const Elm_Genlist_Item_Class *itc,
2914 Elm_Genlist_Item *parent,
2915 Elm_Genlist_Item_Flags flags,
2917 const void *func_data)
2919 Elm_Genlist_Item *it;
2921 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2922 if (!it) return NULL;
2925 it->base.data = data;
2926 it->parent = parent;
2928 it->func.func = func;
2929 it->func.data = func_data;
2930 it->mouse_cursor = NULL;
2931 it->expanded_depth = 0;
2936 _item_block_add(Widget_Data *wd,
2937 Elm_Genlist_Item *it)
2939 Item_Block *itb = NULL;
2946 itb = calloc(1, sizeof(Item_Block));
2949 if (!it->rel->block)
2952 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2953 itb->items = eina_list_append(itb->items, it);
2959 wd->blocks = eina_inlist_prepend_relative
2960 (wd->blocks, EINA_INLIST_GET(itb),
2961 EINA_INLIST_GET(it->rel->block));
2963 eina_list_prepend_relative(itb->items, it, it->rel);
2967 wd->blocks = eina_inlist_append_relative
2968 (wd->blocks, EINA_INLIST_GET(itb),
2969 EINA_INLIST_GET(it->rel->block));
2971 eina_list_append_relative(itb->items, it, it->rel);
2981 itb = (Item_Block *)(wd->blocks);
2982 if (itb->count >= wd->max_items_per_block)
2984 itb = calloc(1, sizeof(Item_Block));
2988 eina_inlist_prepend(wd->blocks,
2989 EINA_INLIST_GET(itb));
2994 itb = calloc(1, sizeof(Item_Block));
2998 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3000 itb->items = eina_list_prepend(itb->items, it);
3006 itb = (Item_Block *)(wd->blocks->last);
3007 if (itb->count >= wd->max_items_per_block)
3009 itb = calloc(1, sizeof(Item_Block));
3013 eina_inlist_append(wd->blocks,
3014 EINA_INLIST_GET(itb));
3019 itb = calloc(1, sizeof(Item_Block));
3023 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3025 itb->items = eina_list_append(itb->items, it);
3031 itb = it->rel->block;
3032 if (!itb) goto newblock;
3034 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3036 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3039 itb->changed = EINA_TRUE;
3041 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3042 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3045 it->rel->relcount--;
3046 if ((it->rel->delete_me) && (!it->rel->relcount))
3050 if (itb->count > itb->wd->max_items_per_block)
3054 Elm_Genlist_Item *it2;
3056 newc = itb->count / 2;
3057 itb2 = calloc(1, sizeof(Item_Block));
3061 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3062 EINA_INLIST_GET(itb));
3063 itb2->changed = EINA_TRUE;
3064 while ((itb->count > newc) && (itb->items))
3068 l = eina_list_last(itb->items);
3070 itb->items = eina_list_remove_list(itb->items, l);
3073 itb2->items = eina_list_prepend(itb2->items, it2);
3081 _queue_process(Widget_Data *wd,
3085 Eina_Bool showme = EINA_FALSE;
3088 t0 = ecore_time_get();
3089 for (n = 0; (wd->queue) && (n < 128); n++)
3091 Elm_Genlist_Item *it;
3093 it = wd->queue->data;
3094 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3095 it->queued = EINA_FALSE;
3096 _item_block_add(wd, it);
3097 t = ecore_time_get();
3098 if (it->block->changed)
3100 showme = _item_block_recalc(it->block, it->block->num, 1,
3102 it->block->changed = 0;
3104 if (showme) it->block->showme = EINA_TRUE;
3105 if (eina_inlist_count(wd->blocks) > 1)
3107 if ((t - t0) > (ecore_animator_frametime_get())) break;
3114 _item_idler(void *data)
3116 Widget_Data *wd = data;
3119 //static double q_start = 0.0;
3120 //if (q_start == 0.0) q_start = ecore_time_get();
3123 if (_queue_process(wd, 1) > 0)
3125 if (wd->calc_job) ecore_job_del(wd->calc_job);
3126 wd->calc_job = ecore_job_add(_calc_job, wd);
3131 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3133 wd->queue_idler = NULL;
3134 return ECORE_CALLBACK_CANCEL;
3136 return ECORE_CALLBACK_RENEW;
3140 _item_queue(Widget_Data *wd,
3141 Elm_Genlist_Item *it)
3143 if (it->queued) return;
3144 it->queued = EINA_TRUE;
3145 wd->queue = eina_list_append(wd->queue, it);
3146 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3148 if (wd->queue_idler)
3150 ecore_idler_del(wd->queue_idler);
3151 wd->queue_idler = NULL;
3153 _queue_process(wd, 0);
3155 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3159 * Append item to the end of the genlist
3161 * This appends the given item to the end of the list or the end of
3162 * the children if the parent is given.
3164 * @param obj The genlist object
3165 * @param itc The item class for the item
3166 * @param data The item data
3167 * @param parent The parent item, or NULL if none
3168 * @param flags Item flags
3169 * @param func Convenience function called when item selected
3170 * @param func_data Data passed to @p func above.
3171 * @return A handle to the item added or NULL if not possible
3175 EAPI Elm_Genlist_Item *
3176 elm_genlist_item_append(Evas_Object *obj,
3177 const Elm_Genlist_Item_Class *itc,
3179 Elm_Genlist_Item *parent,
3180 Elm_Genlist_Item_Flags flags,
3182 const void *func_data)
3184 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3185 Widget_Data *wd = elm_widget_data_get(obj);
3186 if (!wd) return NULL;
3187 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3189 if (!it) return NULL;
3192 if (flags & ELM_GENLIST_ITEM_GROUP)
3193 wd->group_items = eina_list_append(wd->group_items, it);
3194 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3199 Elm_Genlist_Item *it2 = NULL;
3200 Eina_List *ll = eina_list_last(it->parent->items);
3201 if (ll) it2 = ll->data;
3202 it->parent->items = eina_list_append(it->parent->items, it);
3203 if (!it2) it2 = it->parent;
3205 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3206 EINA_INLIST_GET(it2));
3208 it->rel->relcount++;
3210 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3211 it->group_item = parent;
3212 else if (it->parent->group_item)
3213 it->group_item = it->parent->group_item;
3215 it->before = EINA_FALSE;
3216 _item_queue(wd, it);
3221 * Prepend item at start of the genlist
3223 * This adds an item to the beginning of the list or beginning of the
3224 * children of the parent if given.
3226 * @param obj The genlist object
3227 * @param itc The item class for the item
3228 * @param data The item data
3229 * @param parent The parent item, or NULL if none
3230 * @param flags Item flags
3231 * @param func Convenience function called when item selected
3232 * @param func_data Data passed to @p func above.
3233 * @return A handle to the item added or NULL if not possible
3237 EAPI Elm_Genlist_Item *
3238 elm_genlist_item_prepend(Evas_Object *obj,
3239 const Elm_Genlist_Item_Class *itc,
3241 Elm_Genlist_Item *parent,
3242 Elm_Genlist_Item_Flags flags,
3244 const void *func_data)
3246 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3247 Widget_Data *wd = elm_widget_data_get(obj);
3248 if (!wd) return NULL;
3249 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3251 if (!it) return NULL;
3254 if (flags & ELM_GENLIST_ITEM_GROUP)
3255 wd->group_items = eina_list_prepend(wd->group_items, it);
3256 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3261 Elm_Genlist_Item *it2 = NULL;
3262 Eina_List *ll = it->parent->items;
3263 if (ll) it2 = ll->data;
3264 it->parent->items = eina_list_prepend(it->parent->items, it);
3265 if (!it2) it2 = it->parent;
3267 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3268 EINA_INLIST_GET(it2));
3270 it->rel->relcount++;
3272 it->before = EINA_TRUE;
3273 _item_queue(wd, it);
3278 * Insert item before another in the genlist
3280 * This inserts an item before another in the list. It will be in the
3281 * same tree level or group as the item it is inseted before.
3283 * @param obj The genlist object
3284 * @param itc The item class for the item
3285 * @param data The item data
3286 * @param before The item to insert before
3287 * @param flags Item flags
3288 * @param func Convenience function called when item selected
3289 * @param func_data Data passed to @p func above.
3290 * @return A handle to the item added or NULL if not possible
3294 EAPI Elm_Genlist_Item *
3295 elm_genlist_item_insert_before(Evas_Object *obj,
3296 const Elm_Genlist_Item_Class *itc,
3298 Elm_Genlist_Item *parent,
3299 Elm_Genlist_Item *before,
3300 Elm_Genlist_Item_Flags flags,
3302 const void *func_data)
3304 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3305 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3306 Widget_Data *wd = elm_widget_data_get(obj);
3307 if (!wd) return NULL;
3308 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3310 if (!it) return NULL;
3313 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3316 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3317 EINA_INLIST_GET(before));
3319 it->rel->relcount++;
3320 it->before = EINA_TRUE;
3321 _item_queue(wd, it);
3326 * Insert an item after another in the genlst
3328 * This inserts an item after another in the list. It will be in the
3329 * same tree level or group as the item it is inseted after.
3331 * @param obj The genlist object
3332 * @param itc The item class for the item
3333 * @param data The item data
3334 * @param after The item to insert after
3335 * @param flags Item flags
3336 * @param func Convenience function called when item selected
3337 * @param func_data Data passed to @p func above.
3338 * @return A handle to the item added or NULL if not possible
3342 EAPI Elm_Genlist_Item *
3343 elm_genlist_item_insert_after(Evas_Object *obj,
3344 const Elm_Genlist_Item_Class *itc,
3346 Elm_Genlist_Item *parent,
3347 Elm_Genlist_Item *after,
3348 Elm_Genlist_Item_Flags flags,
3350 const void *func_data)
3352 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3353 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3354 Widget_Data *wd = elm_widget_data_get(obj);
3355 if (!wd) return NULL;
3356 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3358 if (!it) return NULL;
3359 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3360 EINA_INLIST_GET(after));
3363 it->parent->items = eina_list_append_relative(it->parent->items, it,
3367 it->rel->relcount++;
3368 it->before = EINA_FALSE;
3369 _item_queue(wd, it);
3376 * This clears all items in the list, leaving it empty.
3378 * @param obj The genlist object
3383 elm_genlist_clear(Evas_Object *obj)
3385 ELM_CHECK_WIDTYPE(obj, widtype);
3386 Widget_Data *wd = elm_widget_data_get(obj);
3388 if (wd->walking > 0)
3390 Elm_Genlist_Item *it;
3392 wd->clear_me = EINA_TRUE;
3393 EINA_INLIST_FOREACH(wd->items, it)
3395 it->delete_me = EINA_TRUE;
3401 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3403 if (wd->anchor_item == it)
3405 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3406 if (!wd->anchor_item)
3408 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3410 wd->items = eina_inlist_remove(wd->items, wd->items);
3411 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3412 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3413 elm_widget_item_pre_notify_del(it);
3414 if (it->realized) _item_unrealize(it, EINA_FALSE);
3415 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3416 it->itc->func.del((void *)it->base.data, it->base.widget);
3417 if (it->long_timer) ecore_timer_del(it->long_timer);
3418 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3419 elm_widget_item_del(it);
3421 wd->clear_me = EINA_FALSE;
3422 wd->anchor_item = NULL;
3425 Item_Block *itb = (Item_Block *)(wd->blocks);
3427 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3428 if (itb->items) eina_list_free(itb->items);
3433 ecore_job_del(wd->calc_job);
3434 wd->calc_job = NULL;
3436 if (wd->queue_idler)
3438 ecore_idler_del(wd->queue_idler);
3439 wd->queue_idler = NULL;
3441 if (wd->must_recalc_idler)
3443 ecore_idler_del(wd->must_recalc_idler);
3444 wd->must_recalc_idler = NULL;
3448 eina_list_free(wd->queue);
3453 eina_list_free(wd->selected);
3454 wd->selected = NULL;
3456 wd->show_item = NULL;
3463 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3464 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3470 * Enable or disable multi-select in the genlist
3472 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3473 * the list. This allows more than 1 item to be selected.
3475 * @param obj The genlist object
3476 * @param multi Multi-select enable/disable
3481 elm_genlist_multi_select_set(Evas_Object *obj,
3484 ELM_CHECK_WIDTYPE(obj, widtype);
3485 Widget_Data *wd = elm_widget_data_get(obj);
3491 * Gets if multi-select in genlist is enable or disable
3493 * @param obj The genlist object
3494 * @return Multi-select enable/disable
3495 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3500 elm_genlist_multi_select_get(const Evas_Object *obj)
3502 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3503 Widget_Data *wd = elm_widget_data_get(obj);
3504 if (!wd) return EINA_FALSE;
3509 * Get the selectd item in the genlist
3511 * This gets the selected item in the list (if multi-select is enabled
3512 * only the first item in the list is selected - which is not very
3513 * useful, so see elm_genlist_selected_items_get() for when
3514 * multi-select is used).
3516 * If no item is selected, NULL is returned.
3518 * @param obj The genlist object
3519 * @return The selected item, or NULL if none.
3523 EAPI Elm_Genlist_Item *
3524 elm_genlist_selected_item_get(const Evas_Object *obj)
3526 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3527 Widget_Data *wd = elm_widget_data_get(obj);
3528 if (!wd) return NULL;
3529 if (wd->selected) return wd->selected->data;
3534 * Get a list of selected items in the genlist
3536 * This returns a list of the selected items. This list pointer is
3537 * only valid so long as no items are selected or unselected (or
3538 * unselected implicitly by deletion). The list contains
3539 * Elm_Genlist_Item pointers.
3541 * @param obj The genlist object
3542 * @return The list of selected items, nor NULL if none are selected.
3546 EAPI const Eina_List *
3547 elm_genlist_selected_items_get(const Evas_Object *obj)
3549 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3550 Widget_Data *wd = elm_widget_data_get(obj);
3551 if (!wd) return NULL;
3552 return wd->selected;
3556 * Get a list of realized items in genlist
3558 * This returns a list of the realized items in the genlist. The list
3559 * contains Elm_Genlist_Item pointers. The list must be freed by the
3560 * caller when done with eina_list_free(). The item pointers in the
3561 * list are only valid so long as those items are not deleted or the
3562 * genlist is not deleted.
3564 * @param obj The genlist object
3565 * @return The list of realized items, nor NULL if none are realized.
3570 elm_genlist_realized_items_get(const Evas_Object *obj)
3572 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3573 Widget_Data *wd = elm_widget_data_get(obj);
3574 Eina_List *list = NULL;
3576 Eina_Bool done = EINA_FALSE;
3577 if (!wd) return NULL;
3578 EINA_INLIST_FOREACH(wd->blocks, itb)
3583 Elm_Genlist_Item *it;
3586 EINA_LIST_FOREACH(itb->items, l, it)
3588 if (it->realized) list = eina_list_append(list, it);
3600 * Get the item that is at the x, y canvas coords
3602 * This returns the item at the given coordinates (which are canvas
3603 * relative not object-relative). If an item is at that coordinate,
3604 * that item handle is returned, and if @p posret is not NULL, the
3605 * integer pointed to is set to a value of -1, 0 or 1, depending if
3606 * the coordinate is on the upper portion of that item (-1), on the
3607 * middle section (0) or on the lower part (1). If NULL is returned as
3608 * an item (no item found there), then posret may indicate -1 or 1
3609 * based if the coordinate is above or below all items respectively in
3612 * @param it The item
3613 * @param x The input x coordinate
3614 * @param y The input y coordinate
3615 * @param posret The position relative to the item returned here
3616 * @return The item at the coordinates or NULL if none
3620 EAPI Elm_Genlist_Item *
3621 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3626 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3627 Widget_Data *wd = elm_widget_data_get(obj);
3628 Evas_Coord ox, oy, ow, oh;
3631 if (!wd) return NULL;
3632 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3634 EINA_INLIST_FOREACH(wd->blocks, itb)
3637 Elm_Genlist_Item *it;
3639 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3640 oy + itb->y - itb->wd->pan_y,
3641 itb->w, itb->h, x, y, 1, 1))
3643 EINA_LIST_FOREACH(itb->items, l, it)
3645 Evas_Coord itx, ity;
3647 itx = ox + itb->x + it->x - itb->wd->pan_x;
3648 ity = oy + itb->y + it->y - itb->wd->pan_y;
3649 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3653 if (y <= (ity + (it->h / 4))) *posret = -1;
3654 else if (y >= (ity + it->h - (it->h / 4)))
3660 lasty = ity + it->h;
3665 if (y > lasty) *posret = 1;
3672 * Get the first item in the genlist
3674 * This returns the first item in the list.
3676 * @param obj The genlist object
3677 * @return The first item, or NULL if none
3681 EAPI Elm_Genlist_Item *
3682 elm_genlist_first_item_get(const Evas_Object *obj)
3684 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3685 Widget_Data *wd = elm_widget_data_get(obj);
3686 if (!wd) return NULL;
3687 if (!wd->items) return NULL;
3688 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3689 while ((it) && (it->delete_me))
3690 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3695 * Get the last item in the genlist
3697 * This returns the last item in the list.
3699 * @return The last item, or NULL if none
3703 EAPI Elm_Genlist_Item *
3704 elm_genlist_last_item_get(const Evas_Object *obj)
3706 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3707 Widget_Data *wd = elm_widget_data_get(obj);
3708 if (!wd) return NULL;
3709 if (!wd->items) return NULL;
3710 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3711 while ((it) && (it->delete_me))
3712 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3717 * Get the next item in the genlist
3719 * This returns the item after the item @p it.
3721 * @param it The item
3722 * @return The item after @p it, or NULL if none
3726 EAPI Elm_Genlist_Item *
3727 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3729 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3732 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3733 if ((it) && (!it->delete_me)) break;
3735 return (Elm_Genlist_Item *)it;
3739 * Get the previous item in the genlist
3741 * This returns the item before the item @p it.
3743 * @param it The item
3744 * @return The item before @p it, or NULL if none
3748 EAPI Elm_Genlist_Item *
3749 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3751 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3754 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3755 if ((it) && (!it->delete_me)) break;
3757 return (Elm_Genlist_Item *)it;
3761 * Get the genlist object from an item
3763 * This returns the genlist object itself that an item belongs to.
3765 * @param it The item
3766 * @return The genlist object
3771 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3773 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3774 return it->base.widget;
3778 * Get the parent item of the given item
3780 * This returns the parent item of the item @p it given.
3782 * @param it The item
3783 * @return The parent of the item or NULL if none
3787 EAPI Elm_Genlist_Item *
3788 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3790 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3795 * Clear all sub-items (children) of the given item
3797 * This clears all items that are children (or their descendants) of the
3800 * @param it The item
3805 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3807 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3808 Eina_List *tl = NULL, *l;
3809 Elm_Genlist_Item *it2;
3811 EINA_LIST_FOREACH(it->items, l, it2)
3812 tl = eina_list_append(tl, it2);
3813 EINA_LIST_FREE(tl, it2)
3814 elm_genlist_item_del(it2);
3818 * Set the selected state of an item
3820 * This sets the selected state (1 selected, 0 not selected) of the given
3823 * @param it The item
3824 * @param selected The selected state
3829 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3832 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3833 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3835 if (it->delete_me) return;
3836 selected = !!selected;
3837 if (it->selected == selected) return;
3843 while (wd->selected)
3844 _item_unselect(wd->selected->data);
3846 _item_highlight(it);
3854 * Get the selected state of an item
3856 * This gets the selected state of an item (1 selected, 0 not selected).
3858 * @param it The item
3859 * @return The selected state
3864 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3866 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3867 return it->selected;
3871 * Sets the expanded state of an item (if it's a parent)
3873 * This expands or contracts a parent item (thus showing or hiding the
3876 * @param it The item
3877 * @param expanded The expanded state (1 expanded, 0 not expanded).
3882 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3885 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3886 if (it->expanded == expanded) return;
3887 it->expanded = expanded;
3891 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3892 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3897 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3898 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3903 * Get the expanded state of an item
3905 * This gets the expanded state of an item
3907 * @param it The item
3908 * @return Thre expanded state
3913 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3915 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3916 return it->expanded;
3920 * Get the depth of expanded item
3922 * @param it The genlist item object
3923 * @return The depth of expanded item
3928 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3930 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3931 return it->expanded_depth;
3935 * Sets the disabled state of an item.
3937 * A disabled item cannot be selected or unselected. It will also
3938 * change appearance to appear disabled. This sets the disabled state
3939 * (1 disabled, 0 not disabled).
3941 * @param it The item
3942 * @param disabled The disabled state
3947 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3950 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3951 if (it->disabled == disabled) return;
3952 if (it->delete_me) return;
3953 it->disabled = disabled;
3957 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3959 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3964 * Get the disabled state of an item
3966 * This gets the disabled state of the given item.
3968 * @param it The item
3969 * @return The disabled state
3974 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3976 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3977 if (it->delete_me) return EINA_FALSE;
3978 return it->disabled;
3982 * Sets the display only state of an item.
3984 * A display only item cannot be selected or unselected. It is for
3985 * display only and not selecting or otherwise clicking, dragging
3986 * etc. by the user, thus finger size rules will not be applied to
3989 * @param it The item
3990 * @param display_only The display only state
3995 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3996 Eina_Bool display_only)
3998 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3999 if (it->display_only == display_only) return;
4000 if (it->delete_me) return;
4001 it->display_only = display_only;
4002 it->mincalcd = EINA_FALSE;
4003 it->updateme = EINA_TRUE;
4004 if (it->block) it->block->updateme = EINA_TRUE;
4005 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4006 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4010 * Get the display only state of an item
4012 * This gets the display only state of the given item.
4014 * @param it The item
4015 * @return The display only state
4020 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4022 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4023 if (it->delete_me) return EINA_FALSE;
4024 return it->display_only;
4028 * Show the given item
4030 * This causes genlist to jump to the given item @p it and show it (by
4031 * scrolling), if it is not fully visible.
4033 * @param it The item
4038 elm_genlist_item_show(Elm_Genlist_Item *it)
4040 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4041 Evas_Coord gith = 0;
4042 if (it->delete_me) return;
4043 if ((it->queued) || (!it->mincalcd))
4045 it->wd->show_item = it;
4046 it->wd->bring_in = EINA_TRUE;
4047 it->showme = EINA_TRUE;
4050 if (it->wd->show_item)
4052 it->wd->show_item->showme = EINA_FALSE;
4053 it->wd->show_item = NULL;
4055 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4056 gith = it->group_item->h;
4057 elm_smart_scroller_child_region_show(it->wd->scr,
4058 it->x + it->block->x,
4059 it->y + it->block->y - gith,
4060 it->block->w, it->h);
4064 * Bring in the given item
4066 * This causes genlist to jump to the given item @p it and show it (by
4067 * scrolling), if it is not fully visible. This may use animation to
4068 * do so and take a period of time
4070 * @param it The item
4075 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4077 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4078 Evas_Coord gith = 0;
4079 if (it->delete_me) return;
4080 if ((it->queued) || (!it->mincalcd))
4082 it->wd->show_item = it;
4083 it->wd->bring_in = EINA_TRUE;
4084 it->showme = EINA_TRUE;
4087 if (it->wd->show_item)
4089 it->wd->show_item->showme = EINA_FALSE;
4090 it->wd->show_item = NULL;
4092 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4093 gith = it->group_item->h;
4094 elm_smart_scroller_region_bring_in(it->wd->scr,
4095 it->x + it->block->x,
4096 it->y + it->block->y - gith,
4097 it->block->w, it->h);
4101 * Show the given item at the top
4103 * This causes genlist to jump to the given item @p it and show it (by
4104 * scrolling), if it is not fully visible.
4106 * @param it The item
4111 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4113 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4115 Evas_Coord gith = 0;
4117 if (it->delete_me) return;
4118 if ((it->queued) || (!it->mincalcd))
4120 it->wd->show_item = it;
4121 it->wd->bring_in = EINA_TRUE;
4122 it->showme = EINA_TRUE;
4125 if (it->wd->show_item)
4127 it->wd->show_item->showme = EINA_FALSE;
4128 it->wd->show_item = NULL;
4130 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4131 if (it->group_item) gith = it->group_item->h;
4132 elm_smart_scroller_child_region_show(it->wd->scr,
4133 it->x + it->block->x,
4134 it->y + it->block->y - gith,
4139 * Bring in the given item at the top
4141 * This causes genlist to jump to the given item @p it and show it (by
4142 * scrolling), if it is not fully visible. This may use animation to
4143 * do so and take a period of time
4145 * @param it The item
4150 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4152 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4154 Evas_Coord gith = 0;
4156 if (it->delete_me) return;
4157 if ((it->queued) || (!it->mincalcd))
4159 it->wd->show_item = it;
4160 it->wd->bring_in = EINA_TRUE;
4161 it->showme = EINA_TRUE;
4164 if (it->wd->show_item)
4166 it->wd->show_item->showme = EINA_FALSE;
4167 it->wd->show_item = NULL;
4169 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4170 if (it->group_item) gith = it->group_item->h;
4171 elm_smart_scroller_region_bring_in(it->wd->scr,
4172 it->x + it->block->x,
4173 it->y + it->block->y - gith,
4178 * Show the given item at the middle
4180 * This causes genlist to jump to the given item @p it and show it (by
4181 * scrolling), if it is not fully visible.
4183 * @param it The item
4188 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4190 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4193 if (it->delete_me) return;
4194 if ((it->queued) || (!it->mincalcd))
4196 it->wd->show_item = it;
4197 it->wd->bring_in = EINA_TRUE;
4198 it->showme = EINA_TRUE;
4201 if (it->wd->show_item)
4203 it->wd->show_item->showme = EINA_FALSE;
4204 it->wd->show_item = NULL;
4206 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4207 elm_smart_scroller_child_region_show(it->wd->scr,
4208 it->x + it->block->x,
4209 it->y + it->block->y - oh / 2 +
4210 it->h / 2, it->block->w, oh);
4214 * Bring in the given item at the middle
4216 * This causes genlist to jump to the given item @p it and show it (by
4217 * scrolling), if it is not fully visible. This may use animation to
4218 * do so and take a period of time
4220 * @param it The item
4225 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4227 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4230 if (it->delete_me) return;
4231 if ((it->queued) || (!it->mincalcd))
4233 it->wd->show_item = it;
4234 it->wd->bring_in = EINA_TRUE;
4235 it->showme = EINA_TRUE;
4238 if (it->wd->show_item)
4240 it->wd->show_item->showme = EINA_FALSE;
4241 it->wd->show_item = NULL;
4243 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4244 elm_smart_scroller_region_bring_in(it->wd->scr,
4245 it->x + it->block->x,
4246 it->y + it->block->y - oh / 2 + it->h / 2,
4251 * Delete a given item
4253 * This deletes the item from genlist and calls the genlist item del
4254 * class callback defined in the item class, if it is set. This clears all
4255 * subitems if it is a tree.
4257 * @param it The item
4262 elm_genlist_item_del(Elm_Genlist_Item *it)
4264 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4265 if ((it->relcount > 0) || (it->walking > 0))
4267 elm_widget_item_pre_notify_del(it);
4268 elm_genlist_item_subitems_clear(it);
4269 it->delete_me = EINA_TRUE;
4270 if (it->wd->show_item == it) it->wd->show_item = NULL;
4272 it->wd->selected = eina_list_remove(it->wd->selected,
4276 if (it->realized) _item_unrealize(it, EINA_FALSE);
4277 it->block->changed = EINA_TRUE;
4278 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4279 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4281 if (it->itc->func.del)
4282 it->itc->func.del((void *)it->base.data, it->base.widget);
4289 * Set the data item from the genlist item
4291 * This set the data value passed on the elm_genlist_item_append() and
4292 * related item addition calls. This function will also call
4293 * elm_genlist_item_update() so the item will be updated to reflect the
4296 * @param it The item
4297 * @param data The new data pointer to set
4302 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4305 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4306 elm_widget_item_data_set(it, data);
4307 elm_genlist_item_update(it);
4311 * Get the data item from the genlist item
4313 * This returns the data value passed on the elm_genlist_item_append()
4314 * and related item addition calls and elm_genlist_item_data_set().
4316 * @param it The item
4317 * @return The data pointer provided when created
4322 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4324 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4325 return elm_widget_item_data_get(it);
4329 * Tells genlist to "orphan" icons fetchs by the item class
4331 * This instructs genlist to release references to icons in the item,
4332 * meaning that they will no longer be managed by genlist and are
4333 * floating "orphans" that can be re-used elsewhere if the user wants
4336 * @param it The item
4341 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4344 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4345 EINA_LIST_FREE(it->icon_objs, icon)
4347 elm_widget_sub_object_del(it->base.widget, icon);
4348 evas_object_smart_member_del(icon);
4349 evas_object_hide(icon);
4354 * Get the real evas object of the genlist item
4356 * This returns the actual evas object used for the specified genlist
4357 * item. This may be NULL as it may not be created, and may be deleted
4358 * at any time by genlist. Do not modify this object (move, resize,
4359 * show, hide etc.) as genlist is controlling it. This function is for
4360 * querying, emitting custom signals or hooking lower level callbacks
4361 * for events. Do not delete this object under any circumstances.
4363 * @param it The item
4364 * @return The object pointer
4368 EAPI const Evas_Object *
4369 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4371 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4372 return it->base.view;
4376 * Update the contents of an item
4378 * This updates an item by calling all the item class functions again
4379 * to get the icons, labels and states. Use this when the original
4380 * item data has changed and the changes are desired to be reflected.
4382 * @param it The item
4387 elm_genlist_item_update(Elm_Genlist_Item *it)
4389 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4390 if (!it->block) return;
4391 if (it->delete_me) return;
4392 it->mincalcd = EINA_FALSE;
4393 it->updateme = EINA_TRUE;
4394 it->block->updateme = EINA_TRUE;
4395 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4396 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4400 * Update the item class of an item
4402 * @param it The item
4403 * @parem itc The item class for the item
4408 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4409 const Elm_Genlist_Item_Class *itc)
4411 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4412 if (!it->block) return;
4413 EINA_SAFETY_ON_NULL_RETURN(itc);
4414 if (it->delete_me) return;
4416 it->nocache = EINA_TRUE;
4417 elm_genlist_item_update(it);
4420 static Evas_Object *
4421 _elm_genlist_item_label_create(void *data,
4423 void *item __UNUSED__)
4425 Evas_Object *label = elm_label_add(obj);
4428 elm_object_style_set(label, "tooltip");
4429 elm_label_label_set(label, data);
4434 _elm_genlist_item_label_del_cb(void *data,
4435 Evas_Object *obj __UNUSED__,
4436 void *event_info __UNUSED__)
4438 eina_stringshare_del(data);
4442 * Set the text to be shown in the genlist item.
4444 * @param item Target item
4445 * @param text The text to set in the content
4447 * Setup the text as tooltip to object. The item can have only one
4448 * tooltip, so any previous tooltip data is removed.
4453 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4456 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4457 text = eina_stringshare_add(text);
4458 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4460 _elm_genlist_item_label_del_cb);
4464 * Set the content to be shown in the tooltip item
4466 * Setup the tooltip to item. The item can have only one tooltip, so
4467 * any previous tooltip data is removed. @p func(with @p data) will be
4468 * called every time that need to show the tooltip and it should return a
4469 * valid Evas_Object. This object is then managed fully by tooltip
4470 * system and is deleted when the tooltip is gone.
4472 * @param item the genlist item being attached by a tooltip.
4473 * @param func the function used to create the tooltip contents.
4474 * @param data what to provide to @a func as callback data/context.
4475 * @param del_cb called when data is not needed anymore, either when
4476 * another callback replaces @func, the tooltip is unset with
4477 * elm_genlist_item_tooltip_unset() or the owner @a item
4478 * dies. This callback receives as the first parameter the
4479 * given @a data, and @c event_info is the item.
4484 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4485 Elm_Tooltip_Item_Content_Cb func,
4487 Evas_Smart_Cb del_cb)
4489 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4491 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4494 if (item->tooltip.del_cb)
4495 item->tooltip.del_cb((void *)item->tooltip.data,
4496 item->base.widget, item);
4498 item->tooltip.content_cb = func;
4499 item->tooltip.data = data;
4500 item->tooltip.del_cb = del_cb;
4502 if (item->base.view)
4504 elm_widget_item_tooltip_content_cb_set(item,
4505 item->tooltip.content_cb,
4506 item->tooltip.data, NULL);
4507 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4513 if (del_cb) del_cb((void *)data, NULL, NULL);
4517 * Unset tooltip from item
4519 * @param item genlist item to remove previously set tooltip.
4521 * Remove tooltip from item. The callback provided as del_cb to
4522 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4523 * it is not used anymore.
4525 * @see elm_genlist_item_tooltip_content_cb_set()
4530 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4532 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4533 if ((item->base.view) && (item->tooltip.content_cb))
4534 elm_widget_item_tooltip_unset(item);
4536 if (item->tooltip.del_cb)
4537 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4538 item->tooltip.del_cb = NULL;
4539 item->tooltip.content_cb = NULL;
4540 item->tooltip.data = NULL;
4541 if (item->tooltip.style)
4542 elm_genlist_item_tooltip_style_set(item, NULL);
4546 * Sets a different style for this item tooltip.
4548 * @note before you set a style you should define a tooltip with
4549 * elm_genlist_item_tooltip_content_cb_set() or
4550 * elm_genlist_item_tooltip_text_set()
4552 * @param item genlist item with tooltip already set.
4553 * @param style the theme style to use (default, transparent, ...)
4558 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4561 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4562 eina_stringshare_replace(&item->tooltip.style, style);
4563 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4567 * Get the style for this item tooltip.
4569 * @param item genlist item with tooltip already set.
4570 * @return style the theme style in use, defaults to "default". If the
4571 * object does not have a tooltip set, then NULL is returned.
4576 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4578 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4579 return item->tooltip.style;
4583 * Set the cursor to be shown when mouse is over the genlist item
4585 * @param item Target item
4586 * @param cursor the cursor name to be used.
4588 * @see elm_object_cursor_set()
4592 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4595 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4596 eina_stringshare_replace(&item->mouse_cursor, cursor);
4597 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4601 * Get the cursor to be shown when mouse is over the genlist item
4603 * @param item genlist item with cursor already set.
4604 * @return the cursor name.
4609 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4612 return elm_widget_item_cursor_get(item);
4616 * Unset the cursor to be shown when mouse is over the genlist item
4618 * @param item Target item
4620 * @see elm_object_cursor_unset()
4624 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4626 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4627 if (!item->mouse_cursor)
4630 if (item->base.view)
4631 elm_widget_item_cursor_unset(item);
4633 eina_stringshare_del(item->mouse_cursor);
4634 item->mouse_cursor = NULL;
4638 * Sets a different style for this item cursor.
4640 * @note before you set a style you should define a cursor with
4641 * elm_genlist_item_cursor_set()
4643 * @param item genlist item with cursor already set.
4644 * @param style the theme style to use (default, transparent, ...)
4649 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4652 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4653 elm_widget_item_cursor_style_set(item, style);
4657 * Get the style for this item cursor.
4659 * @param item genlist item with cursor already set.
4660 * @return style the theme style in use, defaults to "default". If the
4661 * object does not have a cursor set, then NULL is returned.
4666 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4668 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4669 return elm_widget_item_cursor_style_get(item);
4673 * Set if the cursor set should be searched on the theme or should use
4674 * the provided by the engine, only.
4676 * @note before you set if should look on theme you should define a
4677 * cursor with elm_object_cursor_set(). By default it will only look
4678 * for cursors provided by the engine.
4680 * @param item widget item with cursor already set.
4681 * @param engine_only boolean to define it cursors should be looked
4682 * only between the provided by the engine or searched on widget's
4688 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4689 Eina_Bool engine_only)
4691 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4692 elm_widget_item_cursor_engine_only_set(item, engine_only);
4696 * Get the cursor engine only usage for this item cursor.
4698 * @param item widget item with cursor already set.
4699 * @return engine_only boolean to define it cursors should be looked
4700 * only between the provided by the engine or searched on widget's
4701 * theme as well. If the object does not have a cursor set, then
4702 * EINA_FALSE is returned.
4707 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4709 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4710 return elm_widget_item_cursor_engine_only_get(item);
4714 * This sets the horizontal stretching mode
4716 * This sets the mode used for sizing items horizontally. Valid modes
4717 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4718 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4719 * the scroller will scroll horizontally. Otherwise items are expanded
4720 * to fill the width of the viewport of the scroller. If it is
4721 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4722 * limited to that size.
4724 * @param obj The genlist object
4725 * @param mode The mode to use
4730 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4733 ELM_CHECK_WIDTYPE(obj, widtype);
4734 Widget_Data *wd = elm_widget_data_get(obj);
4736 if (wd->mode == mode) return;
4742 * Gets the horizontal stretching mode
4744 * @param obj The genlist object
4745 * @return The mode to use
4746 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4751 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4753 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4754 Widget_Data *wd = elm_widget_data_get(obj);
4755 if (!wd) return ELM_LIST_LAST;
4760 * Set the always select mode.
4762 * Items will only call their selection func and callback when first
4763 * becoming selected. Any further clicks will do nothing, unless you
4764 * enable always select with elm_genlist_always_select_mode_set().
4765 * This means even if selected, every click will make the selected
4766 * callbacks be called.
4768 * @param obj The genlist object
4769 * @param always_select The always select mode
4770 * (EINA_TRUE = on, EINA_FALSE = off)
4775 elm_genlist_always_select_mode_set(Evas_Object *obj,
4776 Eina_Bool always_select)
4778 ELM_CHECK_WIDTYPE(obj, widtype);
4779 Widget_Data *wd = elm_widget_data_get(obj);
4781 wd->always_select = always_select;
4785 * Get the always select mode.
4787 * @param obj The genlist object
4788 * @return The always select mode
4789 * (EINA_TRUE = on, EINA_FALSE = off)
4794 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4796 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4797 Widget_Data *wd = elm_widget_data_get(obj);
4798 if (!wd) return EINA_FALSE;
4799 return wd->always_select;
4803 * Set no select mode
4805 * This will turn off the ability to select items entirely and they
4806 * will neither appear selected nor call selected callback functions.
4808 * @param obj The genlist object
4809 * @param no_select The no select mode
4810 * (EINA_TRUE = on, EINA_FALSE = off)
4815 elm_genlist_no_select_mode_set(Evas_Object *obj,
4816 Eina_Bool no_select)
4818 ELM_CHECK_WIDTYPE(obj, widtype);
4819 Widget_Data *wd = elm_widget_data_get(obj);
4821 wd->no_select = no_select;
4825 * Gets no select mode
4827 * @param obj The genlist object
4828 * @return The no select mode
4829 * (EINA_TRUE = on, EINA_FALSE = off)
4834 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4836 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4837 Widget_Data *wd = elm_widget_data_get(obj);
4838 if (!wd) return EINA_FALSE;
4839 return wd->no_select;
4845 * This will enable the compress mode where items are "compressed"
4846 * horizontally to fit the genlist scrollable viewport width. This is
4847 * special for genlist. Do not rely on
4848 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4849 * work as genlist needs to handle it specially.
4851 * @param obj The genlist object
4852 * @param compress The compress mode
4853 * (EINA_TRUE = on, EINA_FALSE = off)
4858 elm_genlist_compress_mode_set(Evas_Object *obj,
4861 ELM_CHECK_WIDTYPE(obj, widtype);
4862 Widget_Data *wd = elm_widget_data_get(obj);
4864 wd->compress = compress;
4868 * Get the compress mode
4870 * @param obj The genlist object
4871 * @return The compress mode
4872 * (EINA_TRUE = on, EINA_FALSE = off)
4877 elm_genlist_compress_mode_get(const Evas_Object *obj)
4879 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4880 Widget_Data *wd = elm_widget_data_get(obj);
4881 if (!wd) return EINA_FALSE;
4882 return wd->compress;
4886 * Set height-for-width mode
4888 * With height-for-width mode the item width will be fixed (restricted
4889 * to a minimum of) to the list width when calculating its size in
4890 * order to allow the height to be calculated based on it. This allows,
4891 * for instance, text block to wrap lines if the Edje part is
4892 * configured with "text.min: 0 1".
4894 * @note This mode will make list resize slower as it will have to
4895 * recalculate every item height again whenever the list width
4898 * @note When height-for-width mode is enabled, it also enables
4899 * compress mode (see elm_genlist_compress_mode_set()) and
4900 * disables homogeneous (see elm_genlist_homogeneous_set()).
4902 * @param obj The genlist object
4903 * @param setting The height-for-width mode (EINA_TRUE = on,
4909 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4910 Eina_Bool height_for_width)
4912 ELM_CHECK_WIDTYPE(obj, widtype);
4913 Widget_Data *wd = elm_widget_data_get(obj);
4915 wd->height_for_width = !!height_for_width;
4916 if (wd->height_for_width)
4918 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4919 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4924 * Get the height-for-width mode
4926 * @param obj The genlist object
4927 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4933 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4935 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4936 Widget_Data *wd = elm_widget_data_get(obj);
4937 if (!wd) return EINA_FALSE;
4938 return wd->height_for_width;
4944 * This will enable or disable the scroller bounce mode for the
4945 * genlist. See elm_scroller_bounce_set() for details
4947 * @param obj The genlist object
4948 * @param h_bounce Allow bounce horizontally
4949 * @param v_bounce Allow bounce vertically
4954 elm_genlist_bounce_set(Evas_Object *obj,
4958 ELM_CHECK_WIDTYPE(obj, widtype);
4959 Widget_Data *wd = elm_widget_data_get(obj);
4961 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4965 * Get the bounce mode
4967 * @param obj The genlist object
4968 * @param h_bounce Allow bounce horizontally
4969 * @param v_bounce Allow bounce vertically
4974 elm_genlist_bounce_get(const Evas_Object *obj,
4975 Eina_Bool *h_bounce,
4976 Eina_Bool *v_bounce)
4978 ELM_CHECK_WIDTYPE(obj, widtype);
4979 Widget_Data *wd = elm_widget_data_get(obj);
4981 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4985 * Set homogenous mode
4987 * This will enable the homogeneous mode where items are of the same
4988 * height and width so that genlist may do the lazy-loading at its
4989 * maximum. This implies 'compressed' mode.
4991 * @param obj The genlist object
4992 * @param homogeneous Assume the items within the genlist are of the
4993 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4998 elm_genlist_homogeneous_set(Evas_Object *obj,
4999 Eina_Bool homogeneous)
5001 ELM_CHECK_WIDTYPE(obj, widtype);
5002 Widget_Data *wd = elm_widget_data_get(obj);
5004 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5005 wd->homogeneous = homogeneous;
5009 * Get the homogenous mode
5011 * @param obj The genlist object
5012 * @return Assume the items within the genlist are of the same height
5013 * and width (EINA_TRUE = on, EINA_FALSE = off)
5018 elm_genlist_homogeneous_get(const Evas_Object *obj)
5020 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5021 Widget_Data *wd = elm_widget_data_get(obj);
5022 if (!wd) return EINA_FALSE;
5023 return wd->homogeneous;
5027 * Set the maximum number of items within an item block
5029 * This will configure the block count to tune to the target with
5030 * particular performance matrix.
5032 * @param obj The genlist object
5033 * @param n Maximum number of items within an item block
5038 elm_genlist_block_count_set(Evas_Object *obj,
5041 ELM_CHECK_WIDTYPE(obj, widtype);
5042 Widget_Data *wd = elm_widget_data_get(obj);
5044 wd->max_items_per_block = n;
5045 wd->item_cache_max = wd->max_items_per_block * 2;
5046 _item_cache_clean(wd);
5050 * Get the maximum number of items within an item block
5052 * @param obj The genlist object
5053 * @return Maximum number of items within an item block
5058 elm_genlist_block_count_get(const Evas_Object *obj)
5060 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5061 Widget_Data *wd = elm_widget_data_get(obj);
5063 return wd->max_items_per_block;
5067 * Set the timeout in seconds for the longpress event
5069 * @param obj The genlist object
5070 * @param timeout timeout in seconds
5075 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5078 ELM_CHECK_WIDTYPE(obj, widtype);
5079 Widget_Data *wd = elm_widget_data_get(obj);
5081 wd->longpress_timeout = timeout;
5085 * Get the timeout in seconds for the longpress event
5087 * @param obj The genlist object
5088 * @return timeout in seconds
5093 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5095 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5096 Widget_Data *wd = elm_widget_data_get(obj);
5098 return wd->longpress_timeout;
5102 * Set the scrollbar policy
5104 * This sets the scrollbar visibility policy for the given genlist
5105 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5106 * made visible if it is needed, and otherwise kept hidden.
5107 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5108 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5109 * respectively for the horizontal and vertical scrollbars.
5111 * @param obj The genlist object
5112 * @param policy_h Horizontal scrollbar policy
5113 * @param policy_v Vertical scrollbar policy
5118 elm_genlist_scroller_policy_set(Evas_Object *obj,
5119 Elm_Scroller_Policy policy_h,
5120 Elm_Scroller_Policy policy_v)
5122 ELM_CHECK_WIDTYPE(obj, widtype);
5123 Widget_Data *wd = elm_widget_data_get(obj);
5125 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5126 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5129 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5133 * Get the scrollbar policy
5135 * @param obj The genlist object
5136 * @param policy_h Horizontal scrollbar policy
5137 * @param policy_v Vertical scrollbar policy
5142 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5143 Elm_Scroller_Policy *policy_h,
5144 Elm_Scroller_Policy *policy_v)
5146 ELM_CHECK_WIDTYPE(obj, widtype);
5147 Widget_Data *wd = elm_widget_data_get(obj);
5148 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5149 if ((!wd) || (!wd->scr)) return;
5150 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5151 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5152 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5156 * Update the contents of all realized items
5158 * This updates all realized items by calling all the item class functions again
5159 * to get the icons, labels and states. Use this when the original
5160 * item data has changed and the changes are desired to be reflected.
5162 * @param it The item
5167 elm_genlist_realized_items_update(Evas_Object *obj)
5169 ELM_CHECK_WIDTYPE(obj, widtype);
5171 Eina_List *list, *l;
5172 Elm_Genlist_Item *it;
5174 list = elm_genlist_realized_items_get(obj);
5175 EINA_LIST_FOREACH(list, l, it)
5176 elm_genlist_item_update(it);
5180 * Set genlist item mode
5182 * @param item The genlist item
5183 * @param mode Mode name
5184 * @param mode_set Boolean to define set or unset mode.
5189 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5190 const char *mode_type,
5193 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5194 Widget_Data *wd = it->wd;
5196 Elm_Genlist_Item *it2;
5199 if (!mode_type) return;
5201 if ((wd->mode_item == it) &&
5202 (!strcmp(mode_type, wd->mode_type)) &&
5205 if (!it->itc->mode_item_style) return;
5209 EINA_LIST_FOREACH(wd->selected, l, it2)
5211 elm_genlist_item_selected_set(it2, EINA_FALSE);
5215 it2 = elm_genlist_selected_item_get(wd->obj);
5216 if ((it2) && (it2->realized))
5217 elm_genlist_item_selected_set(it2, EINA_FALSE);
5220 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5222 ((it == wd->mode_item) && (!mode_set)))
5223 _item_mode_unset(wd);
5225 eina_stringshare_replace(&wd->mode_type, mode_type);
5226 if (mode_set) _item_mode_set(it);
5230 * Get active genlist mode type
5232 * @param obj The genlist object
5237 elm_genlist_mode_get(const Evas_Object *obj)
5239 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5240 Widget_Data *wd = elm_widget_data_get(obj);
5241 if (!wd) return NULL;
5242 return wd->mode_type;
5246 * Get active genlist mode item
5248 * @param obj The genlist object
5252 EAPI const Elm_Genlist_Item *
5253 elm_genlist_mode_item_get(const Evas_Object *obj)
5255 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5256 Widget_Data *wd = elm_widget_data_get(obj);
5257 if (!wd) return NULL;
5258 return wd->mode_item;