3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list that the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complexity when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * drag,start,up - This is called when the item in the list has been dragged
60 * drag,start,down - This is called when the item in the list has been dragged
61 * (not scrolled) down.
63 * drag,start,left - This is called when the item in the list has been dragged
64 * (not scrolled) left.
66 * drag,start,right - This is called when the item in the list has been dragged
67 * (not scrolled) right.
69 * drag,stop - This is called when the item in the list has stopped being
72 * drag - This is called when the item in the list is being dragged.
74 * Genlist has a fairly large API, mostly because it's relatively complex,
75 * trying to be both expansive, powerful and efficient. First we will begin
76 * an overview o the theory behind genlist.
78 * Evas tracks every object you create. Every time it processes an event
79 * (mouse move, down, up etc.) it needs to walk through objects and find out
80 * what event that affects. Even worse every time it renders display updates,
81 * in order to just calculate what to re-draw, it needs to walk through many
82 * many many objects. Thus, the more objects you keep active, the more
83 * overhead Evas has in just doing its work. It is advisable to keep your
84 * active objects to the minimum working set you need. Also remember that
85 * object creation and deletion carries an overhead, so there is a
86 * middle-ground, which is not easily determined. But don't keep massive lists
87 * of objects you can't see or use. Genlist does this with list objects. It
88 * creates and destroys them dynamically as you scroll around. It groups them
89 * into blocks so it can determine the visibility etc. of a whole block at
90 * once as opposed to having to walk the whole list. This 2-level list allows
91 * for very large numbers of items to be in the list (tests have used up to
92 * 2,000,000 items). Also genlist employs a queue for adding items. As items
93 * may be different sizes, every item added needs to be calculated as to its
94 * size and thus this presents a lot of overhead on populating the list, this
95 * genlist employs a queue. Any item added is queued and spooled off over
96 * time, actually appearing some time later, so if your list has many members
97 * you may find it takes a while for them to all appear, with your process
98 * consuming a lot of CPU while it is busy spooling.
100 * Genlist also implements a tree structure, but it does so with callbacks to
101 * the application, with the application filling in tree structures when
102 * requested (allowing for efficient building of a very deep tree that could
103 * even be used for file-management). See the above smart signal callbacks for
106 * An item in the genlist world can have 0 or more text labels (they can be
107 * regular text or textblock – that's up to the style to determine), 0 or
108 * more icons (which are simply objects swallowed into the genlist item) and
109 * 0 or more boolean states that can be used for check, radio or other
110 * indicators by the edje theme style. An item may be one of several styles
111 * (Elementary provides 2 by default - “default” and “double_label”, but this
112 * can be extended by system or application custom themes/overlays/extensions).
114 * In order to implement the ability to add and delete items on the fly,
115 * Genlist implements a class/callback system where the application provides
116 * a structure with information about that type of item (genlist may contain
117 * multiple different items with different classes, states and styles).
118 * Genlist will call the functions in this struct (methods) when an item is
119 * “realized” (that is created dynamically while scrolling). All objects will
120 * simply be deleted when no longer needed with evas_object_del(). The
121 * Elm_Genlist_Item_Class structure contains the following members:
123 * item_style - This is a constant string and simply defines the name of the
124 * item style. It must be specified and the default should be “default”.
126 * func.label_get - This function is called when an actual item object is
127 * created. The data parameter is the data parameter passed to
128 * elm_genlist_item_append() and related item creation functions. The obj
129 * parameter is the genlist object and the part parameter is the string name
130 * of the text part in the edje design that is listed as one of the possible
131 * labels that can be set. This function must return a strudup()'ed string as
132 * the caller will free() it when done.
134 * func.icon_get - This function is called when an actual item object is
135 * created. The data parameter is the data parameter passed to
136 * elm_genlist_item_append() and related item creation functions. The obj
137 * parameter is the genlist object and the part parameter is the string name
138 * of the icon part in the edje design that is listed as one of the possible
139 * icons that can be set. This must return NULL for no object or a valid
140 * object. The object will be deleted by genlist on shutdown or when the item
143 * func.state_get - This function is called when an actual item object is
144 * created. The data parameter is the data parameter passed to
145 * elm_genlist_item_append() and related item creation functions. The obj
146 * parameter is the genlist object and the part parameter is the string name
147 * of the state part in the edje design that is listed as one of the possible
148 * states that can be set. Return 0 for false or 1 for true. Genlist will
149 * emit a signal to the edje object with “elm,state,XXX,active” “elm” when
150 * true (the default is false), where XXX is the name of the part.
152 * func.del - This is called when elm_genlist_item_del() is called on an
153 * item, elm_genlist_clear() is called on the genlist, or
154 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
155 * intended for use when actual genlist items are deleted, so any backing
156 * data attached to the item (e.g. its data parameter on creation) can be
159 * Items can be added by several calls. All of them return a Elm_Genlist_Item
160 * handle that is an internal member inside the genlist. They all take a data
161 * parameter that is meant to be used for a handle to the applications
162 * internal data (eg the struct with the original item data). The parent
163 * parameter is the parent genlist item this belongs to if it is a tree, and
164 * NULL if there is no parent. The flags can be a bitmask of
165 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
166 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
167 * that is able to expand and have child items. The func parameter is a
168 * convenience callback that is called when the item is selected and the data
169 * parameter will be the func_data parameter, obj be the genlist object and
170 * vent_info will be the genlist item.
172 * elm_genlist_item_append() appends an item to the end of the list, or if
173 * there is a parent, to the end of all the child items of the parent.
174 * elm_genlist_item_prepend() is the same but prepends to the beginning of
175 * the list or children list. elm_genlist_item_insert_before() inserts at
176 * item before another item and elm_genlist_item_insert_after() inserts after
177 * the indicated item.
179 * The application can clear the list with elm_genlist_clear() which deletes
180 * all the items in the list and elm_genlist_item_del() will delete a specific
181 * item. elm_genlist_item_subitems_clear() will clear all items that are
182 * children of the indicated parent item.
184 * If the application wants multiple items to be able to be selected,
185 * elm_genlist_multi_select_set() can enable this. If the list is
186 * single-selection only (the default), then elm_genlist_selected_item_get()
187 * will return the selected item, if any, or NULL I none is selected. If the
188 * list is multi-select then elm_genlist_selected_items_get() will return a
189 * list (that is only valid as long as no items are modified (added, deleted,
190 * selected or unselected).
192 * To help inspect list items you can jump to the item at the top of the list
193 * with elm_genlist_first_item_get() which will return the item pointer, and
194 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
195 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
196 * and previous items respectively relative to the indicated item. Using
197 * these calls you can walk the entire item list/tree. Note that as a tree
198 * the items are flattened in the list, so elm_genlist_item_parent_get() will
199 * let you know which item is the parent (and thus know how to skip them if
202 * There are also convenience functions. elm_genlist_item_genlist_get() will
203 * return the genlist object the item belongs to. elm_genlist_item_show()
204 * will make the scroller scroll to show that specific item so its visible.
205 * elm_genlist_item_data_get() returns the data pointer set by the item
206 * creation functions.
208 * If an item changes (state of boolean changes, label or icons change),
209 * then use elm_genlist_item_update() to have genlist update the item with
210 * the new state. Genlist will re-realize the item thus call the functions
211 * in the _Elm_Genlist_Item_Class for that item.
213 * To programmatically (un)select an item use elm_genlist_item_selected_set().
214 * To get its selected state use elm_genlist_item_selected_get(). Similarly
215 * to expand/contract and item and get its expanded state, use
216 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
217 * again to make an item disabled (unable to be selected and appear
218 * differently) use elm_genlist_item_disabled_set() to set this and
219 * elm_genlist_item_disabled_get() to get the disabled state.
221 * In general to indicate how the genlist should expand items horizontally to
222 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
223 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
224 * mode means that if items are too wide to fit, the scroller will scroll
225 * horizontally. Otherwise items are expanded to fill the width of the
226 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
227 * to the viewport width and limited to that size. This can be combined with
228 * a different style that uses edjes' ellipsis feature (cutting text off like
231 * Items will only call their selection func and callback when first becoming
232 * selected. Any further clicks will do nothing, unless you enable always
233 * select with elm_genlist_always_select_mode_set(). This means even if
234 * selected, every click will make the selected callbacks be called.
235 * elm_genlist_no_select_mode_set() will turn off the ability to select
236 * items entirely and they will neither appear selected nor call selected
237 * callback functions.
239 * Remember that you can create new styles and add you own theme augmentation
240 * per application with elm_theme_extension_add(). If you absolutely must
241 * have a specific style that overrides any theme the user or system sets up
242 * you can use elm_theme_overlay_add() to add such a file.
245 typedef struct _Widget_Data Widget_Data;
246 typedef struct _Item_Block Item_Block;
247 typedef struct _Pan Pan;
248 typedef struct _Edit_Data Edit_Data;
250 #define GROUP_ALIGN_NORTH 1
251 #define GROUP_ALIGN_WEST 2
254 Evas_Object *obj, *scr, *pan_smart;
255 Eina_Inlist *items, *blocks, *group_items;
257 Evas_Coord pan_x, pan_y, minw, minh;
258 Ecore_Job *calc_job, *update_job;
259 Ecore_Idler *queue_idler;
260 Eina_List *queue, *selected;
261 Elm_Genlist_Item *show_item;
263 Eina_Bool on_hold : 1;
265 Eina_Bool always_select : 1;
266 Eina_Bool longpressed : 1;
267 Eina_Bool wasselected : 1;
268 Eina_Bool no_select : 1;
269 Eina_Bool bring_in : 1;
270 Eina_Bool compress : 1;
271 Eina_Bool homogeneous : 1;
274 int max_items_per_block;
276 Eina_Bool animate_edit_controls :1;
281 Elm_Genlist_Edit_Class *ec;
282 Elm_Genlist_Item *del_item;
283 Elm_Genlist_Item *reorder_item;
284 Elm_Genlist_Item *reorder_rel;
285 Eina_Bool del_confirm_state : 1;
286 Evas_Object *del_confirm;
296 Evas_Coord x, y, w, h, minw, minh;
297 Eina_Bool want_unrealize : 1;
298 Eina_Bool realized : 1;
299 Eina_Bool changed : 1;
300 Eina_Bool updateme : 1;
301 Eina_Bool showme : 1;
304 struct _Elm_Genlist_Item
310 Evas_Coord x, y, w, h, minw, minh, edx;
311 const Elm_Genlist_Item_Class *itc;
313 Elm_Genlist_Item *parent;
314 Elm_Genlist_Item_Flags flags;
315 Elm_Genlist_GroupItem *group_item;
322 Evas_Object *base, *spacer, *edit_obj;
323 Eina_List *labels, *icons, *states, *icon_objs;
324 Ecore_Timer *long_timer;
325 Evas_Coord dx, dy, scrl_x, scrl_y;
327 Elm_Genlist_Item *rel;
330 Eina_Bool before : 1;
332 Eina_Bool want_unrealize : 1;
333 Eina_Bool realized : 1;
334 Eina_Bool selected : 1;
335 Eina_Bool hilighted : 1;
336 Eina_Bool expanded : 1;
337 Eina_Bool disabled : 1;
338 Eina_Bool display_only : 1;
339 Eina_Bool mincalcd : 1;
340 Eina_Bool queued : 1;
341 Eina_Bool showme : 1;
342 Eina_Bool delete_me : 1;
344 Eina_Bool dragging : 1;
345 Eina_Bool updateme : 1;
346 Eina_Bool reordering : 1;
348 int pad_left, pad_right;
352 struct _Elm_Genlist_GroupItem
357 Evas_Coord x, y, w, h, minw, minh;
358 const Elm_Genlist_Item_Class *itc;
367 Eina_List *labels, *icons, *states, *icon_objs;
369 Eina_Bool realized : 1;
370 Eina_Bool delete_me : 1;
371 Eina_Bool visible : 1;
372 Eina_Bool mincalcd : 1;
377 Evas_Object_Smart_Clipped_Data __clipped_data;
381 static const char *widtype = NULL;
382 static void _del_hook(Evas_Object *obj);
383 static void _theme_hook(Evas_Object *obj);
384 //static void _show_region_hook(void *data, Evas_Object *obj);
385 static void _sizing_eval(Evas_Object *obj);
386 static void _item_unrealize(Elm_Genlist_Item *it);
387 static void _item_block_unrealize(Item_Block *itb);
388 static void _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items);
389 static void _groupitem_unrealize(Elm_Genlist_GroupItem *git);
390 static void _calc_job(void *data);
391 static Eina_Bool _edit_mode_reset(Widget_Data *wd);
392 static void _edit_controls_eval( Elm_Genlist_Item *it );
393 static void _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity );
396 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
399 _del_hook(Evas_Object *obj)
401 Widget_Data *wd = elm_widget_data_get(obj);
403 if (wd->calc_job) ecore_job_del(wd->calc_job);
404 if (wd->update_job) ecore_job_del(wd->update_job);
409 _del_pre_hook(Evas_Object *obj)
411 Widget_Data *wd = elm_widget_data_get(obj);
413 evas_object_del(wd->pan_smart);
414 wd->pan_smart = NULL;
415 elm_genlist_clear(obj);
419 _theme_hook(Evas_Object *obj)
421 Widget_Data *wd = elm_widget_data_get(obj);
423 Elm_Genlist_GroupItem *git;
425 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
426 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
427 EINA_INLIST_FOREACH(wd->group_items, git)
429 _groupitem_unrealize(git);
431 EINA_INLIST_FOREACH(wd->blocks, itb)
434 Elm_Genlist_Item *it;
436 if (itb->realized) _item_block_unrealize(itb);
437 EINA_LIST_FOREACH(itb->items, l, it)
438 it->mincalcd = EINA_FALSE;
440 itb->changed = EINA_TRUE;
442 if (wd->calc_job) ecore_job_del(wd->calc_job);
443 wd->calc_job = ecore_job_add(_calc_job, wd);
449 _show_region_hook(void *data, Evas_Object *obj)
451 Widget_Data *wd = elm_widget_data_get(data);
452 Evas_Coord x, y, w, h;
454 elm_widget_show_region_get(obj, &x, &y, &w, &h);
455 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
460 _sizing_eval(Evas_Object *obj)
462 Widget_Data *wd = elm_widget_data_get(obj);
463 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
465 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
466 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
468 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
471 Evas_Coord vmw, vmh, vw, vh;
475 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
476 if ((minw > 0) && (vw < minw)) vw = minw;
477 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
479 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
482 evas_object_size_hint_min_set(obj, minw, minh);
483 evas_object_size_hint_max_set(obj, maxw, maxh);
487 _item_hilight(Elm_Genlist_Item *it)
489 const char *selectraise;
491 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
492 (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
493 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
494 selectraise = edje_object_data_get(it->base, "selectraise");
495 if ((selectraise) && (!strcmp(selectraise, "on")))
497 evas_object_raise(it->base);
498 if( it->group_item && it->group_item->realized )
499 evas_object_raise(it->group_item->base);
501 it->hilighted = EINA_TRUE;
505 _item_block_del(Elm_Genlist_Item *it)
508 Item_Block *itb = it->block;
510 itb->items = eina_list_remove(itb->items, it);
512 itb->changed = EINA_TRUE;
513 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
514 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
517 il = EINA_INLIST_GET(itb);
518 Item_Block *itbn = (Item_Block *)(il->next);
520 it->parent->items = eina_list_remove(it->parent->items, it);
522 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
524 if (itbn) itbn->changed = EINA_TRUE;
530 il = EINA_INLIST_GET(itb);
531 Item_Block *itbp = (Item_Block *)(il->prev);
532 Item_Block *itbn = (Item_Block *)(il->next);
533 if ((itbp) && ((itbp->count + itb->count) < 48))
535 Elm_Genlist_Item *it2;
537 EINA_LIST_FREE(itb->items, it2)
540 itbp->items = eina_list_append(itbp->items, it2);
542 itbp->changed = EINA_TRUE;
544 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
547 else if ((itbn) && ((itbn->count + itb->count) < 48))
551 Eina_List *last = eina_list_last(itb->items);
552 Elm_Genlist_Item *it2 = last->data;
555 itb->items = eina_list_remove_list(itb->items, last);
556 itbn->items = eina_list_prepend(itbn->items, it2);
558 itbn->changed = EINA_TRUE;
561 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
569 _item_del(Elm_Genlist_Item *it)
571 elm_genlist_item_subitems_clear(it);
572 if (it->wd->show_item == it) it->wd->show_item = NULL;
573 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
574 if (it->realized) _item_unrealize(it);
575 if (it->block) _item_block_del(it);
576 if ((!it->delete_me) && (it->itc->func.del))
577 it->itc->func.del(it->data, it->wd->obj);
578 it->delete_me = EINA_TRUE;
580 it->wd->queue = eina_list_remove(it->wd->queue, it);
581 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
583 it->parent->items = eina_list_remove(it->parent->items, it);
584 if (it->long_timer) ecore_timer_del(it->long_timer);
587 it->group_item->items = eina_list_remove(it->group_item->items,it);
593 _item_select(Elm_Genlist_Item *it)
595 if ((it->wd->no_select) || (it->delete_me) || (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
598 if (it->wd->always_select) goto call;
601 it->selected = EINA_TRUE;
602 it->wd->selected = eina_list_append(it->wd->selected, it);
605 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
607 evas_object_smart_callback_call(it->wd->obj, "selected", it);
609 if ((it->walking == 0) && (it->delete_me))
611 if (it->relcount == 0) _item_del(it);
616 _item_unselect(Elm_Genlist_Item *it)
618 const char *stacking, *selectraise;
620 if ((it->delete_me) || (!it->hilighted)) return;
621 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
622 stacking = edje_object_data_get(it->base, "stacking");
623 selectraise = edje_object_data_get(it->base, "selectraise");
624 if ((selectraise) && (!strcmp(selectraise, "on")))
626 if ((stacking) && (!strcmp(stacking, "below")))
627 evas_object_lower(it->base);
629 it->hilighted = EINA_FALSE;
632 it->selected = EINA_FALSE;
633 it->wd->selected = eina_list_remove(it->wd->selected, it);
634 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
639 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
641 Elm_Genlist_Item *it = data;
642 Evas_Event_Mouse_Move *ev = event_info;
643 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
645 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
647 if (!it->wd->on_hold)
649 it->wd->on_hold = EINA_TRUE;
653 if ((it->dragging) && (it->down))
657 ecore_timer_del(it->long_timer);
658 it->long_timer = NULL;
660 evas_object_smart_callback_call(it->wd->obj, "drag", it);
663 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
667 ecore_timer_del(it->long_timer);
668 it->long_timer = NULL;
672 if (!it->display_only)
673 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
674 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
675 x = ev->cur.canvas.x - x;
676 y = ev->cur.canvas.y - y;
679 if (adx < 0) adx = -dx;
682 if (ady < 0) ady = -dy;
685 if ((adx > minw) || (ady > minh))
690 ecore_timer_del(it->long_timer);
691 it->long_timer = NULL;
693 if (!it->wd->wasselected)
695 it->wd->wasselected = 0;
699 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
703 evas_object_smart_callback_call(it->wd->obj,
704 "drag,start,left", it);
706 evas_object_smart_callback_call(it->wd->obj,
707 "drag,start,right", it);
713 evas_object_smart_callback_call(it->wd->obj,
714 "drag,start,down", it);
718 evas_object_smart_callback_call(it->wd->obj,
719 "drag,start,left", it);
721 evas_object_smart_callback_call(it->wd->obj,
722 "drag,start,right", it);
729 _long_press(void *data)
731 Elm_Genlist_Item *it = data;
733 it->long_timer = NULL;
734 if ((it->disabled) || (it->dragging)) return 0;
735 it->wd->longpressed = EINA_TRUE;
736 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
741 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
743 Elm_Genlist_Item *it = data;
744 Evas_Event_Mouse_Down *ev = event_info;
747 if( it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
748 (void)_edit_mode_reset( it->wd );
749 if (ev->button != 1) return;
752 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
753 it->dx = ev->canvas.x - x;
754 it->dy = ev->canvas.y - y;
755 it->wd->longpressed = EINA_FALSE;
756 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
757 else it->wd->on_hold = EINA_FALSE;
758 it->wd->wasselected = it->selected;
760 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
761 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
762 if (it->long_timer) ecore_timer_del(it->long_timer);
764 it->long_timer = ecore_timer_add(1.0, _long_press, it);
766 it->long_timer = NULL;
770 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
772 Elm_Genlist_Item *it = data;
773 Evas_Event_Mouse_Up *ev = event_info;
774 Eina_Bool dragged = 0;
776 if (ev->button != 1) return;
778 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
779 else it->wd->on_hold = EINA_FALSE;
782 ecore_timer_del(it->long_timer);
783 it->long_timer = NULL;
788 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
793 it->wd->longpressed = EINA_FALSE;
794 it->wd->on_hold = EINA_FALSE;
797 if (it->wd->longpressed)
799 it->wd->longpressed = EINA_FALSE;
800 if (!it->wd->wasselected)
802 it->wd->wasselected = 0;
807 if (it->want_unrealize)
810 if (it->block->want_unrealize)
811 _item_block_unrealize(it->block);
814 if ((it->disabled) || (dragged)) return;
822 else _item_unselect(it);
828 Widget_Data *wd = it->wd;
831 while (wd->selected) _item_unselect(wd->selected->data);
836 const Eina_List *l, *l_next;
837 Elm_Genlist_Item *it2;
839 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
840 if (it2 != it) _item_unselect(it2);
841 // _item_hilight(it);
850 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
852 Elm_Genlist_Item *it = data;
855 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
857 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
861 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
863 Elm_Genlist_Item *it = data;
866 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
870 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
872 Elm_Genlist_Item *it = data;
875 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
879 _set_groupitem( Elm_Genlist_Item *it, Elm_Genlist_GroupItem *git)
883 it->group_item = git;
884 git->items = eina_list_append(git->items, it);
889 _groupitem_realize(Elm_Genlist_GroupItem *git)
894 if ((git->realized) || (git->delete_me)) return;
895 git->base = edje_object_add(evas_object_evas_get(git->wd->obj));
896 edje_object_scale_set(git->base, elm_widget_scale_get(git->wd->obj) *
898 evas_object_smart_member_add(git->base, git->wd->pan_smart);
899 elm_widget_sub_object_add(git->wd->obj, git->base);
901 strncpy(buf, "item/", sizeof(buf));
902 strncat(buf, git->itc->item_style, sizeof(buf) - strlen(buf));
903 _elm_theme_object_set(git->wd->obj, git->base, "genlist", buf, elm_widget_style_get(git->wd->obj));
905 align = edje_object_data_get(git->base, "orientation");
906 git->align = GROUP_ALIGN_NORTH;
909 if( !strcmp(align, "top") )
910 git->align = GROUP_ALIGN_NORTH;
911 else if( !strcmp(align, "left") )
912 git->align = GROUP_ALIGN_WEST;
913 else git->align = GROUP_ALIGN_NORTH;
916 if (git->itc->func.label_get)
921 git->labels = _elm_stringlist_get(edje_object_data_get(git->base, "labels"));
922 EINA_LIST_FOREACH(git->labels, l, key)
924 char *s = git->itc->func.label_get(git->data, git->wd->obj, l->data);
928 edje_object_part_text_set(git->base, l->data, s);
934 if (git->itc->func.icon_get)
939 git->icons = _elm_stringlist_get(edje_object_data_get(git->base, "icons"));
940 EINA_LIST_FOREACH(git->icons, l, key)
942 Evas_Object *ic = git->itc->func.icon_get(git->data, git->wd->obj, l->data);
946 git->icon_objs = eina_list_append(git->icon_objs, ic);
947 edje_object_part_swallow(git->base, key, ic);
948 evas_object_show(ic);
949 elm_widget_sub_object_add(git->wd->obj, ic);
954 if (git->itc->func.state_get)
959 git->states = _elm_stringlist_get(edje_object_data_get(git->base, "states"));
960 EINA_LIST_FOREACH(git->states, l, key)
962 Eina_Bool on = git->itc->func.state_get(git->data, git->wd->obj, l->data);
966 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
967 edje_object_signal_emit(git->base, buf, "elm");
973 Evas_Coord mw = -1, mh = -1;
975 edje_object_size_min_restricted_calc(git->base, &mw, &mh, mw, mh);
977 git->w = git->minw = mw;
978 git->h = git->minh = mh;
979 git->mincalcd = EINA_TRUE;
981 git->y = git->y = -1;
982 evas_object_show(git->base);
984 git->realized = EINA_TRUE;
989 _groupitem_unrealize(Elm_Genlist_GroupItem *git)
993 if (!git->realized) return;
994 evas_object_del(git->base);
996 _elm_stringlist_free(git->labels);
998 _elm_stringlist_free(git->icons);
1000 _elm_stringlist_free(git->states);
1002 EINA_LIST_FREE(git->icon_objs, icon)
1003 evas_object_del(icon);
1006 git->realized = EINA_FALSE;
1010 _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items)
1012 Elm_Genlist_Item *it;
1018 _groupitem_unrealize( git );
1020 git->wd->group_items = eina_inlist_remove(git->wd->group_items,EINA_INLIST_GET(git));
1024 EINA_LIST_FOREACH(git->items,l, it)
1026 it->group_item = NULL;
1027 elm_genlist_item_update(it);
1031 if (git->itc->func.del) git->itc->func.del(git->data, git->wd->obj);
1036 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1038 Elm_Genlist_Item *it2;
1039 const char *stacking;
1040 const char *treesize;
1042 int depth, tsize = 20;
1044 if ((it->realized) || (it->delete_me)) return;
1045 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1046 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1047 _elm_config->scale);
1048 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1049 elm_widget_sub_object_add(it->wd->obj, it->base);
1051 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1052 else strncpy(buf, "item", sizeof(buf));
1053 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1055 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1056 strncat(buf, "/", sizeof(buf) - strlen(buf));
1057 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1059 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1060 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1061 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1062 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1063 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
1064 treesize = edje_object_data_get(it->base, "treesize");
1065 if (treesize) tsize = atoi(treesize);
1066 evas_object_size_hint_min_set(it->spacer,
1067 (depth * tsize) * _elm_config->scale, 1);
1068 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1071 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1072 "elm", _signal_expand_toggle, it);
1073 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1074 _signal_expand, it);
1075 edje_object_signal_callback_add(it->base, "elm,action,contract",
1076 "elm", _signal_contract, it);
1077 stacking = edje_object_data_get(it->base, "stacking");
1080 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1081 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1083 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1085 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1087 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1090 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1092 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1094 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1097 if (calc && it->wd->homogeneous && it->wd->item_width)
1099 /* homogenous genlist shortcut */
1102 it->w = it->minw = it->wd->item_width;
1103 it->h = it->minh = it->wd->item_height;
1104 it->mincalcd = EINA_TRUE;
1109 if (it->itc->func.label_get)
1114 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1115 EINA_LIST_FOREACH(it->labels, l, key)
1117 char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
1121 edje_object_part_text_set(it->base, l->data, s);
1126 if (it->itc->func.icon_get)
1131 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
1132 EINA_LIST_FOREACH(it->icons, l, key)
1134 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
1138 it->icon_objs = eina_list_append(it->icon_objs, ic);
1139 edje_object_part_swallow(it->base, key, ic);
1140 evas_object_show(ic);
1141 elm_widget_sub_object_add(it->wd->obj, ic);
1145 if (it->itc->func.state_get)
1150 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
1151 EINA_LIST_FOREACH(it->states, l, key)
1153 Eina_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
1157 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1158 edje_object_signal_emit(it->base, buf, "elm");
1164 Evas_Coord mw = -1, mh = -1;
1166 if (!it->display_only)
1167 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1168 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1169 if (!it->display_only)
1170 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1171 it->w = it->minw = mw;
1172 it->h = it->minh = mh;
1173 it->mincalcd = EINA_TRUE;
1175 if (in == 0 && it->wd->homogeneous)
1177 it->wd->item_width = mw;
1178 it->wd->item_height = mh;
1181 if (!calc) evas_object_show(it->base);
1183 it->realized = EINA_TRUE;
1184 it->want_unrealize = EINA_FALSE;
1185 if(it->group_item && !it->group_item->realized)
1186 _groupitem_realize(it->group_item);
1187 if( ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode )
1188 _edit_controls_eval(it);
1192 _item_unrealize(Elm_Genlist_Item *it)
1196 if (!it->realized) return;
1199 ecore_timer_del(it->long_timer);
1200 it->long_timer = NULL;
1202 evas_object_del(it->base);
1204 evas_object_del(it->spacer);
1207 evas_object_del(it->edit_obj);
1208 it->edit_obj = NULL;
1209 _elm_stringlist_free(it->labels);
1211 _elm_stringlist_free(it->icons);
1213 _elm_stringlist_free(it->states);
1215 EINA_LIST_FREE(it->icon_objs, icon)
1216 evas_object_del(icon);
1219 it->realized = EINA_FALSE;
1220 it->want_unrealize = EINA_FALSE;
1224 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1227 Elm_Genlist_Item *it;
1228 Elm_Genlist_GroupItem *git = NULL;
1229 Evas_Coord minw = 0, minh = 0;
1230 int showme = 0, changed = 0;
1234 EINA_LIST_FOREACH(itb->items, l, it)
1236 if (it->delete_me) continue;
1237 showme |= it->showme;
1242 if (!it->mincalcd) changed = 1;
1245 _item_realize(it, in, 1);
1246 _item_unrealize(it);
1251 _item_realize(it, in, 1);
1252 _item_unrealize(it);
1257 Eina_Bool was_realized = it->realized;
1259 _item_realize(it, in, 0);
1261 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1264 if (minw < it->minw) minw = it->minw;
1269 if( git != it->group_item )
1271 git = it->group_item;
1272 if( git && git->align == GROUP_ALIGN_NORTH && git->items->data == it) //Add Place holder for Group title
1282 itb->changed = EINA_FALSE;
1283 /* force an evas norender to garbage collect deleted objects */
1284 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1289 _item_block_realize(Item_Block *itb, int in, int full)
1292 Elm_Genlist_Item *it;
1294 if (itb->realized) return;
1295 EINA_LIST_FOREACH(itb->items, l, it)
1297 if (it->delete_me) continue;
1300 Eina_Bool was_realized = it->realized;
1302 _item_realize(it, in, 0);
1304 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1308 itb->realized = EINA_TRUE;
1309 itb->want_unrealize = EINA_FALSE;
1313 _item_block_unrealize(Item_Block *itb)
1316 Elm_Genlist_Item *it;
1319 if (!itb->realized) return;
1320 EINA_LIST_FOREACH(itb->items, l, it)
1322 if (it->dragging || it->reordering)
1325 it->want_unrealize = EINA_TRUE;
1328 _item_unrealize(it);
1332 itb->realized = EINA_FALSE;
1333 itb->want_unrealize = EINA_TRUE;
1336 itb->want_unrealize = EINA_FALSE;
1340 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
1342 Widget_Data *wd = data;
1343 wd->ed->del_confirm_state = 0;
1344 evas_object_hide( wd->ed->del_confirm );
1345 if( wd->ed->ec && wd->ed->ec->remove )
1346 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
1347 wd->ed->del_item = NULL;
1351 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
1353 const char *del_icon_part;
1354 Elm_Genlist_Item *it = data;
1355 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
1357 edje_object_part_unswallow( it->edit_obj, it->wd->ed->del_confirm );
1359 evas_object_hide( it->wd->ed->del_confirm );
1363 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1365 const char *del_icon_part, *del_conf_style;
1366 Elm_Genlist_Item *it = data;
1367 if(_edit_mode_reset( it->wd ))
1370 it->wd->ed->del_confirm_state = 1;
1371 it->wd->ed->del_item = it;
1373 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
1375 elm_object_style_set( it->wd->ed->del_confirm, del_conf_style);
1378 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
1380 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
1381 evas_object_show( it->wd->ed->del_confirm );
1382 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1386 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1388 Elm_Genlist_Item *it = data;
1390 if(_edit_mode_reset( it->wd ))
1393 if( it->wd->ed->ec && it->wd->ed->ec->insert_new )
1394 it->wd->ed->ec->insert_new(it->wd->obj, it);
1398 _edit_mode_reset(Widget_Data *wd)
1400 if(wd->ed->del_confirm_state)
1402 edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
1403 wd->ed->del_confirm_state = 0;
1404 wd->ed->del_item = NULL;
1411 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1413 Elm_Genlist_Item *it = data;
1414 Evas_Event_Mouse_Down *ev = event_info;
1417 if(_edit_mode_reset( it->wd ) )
1420 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1422 evas_object_raise(it->base);
1423 evas_object_raise( it->edit_obj );
1425 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
1426 it->dx = ev->canvas.x - x;
1427 it->dy = ev->canvas.y - y;
1428 it->wd->ed->reorder_item = it;
1429 it->wd->ed->reorder_item->reordering = 1;
1430 it->wd->ed->reorder_rel = NULL;
1431 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1435 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1437 Elm_Genlist_Item *it = data;
1438 Elm_Genlist_Item *rel_it;
1440 if( it->reordering && it->wd->ed->reorder_item )
1443 it->wd->ed->reorder_item->reordering = 0;
1444 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
1445 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1447 if( (!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
1448 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE ) ) )
1450 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, it->wd->ed->reorder_item->scrl_y);
1451 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y );
1453 it->wd->ed->reorder_item = NULL;
1454 it->wd->ed->reorder_rel = NULL;
1460 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1462 Elm_Genlist_Item *it = data;
1463 Evas_Event_Mouse_Move *ev = event_info;
1465 if( it->reordering && it->wd->ed->reorder_item )
1467 Elm_Genlist_Item *rel_it;
1468 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
1469 evas_object_raise(it->wd->ed->reorder_item->base);
1470 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
1471 evas_object_show(it->wd->ed->reorder_item->base);
1472 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, y );
1474 it->block->updateme = EINA_TRUE;
1476 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1477 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1484 _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity )
1486 if(it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )
1489 evas_object_resize(it->edit_obj,it->w, it->h );
1490 evas_object_move(it->edit_obj, itx, ity );
1491 evas_object_raise( it->edit_obj );
1495 _edit_controls_eval( Elm_Genlist_Item *it )
1498 const char *pad_str;
1503 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj )
1506 if( it->itc->func.editmode_get )
1507 itmode = it->itc->func.editmode_get( it->data, it->wd->obj, it->wd->edit_mode );
1508 itmode &= it->wd->edit_mode;
1512 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
1513 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
1514 _elm_config->scale);
1515 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
1516 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
1517 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
1519 edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
1520 "elm", _edit_mode_reset, it);
1523 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
1524 if (pad_str) pad = atoi(pad_str);
1526 if( (itmode & ELM_GENLIST_EDIT_MODE_INSERT) )
1528 if(it->wd->animate_edit_controls)
1529 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
1531 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
1533 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
1534 "elm", _insert_new_item_cb, it);
1535 it->pad_left += pad;
1538 if(it->wd->animate_edit_controls)
1539 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
1541 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
1543 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
1544 "elm", _insert_new_item_cb );
1547 if( (itmode & ELM_GENLIST_EDIT_MODE_DELETE) )
1549 if(it->wd->animate_edit_controls)
1550 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
1552 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
1554 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
1555 "elm", _remove_item_cb, it);
1557 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
1558 "elm", _hide_delete_confirm_object, it );
1559 it->pad_left += pad;
1563 if(it->wd->animate_edit_controls)
1564 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
1566 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
1568 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
1569 "elm", _remove_item_cb );
1570 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
1571 "elm", _hide_delete_confirm_object );
1575 if( (itmode & ELM_GENLIST_EDIT_MODE_REORDER) )
1577 Evas_Object *reorder_icon;
1578 const char* reorder_part;
1580 if(it->wd->animate_edit_controls)
1581 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,animated,enable", "elm");
1583 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,enable", "elm");
1585 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
1586 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
1588 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
1590 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_DOWN,
1591 _reorder_mouse_down, it);
1592 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_UP,
1593 _reorder_mouse_up, it);
1594 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_MOVE,
1595 _reorder_mouse_move, it);
1597 it->pad_right += pad;
1601 Evas_Object *reorder_icon;
1602 const char* reorder_part;
1604 if(it->wd->animate_edit_controls)
1605 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,animated,disable", "elm");
1607 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,disable", "elm");
1609 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
1610 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
1612 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
1614 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_DOWN,
1615 _reorder_mouse_down);
1616 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_UP,
1618 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_MOVE,
1619 _reorder_mouse_move);
1623 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )//Unrealize
1625 evas_object_del(it->edit_obj);
1626 it->edit_obj = NULL;
1629 _move_edit_controls(it,it->scrl_x, it->scrl_y );
1630 evas_object_show( it->edit_obj );
1634 _notify_item_position( Elm_Genlist_Item *it )
1639 l = eina_list_last(it->parent->items);
1641 //Check if the Item is First Node or Last node of its Parent & raise signal.
1642 if( it->parent->items->data != it && l->data != it )
1644 edje_object_signal_emit(it->base, "normal_item", "elm");
1646 if(it->parent->items->data == it )
1647 edje_object_signal_emit(it->base, "first_item", "elm");
1650 edje_object_signal_emit(it->base, "last_item", "elm");
1657 _get_space_for_reorder_item( Elm_Genlist_Item *it )
1659 int top=0, bottom=0;
1660 Evas_Coord rox, roy, row, roh;
1662 if( !(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) || !it->wd->ed->reorder_item )
1665 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
1667 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
1668 rox, roy+roh/2, row, 1));
1672 it->wd->ed->reorder_rel = it;
1673 it->scrl_y+=it->wd->ed->reorder_item->h;
1674 return it->wd->ed->reorder_item->h;
1681 _item_block_position(Item_Block *itb, int in)
1684 Elm_Genlist_Item *it;
1685 Elm_Genlist_GroupItem *git = NULL;
1686 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1687 int vis=0, new_mov_y = 0;
1689 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1690 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1691 EINA_LIST_FOREACH(itb->items, l, it)
1693 if (it->delete_me) continue;
1697 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
1698 itb->y - it->wd->pan_y + oy,
1700 cvx, cvy, cvw, cvh));
1701 if ((itb->realized) && (!it->realized))
1705 Eina_Bool was_realized = it->realized;
1707 _item_realize(it, in, 0);
1709 evas_object_smart_callback_call(it->wd->obj,
1715 _notify_item_position( it );
1718 it->scrl_x = ox + itb->x + it->x - itb->wd->pan_x;
1719 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y;
1720 if( git != it->group_item )
1722 git = it->group_item;
1725 git->visible = EINA_TRUE; //Mark Group Item to make it visible
1726 if( git->items->data == it)
1727 git->y = it->scrl_y;
1728 if( GROUP_ALIGN_NORTH == git->align )
1731 if( git->items->data == it)
1733 it->scrl_y += git->minh;
1741 git->x = ox + itb->x - itb->wd->pan_x;
1746 if( git->align == GROUP_ALIGN_WEST )
1749 it->scrl_x += git->x + git->w;
1750 git->h = (it->scrl_y + it->h) - git->y ;
1751 if( git->h < it->h )
1753 git->y = it->scrl_y;
1757 if( git->align == GROUP_ALIGN_NORTH )
1760 if( (git->y + git->h) > (it->scrl_y + it->h) )
1761 git->y = (it->scrl_y + it->h) - git->minh;
1766 y+=_get_space_for_reorder_item( it );
1768 if(!it->reordering )
1770 _move_edit_controls( it,it->scrl_x, it->scrl_y );
1771 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
1772 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
1773 evas_object_show(it->base);
1779 _item_unrealize(it);
1783 if(!it->reordering )
1791 itb->wd->animate_edit_controls = 0;
1793 git->visible = EINA_TRUE;
1798 _calc_job(void *data)
1800 Widget_Data *wd = data;
1802 Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
1803 Item_Block *chb = NULL;
1804 int in = 0, minw_change = 0;
1806 EINA_INLIST_FOREACH(wd->blocks, itb)
1811 showme = itb->showme;
1815 if (itb->realized) _item_block_unrealize(itb);
1819 if (itb->realized) _item_block_unrealize(itb);
1820 showme = _item_block_recalc(itb, in, 0, 1);
1826 if (minw == -1) minw = itb->minw;
1827 else if (minw < itb->minw)
1838 wd->show_item->showme = 0;
1840 elm_smart_scroller_region_bring_in(wd->scr,
1841 wd->show_item->x + wd->show_item->block->x,
1842 wd->show_item->y + wd->show_item->block->y,
1843 wd->show_item->block->w,
1846 elm_smart_scroller_child_region_show(wd->scr,
1847 wd->show_item->x + wd->show_item->block->x,
1848 wd->show_item->y + wd->show_item->block->y,
1849 wd->show_item->block->w,
1851 wd->show_item = NULL;
1857 EINA_INLIST_FOREACH(wd->blocks, itb)
1863 if ((chb) && (EINA_INLIST_GET(chb)->next))
1865 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1866 if (itb->realized) _item_block_unrealize(itb);
1868 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1869 if (minw < ow) minw = ow;
1870 if ((minw != wd->minw) || (minh != wd->minh))
1874 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1875 _sizing_eval(wd->obj);
1877 wd->calc_job = NULL;
1878 evas_object_smart_changed(wd->pan_smart);
1882 _update_job(void *data)
1884 Widget_Data *wd = data;
1887 int num, num0, position = 0, recalc = 0;
1889 wd->update_job = NULL;
1891 EINA_INLIST_FOREACH(wd->blocks, itb)
1893 Evas_Coord itminw, itminh;
1894 Elm_Genlist_Item *it;
1900 _item_block_position(itb, num);
1905 EINA_LIST_FOREACH(itb->items, l2, it)
1915 _item_unrealize(it);
1916 _item_realize(it, num, 0);
1917 evas_object_smart_callback_call(it->wd->obj,
1922 _item_realize(it, num, 1);
1923 _item_unrealize(it);
1925 if ((it->minw != itminw) || (it->minh != itminh))
1934 itb->changed = EINA_TRUE;
1935 _item_block_recalc(itb, num0, 0, 1);
1936 _item_block_position(itb, num0);
1941 if (wd->calc_job) ecore_job_del(wd->calc_job);
1942 wd->calc_job = ecore_job_add(_calc_job, wd);
1947 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1949 Pan *sd = evas_object_smart_data_get(obj);
1950 // Evas_Coord ow, oh;
1951 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1952 // ow = sd->wd->minw - ow;
1953 // if (ow < 0) ow = 0;
1954 // oh = sd->wd->minh - oh;
1955 // if (oh < 0) oh = 0;
1956 // if (x < 0) x = 0;
1957 // if (y < 0) y = 0;
1958 // if (x > ow) x = ow;
1959 // if (y > oh) y = oh;
1960 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1963 evas_object_smart_changed(obj);
1967 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1969 Pan *sd = evas_object_smart_data_get(obj);
1971 if (x) *x = sd->wd->pan_x;
1972 if (y) *y = sd->wd->pan_y;
1976 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1978 Pan *sd = evas_object_smart_data_get(obj);
1981 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1982 ow = sd->wd->minw - ow;
1984 oh = sd->wd->minh - oh;
1991 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1993 Pan *sd = evas_object_smart_data_get(obj);
1995 if (w) *w = sd->wd->minw;
1996 if (h) *h = sd->wd->minh;
2000 _pan_add(Evas_Object *obj)
2003 Evas_Object_Smart_Clipped_Data *cd;
2006 cd = evas_object_smart_data_get(obj);
2009 sd->__clipped_data = *cd;
2011 evas_object_smart_data_set(obj, sd);
2015 _pan_del(Evas_Object *obj)
2017 Pan *sd = evas_object_smart_data_get(obj);
2024 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2026 Pan *sd = evas_object_smart_data_get(obj);
2029 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2030 if ((ow == w) && (oh == h)) return;
2031 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2032 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2036 _pan_calculate(Evas_Object *obj)
2038 Pan *sd = evas_object_smart_data_get(obj);
2040 Elm_Genlist_GroupItem *git;
2041 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2043 if( sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
2044 (void)_edit_mode_reset( sd->wd );
2045 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2047 git->visible = EINA_FALSE;
2050 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2051 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2052 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2054 itb->w = sd->wd->minw;
2055 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2056 itb->y - sd->wd->pan_y + oy,
2058 cvx, cvy, cvw, cvh))
2060 if ((!itb->realized) || (itb->changed))
2061 _item_block_realize(itb, in, 0);
2062 _item_block_position(itb, in);
2066 if (itb->realized) _item_block_unrealize(itb);
2070 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2074 evas_object_raise(git->base);
2075 evas_object_resize( git->base, git->w, git->h-1 );
2076 evas_object_move(git->base, git->x, git->y );
2077 evas_object_show(git->base);
2080 evas_object_hide(git->base);
2082 if( (sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) && (sd->wd->ed->reorder_item ) )
2084 evas_object_raise(sd->wd->ed->reorder_item->base);
2085 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2090 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2092 Pan *sd = evas_object_smart_data_get(obj);
2094 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2095 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2099 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2101 Widget_Data *wd = elm_widget_data_get(obj);
2103 elm_smart_scroller_hold_set(wd->scr, 1);
2107 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2109 Widget_Data *wd = elm_widget_data_get(obj);
2111 elm_smart_scroller_hold_set(wd->scr, 0);
2115 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2117 Widget_Data *wd = elm_widget_data_get(obj);
2119 elm_smart_scroller_freeze_set(wd->scr, 1);
2123 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2125 Widget_Data *wd = elm_widget_data_get(obj);
2127 elm_smart_scroller_freeze_set(wd->scr, 0);
2131 * Add a new Genlist object
2133 * @param parent The parent object
2134 * @return The new object or NULL if it cannot be created
2139 elm_genlist_add(Evas_Object *parent)
2144 Evas_Coord minw, minh;
2145 static Evas_Smart *smart = NULL;
2147 wd = ELM_NEW(Widget_Data);
2148 e = evas_object_evas_get(parent);
2149 obj = elm_widget_add(e);
2150 ELM_SET_WIDTYPE(widtype, "genlist");
2151 elm_widget_type_set(obj, "genlist");
2152 elm_widget_sub_object_add(parent, obj);
2153 elm_widget_data_set(obj, wd);
2154 elm_widget_del_hook_set(obj, _del_hook);
2155 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2156 elm_widget_theme_hook_set(obj, _theme_hook);
2158 wd->scr = elm_smart_scroller_add(e);
2159 elm_smart_scroller_widget_set(wd->scr, obj);
2160 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2161 elm_widget_resize_object_set(obj, wd->scr);
2163 elm_smart_scroller_bounce_allow_set(wd->scr, 0, 1);
2166 wd->mode = ELM_LIST_SCROLL;
2167 wd->max_items_per_block = 32;
2169 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2170 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2171 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2172 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2176 static Evas_Smart_Class sc;
2178 evas_object_smart_clipped_smart_set(&_pan_sc);
2180 sc.name = "elm_genlist_pan";
2181 sc.version = EVAS_SMART_CLASS_VERSION;
2184 sc.resize = _pan_resize;
2185 sc.move = _pan_move;
2186 sc.calculate = _pan_calculate;
2187 smart = evas_smart_class_new(&sc);
2191 wd->pan_smart = evas_object_smart_add(e, smart);
2192 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2196 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2198 _pan_max_get, _pan_child_size_get);
2200 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2202 evas_object_size_hint_min_set(obj, minw, minh);
2208 static Elm_Genlist_Item *
2209 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2210 const void *data, Elm_Genlist_Item *parent,
2211 Elm_Genlist_Item_Flags flags,
2213 const void *func_data)
2215 Elm_Genlist_Item *it;
2217 it = calloc(1, sizeof(Elm_Genlist_Item));
2218 if (!it) return NULL;
2222 it->parent = parent;
2224 it->func.func = func;
2225 it->func.data = func_data;
2230 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2232 Item_Block *itb = NULL;
2239 itb = calloc(1, sizeof(Item_Block));
2242 if (!it->rel->block)
2245 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2246 itb->items = eina_list_append(itb->items, it);
2253 eina_inlist_prepend_relative(wd->blocks,
2254 EINA_INLIST_GET(itb),
2255 EINA_INLIST_GET(it->rel->block));
2257 eina_list_prepend_relative(itb->items, it, it->rel);
2262 eina_inlist_append_relative(wd->blocks,
2263 EINA_INLIST_GET(itb),
2264 EINA_INLIST_GET(it->rel->block));
2266 eina_list_append_relative(itb->items, it, it->rel);
2276 itb = (Item_Block *)(wd->blocks);
2277 if (itb->count >= wd->max_items_per_block)
2279 itb = calloc(1, sizeof(Item_Block));
2283 eina_inlist_prepend(wd->blocks,
2284 EINA_INLIST_GET(itb));
2289 itb = calloc(1, sizeof(Item_Block));
2293 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2295 itb->items = eina_list_prepend(itb->items, it);
2301 itb = (Item_Block *)(wd->blocks->last);
2302 if (itb->count >= wd->max_items_per_block)
2304 itb = calloc(1, sizeof(Item_Block));
2308 eina_inlist_append(wd->blocks,
2309 EINA_INLIST_GET(itb));
2314 itb = calloc(1, sizeof(Item_Block));
2318 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2320 itb->items = eina_list_append(itb->items, it);
2326 itb = it->rel->block;
2327 if (!itb) goto newblock;
2329 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2331 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2334 itb->changed = EINA_TRUE;
2336 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2337 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2340 it->rel->relcount--;
2341 if ((it->rel->delete_me) && (it->rel->relcount == 0))
2345 if (itb->count > itb->wd->max_items_per_block)
2349 Elm_Genlist_Item *it2;
2351 newc = itb->count / 2;
2352 itb2 = calloc(1, sizeof(Item_Block));
2356 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2357 EINA_INLIST_GET(itb));
2358 itb2->changed = EINA_TRUE;
2359 while ((itb->count > newc) && (itb->items))
2363 l = eina_list_last(itb->items);
2365 itb->items = eina_list_remove_list(itb->items, l);
2368 itb2->items = eina_list_prepend(itb2->items, it2);
2378 _queue_proecess(Widget_Data *wd, int norender)
2383 t0 = ecore_time_get();
2384 for (n = 0; (wd->queue) && (n < 128); n++)
2386 Elm_Genlist_Item *it;
2388 it = wd->queue->data;
2389 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2390 it->queued = EINA_FALSE;
2391 _item_block_add(wd, it);
2392 t = ecore_time_get();
2393 if (it->block->changed)
2395 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2396 it->block->changed = 0;
2398 if (showme) it->block->showme = 1;
2399 if (eina_inlist_count(wd->blocks) > 1)
2401 if ((t - t0) > (ecore_animator_frametime_get())) break;
2408 _item_idler(void *data)
2410 Widget_Data *wd = data;
2412 if (_queue_proecess(wd, 1) > 0)
2414 if (wd->calc_job) ecore_job_del(wd->calc_job);
2415 wd->calc_job = ecore_job_add(_calc_job, wd);
2419 wd->queue_idler = NULL;
2426 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2428 if (it->queued) return;
2429 it->queued = EINA_TRUE;
2430 wd->queue = eina_list_append(wd->queue, it);
2431 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2433 if (wd->queue_idler)
2435 ecore_idler_del(wd->queue_idler);
2436 wd->queue_idler = NULL;
2438 _queue_proecess(wd, 0);
2440 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2445 _item_idler(void *data)
2447 Widget_Data *wd = data;
2451 t0 = ecore_time_get();
2452 for (n = 0; (wd->queue) && (n < 128); n++)
2454 Elm_Genlist_Item *it;
2456 it = wd->queue->data;
2457 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2458 it->queued = EINA_FALSE;
2459 _item_block_add(wd, it);
2460 t = ecore_time_get();
2461 if (it->block->changed)
2463 showme = _item_block_recalc(it->block, it->block->num, 1, 1);
2464 it->block->changed = 0;
2466 if (showme) it->block->showme = 1;
2467 if (eina_inlist_count(wd->blocks) > 1)
2469 if ((t - t0) > (ecore_animator_frametime_get())) break;
2474 if (wd->calc_job) ecore_job_del(wd->calc_job);
2475 wd->calc_job = ecore_job_add(_calc_job, wd);
2479 wd->queue_idler = NULL;
2486 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2490 // Add the initial set of Items directly to the Blocks, to show the genlist
2491 // without empty screen.
2492 itb = (Item_Block *)(wd->blocks);
2493 if( (NULL == itb) || (itb->count < wd->max_items_per_block) )
2495 _item_block_add(wd, it);
2499 if (it->queued) return;
2500 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2501 it->queued = EINA_TRUE;
2502 wd->queue = eina_list_append(wd->queue, it);
2509 * Add Group Item to the genlist
2511 * @param obj The genlist object
2512 * @param itc The item class for the item
2513 * @param data The group item data
2515 EAPI Elm_Genlist_GroupItem *
2516 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2519 Elm_Genlist_GroupItem *git;
2520 Widget_Data *wd = elm_widget_data_get(obj);
2522 git = calloc(1, sizeof(Elm_Genlist_GroupItem));
2523 if (!git) return NULL;
2528 wd->group_items = eina_inlist_append(wd->group_items, EINA_INLIST_GET(git) );
2533 * Delete a given groupitem
2535 * This deletes the group item from genlist and calls the genlist group item del class
2536 * callback defined in the item class, if it is set.
2538 * @param git The group item
2543 elm_genlist_groupitem_del(Elm_Genlist_GroupItem *git)
2545 _groupitem_remove( git, EINA_TRUE);
2549 * Append item to the end of the genlist
2551 * This appends the given item to the end of the list or the end of the
2552 * children if the parent is given.
2554 * @param obj The genlist object
2555 * @param itc The item class for the item
2556 * @param data The item data
2557 * @param parent The parent item, or NULL if none
2558 * @param flags Item flags
2559 * @param func Convenience function called when item selected
2560 * @param func_data Data passed to @p func above.
2561 * @return A handle to the item added or NULL if not possible
2565 EAPI Elm_Genlist_Item *
2566 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2567 const void *data, Elm_Genlist_Item *parent,
2568 Elm_Genlist_Item_Flags flags,
2569 Evas_Smart_Cb func, const void *func_data)
2571 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2572 Widget_Data *wd = elm_widget_data_get(obj);
2573 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2574 if (!wd) return NULL;
2575 if (!it) return NULL;
2578 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2584 Elm_Genlist_Item *it2 = NULL;
2585 Eina_List *ll = eina_list_last(it->parent->items);
2586 if (ll) it2 = ll->data;
2587 it->parent->items = eina_list_append(it->parent->items, it);
2588 if (!it2) it2 = it->parent;
2590 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2591 EINA_INLIST_GET(it2));
2592 if( it->parent->group_item)
2593 _set_groupitem( it, it->parent->group_item );
2595 it->rel->relcount++;
2598 _item_queue(wd, it);
2603 * Append item to the end of the genlist with Group Item
2605 * This appends the given item to the end of the list or the end of the
2606 * children if the parent is given.
2608 * @param obj The genlist object
2609 * @param itc The item class for the item
2610 * @param data The item data
2611 * @param parent The parent item, or NULL if none
2612 * @param flags Item flags
2613 * @param git Group Item
2614 * @param func Convenience function called when item selected
2615 * @param func_data Data passed to @p func above.
2616 * @return A handle to the item added or NULL if not possible
2620 EAPI Elm_Genlist_Item *
2621 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2622 const void *data, Elm_Genlist_Item *parent,
2623 Elm_Genlist_Item_Flags flags, Elm_Genlist_GroupItem *git,
2624 Evas_Smart_Cb func, const void *func_data)
2626 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2627 Widget_Data *wd = elm_widget_data_get(obj);
2628 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2629 if (!wd) return NULL;
2630 if (!it) return NULL;
2633 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2639 Elm_Genlist_Item *it2 = NULL;
2640 Eina_List *ll = eina_list_last(it->parent->items);
2641 if (ll) it2 = ll->data;
2642 it->parent->items = eina_list_append(it->parent->items, it);
2643 if (!it2) it2 = it->parent;
2645 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2646 EINA_INLIST_GET(it2));
2647 if( it->parent->group_item)
2648 _set_groupitem( it, it->parent->group_item );
2650 it->rel->relcount++;
2653 _set_groupitem( it, git );
2654 _item_queue(wd, it);
2659 * Prepend item at start of the genlist
2661 * This adds an item to the beginning of the list or beginning of the children
2662 * of the parent if given.
2664 * @param obj The genlist object
2665 * @param itc The item class for the item
2666 * @param data The item data
2667 * @param parent The parent item, or NULL if none
2668 * @param flags Item flags
2669 * @param func Convenience function called when item selected
2670 * @param func_data Data passed to @p func above.
2671 * @return A handle to the item added or NULL if not possible
2675 EAPI Elm_Genlist_Item *
2676 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2677 const void *data, Elm_Genlist_Item *parent,
2678 Elm_Genlist_Item_Flags flags,
2679 Evas_Smart_Cb func, const void *func_data)
2681 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2682 Widget_Data *wd = elm_widget_data_get(obj);
2683 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2684 if (!wd) return NULL;
2685 if (!it) return NULL;
2687 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2690 printf("FIXME: 12 tree not handled yet\n");
2694 _item_queue(wd, it);
2699 * Insert item before another in the genlist
2701 * This inserts an item before another in the list. It will be in the same tree
2702 * level as the item it is inseted before.
2704 * @param obj The genlist object
2705 * @param itc The item class for the item
2706 * @param data The item data
2707 * @param before The item to insert before
2708 * @param flags Item flags
2709 * @param func Convenience function called when item selected
2710 * @param func_data Data passed to @p func above.
2711 * @return A handle to the item added or NULL if not possible
2715 EAPI Elm_Genlist_Item *
2716 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2717 const void *data, Elm_Genlist_Item *before,
2718 Elm_Genlist_Item_Flags flags,
2719 Evas_Smart_Cb func, const void *func_data)
2721 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2722 Widget_Data *wd = elm_widget_data_get(obj);
2723 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
2724 if (!wd) return NULL;
2725 if (!it) return NULL;
2727 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2728 EINA_INLIST_GET(before));
2731 printf("FIXME: 13 tree not handled yet\n");
2734 it->rel->relcount++;
2736 _item_queue(wd, it);
2741 * Insert and item after another in the genlst
2743 * This inserts an item after another in the list. It will be in the same tree
2744 * level as the item it is inseted after.
2746 * @param obj The genlist object
2747 * @param itc The item class for the item
2748 * @param data The item data
2749 * @param after The item to insert after
2750 * @param flags Item flags
2751 * @param func Convenience function called when item selected
2752 * @param func_data Data passed to @p func above.
2753 * @return A handle to the item added or NULL if not possible
2757 EAPI Elm_Genlist_Item *
2758 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2759 const void *data, Elm_Genlist_Item *after,
2760 Elm_Genlist_Item_Flags flags,
2761 Evas_Smart_Cb func, const void *func_data)
2763 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2764 Widget_Data *wd = elm_widget_data_get(obj);
2765 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
2766 if (!wd) return NULL;
2767 if (!it) return NULL;
2769 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2770 EINA_INLIST_GET(after));
2773 printf("FIXME: 14 tree not handled yet\n");
2776 it->rel->relcount++;
2778 _item_queue(wd, it);
2783 * Moves the Genlist Item
2786 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after )
2790 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
2791 _item_block_del(it);
2795 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
2796 EINA_INLIST_GET(after));
2798 it->rel->relcount++;
2802 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
2806 _item_queue(it->wd, it);
2812 * This clears all items in the list, leaving it empty.
2814 * @param obj The genlist object
2819 elm_genlist_clear(Evas_Object *obj)
2821 ELM_CHECK_WIDTYPE(obj, widtype);
2822 Widget_Data *wd = elm_widget_data_get(obj);
2825 while (wd->group_items)
2827 _groupitem_remove((Elm_Genlist_GroupItem *)wd->group_items, EINA_FALSE);
2832 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2834 wd->items = eina_inlist_remove(wd->items, wd->items);
2835 if (it->realized) _item_unrealize(it);
2836 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2837 if (it->long_timer) ecore_timer_del(it->long_timer);
2842 Item_Block *itb = (Item_Block *)(wd->blocks);
2844 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
2845 if (itb->items) eina_list_free(itb->items);
2850 ecore_job_del(wd->calc_job);
2851 wd->calc_job = NULL;
2853 if (wd->queue_idler)
2855 ecore_idler_del(wd->queue_idler);
2856 wd->queue_idler = NULL;
2860 eina_list_free(wd->queue);
2865 eina_list_free(wd->selected);
2866 wd->selected = NULL;
2868 wd->show_item = NULL;
2873 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2874 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2879 * Enable or disable multi-select in the genlist
2881 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
2882 * more than 1 item to be selected.
2884 * @param obj The genlist object
2885 * @param multi Multi-select enable/disable
2890 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
2892 ELM_CHECK_WIDTYPE(obj, widtype);
2893 Widget_Data *wd = elm_widget_data_get(obj);
2899 * Gets if multi-select in genlist is enable or disable
2901 * @param obj The genlist object
2902 * @return Multi-select enable/disable
2903 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
2908 elm_genlist_multi_select_get(const Evas_Object *obj)
2910 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2911 Widget_Data *wd = elm_widget_data_get(obj);
2912 if (!wd) return EINA_FALSE;
2918 * Get the selectd item in the genlist
2920 * This gets the selected item in the list (if multi-select is enabled only
2921 * the first item in the list is selected - which is not very useful, so see
2922 * elm_genlist_selected_items_get()for when multi-select is used).
2924 * If no item is selected, NULL is returned.
2926 * @param obj The genlist object
2927 * @return The selected item, or NULL if none.
2931 EAPI Elm_Genlist_Item *
2932 elm_genlist_selected_item_get(const Evas_Object *obj)
2934 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2935 Widget_Data *wd = elm_widget_data_get(obj);
2936 if (!wd) return NULL;
2937 if (wd->selected) return wd->selected->data;
2942 * Get a list of selected items in the genlist
2944 * This retgurns a list of the selected items. This list pointer is only valid
2945 * so long as no items are selected or unselected (or unselected implicitly
2946 * by deletion). The list contains Elm_Genlist_Item pointers.
2948 * @param obj The genlist object
2949 * @return The list of selected items, nor NULL if none are selected.
2953 EAPI const Eina_List *
2954 elm_genlist_selected_items_get(const Evas_Object *obj)
2956 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2957 Widget_Data *wd = elm_widget_data_get(obj);
2958 if (!wd) return NULL;
2959 return wd->selected;
2963 * Get a list of realized items in genlist
2965 * This returns a list of the realized items in the genlist. The list
2966 * contains Elm_Genlist_Item pointers. The list must be freed by the
2967 * caller when done with eina_list_free(). The item pointers in the list
2968 * are only vallid so long as those items are not deleted or the genlist is
2971 * @param obj The genlist object
2972 * @return The list of realized items, nor NULL if none are realized.
2977 elm_genlist_realized_items_get(const Evas_Object *obj)
2979 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2980 Widget_Data *wd = elm_widget_data_get(obj);
2981 Eina_List *list = NULL;
2984 if (!wd) return NULL;
2985 EINA_INLIST_FOREACH(wd->blocks, itb)
2990 Elm_Genlist_Item *it;
2993 EINA_LIST_FOREACH(itb->items, l, it)
2995 if (it->realized) list = eina_list_append(list, it);
3007 * Get the item that is at the x, y canvas coords
3009 * This returns the item at the given coordinates (which are canvas relative
3010 * not object-relative). If an item is at that coordinate, that item handle
3011 * is returned, and if @p posret is not NULL, the integer pointed to is set
3012 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3013 * portion of that item (-1), on the middle section (0) or on the lower part
3014 * (1). If NULL is returned as an item (no item found there), then posret
3015 * may indicate -1 or 1 based if the coordinate is above or below all items
3016 * respectively in the genlist.
3018 * @param it The item
3019 * @param x The input x coordinate
3020 * @param y The input y coordinate
3021 * @param posret The position relative to the item returned here
3022 * @return The item at the coordinates or NULL if none
3026 EAPI Elm_Genlist_Item *
3027 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3029 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3030 Widget_Data *wd = elm_widget_data_get(obj);
3031 Evas_Coord ox, oy, ow, oh;
3034 if (!wd) return NULL;
3035 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3037 EINA_INLIST_FOREACH(wd->blocks, itb)
3040 Elm_Genlist_Item *it;
3042 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3043 oy + itb->y - itb->wd->pan_y,
3044 itb->w, itb->h, x, y, 1, 1))
3046 EINA_LIST_FOREACH(itb->items, l, it)
3048 Evas_Coord itx, ity;
3050 itx = ox + itb->x + it->x - itb->wd->pan_x;
3051 ity = oy + itb->y + it->y - itb->wd->pan_y;
3052 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3056 if (y <= (ity + (it->h / 4))) *posret = -1;
3057 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3062 lasty = ity + it->h;
3067 if (y > lasty) *posret = 1;
3074 * Get the first item in the genlist
3076 * This returns the first item in the list.
3078 * @param obj The genlist object
3079 * @return The first item, or NULL if none
3083 EAPI Elm_Genlist_Item *
3084 elm_genlist_first_item_get(const Evas_Object *obj)
3086 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3087 Widget_Data *wd = elm_widget_data_get(obj);
3088 if (!wd) return NULL;
3089 if (!wd->items) return NULL;
3090 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3091 while ((it) && (it->delete_me))
3092 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3097 * Get the last item in the genlist
3099 * This returns the last item in the list.
3101 * @return The last item, or NULL if none
3105 EAPI Elm_Genlist_Item *
3106 elm_genlist_last_item_get(const Evas_Object *obj)
3108 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3109 Widget_Data *wd = elm_widget_data_get(obj);
3110 if (!wd->items) return NULL;
3111 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3112 if (!wd) return NULL;
3113 while ((it) && (it->delete_me))
3114 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3119 * Get the next item in the genlist
3121 * This returns the item after the item @p it.
3123 * @param it The item
3124 * @return The item after @p it, or NULL if none
3128 EAPI Elm_Genlist_Item *
3129 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3133 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3134 if ((it) && (!it->delete_me)) break;
3136 return (Elm_Genlist_Item *)it;
3140 * Get the previous item in the genlist
3142 * This returns the item before the item @p it.
3144 * @param it The item
3145 * @return The item before @p it, or NULL if none
3149 EAPI Elm_Genlist_Item *
3150 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3154 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3155 if ((it) && (!it->delete_me)) break;
3157 return (Elm_Genlist_Item *)it;
3161 * Get the genlist object from an item
3163 * This returns the genlist object itself that an item belongs to.
3165 * @param it The item
3166 * @return The genlist object
3171 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3173 if (!it) return NULL;
3178 * Get the parent item of the given item
3180 * This returns the prent item of the item @p it given.
3182 * @param it The item
3183 * @return The parent of the item or NULL if none
3187 EAPI Elm_Genlist_Item *
3188 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3190 if (!it) return NULL;
3195 * Clear all sub-items (children) of the given item
3197 * This clears all items that are children (or their descendants) of the
3200 * @param it The item
3205 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3207 Eina_List *tl = NULL, *l;
3208 Elm_Genlist_Item *it2;
3211 EINA_LIST_FOREACH(it->items, l, it2)
3212 tl = eina_list_append(tl, it2);
3213 EINA_LIST_FREE(tl, it2)
3214 elm_genlist_item_del(it2);
3218 * Set the selected state of an item
3220 * This sets the selected state (1 selected, 0 not selected) of the given
3223 * @param it The item
3224 * @param selected The slected state
3229 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3231 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3234 if (it->delete_me) return;
3235 selected = !!selected;
3236 if (it->selected == selected) return;
3242 while (wd->selected)
3243 _item_unselect(wd->selected->data);
3253 * Get the selected state of an item
3255 * This gets the selected state of an item (1 selected, 0 not selected).
3257 * @param it The item
3258 * @return The selected state
3263 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3265 if (!it) return EINA_FALSE;
3266 return it->selected;
3270 * Sets the expanded state of an item (if it's a parent)
3272 * This expands or contracts a parent iterm (thus showing or hiding the
3275 * @param it The item
3276 * @param expanded The expanded state (1 expanded, 0 not expanded).
3281 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3284 if (it->expanded == expanded) return;
3285 it->expanded = expanded;
3289 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3290 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3295 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3296 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3301 * Get the expanded state of an item
3303 * This gets the expanded state of an item
3305 * @param it The item
3306 * @return Thre expanded state
3311 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3313 if (!it) return EINA_FALSE;
3314 return it->expanded;
3318 * Sets the disabled state of an item.
3320 * A disabled item cannot be selected or unselected. It will also change
3321 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3324 * @param it The item
3325 * @param disabled The disabled state
3330 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3333 if (it->disabled == disabled) return;
3334 if (it->delete_me) return;
3335 it->disabled = disabled;
3339 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3341 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3346 * Get the disabled state of an item
3348 * This gets the disabld state of the given item.
3350 * @param it The item
3351 * @return The disabled state
3356 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3358 if (!it) return EINA_FALSE;
3359 if (it->delete_me) return EINA_FALSE;
3360 return it->disabled;
3364 * Sets the display only state of an item.
3366 * A display only item cannot be selected or unselected. It is for display
3367 * only and not selecting or otherwise clicking, dragging etc. by the user,
3368 * thus finger size rules will not be applied to this item.
3370 * @param it The item
3371 * @param display_only The display only state
3376 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3379 if (!it->block) return;
3380 if (it->display_only == display_only) return;
3381 if (it->delete_me) return;
3382 it->display_only = display_only;
3383 it->mincalcd = EINA_FALSE;
3384 it->updateme = EINA_TRUE;
3385 it->block->updateme = EINA_TRUE;
3386 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3387 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3391 * Get the display only state of an item
3393 * This gets the display only state of the given item.
3395 * @param it The item
3396 * @return The display only state
3401 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3403 if (!it) return EINA_FALSE;
3404 if (it->delete_me) return EINA_FALSE;
3405 return it->display_only;
3409 * Show the given item
3411 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3412 * if it is not fully visible.
3414 * @param it The item
3419 elm_genlist_item_show(Elm_Genlist_Item *it)
3422 if (it->delete_me) return;
3423 if ((it->queued) || (!it->mincalcd))
3425 it->wd->show_item = it;
3426 it->wd->bring_in = 1;
3427 it->showme = EINA_TRUE;
3430 if (it->wd->show_item)
3432 it->wd->show_item->showme = EINA_FALSE;
3433 it->wd->show_item = NULL;
3435 elm_smart_scroller_child_region_show(it->wd->scr,
3436 it->x + it->block->x,
3437 it->y + it->block->y,
3438 it->block->w, it->h);
3442 * Bring in the given item
3444 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3445 * if it is not fully visible. This may use animation to do so and take a
3448 * @param it The item
3453 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3456 if (it->delete_me) return;
3457 if ((it->queued) || (!it->mincalcd))
3459 it->wd->show_item = it;
3460 it->wd->bring_in = 1;
3461 it->showme = EINA_TRUE;
3464 if (it->wd->show_item)
3466 it->wd->show_item->showme = EINA_FALSE;
3467 it->wd->show_item = NULL;
3469 elm_smart_scroller_region_bring_in(it->wd->scr,
3470 it->x + it->block->x,
3471 it->y + it->block->y,
3472 it->block->w, it->h);
3476 * Show the given item at the top
3478 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3479 * if it is not fully visible.
3481 * @param it The item
3486 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3491 if (it->delete_me) return;
3492 if ((it->queued) || (!it->mincalcd))
3494 it->wd->show_item = it;
3495 it->wd->bring_in = 1;
3496 it->showme = EINA_TRUE;
3499 if (it->wd->show_item)
3501 it->wd->show_item->showme = EINA_FALSE;
3502 it->wd->show_item = NULL;
3504 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3505 elm_smart_scroller_child_region_show(it->wd->scr,
3506 it->x + it->block->x,
3507 it->y + it->block->y,
3512 * Bring in the given item at the top
3514 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3515 * if it is not fully visible. This may use animation to do so and take a
3518 * @param it The item
3523 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3528 if (it->delete_me) return;
3529 if ((it->queued) || (!it->mincalcd))
3531 it->wd->show_item = it;
3532 it->wd->bring_in = 1;
3533 it->showme = EINA_TRUE;
3536 if (it->wd->show_item)
3538 it->wd->show_item->showme = EINA_FALSE;
3539 it->wd->show_item = NULL;
3541 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3542 elm_smart_scroller_region_bring_in(it->wd->scr,
3543 it->x + it->block->x,
3544 it->y + it->block->y,
3549 * Show the given item at the middle
3551 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3552 * if it is not fully visible.
3554 * @param it The item
3559 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3564 if (it->delete_me) return;
3565 if ((it->queued) || (!it->mincalcd))
3567 it->wd->show_item = it;
3568 it->wd->bring_in = 1;
3569 it->showme = EINA_TRUE;
3572 if (it->wd->show_item)
3574 it->wd->show_item->showme = EINA_FALSE;
3575 it->wd->show_item = NULL;
3577 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3578 elm_smart_scroller_child_region_show(it->wd->scr,
3579 it->x + it->block->x,
3580 it->y + it->block->y - oh/2 + it->h/2,
3586 * Bring in the given item at the middle
3588 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3589 * if it is not fully visible. This may use animation to do so and take a
3592 * @param it The item
3597 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3602 if (it->delete_me) return;
3603 if ((it->queued) || (!it->mincalcd))
3605 it->wd->show_item = it;
3606 it->wd->bring_in = 1;
3607 it->showme = EINA_TRUE;
3610 if (it->wd->show_item)
3612 it->wd->show_item->showme = EINA_FALSE;
3613 it->wd->show_item = NULL;
3615 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3616 elm_smart_scroller_region_bring_in(it->wd->scr,
3617 it->x + it->block->x,
3618 it->y + it->block->y - oh/2 + it->h/2,
3623 * Delete a given item
3625 * This deletes the item from genlist and calls the genlist item del class
3626 * callback defined in the item class, if it is set.
3628 * @param it The item
3633 elm_genlist_item_del(Elm_Genlist_Item *it)
3636 if ((it->relcount > 0) || (it->walking > 0))
3638 elm_genlist_item_subitems_clear(it);
3639 it->delete_me = EINA_TRUE;
3640 if (it->wd->show_item == it) it->wd->show_item = NULL;
3641 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3644 if (it->realized) _item_unrealize(it);
3645 it->block->changed = EINA_TRUE;
3646 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3647 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3649 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
3656 * Set the data item from the genlist item
3658 * This set the data value passed on the elm_genlist_item_append() and
3659 * related item addition calls. This function will also call
3660 * elm_genlist_item_update() so the item will be updated to reflect the
3663 * @param it The item
3664 * @param data The new data pointer to set
3669 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3673 elm_genlist_item_update(it);
3677 * Get the data item from the genlist item
3679 * This returns the data value passed on the elm_genlist_item_append() and
3680 * related item addition calls.
3682 * @param it The item
3683 * @return The data pointer provided when created
3688 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
3690 if (!it) return NULL;
3695 * Get the real evas object of the genlist item
3697 * This returns the actual evas object used for the specified genlist item.
3698 * This may be NULL as it may not be created, and ma be deleted at any time
3699 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
3700 * genlist is controlling it. This function is for querying, emitting
3701 * custom signals or hooking lower level callbacks for events. Do not
3702 * delete this object under any circumstances.
3704 * @param it The item
3705 * @return The objct pointer
3709 EAPI const Evas_Object *
3710 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
3712 if (!it) return NULL;
3717 * Update the contents of an item
3719 * This updates an item by calling all the item class functions again to get
3720 * the icons, labels and states. Use this when he original item data has
3721 * changed and the changes are desired to be reflected.
3723 * @param it The item
3728 elm_genlist_item_update(Elm_Genlist_Item *it)
3730 if (!it->block) return;
3731 if (it->delete_me) return;
3732 it->mincalcd = EINA_FALSE;
3733 it->updateme = EINA_TRUE;
3734 it->block->updateme = EINA_TRUE;
3735 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3736 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3740 * This sets the horizontal stretching mode
3742 * This sets the mode used for sizing items horizontally. Valid modes are
3743 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
3744 * mode means that if items are too wide to fit, the scroller will scroll
3745 * horizontally. Otherwise items are expanded to fill the width of the
3746 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
3747 * to the viewport width and limited to that size.
3749 * @param obj The genlist object
3750 * @param mode The mode to use
3755 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
3757 ELM_CHECK_WIDTYPE(obj, widtype);
3758 Widget_Data *wd = elm_widget_data_get(obj);
3760 if (wd->mode == mode) return;
3766 * Gets the horizontal stretching mode
3768 * @param obj The genlist object
3769 * @return The mode to use
3770 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
3775 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
3777 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
3778 Widget_Data *wd = elm_widget_data_get(obj);
3779 if (!wd) return ELM_LIST_LAST;
3784 * Set the always select mode.
3786 * Items will only call their selection func and callback when first becoming
3787 * selected. Any further clicks will do nothing, unless you enable always
3788 * select with elm_genlist_always_select_mode_set(). This means even if
3789 * selected, every click will make the selected callbacks be called.
3791 * @param obj The genlist object
3792 * @param always_select The always select mode
3793 * (EINA_TRUE = on, EINA_FALSE = off)
3798 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
3800 ELM_CHECK_WIDTYPE(obj, widtype);
3801 Widget_Data *wd = elm_widget_data_get(obj);
3803 wd->always_select = always_select;
3807 * Get the always select mode.
3809 * @param obj The genlist object
3810 * @return The always select mode
3811 * (EINA_TRUE = on, EINA_FALSE = off)
3816 elm_genlist_always_select_mode_get(const Evas_Object *obj)
3818 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3819 Widget_Data *wd = elm_widget_data_get(obj);
3820 if (!wd) return EINA_FALSE;
3821 return wd->always_select;
3825 * Set no select mode
3827 * This will turn off the ability to select items entirely and they will
3828 * neither appear selected nor call selected callback functions.
3830 * @param obj The genlist object
3831 * @param no_select The no select mode
3832 * (EINA_TRUE = on, EINA_FALSE = off)
3837 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
3839 ELM_CHECK_WIDTYPE(obj, widtype);
3840 Widget_Data *wd = elm_widget_data_get(obj);
3842 wd->no_select = no_select;
3846 * Gets no select mode
3848 * @param obj The genlist object
3849 * @return The no select mode
3850 * (EINA_TRUE = on, EINA_FALSE = off)
3855 elm_genlist_no_select_mode_get(const Evas_Object *obj)
3857 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3858 Widget_Data *wd = elm_widget_data_get(obj);
3859 if (!wd) return EINA_FALSE;
3860 return wd->no_select;
3866 * This will enable the compress mode where items are "compressed" horizontally
3867 * to fit the genlist scrollable viewport width.
3869 * @param obj The genlist object
3870 * @param no_select The compress mode
3871 * (EINA_TRUE = on, EINA_FALSE = off)
3876 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
3878 ELM_CHECK_WIDTYPE(obj, widtype);
3879 Widget_Data *wd = elm_widget_data_get(obj);
3881 wd->compress = compress;
3885 * Get the compress mode
3887 * @param obj The genlist object
3888 * @return The compress mode
3889 * (EINA_TRUE = on, EINA_FALSE = off)
3894 elm_genlist_compress_mode_get(const Evas_Object *obj)
3896 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3897 Widget_Data *wd = elm_widget_data_get(obj);
3898 if (!wd) return EINA_FALSE;
3899 return wd->compress;
3905 * This will enable or disable the scroller bounce mode for the genlist. See
3906 * elm_scroller_bounce_set() for details
3908 * @param obj The genlist object
3909 * @param h_bounce Allow bounce horizontally
3910 * @param v_bounce Allow bounce vertically
3915 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
3917 ELM_CHECK_WIDTYPE(obj, widtype);
3918 Widget_Data *wd = elm_widget_data_get(obj);
3920 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
3924 * Get the bounce mode
3926 * @param obj The genlist object
3927 * @param h_bounce Allow bounce horizontally
3928 * @param v_bounce Allow bounce vertically
3933 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
3935 ELM_CHECK_WIDTYPE(obj, widtype);
3936 Widget_Data *wd = elm_widget_data_get(obj);
3938 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
3942 * Set homogenous mode
3944 * This will enable the homogeneous mode where items are of the same height and width
3945 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
3947 * @param obj The genlist object
3948 * @param homogeneous Assume the items within the genlist are of the same height and width
3949 * (EINA_TRUE = on, EINA_FALSE = off)
3954 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
3956 ELM_CHECK_WIDTYPE(obj, widtype);
3957 Widget_Data *wd = elm_widget_data_get(obj);
3959 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
3960 wd->homogeneous = homogeneous;
3964 * Get the homogenous mode
3966 * @param obj The genlist object
3967 * @return Assume the items within the genlist are of the same height and width
3968 * (EINA_TRUE = on, EINA_FALSE = off)
3973 elm_genlist_homogeneous_get(const Evas_Object *obj)
3975 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3976 Widget_Data *wd = elm_widget_data_get(obj);
3977 if (!wd) return EINA_FALSE;
3978 return wd->homogeneous;
3982 * Set the maximum number of items within an item block
3984 * This will configure the block count to tune to the target with particular performance matrix.
3986 * @param obj The genlist object
3987 * @param n Maximum number of items within an item block
3992 elm_genlist_block_count_set(Evas_Object *obj, int n)
3994 ELM_CHECK_WIDTYPE(obj, widtype);
3995 Widget_Data *wd = elm_widget_data_get(obj);
3997 wd->max_items_per_block = n;
4001 * Get the maximum number of items within an item block
4003 * @param obj The genlist object
4004 * @return Maximum number of items within an item block
4009 elm_genlist_block_count_get(const Evas_Object *obj)
4011 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4012 Widget_Data *wd = elm_widget_data_get(obj);
4014 return wd->max_items_per_block;
4018 * Set the Genlist Internal scroller scrollbar policy
4020 * This sets the Genlist Internal scrollbar visibility policy.
4021 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it
4022 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4023 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4024 * This applies respectively for the horizontal and vertical scrollbars.
4026 * @param obj The Genlist object
4027 * @param policy_h Horizontal scrollbar policy
4028 * @param policy_v Vertical scrollbar policy
4033 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4035 ELM_CHECK_WIDTYPE(obj, widtype);
4036 Widget_Data *wd = elm_widget_data_get(obj);
4039 const Elm_Scroller_Policy map[3] =
4041 ELM_SMART_SCROLLER_POLICY_AUTO,
4042 ELM_SMART_SCROLLER_POLICY_ON,
4043 ELM_SMART_SCROLLER_POLICY_OFF
4045 if ((policy_h < 0) || (policy_h >= 3) || (policy_v < 0) || (policy_v >= 3))
4048 elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
4053 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class )
4055 Eina_List * realized_list;
4056 Elm_Genlist_Item *it;
4059 ELM_CHECK_WIDTYPE(obj, widtype);
4060 Widget_Data *wd = elm_widget_data_get(obj);
4062 if( wd->edit_mode == emode ) return;
4064 wd->edit_mode = emode;
4066 wd->animate_edit_controls = 1;
4067 if( wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
4069 if( wd->ed ) free (wd->ed);
4075 wd->ed = calloc(1, sizeof(Edit_Data));
4077 wd->ed->ec = edit_class;
4079 if( (wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) && !wd->ed->del_confirm)
4081 wd->ed->del_confirm = elm_button_add(wd->obj);
4082 elm_button_label_set(wd->ed->del_confirm, "Delete");
4083 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
4084 edje_object_scale_set( wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
4085 _elm_config->scale);
4086 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd );
4090 realized_list = elm_genlist_realized_items_get(obj);
4092 EINA_LIST_FOREACH(realized_list, l, it)
4094 _edit_controls_eval(it);
4097 if (wd->calc_job) ecore_job_del(wd->calc_job);
4098 wd->calc_job = ecore_job_add(_calc_job, wd);