3 #include <Elementary.h>
4 #include <Elementary_Cursor.h>
8 #define MAX_ITEMS_PER_BLOCK 32
11 * @defgroup Genlist Genlist
13 * The aim was to have more expansive list than the simple list in
14 * Elementary that could have more flexible items and allow many more entries
15 * while still being fast and low on memory usage. At the same time it was
16 * also made to be able to do tree structures. But the price to pay is more
17 * complex when it comes to usage. If all you want is a simple list with
18 * icons and a single label, use the normal List object.
20 * Genlist has a fairly large API, mostly because it's relatively complex,
21 * trying to be both expansive, powerful and efficient. First we will begin
22 * an overview on the theory behind genlist.
24 * Evas tracks every object you create. Every time it processes an event
25 * (mouse move, down, up etc.) it needs to walk through objects and find out
26 * what event that affects. Even worse every time it renders display updates,
27 * in order to just calculate what to re-draw, it needs to walk through many
28 * many many objects. Thus, the more objects you keep active, the more
29 * overhead Evas has in just doing its work. It is advisable to keep your
30 * active objects to the minimum working set you need. Also remember that
31 * object creation and deletion carries an overhead, so there is a
32 * middle-ground, which is not easily determined. But don't keep massive lists
33 * of objects you can't see or use. Genlist does this with list objects. It
34 * creates and destroys them dynamically as you scroll around. It groups them
35 * into blocks so it can determine the visibility etc. of a whole block at
36 * once as opposed to having to walk the whole list. This 2-level list allows
37 * for very large numbers of items to be in the list (tests have used up to
38 * 2,000,000 items). Also genlist employs a queue for adding items. As items
39 * may be different sizes, every item added needs to be calculated as to its
40 * size and thus this presents a lot of overhead on populating the list, this
41 * genlist employs a queue. Any item added is queued and spooled off over
42 * time, actually appearing some time later, so if your list has many members
43 * you may find it takes a while for them to all appear, with your process
44 * consuming a lot of CPU while it is busy spooling.
46 * Genlist also implements a tree structure, but it does so with callbacks to
47 * the application, with the application filling in tree structures when
48 * requested (allowing for efficient building of a very deep tree that could
49 * even be used for file-management). See the above smart signal callbacks for
52 * An item in the genlist world can have 0 or more text labels (they can be
53 * regular text or textblock - that's up to the style to determine), 0 or
54 * more icons (which are simply objects swallowed into the genlist item) and
55 * 0 or more boolean states that can be used for check, radio or other
56 * indicators by the edje theme style. An item may be one of several styles
57 * (Elementary provides 4 by default - "default", "double_label", "group_index"
58 * and "icon_top_text_bottom", but this can be extended by system or
59 * application custom themes/overlays/extensions).
61 * In order to implement the ability to add and delete items on the fly,
62 * Genlist implements a class/callback system where the application provides
63 * a structure with information about that type of item (genlist may contain
64 * multiple different items with different classes, states and styles).
65 * Genlist will call the functions in this struct (methods) when an item is
66 * "realized" (that is created dynamically while scrolling). All objects will
67 * simply be deleted when no longer needed with evas_object_del(). The
68 * Elm_Genlist_Item_Class structure contains the following members:
70 * item_style - This is a constant string and simply defines the name of the
71 * item style. It must be specified and the default should be "default".
73 * func.label_get - This function is called when an actual item object is
74 * created. The data parameter is the data parameter passed to
75 * elm_genlist_item_append() and related item creation functions. The obj
76 * parameter is the genlist object and the part parameter is the string name
77 * of the text part in the edje design that is listed as one of the possible
78 * labels that can be set. This function must return a strudup()'ed string as
79 * the caller will free() it when done.
81 * func.icon_get - This function is called when an actual item object is
82 * created. The data parameter is the data parameter passed to
83 * elm_genlist_item_append() and related item creation functions. The obj
84 * parameter is the genlist object and the part parameter is the string name
85 * of the icon part in the edje design that is listed as one of the possible
86 * icons that can be set. This must return NULL for no object or a valid
87 * object. The object will be deleted by genlist on shutdown or when the item
90 * func.state_get - This function is called when an actual item object is
91 * created. The data parameter is the data parameter passed to
92 * elm_genlist_item_append() and related item creation functions. The obj
93 * parameter is the genlist object and the part parameter is the string name
94 * of the state part in the edje design that is listed as one of the possible
95 * states that can be set. Return 0 for false or 1 for true. Genlist will
96 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
97 * true (the default is false), where XXX is the name of the part.
99 * func.del - This is called when elm_genlist_item_del() is called on an
100 * item, elm_genlist_clear() is called on the genlist, or
101 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
102 * intended for use when actual genlist items are deleted, so any backing
103 * data attached to the item (e.g. its data parameter on creation) can be
106 * Items can be added by several calls. All of them return a Elm_Genlist_Item
107 * handle that is an internal member inside the genlist. They all take a data
108 * parameter that is meant to be used for a handle to the applications
109 * internal data (eg the struct with the original item data). The parent
110 * parameter is the parent genlist item this belongs to if it is a tree or
111 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
112 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
113 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
114 * is displayed as an item that is able to expand and have child items.
115 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
116 * displayed at the top until the next group comes. The func parameter is a
117 * convenience callback that is called when the item is selected and the data
118 * parameter will be the func_data parameter, obj be the genlist object and
119 * event_info will be the genlist item.
121 * elm_genlist_item_append() appends an item to the end of the list, or if
122 * there is a parent, to the end of all the child items of the parent.
123 * elm_genlist_item_prepend() is the same but prepends to the beginning of
124 * the list or children list. elm_genlist_item_insert_before() inserts at
125 * item before another item and elm_genlist_item_insert_after() inserts after
126 * the indicated item.
128 * The application can clear the list with elm_genlist_clear() which deletes
129 * all the items in the list and elm_genlist_item_del() will delete a specific
130 * item. elm_genlist_item_subitems_clear() will clear all items that are
131 * children of the indicated parent item.
133 * If the application wants multiple items to be able to be selected,
134 * elm_genlist_multi_select_set() can enable this. If the list is
135 * single-selection only (the default), then elm_genlist_selected_item_get()
136 * will return the selected item, if any, or NULL I none is selected. If the
137 * list is multi-select then elm_genlist_selected_items_get() will return a
138 * list (that is only valid as long as no items are modified (added, deleted,
139 * selected or unselected)).
141 * To help inspect list items you can jump to the item at the top of the list
142 * with elm_genlist_first_item_get() which will return the item pointer, and
143 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
144 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
145 * and previous items respectively relative to the indicated item. Using
146 * these calls you can walk the entire item list/tree. Note that as a tree
147 * the items are flattened in the list, so elm_genlist_item_parent_get() will
148 * let you know which item is the parent (and thus know how to skip them if
151 * There are also convenience functions. elm_genlist_item_genlist_get() will
152 * return the genlist object the item belongs to. elm_genlist_item_show()
153 * will make the scroller scroll to show that specific item so its visible.
154 * elm_genlist_item_data_get() returns the data pointer set by the item
155 * creation functions.
157 * If an item changes (state of boolean changes, label or icons change),
158 * then use elm_genlist_item_update() to have genlist update the item with
159 * the new state. Genlist will re-realize the item thus call the functions
160 * in the _Elm_Genlist_Item_Class for that item.
162 * To programmatically (un)select an item use elm_genlist_item_selected_set().
163 * To get its selected state use elm_genlist_item_selected_get(). Similarly
164 * to expand/contract an item and get its expanded state, use
165 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
166 * again to make an item disabled (unable to be selected and appear
167 * differently) use elm_genlist_item_disabled_set() to set this and
168 * elm_genlist_item_disabled_get() to get the disabled state.
170 * In general to indicate how the genlist should expand items horizontally to
171 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
172 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
173 * mode means that if items are too wide to fit, the scroller will scroll
174 * horizontally. Otherwise items are expanded to fill the width of the
175 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
176 * to the viewport width and limited to that size. This can be combined with
177 * a different style that uses edjes' ellipsis feature (cutting text off like
180 * Items will only call their selection func and callback when first becoming
181 * selected. Any further clicks will do nothing, unless you enable always
182 * select with elm_genlist_always_select_mode_set(). This means even if
183 * selected, every click will make the selected callbacks be called.
184 * elm_genlist_no_select_mode_set() will turn off the ability to select
185 * items entirely and they will neither appear selected nor call selected
186 * callback functions.
188 * Remember that you can create new styles and add your own theme augmentation
189 * per application with elm_theme_extension_add(). If you absolutely must
190 * have a specific style that overrides any theme the user or system sets up
191 * you can use elm_theme_overlay_add() to add such a file.
193 * Signals that you can add callbacks for are:
195 * "clicked,double" - This is called when a user has double-clicked an item. The
196 * event_info parameter is the genlist item that was double-c
198 * "selected" - This is called when a user has made an item selected. The
199 * event_info parameter is the genlist item that was selected.
200 * "unselected" - This is called when a user has made an item unselected. The
201 * event_info parameter is the genlist item that was unselected.
202 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
203 * and the item is now meant to be expanded. The event_info
204 * parameter is the genlist item that was indicated to expand. It
205 * is the job of this callback to then fill in the child items.
206 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
207 * and the item is now meant to be contracted. The event_info
208 * parameter is the genlist item that was indicated to contract.
209 * It is the job of this callback to then delete the child items.
210 * "expand,request" - This is called when a user has indicated they want to
211 * expand a tree branch item. The callback should decide if
212 * the item can expand (has any children) and then call
213 * elm_genlist_item_expanded_set() appropriately to set the
214 * state. The event_info parameter is the genlist item that
215 * was indicated to expand.
216 * "contract,request" - This is called when a user has indicated they want to
217 * contract a tree branch item. The callback should decide
218 * if the item can contract (has any children) and then
219 * call elm_genlist_item_expanded_set() appropriately to
220 * set the state. The event_info parameter is the genlist
221 * item that was indicated to contract.
222 * "realized" - This is called when the item in the list is created as a real
223 * evas object. event_info parameter is the genlist item that was
224 * created. The object may be deleted at any time, so it is up to
225 * the caller to not use the object pointer from
226 * elm_genlist_item_object_get() in a way where it may point to
228 * "unrealized" - This is called just before an item is unrealized. After this
229 * call icon objects provided will be deleted and the item object
230 * itself delete or be put into a floating cache.
231 * "drag,start,up" - This is called when the item in the list has been dragged
233 * "drag,start,down" - This is called when the item in the list has been dragged
234 * (not scrolled) down.
235 * "drag,start,left" - This is called when the item in the list has been dragged
236 * (not scrolled) left.
237 * "drag,start,right" - This is called when the item in the list has been
238 * dragged (not scrolled) right.
239 * "drag,stop" - This is called when the item in the list has stopped being
241 * "drag" - This is called when the item in the list is being dragged.
242 * "longpressed" - This is called when the item is pressed for a certain amount
243 * of time. By default it's 1 second.
244 * "scroll,edge,top" - This is called when the genlist is scrolled until the
246 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
248 * "scroll,edge,left" - This is called when the genlist is scrolled until the
250 * "scroll,edge,right" - This is called when the genlist is scrolled until the
252 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
254 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
256 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
257 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
259 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
261 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
264 typedef struct _Widget_Data Widget_Data;
265 typedef struct _Item_Block Item_Block;
266 typedef struct _Pan Pan;
267 typedef struct _Item_Cache Item_Cache;
271 Evas_Object *obj, *scr, *pan_smart;
272 Eina_Inlist *items, *blocks;
273 Eina_List *group_items;
275 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
276 Ecore_Job *calc_job, *update_job;
277 Ecore_Idler *queue_idler, *must_recalc_idler;
278 Eina_List *queue, *selected;
279 Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
280 Eina_Inlist *item_cache;
283 Ecore_Timer *multi_timer, *scr_hold_timer;
284 const char *mode_type;
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;
327 Evas_Coord x, y, w, h, minw, minh;
328 Eina_Bool want_unrealize : 1;
329 Eina_Bool realized : 1;
330 Eina_Bool changed : 1;
331 Eina_Bool updateme : 1;
332 Eina_Bool showme : 1;
333 Eina_Bool must_recalc : 1;
336 struct _Elm_Genlist_Item
338 Elm_Widget_Item base;
343 Evas_Coord x, y, w, h, minw, minh;
344 const Elm_Genlist_Item_Class *itc;
345 Elm_Genlist_Item *parent;
346 Elm_Genlist_Item *group_item;
347 Elm_Genlist_Item_Flags flags;
355 Eina_List *labels, *icons, *states, *icon_objs;
356 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
357 Ecore_Timer *long_timer;
358 Ecore_Timer *swipe_timer;
360 Evas_Coord scrl_x, scrl_y;
362 Elm_Genlist_Item *rel;
363 Evas_Object *mode_view;
368 Elm_Tooltip_Item_Content_Cb content_cb;
369 Evas_Smart_Cb del_cb;
373 const char *mouse_cursor;
380 Eina_Bool before : 1;
382 Eina_Bool want_unrealize : 1;
383 Eina_Bool want_realize : 1;
384 Eina_Bool realized : 1;
385 Eina_Bool selected : 1;
386 Eina_Bool highlighted : 1;
387 Eina_Bool expanded : 1;
388 Eina_Bool disabled : 1;
389 Eina_Bool display_only : 1;
390 Eina_Bool mincalcd : 1;
391 Eina_Bool queued : 1;
392 Eina_Bool showme : 1;
393 Eina_Bool delete_me : 1;
395 Eina_Bool dragging : 1;
396 Eina_Bool updateme : 1;
397 Eina_Bool nocache : 1;
398 Eina_Bool stacking_even : 1;
399 Eina_Bool nostacking : 1;
406 Evas_Object *base_view, *spacer;
408 const char *item_style; // it->itc->item_style
409 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
410 Eina_Bool compress : 1; // it->wd->compress
412 Eina_Bool selected : 1; // it->selected
413 Eina_Bool disabled : 1; // it->disabled
414 Eina_Bool expanded : 1; // it->expanded
417 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
418 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
422 Evas_Object_Smart_Clipped_Data __clipped_data;
424 Ecore_Job *resize_job;
427 static const char *widtype = NULL;
428 static void _item_cache_zero(Widget_Data *wd);
429 static void _del_hook(Evas_Object *obj);
430 static void _mirrored_set(Evas_Object *obj,
432 static void _theme_hook(Evas_Object *obj);
433 static void _show_region_hook(void *data,
435 static void _sizing_eval(Evas_Object *obj);
436 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
437 static void _item_block_unrealize(Item_Block *itb);
438 static void _calc_job(void *data);
439 static void _on_focus_hook(void *data,
441 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
442 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
443 static Eina_Bool _item_single_select_up(Widget_Data *wd);
444 static Eina_Bool _item_single_select_down(Widget_Data *wd);
445 static Eina_Bool _event_hook(Evas_Object *obj,
447 Evas_Callback_Type type,
449 static void _signal_emit_hook(Evas_Object *obj,
450 const char *emission,
452 static Eina_Bool _deselect_all_items(Widget_Data *wd);
453 static void _pan_calculate(Evas_Object *obj);
454 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
455 static void _mode_item_realize(Elm_Genlist_Item *it);
456 static void _mode_item_unrealize(Elm_Genlist_Item *it);
457 static void _item_mode_set(Elm_Genlist_Item *it);
458 static void _item_mode_unset(Widget_Data *wd);
460 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
463 _event_hook(Evas_Object *obj,
464 Evas_Object *src __UNUSED__,
465 Evas_Callback_Type type,
468 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
469 Evas_Event_Key_Down *ev = event_info;
470 Widget_Data *wd = elm_widget_data_get(obj);
471 if (!wd) return EINA_FALSE;
472 if (!wd->items) return EINA_FALSE;
473 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
474 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
476 Elm_Genlist_Item *it = NULL;
479 Evas_Coord step_x = 0;
480 Evas_Coord step_y = 0;
483 Evas_Coord page_x = 0;
484 Evas_Coord page_y = 0;
486 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
487 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
488 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
489 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
491 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
495 else if ((!strcmp(ev->keyname, "Right")) ||
496 (!strcmp(ev->keyname, "KP_Right")))
500 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
502 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
503 (_item_multi_select_up(wd)))
504 || (_item_single_select_up(wd)))
506 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
512 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
514 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
515 (_item_multi_select_down(wd)))
516 || (_item_single_select_down(wd)))
518 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
524 else if ((!strcmp(ev->keyname, "Home")) ||
525 (!strcmp(ev->keyname, "KP_Home")))
527 it = elm_genlist_first_item_get(obj);
528 elm_genlist_item_bring_in(it);
529 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
532 else if ((!strcmp(ev->keyname, "End")) ||
533 (!strcmp(ev->keyname, "KP_End")))
535 it = elm_genlist_last_item_get(obj);
536 elm_genlist_item_bring_in(it);
537 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
540 else if ((!strcmp(ev->keyname, "Prior")) ||
541 (!strcmp(ev->keyname, "KP_Prior")))
544 y -= -(page_y * v_h) / 100;
548 else if ((!strcmp(ev->keyname, "Next")) ||
549 (!strcmp(ev->keyname, "KP_Next")))
552 y += -(page_y * v_h) / 100;
556 else if(((!strcmp(ev->keyname, "Return")) ||
557 (!strcmp(ev->keyname, "KP_Enter")) ||
558 (!strcmp(ev->keyname, "space")))
559 && (!wd->multi) && (wd->selected))
561 it = elm_genlist_selected_item_get(obj);
562 elm_genlist_item_expanded_set(it,
563 !elm_genlist_item_expanded_get(it));
565 else if (!strcmp(ev->keyname, "Escape"))
567 if (!_deselect_all_items(wd)) return EINA_FALSE;
568 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
571 else return EINA_FALSE;
573 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
574 elm_smart_scroller_child_pos_set(wd->scr, x, y);
579 _deselect_all_items(Widget_Data *wd)
581 if (!wd->selected) return EINA_FALSE;
583 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
589 _item_multi_select_up(Widget_Data *wd)
591 if (!wd->selected) return EINA_FALSE;
592 if (!wd->multi) return EINA_FALSE;
594 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
595 if (!prev) return EINA_TRUE;
597 if (elm_genlist_item_selected_get(prev))
599 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
600 wd->last_selected_item = prev;
601 elm_genlist_item_show(wd->last_selected_item);
605 elm_genlist_item_selected_set(prev, EINA_TRUE);
606 elm_genlist_item_show(prev);
612 _item_multi_select_down(Widget_Data *wd)
614 if (!wd->selected) return EINA_FALSE;
615 if (!wd->multi) return EINA_FALSE;
617 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
618 if (!next) return EINA_TRUE;
620 if (elm_genlist_item_selected_get(next))
622 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
623 wd->last_selected_item = next;
624 elm_genlist_item_show(wd->last_selected_item);
628 elm_genlist_item_selected_set(next, EINA_TRUE);
629 elm_genlist_item_show(next);
635 _item_single_select_up(Widget_Data *wd)
637 Elm_Genlist_Item *prev;
640 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
641 while ((prev) && (prev->delete_me))
642 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
644 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
646 if (!prev) return EINA_FALSE;
648 _deselect_all_items(wd);
650 elm_genlist_item_selected_set(prev, EINA_TRUE);
651 elm_genlist_item_show(prev);
656 _item_single_select_down(Widget_Data *wd)
658 Elm_Genlist_Item *next;
661 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
662 while ((next) && (next->delete_me))
663 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
665 else next = elm_genlist_item_next_get(wd->last_selected_item);
667 if (!next) return EINA_FALSE;
669 _deselect_all_items(wd);
671 elm_genlist_item_selected_set(next, EINA_TRUE);
672 elm_genlist_item_show(next);
677 _on_focus_hook(void *data __UNUSED__,
680 Widget_Data *wd = elm_widget_data_get(obj);
682 if (elm_widget_focus_get(obj))
684 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
685 evas_object_focus_set(wd->obj, EINA_TRUE);
686 if ((wd->selected) && (!wd->last_selected_item))
687 wd->last_selected_item = eina_list_data_get(wd->selected);
691 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
692 evas_object_focus_set(wd->obj, EINA_FALSE);
697 _del_hook(Evas_Object *obj)
699 Widget_Data *wd = elm_widget_data_get(obj);
701 _item_cache_zero(wd);
702 if (wd->calc_job) ecore_job_del(wd->calc_job);
703 if (wd->update_job) ecore_job_del(wd->update_job);
704 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
705 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
706 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
707 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
712 _del_pre_hook(Evas_Object *obj)
714 Widget_Data *wd = elm_widget_data_get(obj);
716 evas_object_del(wd->pan_smart);
717 wd->pan_smart = NULL;
718 elm_genlist_clear(obj);
722 _mirrored_set(Evas_Object *obj,
725 Widget_Data *wd = elm_widget_data_get(obj);
727 _item_cache_zero(wd);
728 elm_smart_scroller_mirrored_set(wd->scr, rtl);
732 _theme_hook(Evas_Object *obj)
734 Widget_Data *wd = elm_widget_data_get(obj);
737 _item_cache_zero(wd);
738 _elm_widget_mirrored_reload(obj);
739 _mirrored_set(obj, elm_widget_mirrored_get(obj));
740 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
741 elm_widget_style_get(obj));
742 edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
743 wd->item_width = wd->item_height = 0;
744 wd->group_item_width = wd->group_item_height = 0;
745 wd->minw = wd->minh = wd->realminw = 0;
746 EINA_INLIST_FOREACH(wd->blocks, itb)
749 Elm_Genlist_Item *it;
751 if (itb->realized) _item_block_unrealize(itb);
752 EINA_LIST_FOREACH(itb->items, l, it)
753 it->mincalcd = EINA_FALSE;
755 itb->changed = EINA_TRUE;
757 if (wd->calc_job) ecore_job_del(wd->calc_job);
758 wd->calc_job = ecore_job_add(_calc_job, wd);
763 _show_region_hook(void *data,
766 Widget_Data *wd = elm_widget_data_get(data);
767 Evas_Coord x, y, w, h;
769 elm_widget_show_region_get(obj, &x, &y, &w, &h);
770 //x & y are screen coordinates, Add with pan coordinates
773 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
777 _sizing_eval(Evas_Object *obj)
779 Widget_Data *wd = elm_widget_data_get(obj);
780 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
782 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
783 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
785 if (wd->height_for_width)
789 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
790 if ((vw != 0) && (vw != wd->prev_viewport_w))
794 wd->prev_viewport_w = vw;
795 EINA_INLIST_FOREACH(wd->blocks, itb)
797 itb->must_recalc = EINA_TRUE;
799 if (wd->calc_job) ecore_job_del(wd->calc_job);
800 wd->calc_job = ecore_job_add(_calc_job, wd);
803 if (wd->mode == ELM_LIST_LIMIT)
805 Evas_Coord vmw, vmh, vw, vh;
809 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
810 if ((minw > 0) && (vw < minw)) vw = minw;
811 else if ((maxw > 0) && (vw > maxw))
813 edje_object_size_min_calc
814 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
821 edje_object_size_min_calc
822 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
826 evas_object_size_hint_min_set(obj, minw, minh);
827 evas_object_size_hint_max_set(obj, maxw, maxh);
831 _signal_emit_hook(Evas_Object *obj,
832 const char *emission,
835 Widget_Data *wd = elm_widget_data_get(obj);
836 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
841 _item_highlight(Elm_Genlist_Item *it)
843 const char *selectraise;
844 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
845 (it->disabled) || (it->display_only) || (it->mode_view))
847 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
848 selectraise = edje_object_data_get(it->base.view, "selectraise");
849 if ((selectraise) && (!strcmp(selectraise, "on")))
851 evas_object_raise(it->base.view);
852 if ((it->group_item) && (it->group_item->realized))
853 evas_object_raise(it->group_item->base.view);
855 it->highlighted = EINA_TRUE;
859 _item_block_del(Elm_Genlist_Item *it)
862 Item_Block *itb = it->block;
864 itb->items = eina_list_remove(itb->items, it);
866 itb->changed = EINA_TRUE;
867 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
868 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
871 il = EINA_INLIST_GET(itb);
872 Item_Block *itbn = (Item_Block *)(il->next);
874 it->parent->items = eina_list_remove(it->parent->items, it);
876 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
878 if (itbn) itbn->changed = EINA_TRUE;
884 il = EINA_INLIST_GET(itb);
885 Item_Block *itbp = (Item_Block *)(il->prev);
886 Item_Block *itbn = (Item_Block *)(il->next);
887 if ((itbp) && ((itbp->count + itb->count) < 48))
889 Elm_Genlist_Item *it2;
891 EINA_LIST_FREE(itb->items, it2)
894 itbp->items = eina_list_append(itbp->items, it2);
896 itbp->changed = EINA_TRUE;
898 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
899 EINA_INLIST_GET(itb));
902 else if ((itbn) && ((itbn->count + itb->count) < 48))
906 Eina_List *last = eina_list_last(itb->items);
907 Elm_Genlist_Item *it2 = last->data;
910 itb->items = eina_list_remove_list(itb->items, last);
911 itbn->items = eina_list_prepend(itbn->items, it2);
913 itbn->changed = EINA_TRUE;
916 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
924 _item_del(Elm_Genlist_Item *it)
926 elm_widget_item_pre_notify_del(it);
927 elm_genlist_item_subitems_clear(it);
928 it->wd->walking -= it->walking;
929 if (it->wd->show_item == it) it->wd->show_item = NULL;
930 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
931 if (it->realized) _item_unrealize(it, EINA_FALSE);
932 if (it->block) _item_block_del(it);
933 if ((!it->delete_me) && (it->itc->func.del))
934 it->itc->func.del((void *)it->base.data, it->base.widget);
935 it->delete_me = EINA_TRUE;
937 it->wd->queue = eina_list_remove(it->wd->queue, it);
938 if (it->wd->anchor_item == it)
940 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
941 if (!it->wd->anchor_item)
942 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
944 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
946 it->parent->items = eina_list_remove(it->parent->items, it);
947 if (it->flags & ELM_GENLIST_ITEM_GROUP)
948 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
949 if (it->long_timer) ecore_timer_del(it->long_timer);
950 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
952 if (it->tooltip.del_cb)
953 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
955 elm_widget_item_del(it);
959 _item_select(Elm_Genlist_Item *it)
961 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
964 if (it->wd->always_select) goto call;
967 it->selected = EINA_TRUE;
968 it->wd->selected = eina_list_append(it->wd->selected, it);
972 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
974 evas_object_smart_callback_call(it->base.widget, "selected", it);
977 if ((it->wd->clear_me) && (!it->wd->walking))
978 elm_genlist_clear(it->base.widget);
981 if ((!it->walking) && (it->delete_me))
983 if (!it->relcount) _item_del(it);
986 it->wd->last_selected_item = it;
990 _item_unselect(Elm_Genlist_Item *it)
992 const char *stacking, *selectraise;
994 if ((it->delete_me) || (!it->highlighted)) return;
995 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
996 stacking = edje_object_data_get(it->base.view, "stacking");
997 selectraise = edje_object_data_get(it->base.view, "selectraise");
1000 if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
1001 else evas_object_raise(it->base.view);
1003 it->highlighted = EINA_FALSE;
1006 it->selected = EINA_FALSE;
1007 it->wd->selected = eina_list_remove(it->wd->selected, it);
1008 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1013 _mouse_move(void *data,
1014 Evas *evas __UNUSED__,
1018 Elm_Genlist_Item *it = data;
1019 Evas_Event_Mouse_Move *ev = event_info;
1020 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1022 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1024 if (!it->wd->on_hold)
1026 it->wd->on_hold = EINA_TRUE;
1027 if (!it->wd->wasselected)
1031 if (it->wd->multitouched)
1033 it->wd->cur_x = ev->cur.canvas.x;
1034 it->wd->cur_y = ev->cur.canvas.y;
1037 if ((it->dragging) && (it->down))
1039 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1042 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1043 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1044 if (abs((it->wd->history[it->wd->movements].x -
1045 it->wd->history[0].x)) > 40)
1046 it->wd->swipe = EINA_TRUE;
1048 it->wd->movements++;
1052 ecore_timer_del(it->long_timer);
1053 it->long_timer = NULL;
1055 evas_object_smart_callback_call(it->base.widget, "drag", it);
1058 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1062 ecore_timer_del(it->long_timer);
1063 it->long_timer = NULL;
1067 if (!it->display_only)
1068 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1069 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1070 x = ev->cur.canvas.x - x;
1071 y = ev->cur.canvas.y - y;
1074 if (adx < 0) adx = -dx;
1077 if (ady < 0) ady = -dy;
1080 if ((adx > minw) || (ady > minh))
1082 it->dragging = EINA_TRUE;
1085 ecore_timer_del(it->long_timer);
1086 it->long_timer = NULL;
1088 if (!it->wd->wasselected)
1093 evas_object_smart_callback_call(it->base.widget,
1094 "drag,start,up", it);
1098 evas_object_smart_callback_call(it->base.widget,
1099 "drag,start,left", it);
1101 evas_object_smart_callback_call(it->base.widget,
1102 "drag,start,right", it);
1108 evas_object_smart_callback_call(it->base.widget,
1109 "drag,start,down", it);
1113 evas_object_smart_callback_call(it->base.widget,
1114 "drag,start,left", it);
1116 evas_object_smart_callback_call(it->base.widget,
1117 "drag,start,right", it);
1124 _long_press(void *data)
1126 Elm_Genlist_Item *it = data;
1128 it->long_timer = NULL;
1129 if ((it->disabled) || (it->dragging) || (it->display_only))
1130 return ECORE_CALLBACK_CANCEL;
1131 it->wd->longpressed = EINA_TRUE;
1132 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1133 return ECORE_CALLBACK_CANCEL;
1137 _swipe(Elm_Genlist_Item *it)
1142 if ((it->display_only) || (it->disabled)) return;
1143 it->wd->swipe = EINA_FALSE;
1144 for (i = 0; i < it->wd->movements; i++)
1146 sum += it->wd->history[i].x;
1147 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1150 sum /= it->wd->movements;
1151 if (abs(sum - it->wd->history[0].x) <= 10) return;
1152 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1156 _swipe_cancel(void *data)
1158 Elm_Genlist_Item *it = data;
1160 if (!it) return ECORE_CALLBACK_CANCEL;
1161 it->wd->swipe = EINA_FALSE;
1162 it->wd->movements = 0;
1163 return ECORE_CALLBACK_RENEW;
1167 _multi_cancel(void *data)
1169 Widget_Data *wd = data;
1171 if (!wd) return ECORE_CALLBACK_CANCEL;
1172 wd->multi_timeout = EINA_TRUE;
1173 return ECORE_CALLBACK_RENEW;
1177 _multi_touch_gesture_eval(void *data)
1179 Elm_Genlist_Item *it = data;
1181 it->wd->multitouched = EINA_FALSE;
1182 if (it->wd->multi_timer)
1184 ecore_timer_del(it->wd->multi_timer);
1185 it->wd->multi_timer = NULL;
1187 if (it->wd->multi_timeout)
1189 it->wd->multi_timeout = EINA_FALSE;
1193 Evas_Coord minw = 0, minh = 0;
1194 Evas_Coord off_x, off_y, off_mx, off_my;
1196 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1197 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1198 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1199 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1200 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1202 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1204 if ((off_x + off_mx) > (off_y + off_my))
1206 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1207 evas_object_smart_callback_call(it->base.widget,
1208 "multi,swipe,right", it);
1209 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1210 evas_object_smart_callback_call(it->base.widget,
1211 "multi,swipe,left", it);
1212 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1213 evas_object_smart_callback_call(it->base.widget,
1214 "multi,pinch,out", it);
1216 evas_object_smart_callback_call(it->base.widget,
1217 "multi,pinch,in", it);
1221 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1222 evas_object_smart_callback_call(it->base.widget,
1223 "multi,swipe,down", it);
1224 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1225 evas_object_smart_callback_call(it->base.widget,
1226 "multi,swipe,up", it);
1227 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1228 evas_object_smart_callback_call(it->base.widget,
1229 "multi,pinch,out", it);
1231 evas_object_smart_callback_call(it->base.widget,
1232 "multi,pinch,in", it);
1235 it->wd->multi_timeout = EINA_FALSE;
1239 _multi_down(void *data,
1240 Evas *evas __UNUSED__,
1241 Evas_Object *obj __UNUSED__,
1244 Elm_Genlist_Item *it = data;
1245 Evas_Event_Multi_Down *ev = event_info;
1247 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1248 it->wd->multi_device = ev->device;
1249 it->wd->multi_down = EINA_TRUE;
1250 it->wd->multitouched = EINA_TRUE;
1251 it->wd->prev_mx = ev->canvas.x;
1252 it->wd->prev_my = ev->canvas.y;
1253 if (!it->wd->wasselected) _item_unselect(it);
1254 it->wd->wasselected = EINA_FALSE;
1255 it->wd->longpressed = EINA_FALSE;
1258 ecore_timer_del(it->long_timer);
1259 it->long_timer = NULL;
1263 it->dragging = EINA_FALSE;
1264 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1266 if (it->swipe_timer)
1268 ecore_timer_del(it->swipe_timer);
1269 it->swipe_timer = NULL;
1271 if (it->wd->on_hold)
1273 it->wd->swipe = EINA_FALSE;
1274 it->wd->movements = 0;
1275 it->wd->on_hold = EINA_FALSE;
1280 _multi_up(void *data,
1281 Evas *evas __UNUSED__,
1282 Evas_Object *obj __UNUSED__,
1285 Elm_Genlist_Item *it = data;
1286 Evas_Event_Multi_Up *ev = event_info;
1288 if (it->wd->multi_device != ev->device) return;
1289 it->wd->multi_device = 0;
1290 it->wd->multi_down = EINA_FALSE;
1291 if (it->wd->mouse_down) return;
1292 _multi_touch_gesture_eval(data);
1296 _multi_move(void *data,
1297 Evas *evas __UNUSED__,
1298 Evas_Object *obj __UNUSED__,
1301 Elm_Genlist_Item *it = data;
1302 Evas_Event_Multi_Move *ev = event_info;
1304 if (it->wd->multi_device != ev->device) return;
1305 it->wd->cur_mx = ev->cur.canvas.x;
1306 it->wd->cur_my = ev->cur.canvas.y;
1310 _mouse_down(void *data,
1311 Evas *evas __UNUSED__,
1315 Elm_Genlist_Item *it = data;
1316 Evas_Event_Mouse_Down *ev = event_info;
1319 if (ev->button != 1) return;
1320 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1322 it->wd->on_hold = EINA_TRUE;
1325 it->down = EINA_TRUE;
1326 it->dragging = EINA_FALSE;
1327 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1328 it->dx = ev->canvas.x - x;
1329 it->dy = ev->canvas.y - y;
1330 it->wd->mouse_down = EINA_TRUE;
1331 if (!it->wd->multitouched)
1333 it->wd->prev_x = ev->canvas.x;
1334 it->wd->prev_y = ev->canvas.y;
1335 it->wd->multi_timeout = EINA_FALSE;
1336 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1337 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1339 it->wd->longpressed = EINA_FALSE;
1340 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1341 else it->wd->on_hold = EINA_FALSE;
1342 if (it->wd->on_hold) return;
1343 it->wd->wasselected = it->selected;
1344 _item_highlight(it);
1345 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1346 if ((!it->disabled) && (!it->display_only))
1348 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1349 evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1351 if (it->long_timer) ecore_timer_del(it->long_timer);
1352 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1353 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1355 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1358 it->long_timer = NULL;
1359 it->wd->swipe = EINA_FALSE;
1360 it->wd->movements = 0;
1364 _mouse_up(void *data,
1365 Evas *evas __UNUSED__,
1366 Evas_Object *obj __UNUSED__,
1369 Elm_Genlist_Item *it = data;
1370 Evas_Event_Mouse_Up *ev = event_info;
1371 Eina_Bool dragged = EINA_FALSE;
1373 if (ev->button != 1) return;
1374 it->down = EINA_FALSE;
1375 it->wd->mouse_down = EINA_FALSE;
1376 if (it->wd->multitouched)
1378 if (it->wd->multi_down) return;
1379 _multi_touch_gesture_eval(data);
1382 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1383 else it->wd->on_hold = EINA_FALSE;
1386 ecore_timer_del(it->long_timer);
1387 it->long_timer = NULL;
1391 it->dragging = EINA_FALSE;
1392 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1395 if (it->swipe_timer)
1397 ecore_timer_del(it->swipe_timer);
1398 it->swipe_timer = NULL;
1400 if (it->wd->multi_timer)
1402 ecore_timer_del(it->wd->multi_timer);
1403 it->wd->multi_timer = NULL;
1404 it->wd->multi_timeout = EINA_FALSE;
1406 if (it->wd->on_hold)
1408 if (it->wd->swipe) _swipe(data);
1409 it->wd->longpressed = EINA_FALSE;
1410 it->wd->on_hold = EINA_FALSE;
1413 if (it->wd->longpressed)
1415 it->wd->longpressed = EINA_FALSE;
1416 if (!it->wd->wasselected)
1418 it->wd->wasselected = EINA_FALSE;
1423 if (it->want_unrealize)
1425 _item_unrealize(it, EINA_FALSE);
1426 if (it->block->want_unrealize)
1427 _item_block_unrealize(it->block);
1430 if ((it->disabled) || (dragged) || (it->display_only)) return;
1431 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1436 _item_highlight(it);
1439 else _item_unselect(it);
1445 Widget_Data *wd = it->wd;
1448 while (wd->selected) _item_unselect(wd->selected->data);
1453 const Eina_List *l, *l_next;
1454 Elm_Genlist_Item *it2;
1456 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1457 if (it2 != it) _item_unselect(it2);
1458 //_item_highlight(it);
1461 _item_highlight(it);
1467 _signal_expand_toggle(void *data,
1468 Evas_Object *obj __UNUSED__,
1469 const char *emission __UNUSED__,
1470 const char *source __UNUSED__)
1472 Elm_Genlist_Item *it = data;
1475 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1477 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1481 _signal_expand(void *data,
1482 Evas_Object *obj __UNUSED__,
1483 const char *emission __UNUSED__,
1484 const char *source __UNUSED__)
1486 Elm_Genlist_Item *it = data;
1489 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1493 _signal_contract(void *data,
1494 Evas_Object *obj __UNUSED__,
1495 const char *emission __UNUSED__,
1496 const char *source __UNUSED__)
1498 Elm_Genlist_Item *it = data;
1501 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1505 _scr_hold_timer_cb(void *data)
1507 if (!data) return ECORE_CALLBACK_CANCEL;
1508 Widget_Data *wd = data;
1509 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1510 wd->scr_hold_timer = NULL;
1511 return ECORE_CALLBACK_CANCEL;
1515 _mode_finished_signal_cb(void *data,
1517 const char *emission __UNUSED__,
1518 const char *source __UNUSED__)
1522 Elm_Genlist_Item *it = data;
1523 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1526 it->nocache = EINA_FALSE;
1527 _mode_item_unrealize(it);
1528 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1529 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1533 _item_cache_clean(Widget_Data *wd)
1535 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1539 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1540 wd->item_cache = eina_inlist_remove(wd->item_cache,
1541 wd->item_cache->last);
1542 wd->item_cache_count--;
1543 if (itc->spacer) evas_object_del(itc->spacer);
1544 if (itc->base_view) evas_object_del(itc->base_view);
1545 if (itc->item_style) eina_stringshare_del(itc->item_style);
1551 _item_cache_zero(Widget_Data *wd)
1553 int pmax = wd->item_cache_max;
1554 wd->item_cache_max = 0;
1555 _item_cache_clean(wd);
1556 wd->item_cache_max = pmax;
1560 _item_cache_add(Elm_Genlist_Item *it)
1564 if (it->wd->item_cache_max <= 0)
1566 evas_object_del(it->base.view);
1567 it->base.view = NULL;
1568 evas_object_del(it->spacer);
1573 it->wd->item_cache_count++;
1574 itc = calloc(1, sizeof(Item_Cache));
1575 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1576 EINA_INLIST_GET(itc));
1577 itc->spacer = it->spacer;
1579 itc->base_view = it->base.view;
1580 it->base.view = NULL;
1581 evas_object_hide(itc->base_view);
1582 evas_object_move(itc->base_view, -9999, -9999);
1583 itc->item_style = eina_stringshare_add(it->itc->item_style);
1584 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1585 itc->compress = (it->wd->compress);
1586 itc->selected = it->selected;
1587 itc->disabled = it->disabled;
1588 itc->expanded = it->expanded;
1591 ecore_timer_del(it->long_timer);
1592 it->long_timer = NULL;
1594 if (it->swipe_timer)
1596 ecore_timer_del(it->swipe_timer);
1597 it->swipe_timer = NULL;
1599 // FIXME: other callbacks?
1600 edje_object_signal_callback_del_full(itc->base_view,
1601 "elm,action,expand,toggle",
1602 "elm", _signal_expand_toggle, it);
1603 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1605 _signal_expand, it);
1606 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1607 "elm", _signal_contract, it);
1608 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1610 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1612 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1614 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1616 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1618 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1620 _item_cache_clean(it->wd);
1624 _item_cache_find(Elm_Genlist_Item *it)
1629 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1630 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1632 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1634 if ((itc->tree == tree) &&
1635 (itc->compress == it->wd->compress) &&
1636 (!strcmp(it->itc->item_style, itc->item_style)))
1638 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1639 EINA_INLIST_GET(itc));
1640 it->wd->item_cache_count--;
1648 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1650 if (!it->nostacking)
1652 if ((it->order_num_in & 0x1) ^ it->stacking_even)
1653 evas_object_lower(it->base.view);
1655 evas_object_raise(it->base.view);
1658 if (it->order_num_in & 0x1)
1659 edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1661 edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1665 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1669 if (it->selected != itc->selected)
1672 edje_object_signal_emit(it->base.view,
1673 "elm,state,selected", "elm");
1675 if (it->disabled != itc->disabled)
1678 edje_object_signal_emit(it->base.view,
1679 "elm,state,disabled", "elm");
1681 if (it->expanded != itc->expanded)
1684 edje_object_signal_emit(it->base.view,
1685 "elm,state,expanded", "elm");
1691 edje_object_signal_emit(it->base.view,
1692 "elm,state,selected", "elm");
1694 edje_object_signal_emit(it->base.view,
1695 "elm,state,disabled", "elm");
1697 edje_object_signal_emit(it->base.view,
1698 "elm,state,expanded", "elm");
1703 _item_cache_free(Item_Cache *itc)
1705 if (itc->spacer) evas_object_del(itc->spacer);
1706 if (itc->base_view) evas_object_del(itc->base_view);
1707 if (itc->item_style) eina_stringshare_del(itc->item_style);
1712 _item_label_realize(Elm_Genlist_Item *it,
1713 Evas_Object *target,
1716 if (it->itc->func.label_get)
1721 *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
1722 EINA_LIST_FOREACH(*source, l, key)
1724 char *s = it->itc->func.label_get
1725 ((void *)it->base.data, it->base.widget, key);
1729 edje_object_part_text_set(target, key, s);
1734 edje_object_part_text_set(target, key, "");
1741 _item_icon_realize(Elm_Genlist_Item *it,
1742 Evas_Object *target,
1745 Eina_List *res = NULL;
1747 if (it->itc->func.icon_get)
1752 *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
1753 EINA_LIST_FOREACH(*source, l, key)
1755 Evas_Object *ic = it->itc->func.icon_get
1756 ((void *)it->base.data, it->base.widget, key);
1760 res = eina_list_append(res, ic);
1761 edje_object_part_swallow(target, key, ic);
1762 evas_object_show(ic);
1763 elm_widget_sub_object_add(it->base.widget, ic);
1772 _item_state_realize(Elm_Genlist_Item *it,
1773 Evas_Object *target,
1776 if (it->itc->func.state_get)
1782 *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
1783 EINA_LIST_FOREACH(*source, l, key)
1785 Eina_Bool on = it->itc->func.state_get
1786 ((void *)it->base.data, it->base.widget, key);
1790 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1791 edje_object_signal_emit(target, buf, "elm");
1795 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1796 edje_object_signal_emit(target, buf, "elm");
1803 _item_realize(Elm_Genlist_Item *it,
1807 Elm_Genlist_Item *it2;
1808 const char *treesize;
1810 int depth, tsize = 20;
1811 Item_Cache *itc = NULL;
1813 if (it->delete_me) return ;
1816 if (it->order_num_in != in)
1818 it->order_num_in = in;
1819 _elm_genlist_item_odd_even_update(it);
1820 _elm_genlist_item_state_update(it, NULL);
1824 it->order_num_in = in;
1827 it->nocache = EINA_FALSE;
1829 itc = _item_cache_find(it);
1832 it->base.view = itc->base_view;
1833 itc->base_view = NULL;
1834 it->spacer = itc->spacer;
1839 const char *stacking_even;
1840 const char *stacking;
1842 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1843 edje_object_scale_set(it->base.view,
1844 elm_widget_scale_get(it->base.widget) *
1845 _elm_config->scale);
1846 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1847 elm_widget_sub_object_add(it->base.widget, it->base.view);
1849 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1850 strncpy(buf, "tree", sizeof(buf));
1851 else strncpy(buf, "item", sizeof(buf));
1852 if (it->wd->compress)
1853 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1855 strncat(buf, "/", sizeof(buf) - strlen(buf));
1856 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1858 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1859 elm_widget_style_get(it->base.widget));
1861 stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1862 if (!stacking_even) stacking_even = "above";
1863 it->stacking_even = !!strcmp("above", stacking_even);
1865 stacking = edje_object_data_get(it->base.view, "stacking");
1866 if (!stacking) stacking = "yes";
1867 it->nostacking = !!strcmp("yes", stacking);
1869 edje_object_mirrored_set(it->base.view,
1870 elm_widget_mirrored_get(it->base.widget));
1872 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1873 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1874 elm_widget_sub_object_add(it->base.widget, it->spacer);
1877 _elm_genlist_item_odd_even_update(it);
1879 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1881 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1883 it->expanded_depth = depth;
1884 treesize = edje_object_data_get(it->base.view, "treesize");
1885 if (treesize) tsize = atoi(treesize);
1886 evas_object_size_hint_min_set(it->spacer,
1887 (depth * tsize) * _elm_config->scale, 1);
1888 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1891 edje_object_signal_callback_add(it->base.view,
1892 "elm,action,expand,toggle",
1893 "elm", _signal_expand_toggle, it);
1894 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1895 "elm", _signal_expand, it);
1896 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1897 "elm", _signal_contract, it);
1898 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1900 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1902 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1904 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1906 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1908 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1911 _elm_genlist_item_state_update(it, itc);
1914 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1916 /* homogenous genlist shortcut */
1919 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1921 it->w = it->minw = it->wd->group_item_width;
1922 it->h = it->minh = it->wd->group_item_height;
1926 it->w = it->minw = it->wd->item_width;
1927 it->h = it->minh = it->wd->item_height;
1929 it->mincalcd = EINA_TRUE;
1934 /* FIXME: If you see that assert, please notify us and we
1935 will clean our mess */
1936 assert(eina_list_count(it->icon_objs) == 0);
1938 _item_label_realize(it, it->base.view, &it->labels);
1939 it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
1940 _item_state_realize(it, it->base.view, &it->states);
1944 Evas_Coord mw = -1, mh = -1;
1946 if (it->wd->height_for_width) mw = it->wd->w;
1948 if (!it->display_only)
1949 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1950 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1951 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1953 if (!it->display_only)
1954 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1955 it->w = it->minw = mw;
1956 it->h = it->minh = mh;
1957 it->mincalcd = EINA_TRUE;
1959 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1961 it->wd->group_item_width = mw;
1962 it->wd->group_item_height = mh;
1964 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1966 it->wd->item_width = mw;
1967 it->wd->item_height = mh;
1970 if (!calc) evas_object_show(it->base.view);
1973 if (it->tooltip.content_cb)
1975 elm_widget_item_tooltip_content_cb_set(it,
1976 it->tooltip.content_cb,
1977 it->tooltip.data, NULL);
1978 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1981 if (it->mouse_cursor)
1982 elm_widget_item_cursor_set(it, it->mouse_cursor);
1984 it->realized = EINA_TRUE;
1985 it->want_unrealize = EINA_FALSE;
1987 if (itc) _item_cache_free(itc);
1988 if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1992 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1996 if (!it->realized) return;
1997 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2000 ecore_timer_del(it->long_timer);
2001 it->long_timer = NULL;
2005 evas_object_del(it->base.view);
2006 it->base.view = NULL;
2007 evas_object_del(it->spacer);
2012 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2013 edje_object_scale_set(it->base.view, elm_widget_scale_get(it->base.widget) * _elm_config->scale);
2014 _item_cache_add(it);
2016 elm_widget_stringlist_free(it->labels);
2018 elm_widget_stringlist_free(it->icons);
2020 elm_widget_stringlist_free(it->states);
2022 EINA_LIST_FREE(it->icon_objs, icon)
2023 evas_object_del(icon);
2025 _mode_item_unrealize(it);
2027 it->realized = EINA_FALSE;
2028 it->want_unrealize = EINA_FALSE;
2032 _item_block_recalc(Item_Block *itb,
2038 Elm_Genlist_Item *it;
2039 Evas_Coord minw = 0, minh = 0;
2040 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2044 EINA_LIST_FOREACH(itb->items, l, it)
2046 if (it->delete_me) continue;
2047 showme |= it->showme;
2052 if (!it->mincalcd) changed = EINA_TRUE;
2055 _item_realize(it, in, EINA_TRUE);
2056 _item_unrealize(it, EINA_TRUE);
2061 _item_realize(it, in, EINA_TRUE);
2062 _item_unrealize(it, EINA_TRUE);
2066 _item_realize(it, in, EINA_FALSE);
2068 if (minw < it->minw) minw = it->minw;
2076 itb->changed = EINA_FALSE;
2077 /* force an evas norender to garbage collect deleted objects */
2078 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2083 _item_block_realize(Item_Block *itb,
2088 Elm_Genlist_Item *it;
2090 if (itb->realized) return;
2091 EINA_LIST_FOREACH(itb->items, l, it)
2093 if (it->delete_me) continue;
2094 if (full) _item_realize(it, in, EINA_FALSE);
2097 itb->realized = EINA_TRUE;
2098 itb->want_unrealize = EINA_FALSE;
2102 _item_block_unrealize(Item_Block *itb)
2105 Elm_Genlist_Item *it;
2106 Eina_Bool dragging = EINA_FALSE;
2108 if (!itb->realized) return;
2109 EINA_LIST_FOREACH(itb->items, l, it)
2111 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2115 dragging = EINA_TRUE;
2116 it->want_unrealize = EINA_TRUE;
2119 _item_unrealize(it, EINA_FALSE);
2124 itb->realized = EINA_FALSE;
2125 itb->want_unrealize = EINA_TRUE;
2128 itb->want_unrealize = EINA_FALSE;
2132 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2137 evas_object_resize(view, it->w, it->h);
2138 evas_object_move(view, it->scrl_x, it->scrl_y);
2139 evas_object_show(view);
2143 _item_block_position(Item_Block *itb,
2147 Elm_Genlist_Item *it;
2148 Elm_Genlist_Item *git;
2149 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2152 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2153 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2155 EINA_LIST_FOREACH(itb->items, l, it)
2157 if (it->delete_me) continue;
2161 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2162 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2164 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2165 cvx, cvy, cvw, cvh));
2166 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2168 if ((itb->realized) && (!it->realized))
2170 if (vis) _item_realize(it, in, EINA_FALSE);
2176 git = it->group_item;
2179 if (git->scrl_y < oy)
2181 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2182 git->scrl_y = (it->scrl_y + it->h) - git->h;
2183 git->want_realize = EINA_TRUE;
2186 _item_position(it, it->mode_view);
2188 _item_position(it, it->base.view);
2192 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2199 if (vis) it->want_realize = EINA_TRUE;
2206 _group_items_recalc(void *data)
2208 Widget_Data *wd = data;
2210 Elm_Genlist_Item *git;
2212 EINA_LIST_FOREACH(wd->group_items, l, git)
2214 if (git->want_realize)
2217 _item_realize(git, 0, EINA_FALSE);
2218 evas_object_resize(git->base.view, wd->minw, git->h);
2219 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2220 evas_object_show(git->base.view);
2221 evas_object_raise(git->base.view);
2223 else if (!git->want_realize && git->realized)
2226 _item_unrealize(git, EINA_FALSE);
2232 _must_recalc_idler(void *data)
2234 Widget_Data *wd = data;
2235 if (wd->calc_job) ecore_job_del(wd->calc_job);
2236 wd->calc_job = ecore_job_add(_calc_job, wd);
2237 wd->must_recalc_idler = NULL;
2238 return ECORE_CALLBACK_CANCEL;
2242 _calc_job(void *data)
2244 Widget_Data *wd = data;
2246 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2247 Item_Block *chb = NULL;
2248 int in = 0, minw_change = 0;
2249 Eina_Bool changed = EINA_FALSE;
2251 Eina_Bool did_must_recalc = EINA_FALSE;
2254 t0 = ecore_time_get();
2255 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2259 // if (wd->height_for_width) changed = EINA_TRUE;
2262 EINA_INLIST_FOREACH(wd->blocks, itb)
2264 Eina_Bool showme = EINA_FALSE;
2267 showme = itb->showme;
2268 itb->showme = EINA_FALSE;
2271 if (itb->realized) _item_block_unrealize(itb);
2273 if ((itb->changed) || (changed) ||
2274 ((itb->must_recalc) && (!did_must_recalc)))
2276 if ((changed) || (itb->must_recalc))
2279 Elm_Genlist_Item *it;
2280 EINA_LIST_FOREACH(itb->items, l, it)
2281 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2282 itb->changed = EINA_TRUE;
2283 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2284 itb->must_recalc = EINA_FALSE;
2286 if (itb->realized) _item_block_unrealize(itb);
2287 showme = _item_block_recalc(itb, in, 0, 1);
2293 if (minw == -1) minw = itb->minw;
2294 else if ((!itb->must_recalc) && (minw < itb->minw))
2303 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2305 wd->show_item->showme = EINA_FALSE;
2307 elm_smart_scroller_region_bring_in(wd->scr,
2309 wd->show_item->block->x,
2311 wd->show_item->block->y,
2312 wd->show_item->block->w,
2315 elm_smart_scroller_child_region_show(wd->scr,
2317 wd->show_item->block->x,
2319 wd->show_item->block->y,
2320 wd->show_item->block->w,
2322 wd->show_item = NULL;
2327 EINA_INLIST_FOREACH(wd->blocks, itb)
2333 if ((chb) && (EINA_INLIST_GET(chb)->next))
2335 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2337 if (itb->realized) _item_block_unrealize(itb);
2340 wd->realminw = minw;
2341 if (minw < wd->w) minw = wd->w;
2342 if ((minw != wd->minw) || (minh != wd->minh))
2346 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2347 _sizing_eval(wd->obj);
2348 if ((wd->anchor_item) && (wd->anchor_item->block))
2350 Elm_Genlist_Item *it;
2353 it = wd->anchor_item;
2354 it_y = wd->anchor_y;
2355 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2356 it->block->y + it->y + it_y);
2357 wd->anchor_item = it;
2358 wd->anchor_y = it_y;
2361 t = ecore_time_get();
2362 if (did_must_recalc)
2364 if (!wd->must_recalc_idler)
2365 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2367 wd->calc_job = NULL;
2368 evas_object_smart_changed(wd->pan_smart);
2372 _update_job(void *data)
2374 Widget_Data *wd = data;
2377 int num, num0, position = 0, recalc = 0;
2379 wd->update_job = NULL;
2381 EINA_INLIST_FOREACH(wd->blocks, itb)
2383 Evas_Coord itminw, itminh;
2384 Elm_Genlist_Item *it;
2390 _item_block_position(itb, num);
2395 EINA_LIST_FOREACH(itb->items, l2, it)
2402 it->updateme = EINA_FALSE;
2405 _item_unrealize(it, EINA_FALSE);
2406 _item_realize(it, num, EINA_FALSE);
2411 _item_realize(it, num, EINA_TRUE);
2412 _item_unrealize(it, EINA_TRUE);
2414 if ((it->minw != itminw) || (it->minh != itminh))
2419 itb->updateme = EINA_FALSE;
2423 itb->changed = EINA_TRUE;
2424 _item_block_recalc(itb, num0, 0, 1);
2425 _item_block_position(itb, num0);
2430 if (wd->calc_job) ecore_job_del(wd->calc_job);
2431 wd->calc_job = ecore_job_add(_calc_job, wd);
2436 _pan_set(Evas_Object *obj,
2440 Pan *sd = evas_object_smart_data_get(obj);
2443 // Evas_Coord ow, oh;
2444 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2445 // ow = sd->wd->minw - ow;
2446 // if (ow < 0) ow = 0;
2447 // oh = sd->wd->minh - oh;
2448 // if (oh < 0) oh = 0;
2449 // if (x < 0) x = 0;
2450 // if (y < 0) y = 0;
2451 // if (x > ow) x = ow;
2452 // if (y > oh) y = oh;
2453 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2457 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2459 if ((itb->y + itb->h) > y)
2461 Elm_Genlist_Item *it;
2464 EINA_LIST_FOREACH(itb->items, l2, it)
2466 if ((itb->y + it->y) >= y)
2468 sd->wd->anchor_item = it;
2469 sd->wd->anchor_y = -(itb->y + it->y - y);
2476 evas_object_smart_changed(obj);
2480 _pan_get(Evas_Object *obj,
2484 Pan *sd = evas_object_smart_data_get(obj);
2486 if (x) *x = sd->wd->pan_x;
2487 if (y) *y = sd->wd->pan_y;
2491 _pan_max_get(Evas_Object *obj,
2495 Pan *sd = evas_object_smart_data_get(obj);
2498 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2499 ow = sd->wd->minw - ow;
2501 oh = sd->wd->minh - oh;
2508 _pan_min_get(Evas_Object *obj __UNUSED__,
2517 _pan_child_size_get(Evas_Object *obj,
2521 Pan *sd = evas_object_smart_data_get(obj);
2523 if (w) *w = sd->wd->minw;
2524 if (h) *h = sd->wd->minh;
2528 _pan_add(Evas_Object *obj)
2531 Evas_Object_Smart_Clipped_Data *cd;
2534 cd = evas_object_smart_data_get(obj);
2537 sd->__clipped_data = *cd;
2539 evas_object_smart_data_set(obj, sd);
2543 _pan_del(Evas_Object *obj)
2545 Pan *sd = evas_object_smart_data_get(obj);
2550 ecore_job_del(sd->resize_job);
2551 sd->resize_job = NULL;
2557 _pan_resize_job(void *data)
2560 _sizing_eval(sd->wd->obj);
2561 sd->resize_job = NULL;
2565 _pan_resize(Evas_Object *obj,
2569 Pan *sd = evas_object_smart_data_get(obj);
2572 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2573 if ((ow == w) && (oh == h)) return;
2574 if ((sd->wd->height_for_width) && (ow != w))
2576 if (sd->resize_job) ecore_job_del(sd->resize_job);
2577 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2579 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2580 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2584 _pan_calculate(Evas_Object *obj)
2586 Pan *sd = evas_object_smart_data_get(obj);
2588 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2590 Elm_Genlist_Item *git;
2593 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2594 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2595 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2597 git->want_realize = EINA_FALSE;
2599 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2601 itb->w = sd->wd->minw;
2602 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2603 itb->y - sd->wd->pan_y + oy,
2605 cvx, cvy, cvw, cvh))
2607 if ((!itb->realized) || (itb->changed))
2608 _item_block_realize(itb, in, 0);
2609 _item_block_position(itb, in);
2613 if (itb->realized) _item_block_unrealize(itb);
2617 _group_items_recalc(sd->wd);
2621 _pan_move(Evas_Object *obj,
2622 Evas_Coord x __UNUSED__,
2623 Evas_Coord y __UNUSED__)
2625 Pan *sd = evas_object_smart_data_get(obj);
2627 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2628 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2632 _hold_on(void *data __UNUSED__,
2634 void *event_info __UNUSED__)
2636 Widget_Data *wd = elm_widget_data_get(obj);
2638 elm_smart_scroller_hold_set(wd->scr, 1);
2642 _hold_off(void *data __UNUSED__,
2644 void *event_info __UNUSED__)
2646 Widget_Data *wd = elm_widget_data_get(obj);
2648 elm_smart_scroller_hold_set(wd->scr, 0);
2652 _freeze_on(void *data __UNUSED__,
2654 void *event_info __UNUSED__)
2656 Widget_Data *wd = elm_widget_data_get(obj);
2658 elm_smart_scroller_freeze_set(wd->scr, 1);
2662 _freeze_off(void *data __UNUSED__,
2664 void *event_info __UNUSED__)
2666 Widget_Data *wd = elm_widget_data_get(obj);
2668 elm_smart_scroller_freeze_set(wd->scr, 0);
2672 _scroll_edge_left(void *data,
2673 Evas_Object *scr __UNUSED__,
2674 void *event_info __UNUSED__)
2676 Evas_Object *obj = data;
2677 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2681 _scroll_edge_right(void *data,
2682 Evas_Object *scr __UNUSED__,
2683 void *event_info __UNUSED__)
2685 Evas_Object *obj = data;
2686 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2690 _scroll_edge_top(void *data,
2691 Evas_Object *scr __UNUSED__,
2692 void *event_info __UNUSED__)
2694 Evas_Object *obj = data;
2695 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2699 _scroll_edge_bottom(void *data,
2700 Evas_Object *scr __UNUSED__,
2701 void *event_info __UNUSED__)
2703 Evas_Object *obj = data;
2704 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2708 _mode_item_realize(Elm_Genlist_Item *it)
2712 if ((it->mode_view) || (it->delete_me)) return;
2714 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2715 edje_object_scale_set(it->mode_view,
2716 elm_widget_scale_get(it->base.widget) *
2717 _elm_config->scale);
2718 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2719 elm_widget_sub_object_add(it->base.widget, it->mode_view);
2721 strncpy(buf, "item", sizeof(buf));
2722 if (it->wd->compress)
2723 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2725 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2726 strncat(buf, "/", sizeof(buf) - strlen(buf));
2727 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2729 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2730 elm_widget_style_get(it->base.widget));
2731 edje_object_mirrored_set(it->mode_view,
2732 elm_widget_mirrored_get(it->base.widget));
2734 /* signal callback add */
2735 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2737 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2739 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2742 /* label_get, icon_get, state_get */
2743 /* FIXME: If you see that assert, please notify us and we
2744 will clean our mess */
2745 assert(eina_list_count(it->mode_icon_objs) == 0);
2747 _item_label_realize(it, it->mode_view, &it->mode_labels);
2748 it->mode_icon_objs = _item_icon_realize(it,
2751 _item_state_realize(it, it->mode_view, &it->mode_states);
2753 edje_object_part_swallow(it->mode_view,
2754 edje_object_data_get(it->mode_view, "mode_part"),
2757 it->want_unrealize = EINA_FALSE;
2761 _mode_item_unrealize(Elm_Genlist_Item *it)
2763 Widget_Data *wd = it->wd;
2765 if (!it->mode_view) return;
2767 elm_widget_stringlist_free(it->mode_labels);
2768 it->mode_labels = NULL;
2769 elm_widget_stringlist_free(it->mode_icons);
2770 it->mode_icons = NULL;
2771 elm_widget_stringlist_free(it->mode_states);
2773 EINA_LIST_FREE(it->mode_icon_objs, icon)
2774 evas_object_del(icon);
2776 edje_object_part_unswallow(it->mode_view, it->base.view);
2777 evas_object_smart_member_add(it->base.view, wd->pan_smart);
2778 evas_object_del(it->mode_view);
2779 it->mode_view = NULL;
2781 if (wd->mode_item == it)
2782 wd->mode_item = NULL;
2786 _item_mode_set(Elm_Genlist_Item *it)
2789 Widget_Data *wd = it->wd;
2794 it->nocache = EINA_TRUE;
2796 if (wd->scr_hold_timer)
2798 ecore_timer_del(wd->scr_hold_timer);
2799 wd->scr_hold_timer = NULL;
2801 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2802 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2804 _mode_item_realize(it);
2805 _item_position(it, it->mode_view);
2807 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2808 edje_object_signal_emit(it->mode_view, buf, "elm");
2812 _item_mode_unset(Widget_Data *wd)
2815 if (!wd->mode_item) return;
2816 char buf[1024], buf2[1024];
2817 Elm_Genlist_Item *it;
2820 it->nocache = EINA_TRUE;
2822 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2823 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2825 edje_object_signal_emit(it->mode_view, buf, "elm");
2826 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2828 wd->mode_item = NULL;
2832 * Add a new Genlist object
2834 * @param parent The parent object
2835 * @return The new object or NULL if it cannot be created
2840 elm_genlist_add(Evas_Object *parent)
2845 Evas_Coord minw, minh;
2846 static Evas_Smart *smart = NULL;
2850 static Evas_Smart_Class sc;
2852 evas_object_smart_clipped_smart_set(&_pan_sc);
2854 sc.name = "elm_genlist_pan";
2855 sc.version = EVAS_SMART_CLASS_VERSION;
2858 sc.resize = _pan_resize;
2859 sc.move = _pan_move;
2860 sc.calculate = _pan_calculate;
2861 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2864 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2866 ELM_SET_WIDTYPE(widtype, "genlist");
2867 elm_widget_type_set(obj, "genlist");
2868 elm_widget_sub_object_add(parent, obj);
2869 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2870 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2871 elm_widget_data_set(obj, wd);
2872 elm_widget_del_hook_set(obj, _del_hook);
2873 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2874 elm_widget_theme_hook_set(obj, _theme_hook);
2875 elm_widget_can_focus_set(obj, EINA_TRUE);
2876 elm_widget_event_hook_set(obj, _event_hook);
2877 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2879 wd->scr = elm_smart_scroller_add(e);
2880 elm_smart_scroller_widget_set(wd->scr, obj);
2881 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2882 elm_widget_style_get(obj));
2883 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2884 _elm_config->thumbscroll_bounce_enable);
2885 elm_widget_resize_object_set(obj, wd->scr);
2887 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2888 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2890 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2891 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2895 wd->mode = ELM_LIST_SCROLL;
2896 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2897 wd->item_cache_max = wd->max_items_per_block * 2;
2898 wd->longpress_timeout = _elm_config->longpress_timeout;
2900 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2901 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2902 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2903 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2905 wd->pan_smart = evas_object_smart_add(e, smart);
2906 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2909 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2910 _pan_set, _pan_get, _pan_max_get,
2911 _pan_min_get, _pan_child_size_get);
2913 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2915 evas_object_size_hint_min_set(obj, minw, minh);
2917 _mirrored_set(obj, elm_widget_mirrored_get(obj));
2922 static Elm_Genlist_Item *
2923 _item_new(Widget_Data *wd,
2924 const Elm_Genlist_Item_Class *itc,
2926 Elm_Genlist_Item *parent,
2927 Elm_Genlist_Item_Flags flags,
2929 const void *func_data)
2931 Elm_Genlist_Item *it;
2933 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2934 if (!it) return NULL;
2937 it->base.data = data;
2938 it->parent = parent;
2940 it->func.func = func;
2941 it->func.data = func_data;
2942 it->mouse_cursor = NULL;
2943 it->expanded_depth = 0;
2948 _item_block_add(Widget_Data *wd,
2949 Elm_Genlist_Item *it)
2951 Item_Block *itb = NULL;
2958 itb = calloc(1, sizeof(Item_Block));
2961 if (!it->rel->block)
2964 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2965 itb->items = eina_list_append(itb->items, it);
2971 wd->blocks = eina_inlist_prepend_relative
2972 (wd->blocks, EINA_INLIST_GET(itb),
2973 EINA_INLIST_GET(it->rel->block));
2975 eina_list_prepend_relative(itb->items, it, it->rel);
2979 wd->blocks = eina_inlist_append_relative
2980 (wd->blocks, EINA_INLIST_GET(itb),
2981 EINA_INLIST_GET(it->rel->block));
2983 eina_list_append_relative(itb->items, it, it->rel);
2993 itb = (Item_Block *)(wd->blocks);
2994 if (itb->count >= wd->max_items_per_block)
2996 itb = calloc(1, sizeof(Item_Block));
3000 eina_inlist_prepend(wd->blocks,
3001 EINA_INLIST_GET(itb));
3006 itb = calloc(1, sizeof(Item_Block));
3010 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3012 itb->items = eina_list_prepend(itb->items, it);
3018 itb = (Item_Block *)(wd->blocks->last);
3019 if (itb->count >= wd->max_items_per_block)
3021 itb = calloc(1, sizeof(Item_Block));
3025 eina_inlist_append(wd->blocks,
3026 EINA_INLIST_GET(itb));
3031 itb = calloc(1, sizeof(Item_Block));
3035 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3037 itb->items = eina_list_append(itb->items, it);
3043 itb = it->rel->block;
3044 if (!itb) goto newblock;
3046 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3048 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3051 itb->changed = EINA_TRUE;
3053 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3054 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3057 it->rel->relcount--;
3058 if ((it->rel->delete_me) && (!it->rel->relcount))
3062 if (itb->count > itb->wd->max_items_per_block)
3066 Elm_Genlist_Item *it2;
3068 newc = itb->count / 2;
3069 itb2 = calloc(1, sizeof(Item_Block));
3073 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3074 EINA_INLIST_GET(itb));
3075 itb2->changed = EINA_TRUE;
3076 while ((itb->count > newc) && (itb->items))
3080 l = eina_list_last(itb->items);
3082 itb->items = eina_list_remove_list(itb->items, l);
3085 itb2->items = eina_list_prepend(itb2->items, it2);
3093 _queue_process(Widget_Data *wd,
3097 Eina_Bool showme = EINA_FALSE;
3100 t0 = ecore_time_get();
3101 for (n = 0; (wd->queue) && (n < 128); n++)
3103 Elm_Genlist_Item *it;
3105 it = wd->queue->data;
3106 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3107 it->queued = EINA_FALSE;
3108 _item_block_add(wd, it);
3109 t = ecore_time_get();
3110 if (it->block->changed)
3112 showme = _item_block_recalc(it->block, it->block->num, 1,
3114 it->block->changed = 0;
3116 if (showme) it->block->showme = EINA_TRUE;
3117 if (eina_inlist_count(wd->blocks) > 1)
3119 if ((t - t0) > (ecore_animator_frametime_get())) break;
3126 _item_idler(void *data)
3128 Widget_Data *wd = data;
3131 //static double q_start = 0.0;
3132 //if (q_start == 0.0) q_start = ecore_time_get();
3135 if (_queue_process(wd, 1) > 0)
3137 if (wd->calc_job) ecore_job_del(wd->calc_job);
3138 wd->calc_job = ecore_job_add(_calc_job, wd);
3143 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3145 wd->queue_idler = NULL;
3146 return ECORE_CALLBACK_CANCEL;
3148 return ECORE_CALLBACK_RENEW;
3152 _item_queue(Widget_Data *wd,
3153 Elm_Genlist_Item *it)
3155 if (it->queued) return;
3156 it->queued = EINA_TRUE;
3157 wd->queue = eina_list_append(wd->queue, it);
3158 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3160 if (wd->queue_idler)
3162 ecore_idler_del(wd->queue_idler);
3163 wd->queue_idler = NULL;
3165 _queue_process(wd, 0);
3167 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3171 * Append item to the end of the genlist
3173 * This appends the given item to the end of the list or the end of
3174 * the children if the parent is given.
3176 * @param obj The genlist object
3177 * @param itc The item class for the item
3178 * @param data The item data
3179 * @param parent The parent item, or NULL if none
3180 * @param flags Item flags
3181 * @param func Convenience function called when item selected
3182 * @param func_data Data passed to @p func above.
3183 * @return A handle to the item added or NULL if not possible
3187 EAPI Elm_Genlist_Item *
3188 elm_genlist_item_append(Evas_Object *obj,
3189 const Elm_Genlist_Item_Class *itc,
3191 Elm_Genlist_Item *parent,
3192 Elm_Genlist_Item_Flags flags,
3194 const void *func_data)
3196 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3197 Widget_Data *wd = elm_widget_data_get(obj);
3198 if (!wd) return NULL;
3199 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3201 if (!it) return NULL;
3204 if (flags & ELM_GENLIST_ITEM_GROUP)
3205 wd->group_items = eina_list_append(wd->group_items, it);
3206 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3211 Elm_Genlist_Item *it2 = NULL;
3212 Eina_List *ll = eina_list_last(it->parent->items);
3213 if (ll) it2 = ll->data;
3214 it->parent->items = eina_list_append(it->parent->items, it);
3215 if (!it2) it2 = it->parent;
3217 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3218 EINA_INLIST_GET(it2));
3220 it->rel->relcount++;
3222 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3223 it->group_item = parent;
3224 else if (it->parent->group_item)
3225 it->group_item = it->parent->group_item;
3227 it->before = EINA_FALSE;
3228 _item_queue(wd, it);
3233 * Prepend item at start of the genlist
3235 * This adds an item to the beginning of the list or beginning of the
3236 * children of the parent if given.
3238 * @param obj The genlist object
3239 * @param itc The item class for the item
3240 * @param data The item data
3241 * @param parent The parent item, or NULL if none
3242 * @param flags Item flags
3243 * @param func Convenience function called when item selected
3244 * @param func_data Data passed to @p func above.
3245 * @return A handle to the item added or NULL if not possible
3249 EAPI Elm_Genlist_Item *
3250 elm_genlist_item_prepend(Evas_Object *obj,
3251 const Elm_Genlist_Item_Class *itc,
3253 Elm_Genlist_Item *parent,
3254 Elm_Genlist_Item_Flags flags,
3256 const void *func_data)
3258 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3259 Widget_Data *wd = elm_widget_data_get(obj);
3260 if (!wd) return NULL;
3261 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3263 if (!it) return NULL;
3266 if (flags & ELM_GENLIST_ITEM_GROUP)
3267 wd->group_items = eina_list_prepend(wd->group_items, it);
3268 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3273 Elm_Genlist_Item *it2 = NULL;
3274 Eina_List *ll = it->parent->items;
3275 if (ll) it2 = ll->data;
3276 it->parent->items = eina_list_prepend(it->parent->items, it);
3277 if (!it2) it2 = it->parent;
3279 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3280 EINA_INLIST_GET(it2));
3282 it->rel->relcount++;
3284 it->before = EINA_TRUE;
3285 _item_queue(wd, it);
3290 * Insert item before another in the genlist
3292 * This inserts an item before another in the list. It will be in the
3293 * same tree level or group as the item it is inseted before.
3295 * @param obj The genlist object
3296 * @param itc The item class for the item
3297 * @param data The item data
3298 * @param before The item to insert before
3299 * @param flags Item flags
3300 * @param func Convenience function called when item selected
3301 * @param func_data Data passed to @p func above.
3302 * @return A handle to the item added or NULL if not possible
3306 EAPI Elm_Genlist_Item *
3307 elm_genlist_item_insert_before(Evas_Object *obj,
3308 const Elm_Genlist_Item_Class *itc,
3310 Elm_Genlist_Item *parent,
3311 Elm_Genlist_Item *before,
3312 Elm_Genlist_Item_Flags flags,
3314 const void *func_data)
3316 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3317 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3318 Widget_Data *wd = elm_widget_data_get(obj);
3319 if (!wd) return NULL;
3320 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3322 if (!it) return NULL;
3325 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3328 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3329 EINA_INLIST_GET(before));
3331 it->rel->relcount++;
3332 it->before = EINA_TRUE;
3333 _item_queue(wd, it);
3338 * Insert an item after another in the genlst
3340 * This inserts an item after another in the list. It will be in the
3341 * same tree level or group as the item it is inseted after.
3343 * @param obj The genlist object
3344 * @param itc The item class for the item
3345 * @param data The item data
3346 * @param after The item to insert after
3347 * @param flags Item flags
3348 * @param func Convenience function called when item selected
3349 * @param func_data Data passed to @p func above.
3350 * @return A handle to the item added or NULL if not possible
3354 EAPI Elm_Genlist_Item *
3355 elm_genlist_item_insert_after(Evas_Object *obj,
3356 const Elm_Genlist_Item_Class *itc,
3358 Elm_Genlist_Item *parent,
3359 Elm_Genlist_Item *after,
3360 Elm_Genlist_Item_Flags flags,
3362 const void *func_data)
3364 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3365 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3366 Widget_Data *wd = elm_widget_data_get(obj);
3367 if (!wd) return NULL;
3368 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3370 if (!it) return NULL;
3371 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3372 EINA_INLIST_GET(after));
3375 it->parent->items = eina_list_append_relative(it->parent->items, it,
3379 it->rel->relcount++;
3380 it->before = EINA_FALSE;
3381 _item_queue(wd, it);
3388 * This clears all items in the list, leaving it empty.
3390 * @param obj The genlist object
3395 elm_genlist_clear(Evas_Object *obj)
3397 ELM_CHECK_WIDTYPE(obj, widtype);
3398 Widget_Data *wd = elm_widget_data_get(obj);
3400 if (wd->walking > 0)
3402 Elm_Genlist_Item *it;
3404 wd->clear_me = EINA_TRUE;
3405 EINA_INLIST_FOREACH(wd->items, it)
3407 it->delete_me = EINA_TRUE;
3413 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3415 if (wd->anchor_item == it)
3417 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3418 if (!wd->anchor_item)
3420 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3422 wd->items = eina_inlist_remove(wd->items, wd->items);
3423 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3424 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3425 elm_widget_item_pre_notify_del(it);
3426 if (it->realized) _item_unrealize(it, EINA_FALSE);
3427 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3428 it->itc->func.del((void *)it->base.data, it->base.widget);
3429 if (it->long_timer) ecore_timer_del(it->long_timer);
3430 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3431 elm_widget_item_del(it);
3433 wd->clear_me = EINA_FALSE;
3434 wd->anchor_item = NULL;
3437 Item_Block *itb = (Item_Block *)(wd->blocks);
3439 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3440 if (itb->items) eina_list_free(itb->items);
3445 ecore_job_del(wd->calc_job);
3446 wd->calc_job = NULL;
3448 if (wd->queue_idler)
3450 ecore_idler_del(wd->queue_idler);
3451 wd->queue_idler = NULL;
3453 if (wd->must_recalc_idler)
3455 ecore_idler_del(wd->must_recalc_idler);
3456 wd->must_recalc_idler = NULL;
3460 eina_list_free(wd->queue);
3465 eina_list_free(wd->selected);
3466 wd->selected = NULL;
3468 wd->show_item = NULL;
3475 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3476 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3482 * Enable or disable multi-select in the genlist
3484 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3485 * the list. This allows more than 1 item to be selected.
3487 * @param obj The genlist object
3488 * @param multi Multi-select enable/disable
3493 elm_genlist_multi_select_set(Evas_Object *obj,
3496 ELM_CHECK_WIDTYPE(obj, widtype);
3497 Widget_Data *wd = elm_widget_data_get(obj);
3503 * Gets if multi-select in genlist is enable or disable
3505 * @param obj The genlist object
3506 * @return Multi-select enable/disable
3507 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3512 elm_genlist_multi_select_get(const Evas_Object *obj)
3514 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3515 Widget_Data *wd = elm_widget_data_get(obj);
3516 if (!wd) return EINA_FALSE;
3521 * Get the selectd item in the genlist
3523 * This gets the selected item in the list (if multi-select is enabled
3524 * only the first item in the list is selected - which is not very
3525 * useful, so see elm_genlist_selected_items_get() for when
3526 * multi-select is used).
3528 * If no item is selected, NULL is returned.
3530 * @param obj The genlist object
3531 * @return The selected item, or NULL if none.
3535 EAPI Elm_Genlist_Item *
3536 elm_genlist_selected_item_get(const Evas_Object *obj)
3538 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3539 Widget_Data *wd = elm_widget_data_get(obj);
3540 if (!wd) return NULL;
3541 if (wd->selected) return wd->selected->data;
3546 * Get a list of selected items in the genlist
3548 * This returns a list of the selected items. This list pointer is
3549 * only valid so long as no items are selected or unselected (or
3550 * unselected implicitly by deletion). The list contains
3551 * Elm_Genlist_Item pointers.
3553 * @param obj The genlist object
3554 * @return The list of selected items, nor NULL if none are selected.
3558 EAPI const Eina_List *
3559 elm_genlist_selected_items_get(const Evas_Object *obj)
3561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3562 Widget_Data *wd = elm_widget_data_get(obj);
3563 if (!wd) return NULL;
3564 return wd->selected;
3568 * Get a list of realized items in genlist
3570 * This returns a list of the realized items in the genlist. The list
3571 * contains Elm_Genlist_Item pointers. The list must be freed by the
3572 * caller when done with eina_list_free(). The item pointers in the
3573 * list are only valid so long as those items are not deleted or the
3574 * genlist is not deleted.
3576 * @param obj The genlist object
3577 * @return The list of realized items, nor NULL if none are realized.
3582 elm_genlist_realized_items_get(const Evas_Object *obj)
3584 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3585 Widget_Data *wd = elm_widget_data_get(obj);
3586 Eina_List *list = NULL;
3588 Eina_Bool done = EINA_FALSE;
3589 if (!wd) return NULL;
3590 EINA_INLIST_FOREACH(wd->blocks, itb)
3595 Elm_Genlist_Item *it;
3598 EINA_LIST_FOREACH(itb->items, l, it)
3600 if (it->realized) list = eina_list_append(list, it);
3612 * Get the item that is at the x, y canvas coords
3614 * This returns the item at the given coordinates (which are canvas
3615 * relative not object-relative). If an item is at that coordinate,
3616 * that item handle is returned, and if @p posret is not NULL, the
3617 * integer pointed to is set to a value of -1, 0 or 1, depending if
3618 * the coordinate is on the upper portion of that item (-1), on the
3619 * middle section (0) or on the lower part (1). If NULL is returned as
3620 * an item (no item found there), then posret may indicate -1 or 1
3621 * based if the coordinate is above or below all items respectively in
3624 * @param it The item
3625 * @param x The input x coordinate
3626 * @param y The input y coordinate
3627 * @param posret The position relative to the item returned here
3628 * @return The item at the coordinates or NULL if none
3632 EAPI Elm_Genlist_Item *
3633 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3638 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3639 Widget_Data *wd = elm_widget_data_get(obj);
3640 Evas_Coord ox, oy, ow, oh;
3643 if (!wd) return NULL;
3644 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3646 EINA_INLIST_FOREACH(wd->blocks, itb)
3649 Elm_Genlist_Item *it;
3651 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3652 oy + itb->y - itb->wd->pan_y,
3653 itb->w, itb->h, x, y, 1, 1))
3655 EINA_LIST_FOREACH(itb->items, l, it)
3657 Evas_Coord itx, ity;
3659 itx = ox + itb->x + it->x - itb->wd->pan_x;
3660 ity = oy + itb->y + it->y - itb->wd->pan_y;
3661 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3665 if (y <= (ity + (it->h / 4))) *posret = -1;
3666 else if (y >= (ity + it->h - (it->h / 4)))
3672 lasty = ity + it->h;
3677 if (y > lasty) *posret = 1;
3684 * Get the first item in the genlist
3686 * This returns the first item in the list.
3688 * @param obj The genlist object
3689 * @return The first item, or NULL if none
3693 EAPI Elm_Genlist_Item *
3694 elm_genlist_first_item_get(const Evas_Object *obj)
3696 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3697 Widget_Data *wd = elm_widget_data_get(obj);
3698 if (!wd) return NULL;
3699 if (!wd->items) return NULL;
3700 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3701 while ((it) && (it->delete_me))
3702 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3707 * Get the last item in the genlist
3709 * This returns the last item in the list.
3711 * @return The last item, or NULL if none
3715 EAPI Elm_Genlist_Item *
3716 elm_genlist_last_item_get(const Evas_Object *obj)
3718 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3719 Widget_Data *wd = elm_widget_data_get(obj);
3720 if (!wd) return NULL;
3721 if (!wd->items) return NULL;
3722 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3723 while ((it) && (it->delete_me))
3724 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3729 * Get the next item in the genlist
3731 * This returns the item after the item @p it.
3733 * @param it The item
3734 * @return The item after @p it, or NULL if none
3738 EAPI Elm_Genlist_Item *
3739 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3741 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3744 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3745 if ((it) && (!it->delete_me)) break;
3747 return (Elm_Genlist_Item *)it;
3751 * Get the previous item in the genlist
3753 * This returns the item before the item @p it.
3755 * @param it The item
3756 * @return The item before @p it, or NULL if none
3760 EAPI Elm_Genlist_Item *
3761 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3763 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3766 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3767 if ((it) && (!it->delete_me)) break;
3769 return (Elm_Genlist_Item *)it;
3773 * Get the genlist object from an item
3775 * This returns the genlist object itself that an item belongs to.
3777 * @param it The item
3778 * @return The genlist object
3783 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3785 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3786 return it->base.widget;
3790 * Get the parent item of the given item
3792 * This returns the parent item of the item @p it given.
3794 * @param it The item
3795 * @return The parent of the item or NULL if none
3799 EAPI Elm_Genlist_Item *
3800 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3802 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3807 * Clear all sub-items (children) of the given item
3809 * This clears all items that are children (or their descendants) of the
3812 * @param it The item
3817 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3819 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3820 Eina_List *tl = NULL, *l;
3821 Elm_Genlist_Item *it2;
3823 EINA_LIST_FOREACH(it->items, l, it2)
3824 tl = eina_list_append(tl, it2);
3825 EINA_LIST_FREE(tl, it2)
3826 elm_genlist_item_del(it2);
3830 * Set the selected state of an item
3832 * This sets the selected state (1 selected, 0 not selected) of the given
3835 * @param it The item
3836 * @param selected The selected state
3841 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3844 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3845 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3847 if (it->delete_me) return;
3848 selected = !!selected;
3849 if (it->selected == selected) return;
3855 while (wd->selected)
3856 _item_unselect(wd->selected->data);
3858 _item_highlight(it);
3866 * Get the selected state of an item
3868 * This gets the selected state of an item (1 selected, 0 not selected).
3870 * @param it The item
3871 * @return The selected state
3876 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3878 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3879 return it->selected;
3883 * Sets the expanded state of an item (if it's a parent)
3885 * This expands or contracts a parent item (thus showing or hiding the
3888 * @param it The item
3889 * @param expanded The expanded state (1 expanded, 0 not expanded).
3894 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3897 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3898 if (it->expanded == expanded) return;
3899 it->expanded = expanded;
3903 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3904 evas_object_smart_callback_call(it->base.widget, "expanded", it);
3909 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3910 evas_object_smart_callback_call(it->base.widget, "contracted", it);
3915 * Get the expanded state of an item
3917 * This gets the expanded state of an item
3919 * @param it The item
3920 * @return Thre expanded state
3925 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3927 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3928 return it->expanded;
3932 * Get the depth of expanded item
3934 * @param it The genlist item object
3935 * @return The depth of expanded item
3940 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3942 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3943 return it->expanded_depth;
3947 * Sets the disabled state of an item.
3949 * A disabled item cannot be selected or unselected. It will also
3950 * change appearance to appear disabled. This sets the disabled state
3951 * (1 disabled, 0 not disabled).
3953 * @param it The item
3954 * @param disabled The disabled state
3959 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3962 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3963 if (it->disabled == disabled) return;
3964 if (it->delete_me) return;
3965 it->disabled = disabled;
3969 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3971 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3976 * Get the disabled state of an item
3978 * This gets the disabled state of the given item.
3980 * @param it The item
3981 * @return The disabled state
3986 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3988 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3989 if (it->delete_me) return EINA_FALSE;
3990 return it->disabled;
3994 * Sets the display only state of an item.
3996 * A display only item cannot be selected or unselected. It is for
3997 * display only and not selecting or otherwise clicking, dragging
3998 * etc. by the user, thus finger size rules will not be applied to
4001 * @param it The item
4002 * @param display_only The display only state
4007 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4008 Eina_Bool display_only)
4010 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4011 if (it->display_only == display_only) return;
4012 if (it->delete_me) return;
4013 it->display_only = display_only;
4014 it->mincalcd = EINA_FALSE;
4015 it->updateme = EINA_TRUE;
4016 if (it->block) it->block->updateme = EINA_TRUE;
4017 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4018 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4022 * Get the display only state of an item
4024 * This gets the display only state of the given item.
4026 * @param it The item
4027 * @return The display only state
4032 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4034 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4035 if (it->delete_me) return EINA_FALSE;
4036 return it->display_only;
4040 * Show the given item
4042 * This causes genlist to jump to the given item @p it and show it (by
4043 * scrolling), if it is not fully visible.
4045 * @param it The item
4050 elm_genlist_item_show(Elm_Genlist_Item *it)
4052 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4053 Evas_Coord gith = 0;
4054 if (it->delete_me) return;
4055 if ((it->queued) || (!it->mincalcd))
4057 it->wd->show_item = it;
4058 it->wd->bring_in = EINA_TRUE;
4059 it->showme = EINA_TRUE;
4062 if (it->wd->show_item)
4064 it->wd->show_item->showme = EINA_FALSE;
4065 it->wd->show_item = NULL;
4067 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4068 gith = it->group_item->h;
4069 elm_smart_scroller_child_region_show(it->wd->scr,
4070 it->x + it->block->x,
4071 it->y + it->block->y - gith,
4072 it->block->w, it->h);
4076 * Bring in the given item
4078 * This causes genlist to jump to the given item @p it and show it (by
4079 * scrolling), if it is not fully visible. This may use animation to
4080 * do so and take a period of time
4082 * @param it The item
4087 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4089 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4090 Evas_Coord gith = 0;
4091 if (it->delete_me) return;
4092 if ((it->queued) || (!it->mincalcd))
4094 it->wd->show_item = it;
4095 it->wd->bring_in = EINA_TRUE;
4096 it->showme = EINA_TRUE;
4099 if (it->wd->show_item)
4101 it->wd->show_item->showme = EINA_FALSE;
4102 it->wd->show_item = NULL;
4104 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4105 gith = it->group_item->h;
4106 elm_smart_scroller_region_bring_in(it->wd->scr,
4107 it->x + it->block->x,
4108 it->y + it->block->y - gith,
4109 it->block->w, it->h);
4113 * Show the given item at the top
4115 * This causes genlist to jump to the given item @p it and show it (by
4116 * scrolling), if it is not fully visible.
4118 * @param it The item
4123 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4125 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4127 Evas_Coord gith = 0;
4129 if (it->delete_me) return;
4130 if ((it->queued) || (!it->mincalcd))
4132 it->wd->show_item = it;
4133 it->wd->bring_in = EINA_TRUE;
4134 it->showme = EINA_TRUE;
4137 if (it->wd->show_item)
4139 it->wd->show_item->showme = EINA_FALSE;
4140 it->wd->show_item = NULL;
4142 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4143 if (it->group_item) gith = it->group_item->h;
4144 elm_smart_scroller_child_region_show(it->wd->scr,
4145 it->x + it->block->x,
4146 it->y + it->block->y - gith,
4151 * Bring in the given item at the top
4153 * This causes genlist to jump to the given item @p it and show it (by
4154 * scrolling), if it is not fully visible. This may use animation to
4155 * do so and take a period of time
4157 * @param it The item
4162 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4164 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4166 Evas_Coord gith = 0;
4168 if (it->delete_me) return;
4169 if ((it->queued) || (!it->mincalcd))
4171 it->wd->show_item = it;
4172 it->wd->bring_in = EINA_TRUE;
4173 it->showme = EINA_TRUE;
4176 if (it->wd->show_item)
4178 it->wd->show_item->showme = EINA_FALSE;
4179 it->wd->show_item = NULL;
4181 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4182 if (it->group_item) gith = it->group_item->h;
4183 elm_smart_scroller_region_bring_in(it->wd->scr,
4184 it->x + it->block->x,
4185 it->y + it->block->y - gith,
4190 * Show the given item at the middle
4192 * This causes genlist to jump to the given item @p it and show it (by
4193 * scrolling), if it is not fully visible.
4195 * @param it The item
4200 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4202 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4205 if (it->delete_me) return;
4206 if ((it->queued) || (!it->mincalcd))
4208 it->wd->show_item = it;
4209 it->wd->bring_in = EINA_TRUE;
4210 it->showme = EINA_TRUE;
4213 if (it->wd->show_item)
4215 it->wd->show_item->showme = EINA_FALSE;
4216 it->wd->show_item = NULL;
4218 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4219 elm_smart_scroller_child_region_show(it->wd->scr,
4220 it->x + it->block->x,
4221 it->y + it->block->y - oh / 2 +
4222 it->h / 2, it->block->w, oh);
4226 * Bring in the given item at the middle
4228 * This causes genlist to jump to the given item @p it and show it (by
4229 * scrolling), if it is not fully visible. This may use animation to
4230 * do so and take a period of time
4232 * @param it The item
4237 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4239 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4242 if (it->delete_me) return;
4243 if ((it->queued) || (!it->mincalcd))
4245 it->wd->show_item = it;
4246 it->wd->bring_in = EINA_TRUE;
4247 it->showme = EINA_TRUE;
4250 if (it->wd->show_item)
4252 it->wd->show_item->showme = EINA_FALSE;
4253 it->wd->show_item = NULL;
4255 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4256 elm_smart_scroller_region_bring_in(it->wd->scr,
4257 it->x + it->block->x,
4258 it->y + it->block->y - oh / 2 + it->h / 2,
4263 * Delete a given item
4265 * This deletes the item from genlist and calls the genlist item del
4266 * class callback defined in the item class, if it is set. This clears all
4267 * subitems if it is a tree.
4269 * @param it The item
4274 elm_genlist_item_del(Elm_Genlist_Item *it)
4276 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4277 if ((it->relcount > 0) || (it->walking > 0))
4279 elm_widget_item_pre_notify_del(it);
4280 elm_genlist_item_subitems_clear(it);
4281 it->delete_me = EINA_TRUE;
4282 if (it->wd->show_item == it) it->wd->show_item = NULL;
4284 it->wd->selected = eina_list_remove(it->wd->selected,
4288 if (it->realized) _item_unrealize(it, EINA_FALSE);
4289 it->block->changed = EINA_TRUE;
4290 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4291 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4293 if (it->itc->func.del)
4294 it->itc->func.del((void *)it->base.data, it->base.widget);
4301 * Set the data item from the genlist item
4303 * This set the data value passed on the elm_genlist_item_append() and
4304 * related item addition calls. This function will also call
4305 * elm_genlist_item_update() so the item will be updated to reflect the
4308 * @param it The item
4309 * @param data The new data pointer to set
4314 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4317 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4318 elm_widget_item_data_set(it, data);
4319 elm_genlist_item_update(it);
4323 * Get the data item from the genlist item
4325 * This returns the data value passed on the elm_genlist_item_append()
4326 * and related item addition calls and elm_genlist_item_data_set().
4328 * @param it The item
4329 * @return The data pointer provided when created
4334 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4337 return elm_widget_item_data_get(it);
4341 * Tells genlist to "orphan" icons fetchs by the item class
4343 * This instructs genlist to release references to icons in the item,
4344 * meaning that they will no longer be managed by genlist and are
4345 * floating "orphans" that can be re-used elsewhere if the user wants
4348 * @param it The item
4353 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4356 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4357 EINA_LIST_FREE(it->icon_objs, icon)
4359 elm_widget_sub_object_del(it->base.widget, icon);
4360 evas_object_smart_member_del(icon);
4361 evas_object_hide(icon);
4366 * Get the real evas object of the genlist item
4368 * This returns the actual evas object used for the specified genlist
4369 * item. This may be NULL as it may not be created, and may be deleted
4370 * at any time by genlist. Do not modify this object (move, resize,
4371 * show, hide etc.) as genlist is controlling it. This function is for
4372 * querying, emitting custom signals or hooking lower level callbacks
4373 * for events. Do not delete this object under any circumstances.
4375 * @param it The item
4376 * @return The object pointer
4380 EAPI const Evas_Object *
4381 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4383 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4384 return it->base.view;
4388 * Update the contents of an item
4390 * This updates an item by calling all the item class functions again
4391 * to get the icons, labels and states. Use this when the original
4392 * item data has changed and the changes are desired to be reflected.
4394 * @param it The item
4399 elm_genlist_item_update(Elm_Genlist_Item *it)
4401 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4402 if (!it->block) return;
4403 if (it->delete_me) return;
4404 it->mincalcd = EINA_FALSE;
4405 it->updateme = EINA_TRUE;
4406 it->block->updateme = EINA_TRUE;
4407 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4408 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4412 * Update the item class of an item
4414 * @param it The item
4415 * @parem itc The item class for the item
4420 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4421 const Elm_Genlist_Item_Class *itc)
4423 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4424 if (!it->block) return;
4425 EINA_SAFETY_ON_NULL_RETURN(itc);
4426 if (it->delete_me) return;
4428 it->nocache = EINA_TRUE;
4429 elm_genlist_item_update(it);
4432 static Evas_Object *
4433 _elm_genlist_item_label_create(void *data,
4435 void *item __UNUSED__)
4437 Evas_Object *label = elm_label_add(obj);
4440 elm_object_style_set(label, "tooltip");
4441 elm_label_label_set(label, data);
4446 _elm_genlist_item_label_del_cb(void *data,
4447 Evas_Object *obj __UNUSED__,
4448 void *event_info __UNUSED__)
4450 eina_stringshare_del(data);
4454 * Set the text to be shown in the genlist item.
4456 * @param item Target item
4457 * @param text The text to set in the content
4459 * Setup the text as tooltip to object. The item can have only one
4460 * tooltip, so any previous tooltip data is removed.
4465 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4468 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4469 text = eina_stringshare_add(text);
4470 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4472 _elm_genlist_item_label_del_cb);
4476 * Set the content to be shown in the tooltip item
4478 * Setup the tooltip to item. The item can have only one tooltip, so
4479 * any previous tooltip data is removed. @p func(with @p data) will be
4480 * called every time that need to show the tooltip and it should return a
4481 * valid Evas_Object. This object is then managed fully by tooltip
4482 * system and is deleted when the tooltip is gone.
4484 * @param item the genlist item being attached by a tooltip.
4485 * @param func the function used to create the tooltip contents.
4486 * @param data what to provide to @a func as callback data/context.
4487 * @param del_cb called when data is not needed anymore, either when
4488 * another callback replaces @func, the tooltip is unset with
4489 * elm_genlist_item_tooltip_unset() or the owner @a item
4490 * dies. This callback receives as the first parameter the
4491 * given @a data, and @c event_info is the item.
4496 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4497 Elm_Tooltip_Item_Content_Cb func,
4499 Evas_Smart_Cb del_cb)
4501 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4503 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4506 if (item->tooltip.del_cb)
4507 item->tooltip.del_cb((void *)item->tooltip.data,
4508 item->base.widget, item);
4510 item->tooltip.content_cb = func;
4511 item->tooltip.data = data;
4512 item->tooltip.del_cb = del_cb;
4514 if (item->base.view)
4516 elm_widget_item_tooltip_content_cb_set(item,
4517 item->tooltip.content_cb,
4518 item->tooltip.data, NULL);
4519 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4525 if (del_cb) del_cb((void *)data, NULL, NULL);
4529 * Unset tooltip from item
4531 * @param item genlist item to remove previously set tooltip.
4533 * Remove tooltip from item. The callback provided as del_cb to
4534 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4535 * it is not used anymore.
4537 * @see elm_genlist_item_tooltip_content_cb_set()
4542 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4545 if ((item->base.view) && (item->tooltip.content_cb))
4546 elm_widget_item_tooltip_unset(item);
4548 if (item->tooltip.del_cb)
4549 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4550 item->tooltip.del_cb = NULL;
4551 item->tooltip.content_cb = NULL;
4552 item->tooltip.data = NULL;
4553 if (item->tooltip.style)
4554 elm_genlist_item_tooltip_style_set(item, NULL);
4558 * Sets a different style for this item tooltip.
4560 * @note before you set a style you should define a tooltip with
4561 * elm_genlist_item_tooltip_content_cb_set() or
4562 * elm_genlist_item_tooltip_text_set()
4564 * @param item genlist item with tooltip already set.
4565 * @param style the theme style to use (default, transparent, ...)
4570 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4573 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4574 eina_stringshare_replace(&item->tooltip.style, style);
4575 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4579 * Get the style for this item tooltip.
4581 * @param item genlist item with tooltip already set.
4582 * @return style the theme style in use, defaults to "default". If the
4583 * object does not have a tooltip set, then NULL is returned.
4588 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4590 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4591 return item->tooltip.style;
4595 * Set the cursor to be shown when mouse is over the genlist item
4597 * @param item Target item
4598 * @param cursor the cursor name to be used.
4600 * @see elm_object_cursor_set()
4604 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4607 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4608 eina_stringshare_replace(&item->mouse_cursor, cursor);
4609 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4613 * Get the cursor to be shown when mouse is over the genlist item
4615 * @param item genlist item with cursor already set.
4616 * @return the cursor name.
4621 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4623 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4624 return elm_widget_item_cursor_get(item);
4628 * Unset the cursor to be shown when mouse is over the genlist item
4630 * @param item Target item
4632 * @see elm_object_cursor_unset()
4636 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4638 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4639 if (!item->mouse_cursor)
4642 if (item->base.view)
4643 elm_widget_item_cursor_unset(item);
4645 eina_stringshare_del(item->mouse_cursor);
4646 item->mouse_cursor = NULL;
4650 * Sets a different style for this item cursor.
4652 * @note before you set a style you should define a cursor with
4653 * elm_genlist_item_cursor_set()
4655 * @param item genlist item with cursor already set.
4656 * @param style the theme style to use (default, transparent, ...)
4661 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4664 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4665 elm_widget_item_cursor_style_set(item, style);
4669 * Get the style for this item cursor.
4671 * @param item genlist item with cursor already set.
4672 * @return style the theme style in use, defaults to "default". If the
4673 * object does not have a cursor set, then NULL is returned.
4678 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4680 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4681 return elm_widget_item_cursor_style_get(item);
4685 * Set if the cursor set should be searched on the theme or should use
4686 * the provided by the engine, only.
4688 * @note before you set if should look on theme you should define a
4689 * cursor with elm_object_cursor_set(). By default it will only look
4690 * for cursors provided by the engine.
4692 * @param item widget item with cursor already set.
4693 * @param engine_only boolean to define it cursors should be looked
4694 * only between the provided by the engine or searched on widget's
4700 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4701 Eina_Bool engine_only)
4703 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4704 elm_widget_item_cursor_engine_only_set(item, engine_only);
4708 * Get the cursor engine only usage for this item cursor.
4710 * @param item widget item with cursor already set.
4711 * @return engine_only boolean to define it cursors should be looked
4712 * only between the provided by the engine or searched on widget's
4713 * theme as well. If the object does not have a cursor set, then
4714 * EINA_FALSE is returned.
4719 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4721 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4722 return elm_widget_item_cursor_engine_only_get(item);
4726 * This sets the horizontal stretching mode
4728 * This sets the mode used for sizing items horizontally. Valid modes
4729 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4730 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4731 * the scroller will scroll horizontally. Otherwise items are expanded
4732 * to fill the width of the viewport of the scroller. If it is
4733 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4734 * limited to that size.
4736 * @param obj The genlist object
4737 * @param mode The mode to use
4742 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4745 ELM_CHECK_WIDTYPE(obj, widtype);
4746 Widget_Data *wd = elm_widget_data_get(obj);
4748 if (wd->mode == mode) return;
4754 * Gets the horizontal stretching mode
4756 * @param obj The genlist object
4757 * @return The mode to use
4758 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4763 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4765 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4766 Widget_Data *wd = elm_widget_data_get(obj);
4767 if (!wd) return ELM_LIST_LAST;
4772 * Set the always select mode.
4774 * Items will only call their selection func and callback when first
4775 * becoming selected. Any further clicks will do nothing, unless you
4776 * enable always select with elm_genlist_always_select_mode_set().
4777 * This means even if selected, every click will make the selected
4778 * callbacks be called.
4780 * @param obj The genlist object
4781 * @param always_select The always select mode
4782 * (EINA_TRUE = on, EINA_FALSE = off)
4787 elm_genlist_always_select_mode_set(Evas_Object *obj,
4788 Eina_Bool always_select)
4790 ELM_CHECK_WIDTYPE(obj, widtype);
4791 Widget_Data *wd = elm_widget_data_get(obj);
4793 wd->always_select = always_select;
4797 * Get the always select mode.
4799 * @param obj The genlist object
4800 * @return The always select mode
4801 * (EINA_TRUE = on, EINA_FALSE = off)
4806 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4808 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4809 Widget_Data *wd = elm_widget_data_get(obj);
4810 if (!wd) return EINA_FALSE;
4811 return wd->always_select;
4815 * Set no select mode
4817 * This will turn off the ability to select items entirely and they
4818 * will neither appear selected nor call selected callback functions.
4820 * @param obj The genlist object
4821 * @param no_select The no select mode
4822 * (EINA_TRUE = on, EINA_FALSE = off)
4827 elm_genlist_no_select_mode_set(Evas_Object *obj,
4828 Eina_Bool no_select)
4830 ELM_CHECK_WIDTYPE(obj, widtype);
4831 Widget_Data *wd = elm_widget_data_get(obj);
4833 wd->no_select = no_select;
4837 * Gets no select mode
4839 * @param obj The genlist object
4840 * @return The no select mode
4841 * (EINA_TRUE = on, EINA_FALSE = off)
4846 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4848 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4849 Widget_Data *wd = elm_widget_data_get(obj);
4850 if (!wd) return EINA_FALSE;
4851 return wd->no_select;
4857 * This will enable the compress mode where items are "compressed"
4858 * horizontally to fit the genlist scrollable viewport width. This is
4859 * special for genlist. Do not rely on
4860 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4861 * work as genlist needs to handle it specially.
4863 * @param obj The genlist object
4864 * @param compress The compress mode
4865 * (EINA_TRUE = on, EINA_FALSE = off)
4870 elm_genlist_compress_mode_set(Evas_Object *obj,
4873 ELM_CHECK_WIDTYPE(obj, widtype);
4874 Widget_Data *wd = elm_widget_data_get(obj);
4876 wd->compress = compress;
4880 * Get the compress mode
4882 * @param obj The genlist object
4883 * @return The compress mode
4884 * (EINA_TRUE = on, EINA_FALSE = off)
4889 elm_genlist_compress_mode_get(const Evas_Object *obj)
4891 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4892 Widget_Data *wd = elm_widget_data_get(obj);
4893 if (!wd) return EINA_FALSE;
4894 return wd->compress;
4898 * Set height-for-width mode
4900 * With height-for-width mode the item width will be fixed (restricted
4901 * to a minimum of) to the list width when calculating its size in
4902 * order to allow the height to be calculated based on it. This allows,
4903 * for instance, text block to wrap lines if the Edje part is
4904 * configured with "text.min: 0 1".
4906 * @note This mode will make list resize slower as it will have to
4907 * recalculate every item height again whenever the list width
4910 * @note When height-for-width mode is enabled, it also enables
4911 * compress mode (see elm_genlist_compress_mode_set()) and
4912 * disables homogeneous (see elm_genlist_homogeneous_set()).
4914 * @param obj The genlist object
4915 * @param setting The height-for-width mode (EINA_TRUE = on,
4921 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4922 Eina_Bool height_for_width)
4924 ELM_CHECK_WIDTYPE(obj, widtype);
4925 Widget_Data *wd = elm_widget_data_get(obj);
4927 wd->height_for_width = !!height_for_width;
4928 if (wd->height_for_width)
4930 elm_genlist_homogeneous_set(obj, EINA_FALSE);
4931 elm_genlist_compress_mode_set(obj, EINA_TRUE);
4936 * Get the height-for-width mode
4938 * @param obj The genlist object
4939 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4945 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4947 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4948 Widget_Data *wd = elm_widget_data_get(obj);
4949 if (!wd) return EINA_FALSE;
4950 return wd->height_for_width;
4956 * This will enable or disable the scroller bounce mode for the
4957 * genlist. See elm_scroller_bounce_set() for details
4959 * @param obj The genlist object
4960 * @param h_bounce Allow bounce horizontally
4961 * @param v_bounce Allow bounce vertically
4966 elm_genlist_bounce_set(Evas_Object *obj,
4970 ELM_CHECK_WIDTYPE(obj, widtype);
4971 Widget_Data *wd = elm_widget_data_get(obj);
4973 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4977 * Get the bounce mode
4979 * @param obj The genlist object
4980 * @param h_bounce Allow bounce horizontally
4981 * @param v_bounce Allow bounce vertically
4986 elm_genlist_bounce_get(const Evas_Object *obj,
4987 Eina_Bool *h_bounce,
4988 Eina_Bool *v_bounce)
4990 ELM_CHECK_WIDTYPE(obj, widtype);
4991 Widget_Data *wd = elm_widget_data_get(obj);
4993 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4997 * Set homogenous mode
4999 * This will enable the homogeneous mode where items are of the same
5000 * height and width so that genlist may do the lazy-loading at its
5001 * maximum. This implies 'compressed' mode.
5003 * @param obj The genlist object
5004 * @param homogeneous Assume the items within the genlist are of the
5005 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5010 elm_genlist_homogeneous_set(Evas_Object *obj,
5011 Eina_Bool homogeneous)
5013 ELM_CHECK_WIDTYPE(obj, widtype);
5014 Widget_Data *wd = elm_widget_data_get(obj);
5016 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5017 wd->homogeneous = homogeneous;
5021 * Get the homogenous mode
5023 * @param obj The genlist object
5024 * @return Assume the items within the genlist are of the same height
5025 * and width (EINA_TRUE = on, EINA_FALSE = off)
5030 elm_genlist_homogeneous_get(const Evas_Object *obj)
5032 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5033 Widget_Data *wd = elm_widget_data_get(obj);
5034 if (!wd) return EINA_FALSE;
5035 return wd->homogeneous;
5039 * Set the maximum number of items within an item block
5041 * This will configure the block count to tune to the target with
5042 * particular performance matrix.
5044 * @param obj The genlist object
5045 * @param n Maximum number of items within an item block
5050 elm_genlist_block_count_set(Evas_Object *obj,
5053 ELM_CHECK_WIDTYPE(obj, widtype);
5054 Widget_Data *wd = elm_widget_data_get(obj);
5056 wd->max_items_per_block = n;
5057 wd->item_cache_max = wd->max_items_per_block * 2;
5058 _item_cache_clean(wd);
5062 * Get the maximum number of items within an item block
5064 * @param obj The genlist object
5065 * @return Maximum number of items within an item block
5070 elm_genlist_block_count_get(const Evas_Object *obj)
5072 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5073 Widget_Data *wd = elm_widget_data_get(obj);
5075 return wd->max_items_per_block;
5079 * Set the timeout in seconds for the longpress event
5081 * @param obj The genlist object
5082 * @param timeout timeout in seconds
5087 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5090 ELM_CHECK_WIDTYPE(obj, widtype);
5091 Widget_Data *wd = elm_widget_data_get(obj);
5093 wd->longpress_timeout = timeout;
5097 * Get the timeout in seconds for the longpress event
5099 * @param obj The genlist object
5100 * @return timeout in seconds
5105 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5107 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5108 Widget_Data *wd = elm_widget_data_get(obj);
5110 return wd->longpress_timeout;
5114 * Set the scrollbar policy
5116 * This sets the scrollbar visibility policy for the given genlist
5117 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5118 * made visible if it is needed, and otherwise kept hidden.
5119 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5120 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5121 * respectively for the horizontal and vertical scrollbars.
5123 * @param obj The genlist object
5124 * @param policy_h Horizontal scrollbar policy
5125 * @param policy_v Vertical scrollbar policy
5130 elm_genlist_scroller_policy_set(Evas_Object *obj,
5131 Elm_Scroller_Policy policy_h,
5132 Elm_Scroller_Policy policy_v)
5134 ELM_CHECK_WIDTYPE(obj, widtype);
5135 Widget_Data *wd = elm_widget_data_get(obj);
5137 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5138 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5141 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5145 * Get the scrollbar policy
5147 * @param obj The genlist object
5148 * @param policy_h Horizontal scrollbar policy
5149 * @param policy_v Vertical scrollbar policy
5154 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5155 Elm_Scroller_Policy *policy_h,
5156 Elm_Scroller_Policy *policy_v)
5158 ELM_CHECK_WIDTYPE(obj, widtype);
5159 Widget_Data *wd = elm_widget_data_get(obj);
5160 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5161 if ((!wd) || (!wd->scr)) return;
5162 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5163 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5164 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5168 * Update the contents of all realized items
5170 * This updates all realized items by calling all the item class functions again
5171 * to get the icons, labels and states. Use this when the original
5172 * item data has changed and the changes are desired to be reflected.
5174 * @param it The item
5179 elm_genlist_realized_items_update(Evas_Object *obj)
5181 ELM_CHECK_WIDTYPE(obj, widtype);
5183 Eina_List *list, *l;
5184 Elm_Genlist_Item *it;
5186 list = elm_genlist_realized_items_get(obj);
5187 EINA_LIST_FOREACH(list, l, it)
5188 elm_genlist_item_update(it);
5192 * Set genlist item mode
5194 * @param item The genlist item
5195 * @param mode Mode name
5196 * @param mode_set Boolean to define set or unset mode.
5201 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5202 const char *mode_type,
5205 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5206 Widget_Data *wd = it->wd;
5208 Elm_Genlist_Item *it2;
5211 if (!mode_type) return;
5213 if ((wd->mode_item == it) &&
5214 (!strcmp(mode_type, wd->mode_type)) &&
5217 if (!it->itc->mode_item_style) return;
5221 EINA_LIST_FOREACH(wd->selected, l, it2)
5223 elm_genlist_item_selected_set(it2, EINA_FALSE);
5227 it2 = elm_genlist_selected_item_get(wd->obj);
5228 if ((it2) && (it2->realized))
5229 elm_genlist_item_selected_set(it2, EINA_FALSE);
5232 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5234 ((it == wd->mode_item) && (!mode_set)))
5235 _item_mode_unset(wd);
5237 eina_stringshare_replace(&wd->mode_type, mode_type);
5238 if (mode_set) _item_mode_set(it);
5242 * Get active genlist mode type
5244 * @param obj The genlist object
5249 elm_genlist_mode_get(const Evas_Object *obj)
5251 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5252 Widget_Data *wd = elm_widget_data_get(obj);
5253 if (!wd) return NULL;
5254 return wd->mode_type;
5258 * Get active genlist mode item
5260 * @param obj The genlist object
5264 EAPI const Elm_Genlist_Item *
5265 elm_genlist_mode_item_get(const Evas_Object *obj)
5267 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5268 Widget_Data *wd = elm_widget_data_get(obj);
5269 if (!wd) return NULL;
5270 return wd->mode_item;