3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup Genlist Genlist
12 * The aim was to have more expansive list that the simple list in
13 * Elementary that could have more flexible items and allow many more entries
14 * while still being fast and low on memory usage. At the same time it was
15 * also made to be able to do tree structures. But the price to pay is more
16 * complexity when it comes to usage. If all you want is a simple list with
17 * icons and a single label, use the normal List object.
19 * Signals that you can add callbacks for are:
21 * clicked - This is called when a user has double-clicked an item. The
22 * event_info parameter is the genlist item that was double-clicked.
24 * selected - This is called when a user has made an item selected. The
25 * event_info parameter is the genlist item that was selected.
27 * unselected - This is called when a user has made an item unselected. The
28 * event_info parameter is the genlist item that was unselected.
30 * expanded - This is called when elm_genlist_item_expanded_set() is called
31 * and the item is now meant to be expanded. The event_info parameter is the
32 * genlist item that was indicated to expand. It is the job of this callback
33 * to then fill in the child items.
35 * contracted - This is called when elm_genlist_item_expanded_set() is called
36 * and the item is now meant to be contracted. The event_info parameter is
37 * the genlist item that was indicated to contract. It is the job of this
38 * callback to then delete the child items
40 * expand,request - This is called when a user has indicated they want to
41 * expand a tree branch item. The callback should decide if the item can
42 * expand (has any children) and then call elm_genlist_item_expanded_set()
43 * appropriately to set the state. The event_info parameter is the genlist
44 * item that was indicated to expand.
46 * contract,request - This is called when a user has indicated they want to
47 * contract a tree branch item. The callback should decide if the item can
48 * contract (has any children) and then call elm_genlist_item_expanded_set()
49 * appropriately to set the state. The event_info parameter is the genlist
50 * item that was indicated to contract.
52 * realized - This is called when the item in the list is created as a real
53 * evas object. event_info parameter is the genlist item that was created.
54 * The object may be deleted at any time, so it is up to the caller to
55 * not use the object pointer from elm_genlist_item_object_get() in a way
56 * where it may point to freed objects.
58 * drag,start,up - This is called when the item in the list has been dragged
61 * drag,start,down - This is called when the item in the list has been dragged
62 * (not scrolled) down.
64 * drag,start,left - This is called when the item in the list has been dragged
65 * (not scrolled) left.
67 * drag,start,right - This is called when the item in the list has been dragged
68 * (not scrolled) right.
70 * drag,stop - This is called when the item in the list has stopped being
73 * drag - This is called when the item in the list is being dragged.
75 * Genlist has a fairly large API, mostly because it's relatively complex,
76 * trying to be both expansive, powerful and efficient. First we will begin
77 * an overview o the theory behind genlist.
79 * Evas tracks every object you create. Every time it processes an event
80 * (mouse move, down, up etc.) it needs to walk through objects and find out
81 * what event that affects. Even worse every time it renders display updates,
82 * in order to just calculate what to re-draw, it needs to walk through many
83 * many many objects. Thus, the more objects you keep active, the more
84 * overhead Evas has in just doing its work. It is advisable to keep your
85 * active objects to the minimum working set you need. Also remember that
86 * object creation and deletion carries an overhead, so there is a
87 * middle-ground, which is not easily determined. But don't keep massive lists
88 * of objects you can't see or use. Genlist does this with list objects. It
89 * creates and destroys them dynamically as you scroll around. It groups them
90 * into blocks so it can determine the visibility etc. of a whole block at
91 * once as opposed to having to walk the whole list. This 2-level list allows
92 * for very large numbers of items to be in the list (tests have used up to
93 * 2,000,000 items). Also genlist employs a queue for adding items. As items
94 * may be different sizes, every item added needs to be calculated as to its
95 * size and thus this presents a lot of overhead on populating the list, this
96 * genlist employs a queue. Any item added is queued and spooled off over
97 * time, actually appearing some time later, so if your list has many members
98 * you may find it takes a while for them to all appear, with your process
99 * consuming a lot of CPU while it is busy spooling.
101 * Genlist also implements a tree structure, but it does so with callbacks to
102 * the application, with the application filling in tree structures when
103 * requested (allowing for efficient building of a very deep tree that could
104 * even be used for file-management). See the above smart signal callbacks for
107 * An item in the genlist world can have 0 or more text labels (they can be
108 * regular text or textblock ??that's up to the style to determine), 0 or
109 * more icons (which are simply objects swallowed into the genlist item) and
110 * 0 or more boolean states that can be used for check, radio or other
111 * indicators by the edje theme style. An item may be one of several styles
112 * (Elementary provides 2 by default - ?
\9cdefault??and ?
\9cdouble_label?? but this
113 * can be extended by system or application custom themes/overlays/extensions).
115 * In order to implement the ability to add and delete items on the fly,
116 * Genlist implements a class/callback system where the application provides
117 * a structure with information about that type of item (genlist may contain
118 * multiple different items with different classes, states and styles).
119 * Genlist will call the functions in this struct (methods) when an item is
120 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
121 * simply be deleted when no longer needed with evas_object_del(). The
122 * Elm_Genlist_Item_Class structure contains the following members:
124 * item_style - This is a constant string and simply defines the name of the
125 * item style. It must be specified and the default should be ?
\9cdefault??
127 * func.label_get - This function is called when an actual item object is
128 * created. The data parameter is the data parameter passed to
129 * elm_genlist_item_append() and related item creation functions. The obj
130 * parameter is the genlist object and the part parameter is the string name
131 * of the text part in the edje design that is listed as one of the possible
132 * labels that can be set. This function must return a strudup()'ed string as
133 * the caller will free() it when done.
135 * func.icon_get - This function is called when an actual item object is
136 * created. The data parameter is the data parameter passed to
137 * elm_genlist_item_append() and related item creation functions. The obj
138 * parameter is the genlist object and the part parameter is the string name
139 * of the icon part in the edje design that is listed as one of the possible
140 * icons that can be set. This must return NULL for no object or a valid
141 * object. The object will be deleted by genlist on shutdown or when the item
144 * func.state_get - This function is called when an actual item object is
145 * created. The data parameter is the data parameter passed to
146 * elm_genlist_item_append() and related item creation functions. The obj
147 * parameter is the genlist object and the part parameter is the string name
148 * of the state part in the edje design that is listed as one of the possible
149 * states that can be set. Return 0 for false or 1 for true. Genlist will
150 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
151 * true (the default is false), where XXX is the name of the part.
153 * func.del - This is called when elm_genlist_item_del() is called on an
154 * item, elm_genlist_clear() is called on the genlist, or
155 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
156 * intended for use when actual genlist items are deleted, so any backing
157 * data attached to the item (e.g. its data parameter on creation) can be
160 * Items can be added by several calls. All of them return a Elm_Genlist_Item
161 * handle that is an internal member inside the genlist. They all take a data
162 * parameter that is meant to be used for a handle to the applications
163 * internal data (eg the struct with the original item data). The parent
164 * parameter is the parent genlist item this belongs to if it is a tree, and
165 * NULL if there is no parent. The flags can be a bitmask of
166 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
167 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
168 * that is able to expand and have child items. The func parameter is a
169 * convenience callback that is called when the item is selected and the data
170 * parameter will be the func_data parameter, obj be the genlist object and
171 * vent_info will be the genlist item.
173 * elm_genlist_item_append() appends an item to the end of the list, or if
174 * there is a parent, to the end of all the child items of the parent.
175 * elm_genlist_item_prepend() is the same but prepends to the beginning of
176 * the list or children list. elm_genlist_item_insert_before() inserts at
177 * item before another item and elm_genlist_item_insert_after() inserts after
178 * the indicated item.
180 * The application can clear the list with elm_genlist_clear() which deletes
181 * all the items in the list and elm_genlist_item_del() will delete a specific
182 * item. elm_genlist_item_subitems_clear() will clear all items that are
183 * children of the indicated parent item.
185 * If the application wants multiple items to be able to be selected,
186 * elm_genlist_multi_select_set() can enable this. If the list is
187 * single-selection only (the default), then elm_genlist_selected_item_get()
188 * will return the selected item, if any, or NULL I none is selected. If the
189 * list is multi-select then elm_genlist_selected_items_get() will return a
190 * list (that is only valid as long as no items are modified (added, deleted,
191 * selected or unselected).
193 * To help inspect list items you can jump to the item at the top of the list
194 * with elm_genlist_first_item_get() which will return the item pointer, and
195 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
196 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
197 * and previous items respectively relative to the indicated item. Using
198 * these calls you can walk the entire item list/tree. Note that as a tree
199 * the items are flattened in the list, so elm_genlist_item_parent_get() will
200 * let you know which item is the parent (and thus know how to skip them if
203 * There are also convenience functions. elm_genlist_item_genlist_get() will
204 * return the genlist object the item belongs to. elm_genlist_item_show()
205 * will make the scroller scroll to show that specific item so its visible.
206 * elm_genlist_item_data_get() returns the data pointer set by the item
207 * creation functions.
209 * If an item changes (state of boolean changes, label or icons change),
210 * then use elm_genlist_item_update() to have genlist update the item with
211 * the new state. Genlist will re-realize the item thus call the functions
212 * in the _Elm_Genlist_Item_Class for that item.
214 * To programmatically (un)select an item use elm_genlist_item_selected_set().
215 * To get its selected state use elm_genlist_item_selected_get(). Similarly
216 * to expand/contract and item and get its expanded state, use
217 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
218 * again to make an item disabled (unable to be selected and appear
219 * differently) use elm_genlist_item_disabled_set() to set this and
220 * elm_genlist_item_disabled_get() to get the disabled state.
222 * In general to indicate how the genlist should expand items horizontally to
223 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
224 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
225 * mode means that if items are too wide to fit, the scroller will scroll
226 * horizontally. Otherwise items are expanded to fill the width of the
227 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
228 * to the viewport width and limited to that size. This can be combined with
229 * a different style that uses edjes' ellipsis feature (cutting text off like
230 * this: ?
\9ctex...??.
232 * Items will only call their selection func and callback when first becoming
233 * selected. Any further clicks will do nothing, unless you enable always
234 * select with elm_genlist_always_select_mode_set(). This means even if
235 * selected, every click will make the selected callbacks be called.
236 * elm_genlist_no_select_mode_set() will turn off the ability to select
237 * items entirely and they will neither appear selected nor call selected
238 * callback functions.
240 * Remember that you can create new styles and add you own theme augmentation
241 * per application with elm_theme_extension_add(). If you absolutely must
242 * have a specific style that overrides any theme the user or system sets up
243 * you can use elm_theme_overlay_add() to add such a file.
246 typedef struct _Widget_Data Widget_Data;
247 typedef struct _Item_Block Item_Block;
248 typedef struct _Pan Pan;
249 typedef struct _Edit_Data Edit_Data;
251 #define GROUP_ALIGN_NORTH 1
252 #define GROUP_ALIGN_WEST 2
255 Evas_Object *obj, *scr, *pan_smart;
256 Eina_Inlist *items, *blocks, *group_items;
258 Evas_Coord pan_x, pan_y, minw, minh;
259 Ecore_Job *calc_job, *update_job;
260 Ecore_Idler *queue_idler;
261 Eina_List *queue, *selected, *menuopened;
262 Elm_Genlist_Item *show_item;
264 Eina_Bool on_hold : 1;
266 Eina_Bool always_select : 1;
267 Eina_Bool longpressed : 1;
268 Eina_Bool wasselected : 1;
269 Eina_Bool no_select : 1;
270 Eina_Bool bring_in : 1;
271 Eina_Bool compress : 1;
272 Eina_Bool homogeneous : 1;
273 Eina_Bool selct_all : 1;
277 int max_items_per_block;
279 Eina_Bool animate_edit_controls :1;
282 Evas_Coord td1_x, td1_y, tu1_x, tu1_y;
283 Evas_Coord td2_x, td2_y, tu2_x, tu2_y;
284 Evas_Coord d1_x, d1_y, d2_x, d2_y;
285 Evas_Coord acc_x1, acc_y1, acc_x2, acc_y2;
286 Evas_Coord prev_multi_x, prev_multi_y;
287 Eina_Bool multi_down : 1;
288 Eina_Bool multi_touch : 1;
292 Elm_Genlist_Edit_Class *ec;
293 Elm_Genlist_Item *del_item;
294 Elm_Genlist_Item *reorder_item;
295 Elm_Genlist_Item *reorder_rel;
296 Evas_Object *del_confirm;
306 Evas_Coord x, y, w, h, minw, minh;
307 Eina_Bool want_unrealize : 1;
308 Eina_Bool realized : 1;
309 Eina_Bool changed : 1;
310 Eina_Bool updateme : 1;
311 Eina_Bool showme : 1;
314 struct _Elm_Genlist_Item
320 Evas_Coord x, y, w, h, minw, minh, edx;
321 const Elm_Genlist_Item_Class *itc;
323 Elm_Genlist_Item *parent;
324 Elm_Genlist_Item_Flags flags;
325 Elm_Genlist_GroupItem *group_item;
332 Evas_Object *base, *spacer, *edit_obj;
333 Eina_List *labels, *icons, *states, *icon_objs;
334 Ecore_Timer *long_timer, *edit_long_timer;
335 Evas_Coord dx, dy, scrl_x, scrl_y;
336 Evas_Coord reoder_cavas_x, reoder_cavas_y;
338 Elm_Genlist_Item *rel;
341 Eina_Bool before : 1;
343 Eina_Bool want_unrealize : 1;
344 Eina_Bool realized : 1;
345 Eina_Bool selected : 1;
346 Eina_Bool hilighted : 1;
347 Eina_Bool expanded : 1;
348 Eina_Bool disabled : 1;
349 Eina_Bool display_only : 1;
350 Eina_Bool mincalcd : 1;
351 Eina_Bool queued : 1;
352 Eina_Bool showme : 1;
353 Eina_Bool delete_me : 1;
354 Eina_Bool delete_check : 1;
355 Eina_Bool del_confirm_state : 1;
357 Eina_Bool dragging : 1;
358 Eina_Bool updateme : 1;
359 Eina_Bool reordering : 1;
360 Eina_Bool menuopened : 1;
361 Eina_Bool select_all_item : 1;
364 int pad_left, pad_right;
369 struct _Elm_Genlist_GroupItem
374 Evas_Coord x, y, w, h, minw, minh;
375 const Elm_Genlist_Item_Class *itc;
384 Eina_List *labels, *icons, *states, *icon_objs;
386 Eina_Bool realized : 1;
387 Eina_Bool delete_me : 1;
388 Eina_Bool visible : 1;
389 Eina_Bool mincalcd : 1;
394 Evas_Object_Smart_Clipped_Data __clipped_data;
398 static const char *widtype = NULL;
399 static void _del_hook(Evas_Object *obj);
400 static void _theme_hook(Evas_Object *obj);
401 //static void _show_region_hook(void *data, Evas_Object *obj);
402 static void _sizing_eval(Evas_Object *obj);
403 static void _item_unrealize(Elm_Genlist_Item *it);
404 static void _item_block_unrealize(Item_Block *itb);
405 static void _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items);
406 static void _groupitem_unrealize(Elm_Genlist_GroupItem *git);
407 static void _calc_job(void *data);
408 static Eina_Bool _edit_mode_reset(Widget_Data *wd);
409 static void _edit_controls_eval( Elm_Genlist_Item *it );
410 static void _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity );
413 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
416 _del_hook(Evas_Object *obj)
418 Widget_Data *wd = elm_widget_data_get(obj);
420 if (wd->calc_job) ecore_job_del(wd->calc_job);
421 if (wd->update_job) ecore_job_del(wd->update_job);
426 _del_pre_hook(Evas_Object *obj)
428 Widget_Data *wd = elm_widget_data_get(obj);
430 evas_object_del(wd->pan_smart);
431 wd->pan_smart = NULL;
432 elm_genlist_clear(obj);
436 _theme_hook(Evas_Object *obj)
438 Widget_Data *wd = elm_widget_data_get(obj);
440 Elm_Genlist_GroupItem *git;
442 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
443 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
444 EINA_INLIST_FOREACH(wd->group_items, git)
446 _groupitem_unrealize(git);
448 EINA_INLIST_FOREACH(wd->blocks, itb)
451 Elm_Genlist_Item *it;
453 if (itb->realized) _item_block_unrealize(itb);
454 EINA_LIST_FOREACH(itb->items, l, it)
455 it->mincalcd = EINA_FALSE;
457 itb->changed = EINA_TRUE;
459 if (wd->calc_job) ecore_job_del(wd->calc_job);
460 wd->calc_job = ecore_job_add(_calc_job, wd);
466 _show_region_hook(void *data, Evas_Object *obj)
468 Widget_Data *wd = elm_widget_data_get(data);
469 Evas_Coord x, y, w, h;
471 elm_widget_show_region_get(obj, &x, &y, &w, &h);
472 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
477 _sizing_eval(Evas_Object *obj)
479 Widget_Data *wd = elm_widget_data_get(obj);
480 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
482 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
483 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
485 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
488 Evas_Coord vmw, vmh, vw, vh;
492 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
493 if ((minw > 0) && (vw < minw)) vw = minw;
494 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
496 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
499 evas_object_size_hint_min_set(obj, minw, minh);
500 evas_object_size_hint_max_set(obj, maxw, maxh);
504 _item_hilight(Elm_Genlist_Item *it)
506 const char *selectraise;
508 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
509 (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
510 if( !it->menuopened )
511 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
512 selectraise = edje_object_data_get(it->base, "selectraise");
513 if ((selectraise) && (!strcmp(selectraise, "on")))
515 evas_object_raise(it->base);
516 if( it->group_item && it->group_item->realized )
517 evas_object_raise(it->group_item->base);
519 it->hilighted = EINA_TRUE;
523 _item_block_del(Elm_Genlist_Item *it)
526 Item_Block *itb = it->block;
528 itb->items = eina_list_remove(itb->items, it);
530 itb->changed = EINA_TRUE;
531 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
532 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
535 il = EINA_INLIST_GET(itb);
536 Item_Block *itbn = (Item_Block *)(il->next);
538 it->parent->items = eina_list_remove(it->parent->items, it);
540 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
542 if (itbn) itbn->changed = EINA_TRUE;
548 il = EINA_INLIST_GET(itb);
549 Item_Block *itbp = (Item_Block *)(il->prev);
550 Item_Block *itbn = (Item_Block *)(il->next);
551 if ((itbp) && ((itbp->count + itb->count) < 48))
553 Elm_Genlist_Item *it2;
555 EINA_LIST_FREE(itb->items, it2)
558 itbp->items = eina_list_append(itbp->items, it2);
560 itbp->changed = EINA_TRUE;
562 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
565 else if ((itbn) && ((itbn->count + itb->count) < 48))
569 Eina_List *last = eina_list_last(itb->items);
570 Elm_Genlist_Item *it2 = last->data;
573 itb->items = eina_list_remove_list(itb->items, last);
574 itbn->items = eina_list_prepend(itbn->items, it2);
576 itbn->changed = EINA_TRUE;
579 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
587 _item_del(Elm_Genlist_Item *it)
589 elm_genlist_item_subitems_clear(it);
590 if (it->wd->show_item == it) it->wd->show_item = NULL;
591 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
592 if (it->realized) _item_unrealize(it);
593 if (it->block) _item_block_del(it);
594 if ((!it->delete_me) && (it->itc->func.del))
595 it->itc->func.del(it->data, it->wd->obj);
596 it->delete_me = EINA_TRUE;
598 it->wd->queue = eina_list_remove(it->wd->queue, it);
599 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
601 it->parent->items = eina_list_remove(it->parent->items, it);
602 if (it->long_timer) ecore_timer_del(it->long_timer);
605 it->group_item->items = eina_list_remove(it->group_item->items,it);
611 _item_select(Elm_Genlist_Item *it)
613 if ((it->wd->no_select) || (it->delete_me) || (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
616 if (it->wd->always_select) goto call;
619 it->selected = EINA_TRUE;
620 it->wd->selected = eina_list_append(it->wd->selected, it);
623 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
625 evas_object_smart_callback_call(it->wd->obj, "selected", it);
627 if ((it->walking == 0) && (it->delete_me))
629 if (it->relcount == 0) _item_del(it);
634 _item_unselect(Elm_Genlist_Item *it)
636 const char *stacking, *selectraise;
638 if ((it->delete_me) || (!it->hilighted)) return;
639 if( !it->menuopened )
640 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
641 stacking = edje_object_data_get(it->base, "stacking");
642 selectraise = edje_object_data_get(it->base, "selectraise");
643 if ((selectraise) && (!strcmp(selectraise, "on")))
645 if ((stacking) && (!strcmp(stacking, "below")))
646 evas_object_lower(it->base);
648 it->hilighted = EINA_FALSE;
651 it->selected = EINA_FALSE;
652 it->wd->selected = eina_list_remove(it->wd->selected, it);
653 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
658 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
660 const Eina_List *l, *l_next;
661 Elm_Genlist_Item *it2;
662 const char *allow_slide;
664 allow_slide = edje_object_data_get(it->base, "allow_slide");
668 if (atoi(allow_slide) != 1)
674 edje_object_signal_emit(it->base, "elm,state,slide,right", "elm");
675 it->wd->menuopened = eina_list_append(it->wd->menuopened, it);
677 EINA_LIST_FOREACH(it->wd->menuopened, l, it2)
681 it2->menuopened = EINA_FALSE;
682 edje_object_signal_emit(it2->base, "elm,state,slide,left", "elm");
683 it2->wd->menuopened = eina_list_remove(it2->wd->menuopened, it2);
690 edje_object_signal_emit(it->base, "elm,state,slide,left", "elm");
691 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
694 it->menuopened = slide_to_right;
698 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
700 Elm_Genlist_Item *it = data;
701 Evas_Event_Mouse_Move *ev = event_info;
702 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
703 Evas_Coord acc_x, acc_y;
705 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
707 if (!it->wd->on_hold)
709 it->wd->on_hold = EINA_TRUE;
713 if ((it->dragging) && (it->down))
717 ecore_timer_del(it->long_timer);
718 it->long_timer = NULL;
720 evas_object_smart_callback_call(it->wd->obj, "drag", it);
723 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
727 ecore_timer_del(it->long_timer);
728 it->long_timer = NULL;
733 if (it->wd->multi_down)
735 acc_x = ev->prev.canvas.x - ev->cur.canvas.x;
737 it->wd->acc_x1 = it->wd->acc_x1 - acc_x;
739 it->wd->acc_x1 = it->wd->acc_x1 + acc_x;
741 acc_y = ev->prev.canvas.y - ev->cur.canvas.y;
743 it->wd->acc_y1 = it->wd->acc_y1 - acc_y;
745 it->wd->acc_y1 = it->wd->acc_y1 + acc_y;
750 if (!it->display_only)
751 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
752 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
753 x = ev->cur.canvas.x - x;
754 y = ev->cur.canvas.y - y;
757 if (adx < 0) adx = -dx;
760 if (ady < 0) ady = -dy;
763 if ((adx > minw) || (ady > minh))
768 ecore_timer_del(it->long_timer);
769 it->long_timer = NULL;
771 if (!it->wd->wasselected)
773 it->wd->wasselected = 0;
777 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
782 evas_object_smart_callback_call(it->wd->obj,
783 "drag,start,left", it);
784 _item_slide( it, 0 );
788 evas_object_smart_callback_call(it->wd->obj,
789 "drag,start,right", it);
790 _item_slide( it, 1 );
797 evas_object_smart_callback_call(it->wd->obj,
798 "drag,start,down", it);
803 evas_object_smart_callback_call(it->wd->obj,
804 "drag,start,left", it);
805 _item_slide( it, 0 );
809 evas_object_smart_callback_call(it->wd->obj,
810 "drag,start,right", it);
811 _item_slide( it, 1 );
819 _long_press(void *data)
821 Elm_Genlist_Item *it = data;
823 it->long_timer = NULL;
824 if ((it->disabled) || (it->dragging)) return 0;
825 it->wd->longpressed = EINA_TRUE;
826 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
831 _edit_long_press(void *data)
833 Elm_Genlist_Item *it = data;
836 if ((it->disabled) || (it->dragging)) return 0;
837 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
839 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
841 it->dx = it->reoder_cavas_x - x;
842 it->dy = it->reoder_cavas_y - y;
844 evas_object_raise(it->base);
845 evas_object_raise( it->edit_obj );
847 it->wd->ed->reorder_item = it;
848 it->wd->ed->reorder_item->reordering = 1;
849 it->wd->ed->reorder_rel = NULL;
850 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
856 _multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
858 Elm_Genlist_Item *it = data;
859 Evas_Event_Multi_Down *ev = event_info;
860 Evas_Coord dx, dy, adx, ady;
864 ecore_timer_del(it->long_timer);
865 it->long_timer = NULL;
868 dx = it->wd->td1_x - ev->canvas.x;
870 if (adx < 0) adx = -dx;
871 dy = it->wd->td1_y - ev->canvas.y;
873 if (ady < 0) ady = -dy;
875 if (adx < 60 && ady < 60)
878 it->wd->multi_down = 1;
879 it->wd->td2_x = ev->canvas.x;
880 it->wd->td2_y = ev->canvas.y;
882 fprintf(stderr, "\n MULTI_DOWN - BUTTON ID = %d, x= %d, y= %d\n", ev->device, it->wd->td2_x, it->wd->td2_y);
886 _multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
888 Elm_Genlist_Item *it = data;
889 Evas_Event_Multi_Up *ev = event_info;
890 Evas_Coord dy, uy, ady, auy;
892 fprintf(stderr, "\n MULTI_UP - x= %d, y= %d down= %d multi_down= %d\n", ev->canvas.x, ev->canvas.y, it->down, it->wd->multi_down);
894 if (!it->wd->multi_down)
897 it->wd->multi_down = 0;
898 it->wd->tu2_x = ev->canvas.x;
899 it->wd->tu2_y = ev->canvas.y;
900 it->wd->d2_x = ev->canvas.x - it->wd->td2_x;
901 it->wd->d2_y = ev->canvas.y - it->wd->td2_y;
905 it->wd->multi_touch = EINA_TRUE;
909 fprintf(stderr, "CHECK d1_x= %d, d2_x= %d, d1_y= %d, d2_y= %d\n", it->wd->d1_x, it->wd->d2_x, it->wd->d1_y, it->wd->d2_y);
911 if ( (it->wd->d1_x > 180) && (it->wd->d2_x > 180) )
913 // Two finger : Left -> Right
914 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
915 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
916 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
918 else if ( (it->wd->d1_y > 180) && (it->wd->d2_y > 180) )
920 // Two finger : Top -> Bottom
921 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
922 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
923 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
927 dy = it->wd->td1_y - it->wd->td2_y;
933 uy = it->wd->tu1_y - it->wd->tu2_y;
943 // Two finger : Pinch Out
944 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
951 // Two finger : Pinch In
952 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
961 it->wd->prev_multi_x = 0;
962 it->wd->prev_multi_y = 0;
967 _multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
969 Elm_Genlist_Item *it = data;
970 Evas_Event_Multi_Move *ev = event_info;
971 Evas_Coord acc_x, acc_y;
973 if (it->wd->prev_multi_x == 0)
975 it->wd->prev_multi_x = ev->cur.canvas.x;
976 it->wd->prev_multi_y = ev->cur.canvas.y;
980 acc_x = it->wd->prev_multi_x - ev->cur.canvas.x;
982 it->wd->acc_x2 = it->wd->acc_x2 - acc_x;
984 it->wd->acc_x2 = it->wd->acc_x2 + acc_x;
986 acc_y = it->wd->prev_multi_y - ev->cur.canvas.y;
988 it->wd->acc_y2 = it->wd->acc_y2 - acc_y;
990 it->wd->acc_y2 = it->wd->acc_y2 + acc_y;
992 it->wd->prev_multi_x = ev->cur.canvas.x;
993 it->wd->prev_multi_y = ev->cur.canvas.y;
997 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
999 Elm_Genlist_Item *it = data;
1000 Evas_Event_Mouse_Down *ev = event_info;
1003 if( it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
1004 (void)_edit_mode_reset( it->wd );
1005 if (ev->button != 1) return;
1008 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1009 it->dx = ev->canvas.x - x;
1010 it->dy = ev->canvas.y - y;
1011 it->wd->td1_x = ev->canvas.x;
1012 it->wd->td1_y = ev->canvas.y;
1013 it->wd->longpressed = EINA_FALSE;
1014 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1015 else it->wd->on_hold = EINA_FALSE;
1016 it->wd->wasselected = it->selected;
1018 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1019 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
1020 if (it->long_timer) ecore_timer_del(it->long_timer);
1022 it->long_timer = ecore_timer_add(1.0, _long_press, it);
1024 it->long_timer = NULL;
1028 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1030 Elm_Genlist_Item *it = data;
1031 Evas_Event_Mouse_Up *ev = event_info;
1032 Eina_Bool dragged = EINA_FALSE;
1033 Evas_Coord dy, uy, ady, auy;
1035 if (ev->button != 1) return;
1040 it->wd->tu1_x = ev->canvas.x;
1041 it->wd->tu1_y = ev->canvas.y;
1042 it->wd->d1_x = ev->canvas.x - it->wd->td1_x;
1043 it->wd->d1_y = ev->canvas.y - it->wd->td1_y;
1045 if (it->wd->multi_down == 0 && it->wd->multi_touch == EINA_TRUE)
1047 if ( (it->wd->d1_x > 180) && (it->wd->d2_x > 180) )
1049 // Two finger : Left -> Right
1050 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1051 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1052 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1054 else if ( (it->wd->d1_y > 180) && (it->wd->d2_y > 180) )
1056 // Two finger : Top -> Bottom
1057 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1058 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1059 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1063 dy = it->wd->td1_y - it->wd->td2_y;
1069 uy = it->wd->tu1_y - it->wd->tu2_y;
1079 // Two finger : Pinch Out
1080 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1087 // Two finger : Pinch In
1088 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1098 it->wd->prev_multi_x = 0;
1099 it->wd->prev_multi_y = 0;
1100 it->wd->multi_down = 0;
1103 it->wd->multi_touch = EINA_FALSE;
1105 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1106 else it->wd->on_hold = EINA_FALSE;
1109 ecore_timer_del(it->long_timer);
1110 it->long_timer = NULL;
1115 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
1118 if (it->wd->on_hold)
1120 it->wd->longpressed = EINA_FALSE;
1121 it->wd->on_hold = EINA_FALSE;
1124 if (it->wd->longpressed)
1126 it->wd->longpressed = EINA_FALSE;
1127 if (!it->wd->wasselected)
1129 it->wd->wasselected = 0;
1134 if (it->want_unrealize)
1136 _item_unrealize(it);
1137 if (it->block->want_unrealize)
1138 _item_block_unrealize(it->block);
1141 if ((it->disabled) || (dragged)) return;
1149 else _item_unselect(it);
1155 Widget_Data *wd = it->wd;
1158 while (wd->selected) _item_unselect(wd->selected->data);
1163 const Eina_List *l, *l_next;
1164 Elm_Genlist_Item *it2;
1166 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1167 if (it2 != it) _item_unselect(it2);
1168 // _item_hilight(it);
1169 // _item_select(it);
1177 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1179 Elm_Genlist_Item *it = data;
1182 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1184 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1188 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1190 Elm_Genlist_Item *it = data;
1193 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1197 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1199 Elm_Genlist_Item *it = data;
1202 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1206 _set_groupitem( Elm_Genlist_Item *it, Elm_Genlist_GroupItem *git)
1210 it->group_item = git;
1211 git->items = eina_list_append(git->items, it);
1216 _groupitem_realize(Elm_Genlist_GroupItem *git)
1221 if ((git->realized) || (git->delete_me)) return;
1222 git->base = edje_object_add(evas_object_evas_get(git->wd->obj));
1223 edje_object_scale_set(git->base, elm_widget_scale_get(git->wd->obj) *
1224 _elm_config->scale);
1225 evas_object_smart_member_add(git->base, git->wd->pan_smart);
1226 elm_widget_sub_object_add(git->wd->obj, git->base);
1228 strncpy(buf, "item/", sizeof(buf));
1229 strncat(buf, git->itc->item_style, sizeof(buf) - strlen(buf));
1230 _elm_theme_object_set(git->wd->obj, git->base, "genlist", buf, elm_widget_style_get(git->wd->obj));
1232 align = edje_object_data_get(git->base, "orientation");
1233 git->align = GROUP_ALIGN_NORTH;
1236 if( !strcmp(align, "top") )
1237 git->align = GROUP_ALIGN_NORTH;
1238 else if( !strcmp(align, "left") )
1239 git->align = GROUP_ALIGN_WEST;
1240 else git->align = GROUP_ALIGN_NORTH;
1243 if (git->itc->func.label_get)
1248 git->labels = _elm_stringlist_get(edje_object_data_get(git->base, "labels"));
1249 EINA_LIST_FOREACH(git->labels, l, key)
1251 char *s = git->itc->func.label_get(git->data, git->wd->obj, l->data);
1255 edje_object_part_text_set(git->base, l->data, s);
1261 if (git->itc->func.icon_get)
1266 git->icons = _elm_stringlist_get(edje_object_data_get(git->base, "icons"));
1267 EINA_LIST_FOREACH(git->icons, l, key)
1269 Evas_Object *ic = git->itc->func.icon_get(git->data, git->wd->obj, l->data);
1273 git->icon_objs = eina_list_append(git->icon_objs, ic);
1274 edje_object_part_swallow(git->base, key, ic);
1275 evas_object_show(ic);
1276 elm_widget_sub_object_add(git->wd->obj, ic);
1281 if (git->itc->func.state_get)
1286 git->states = _elm_stringlist_get(edje_object_data_get(git->base, "states"));
1287 EINA_LIST_FOREACH(git->states, l, key)
1289 Eina_Bool on = git->itc->func.state_get(git->data, git->wd->obj, l->data);
1293 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1294 edje_object_signal_emit(git->base, buf, "elm");
1300 Evas_Coord mw = -1, mh = -1;
1302 edje_object_size_min_restricted_calc(git->base, &mw, &mh, mw, mh);
1304 git->w = git->minw = mw;
1305 git->h = git->minh = mh;
1306 git->mincalcd = EINA_TRUE;
1308 git->y = git->y = -1;
1309 evas_object_show(git->base);
1311 git->realized = EINA_TRUE;
1316 _groupitem_unrealize(Elm_Genlist_GroupItem *git)
1320 if (!git->realized) return;
1321 evas_object_del(git->base);
1323 _elm_stringlist_free(git->labels);
1325 _elm_stringlist_free(git->icons);
1327 _elm_stringlist_free(git->states);
1329 EINA_LIST_FREE(git->icon_objs, icon)
1330 evas_object_del(icon);
1333 git->realized = EINA_FALSE;
1337 _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items)
1339 Elm_Genlist_Item *it;
1345 _groupitem_unrealize( git );
1347 git->wd->group_items = eina_inlist_remove(git->wd->group_items,EINA_INLIST_GET(git));
1351 EINA_LIST_FOREACH(git->items,l, it)
1353 it->group_item = NULL;
1354 elm_genlist_item_update(it);
1358 if (git->itc->func.del) git->itc->func.del(git->data, git->wd->obj);
1363 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1365 Elm_Genlist_Item *it2;
1366 const char *stacking;
1367 const char *treesize;
1369 int depth, tsize = 20;
1371 if ((it->realized) || (it->delete_me)) return;
1372 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1373 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1374 _elm_config->scale);
1375 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1376 elm_widget_sub_object_add(it->wd->obj, it->base);
1378 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1379 else strncpy(buf, "item", sizeof(buf));
1380 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1382 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1383 strncat(buf, "/", sizeof(buf) - strlen(buf));
1384 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1386 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1387 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1388 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1389 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1390 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
1392 treesize = edje_object_data_get(it->base, "treesize");
1393 if (treesize) tsize = atoi(treesize);
1394 evas_object_size_hint_min_set(it->spacer,
1395 (depth * tsize) * _elm_config->scale, 1);
1396 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1399 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1400 "elm", _signal_expand_toggle, it);
1401 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1402 _signal_expand, it);
1403 edje_object_signal_callback_add(it->base, "elm,action,contract",
1404 "elm", _signal_contract, it);
1405 stacking = edje_object_data_get(it->base, "stacking");
1408 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1409 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1411 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1413 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1415 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1417 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_DOWN,
1419 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_UP,
1421 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_MOVE,
1423 if (it->selected && !it->menuopened)
1424 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1426 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1428 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1431 if (calc && it->wd->homogeneous && it->wd->item_width)
1433 /* homogenous genlist shortcut */
1436 it->w = it->minw = it->wd->item_width;
1437 it->h = it->minh = it->wd->item_height;
1438 it->mincalcd = EINA_TRUE;
1443 if(!strcmp(it->itc->item_style, "select_all")) {
1447 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1448 EINA_LIST_FOREACH(it->labels, l, key) {
1449 edje_object_part_text_set(it->base, l->data, "Select all");
1453 if (it->itc->func.label_get)
1458 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1459 EINA_LIST_FOREACH(it->labels, l, key)
1461 char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
1465 edje_object_part_text_set(it->base, l->data, s);
1470 if (it->itc->func.icon_get)
1475 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
1476 EINA_LIST_FOREACH(it->icons, l, key)
1478 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
1482 it->icon_objs = eina_list_append(it->icon_objs, ic);
1483 edje_object_part_swallow(it->base, key, ic);
1484 evas_object_show(ic);
1485 elm_widget_sub_object_add(it->wd->obj, ic);
1489 if (it->itc->func.state_get)
1494 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
1495 EINA_LIST_FOREACH(it->states, l, key)
1497 Eina_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
1501 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1502 edje_object_signal_emit(it->base, buf, "elm");
1508 Evas_Coord mw = -1, mh = -1;
1510 if (!it->display_only)
1511 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1512 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1513 if (!it->display_only)
1514 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1515 it->w = it->minw = mw;
1516 it->h = it->minh = mh;
1517 it->mincalcd = EINA_TRUE;
1519 if (in == 0 && it->wd->homogeneous)
1521 it->wd->item_width = mw;
1522 it->wd->item_height = mh;
1525 if (!calc) evas_object_show(it->base);
1527 it->realized = EINA_TRUE;
1528 it->want_unrealize = EINA_FALSE;
1529 if(it->group_item && !it->group_item->realized)
1530 _groupitem_realize(it->group_item);
1531 if( ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode )
1532 _edit_controls_eval(it);
1536 _item_unrealize(Elm_Genlist_Item *it)
1540 if (!it->realized) return;
1541 it->menuopened = EINA_FALSE;
1542 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
1545 ecore_timer_del(it->long_timer);
1546 it->long_timer = NULL;
1548 evas_object_del(it->base);
1550 evas_object_del(it->spacer);
1553 evas_object_del(it->edit_obj);
1554 it->edit_obj = NULL;
1555 _elm_stringlist_free(it->labels);
1557 _elm_stringlist_free(it->icons);
1559 _elm_stringlist_free(it->states);
1561 EINA_LIST_FREE(it->icon_objs, icon)
1562 evas_object_del(icon);
1565 it->realized = EINA_FALSE;
1566 it->want_unrealize = EINA_FALSE;
1570 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1573 Elm_Genlist_Item *it;
1574 Elm_Genlist_GroupItem *git = NULL;
1575 Evas_Coord minw = 0, minh = 0;
1576 int showme = 0, changed = 0;
1580 EINA_LIST_FOREACH(itb->items, l, it)
1582 if (it->delete_me) continue;
1583 showme |= it->showme;
1588 if (!it->mincalcd) changed = 1;
1591 _item_realize(it, in, 1);
1592 _item_unrealize(it);
1597 _item_realize(it, in, 1);
1598 _item_unrealize(it);
1603 Eina_Bool was_realized = it->realized;
1605 _item_realize(it, in, 0);
1607 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1610 if (minw < it->minw) minw = it->minw;
1615 if( git != it->group_item )
1617 git = it->group_item;
1618 if( git && git->align == GROUP_ALIGN_NORTH && git->items->data == it) //Add Place holder for Group title
1628 itb->changed = EINA_FALSE;
1629 /* force an evas norender to garbage collect deleted objects */
1630 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1635 _item_block_realize(Item_Block *itb, int in, int full)
1638 Elm_Genlist_Item *it;
1640 if (itb->realized) return;
1641 EINA_LIST_FOREACH(itb->items, l, it)
1643 if (it->delete_me) continue;
1646 Eina_Bool was_realized = it->realized;
1648 _item_realize(it, in, 0);
1650 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1654 itb->realized = EINA_TRUE;
1655 itb->want_unrealize = EINA_FALSE;
1659 _item_block_unrealize(Item_Block *itb)
1662 Elm_Genlist_Item *it;
1665 if (!itb->realized) return;
1666 EINA_LIST_FOREACH(itb->items, l, it)
1668 if (it->dragging || it->reordering)
1671 it->want_unrealize = EINA_TRUE;
1674 _item_unrealize(it);
1678 itb->realized = EINA_FALSE;
1679 itb->want_unrealize = EINA_TRUE;
1682 itb->want_unrealize = EINA_FALSE;
1686 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
1688 Widget_Data *wd = data;
1689 evas_object_hide( wd->ed->del_confirm );
1690 if( wd->ed->ec && wd->ed->ec->remove )
1691 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
1692 wd->ed->del_item = NULL;
1696 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
1698 const char *del_icon_part;
1699 Elm_Genlist_Item *it = data;
1700 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
1702 edje_object_part_unswallow( it->edit_obj, it->wd->ed->del_confirm );
1704 evas_object_hide( it->wd->ed->del_confirm );
1708 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1710 const char *del_icon_part, *del_conf_style;
1711 Elm_Genlist_Item *it = data;
1712 if(_edit_mode_reset( it->wd ))
1715 if (it->edit_long_timer)
1717 ecore_timer_del(it->edit_long_timer);
1718 it->edit_long_timer = NULL;
1721 if( it->del_confirm_state )
1723 it->del_confirm_state = 0;
1724 it->delete_check = 0;
1725 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
1729 it->del_confirm_state = 1;
1730 it->delete_check = 1;
1732 it->wd->ed->del_item = it;
1734 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
1736 elm_object_style_set( it->wd->ed->del_confirm, del_conf_style);
1739 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1743 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1745 Elm_Genlist_Item *it = data;
1747 if(_edit_mode_reset( it->wd ))
1750 if( it->wd->ed->ec && it->wd->ed->ec->insert_new )
1751 it->wd->ed->ec->insert_new(it->wd->obj, it);
1755 _edit_mode_reset(Widget_Data *wd)
1758 if(wd->ed->del_confirm_state)
1760 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
1761 //wd->ed->del_confirm_state = 0;
1762 //wd->ed->del_item = NULL;
1770 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1772 Elm_Genlist_Item *it = data;
1773 Evas_Event_Mouse_Down *ev = event_info;
1776 if(_edit_mode_reset( it->wd ) )
1782 it->reoder_cavas_x = ev->canvas.x;
1783 it->reoder_cavas_y = ev->canvas.y;
1785 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1786 it->dx = ev->canvas.x - x;
1787 it->dy = ev->canvas.y - y;
1789 if (it->edit_long_timer)
1791 ecore_timer_del(it->edit_long_timer);
1792 it->edit_long_timer = NULL;
1796 it->edit_long_timer = ecore_timer_add(0.3,_edit_long_press, it);
1799 it->edit_long_timer = NULL;
1804 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1806 Elm_Genlist_Item *it = data;
1807 Evas_Event_Mouse_Up *ev = event_info;
1809 if (it->edit_long_timer)
1811 ecore_timer_del(it->edit_long_timer);
1812 it->edit_long_timer = NULL;
1816 if( it->reordering && it->wd->ed->reorder_item )
1818 it->wd->ed->reorder_item->reordering = 0;
1819 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
1820 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1822 if( (!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
1823 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE ) ) )
1825 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);
1826 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y );
1828 it->wd->ed->reorder_item = NULL;
1829 it->wd->ed->reorder_rel = NULL;
1835 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1837 Elm_Genlist_Item *it = data;
1838 Evas_Event_Mouse_Move *ev = event_info;
1840 if ((it->dragging) && (it->down))
1842 if (it->edit_long_timer)
1844 ecore_timer_del(it->edit_long_timer);
1845 it->edit_long_timer = NULL;
1848 evas_object_smart_callback_call(it->wd->obj, "drag", it);
1853 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1855 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1856 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1857 x = ev->cur.canvas.x - x;
1858 y = ev->cur.canvas.y - y;
1861 if (adx < 0) adx = -dx;
1864 if (ady < 0) ady = -dy;
1867 if ((adx > minw) || (ady > minh))
1870 if (it->edit_long_timer)
1872 ecore_timer_del(it->edit_long_timer);
1873 it->edit_long_timer = NULL;
1877 if( it->reordering && it->wd->ed->reorder_item )
1879 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
1880 evas_object_raise(it->wd->ed->reorder_item->base);
1881 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
1882 evas_object_show(it->wd->ed->reorder_item->base);
1883 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, y );
1885 it->block->updateme = EINA_TRUE;
1887 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1888 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1895 _select_all_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1897 Elm_Genlist_Item *it = data;
1900 Widget_Data *wd = it->wd;
1903 Eina_List *realized_list = elm_genlist_realized_items_get(wd->obj);
1905 EINA_LIST_FOREACH(realized_list, l, it)
1907 if( !strcmp(it->itc->item_style, "select_all") )
1908 it->select_all_item = 1;
1910 if(!wd->selct_all) {
1911 it->delete_check = 1;
1912 it->del_confirm_state = 1;
1913 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1914 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
1917 it->delete_check = 0;
1918 it->del_confirm_state = 0;
1919 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
1920 edje_object_signal_emit(it->base, "elm,state,del,animated,enable", "elm");
1925 wd->selct_all ^= 0xFF;
1927 if (wd->calc_job) ecore_job_del(wd->calc_job);
1928 wd->calc_job = ecore_job_add(_calc_job, wd);
1933 _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity )
1935 if(it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )
1938 evas_object_resize(it->edit_obj,it->w, it->h );
1939 evas_object_move(it->edit_obj, itx, ity );
1940 evas_object_raise( it->edit_obj );
1944 _edit_controls_eval( Elm_Genlist_Item *it )
1947 const char *pad_str;
1952 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj )
1955 if( !strcmp(it->itc->item_style, "select_all") ) {
1956 edje_object_signal_callback_add(it->base, "elm,action,select,press", "elm",_select_all_down, it);
1960 if( it->itc->func.editmode_get )
1961 itmode = it->itc->func.editmode_get( it->data, it->wd->obj, it->wd->edit_mode );
1962 itmode &= it->wd->edit_mode;
1966 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
1967 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
1968 _elm_config->scale);
1969 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
1970 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
1971 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
1973 edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
1974 "elm", _edit_mode_reset, it);
1977 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
1978 if (pad_str) pad = atoi(pad_str);
1980 if( (itmode & ELM_GENLIST_EDIT_MODE_INSERT) )
1982 if(it->wd->animate_edit_controls)
1983 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
1985 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
1987 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
1988 "elm", _insert_new_item_cb, it);
1989 it->pad_left += pad;
1993 if(it->wd->animate_edit_controls)
1994 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
1996 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
1998 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
1999 "elm", _insert_new_item_cb );
2002 if( (itmode & ELM_GENLIST_EDIT_MODE_DELETE) )
2004 if(it->wd->animate_edit_controls)
2005 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
2007 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
2009 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
2010 "elm", _remove_item_cb, it);
2012 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
2013 "elm", _hide_delete_confirm_object, it );
2014 it->pad_left += pad;
2018 if(it->wd->animate_edit_controls)
2019 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
2021 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
2023 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
2024 "elm", _remove_item_cb );
2025 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
2026 "elm", _hide_delete_confirm_object );
2030 if( (itmode & ELM_GENLIST_EDIT_MODE_REORDER) )
2032 Evas_Object *reorder_icon;
2033 const char* reorder_part;
2035 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
2036 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
2038 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
2040 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
2041 _reorder_mouse_down, it);
2042 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
2043 _reorder_mouse_up, it);
2044 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
2045 _reorder_mouse_move, it);
2047 // it->pad_right += pad;
2051 Evas_Object *reorder_icon;
2052 const char* reorder_part;
2054 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
2055 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
2057 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
2059 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
2060 _reorder_mouse_down);
2061 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
2063 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
2064 _reorder_mouse_move);
2068 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )//Unrealize
2070 evas_object_del(it->edit_obj);
2071 it->edit_obj = NULL;
2074 _move_edit_controls(it,it->scrl_x, it->scrl_y );
2075 evas_object_show( it->edit_obj );
2079 _notify_item_position( Elm_Genlist_Item *it )
2084 l = eina_list_last(it->parent->items);
2086 //Check if the Item is First Node or Last node of its Parent & raise signal.
2087 if( it->parent->items->data != it && l->data != it )
2089 edje_object_signal_emit(it->base, "normal_item", "elm");
2093 if(it->parent->items->data == it )
2094 edje_object_signal_emit(it->base, "first_item", "elm");
2097 edje_object_signal_emit(it->base, "last_item", "elm");
2104 _get_space_for_reorder_item( Elm_Genlist_Item *it )
2107 Evas_Coord rox, roy, row, roh;
2109 if( !(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) || !it->wd->ed->reorder_item )
2112 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
2114 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2115 rox, roy+roh/2, row, 1));
2119 it->wd->ed->reorder_rel = it;
2120 it->scrl_y+=it->wd->ed->reorder_item->h;
2121 return it->wd->ed->reorder_item->h;
2128 _item_block_position(Item_Block *itb, int in)
2131 Elm_Genlist_Item *it;
2132 Elm_Genlist_GroupItem *git = NULL;
2133 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2136 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2137 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
2138 EINA_LIST_FOREACH(itb->items, l, it)
2140 if (it->delete_me) continue;
2144 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
2145 itb->y - it->wd->pan_y + oy,
2147 cvx, cvy, cvw, cvh));
2148 if ((itb->realized) && (!it->realized))
2152 Eina_Bool was_realized = it->realized;
2154 _item_realize(it, in, 0);
2156 evas_object_smart_callback_call(it->wd->obj,
2162 _notify_item_position( it );
2165 it->scrl_x = ox + itb->x + it->x - itb->wd->pan_x;
2166 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y;
2167 if( git != it->group_item )
2169 git = it->group_item;
2172 git->visible = EINA_TRUE; //Mark Group Item to make it visible
2173 if( git->items->data == it)
2174 git->y = it->scrl_y;
2175 if( GROUP_ALIGN_NORTH == git->align )
2178 if( git->items->data == it)
2180 it->scrl_y += git->minh;
2188 git->x = ox + itb->x - itb->wd->pan_x;
2193 if( git->align == GROUP_ALIGN_WEST )
2196 it->scrl_x += git->x + git->w;
2197 git->h = (it->scrl_y + it->h) - git->y ;
2198 if( git->h < it->h )
2200 git->y = it->scrl_y;
2204 if( git->align == GROUP_ALIGN_NORTH )
2207 if( (git->y + git->h) > (it->scrl_y + it->h) )
2208 git->y = (it->scrl_y + it->h) - git->minh;
2213 if(!it->select_all_item)
2214 y+=_get_space_for_reorder_item( it );
2216 if(!it->reordering )
2218 _move_edit_controls( it,it->scrl_x, it->scrl_y );
2219 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
2221 if(it->select_all_item) {
2222 evas_object_move(it->base, it->scrl_x+it->pad_left, oy);
2223 evas_object_raise(it->base);
2226 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
2228 if(it->delete_check) {
2229 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
2230 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
2232 evas_object_show(it->base);
2238 _item_unrealize(it);
2242 if(!it->reordering )
2248 EINA_LIST_FOREACH(itb->items, l, it)
2250 if(it->select_all_item) {
2251 evas_object_raise(it->base);
2258 itb->wd->animate_edit_controls = 0;
2260 git->visible = EINA_TRUE;
2265 _calc_job(void *data)
2267 Widget_Data *wd = data;
2269 Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
2270 Item_Block *chb = NULL;
2271 int in = 0, minw_change = 0;
2273 EINA_INLIST_FOREACH(wd->blocks, itb)
2278 showme = itb->showme;
2282 if (itb->realized) _item_block_unrealize(itb);
2286 if (itb->realized) _item_block_unrealize(itb);
2287 showme = _item_block_recalc(itb, in, 0, 1);
2293 if (minw == -1) minw = itb->minw;
2294 else if (minw < itb->minw)
2305 wd->show_item->showme = 0;
2307 elm_smart_scroller_region_bring_in(wd->scr,
2308 wd->show_item->x + wd->show_item->block->x,
2309 wd->show_item->y + wd->show_item->block->y,
2310 wd->show_item->block->w,
2313 elm_smart_scroller_child_region_show(wd->scr,
2314 wd->show_item->x + wd->show_item->block->x,
2315 wd->show_item->y + wd->show_item->block->y,
2316 wd->show_item->block->w,
2318 wd->show_item = NULL;
2324 EINA_INLIST_FOREACH(wd->blocks, itb)
2330 if ((chb) && (EINA_INLIST_GET(chb)->next))
2332 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2333 if (itb->realized) _item_block_unrealize(itb);
2335 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2336 if (minw < ow) minw = ow;
2337 if ((minw != wd->minw) || (minh != wd->minh))
2341 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2342 _sizing_eval(wd->obj);
2344 wd->calc_job = NULL;
2345 evas_object_smart_changed(wd->pan_smart);
2349 _update_job(void *data)
2351 Widget_Data *wd = data;
2354 int num, num0, position = 0, recalc = 0;
2356 wd->update_job = NULL;
2358 EINA_INLIST_FOREACH(wd->blocks, itb)
2360 Evas_Coord itminw, itminh;
2361 Elm_Genlist_Item *it;
2367 _item_block_position(itb, num);
2372 EINA_LIST_FOREACH(itb->items, l2, it)
2382 _item_unrealize(it);
2383 _item_realize(it, num, 0);
2384 evas_object_smart_callback_call(it->wd->obj,
2389 _item_realize(it, num, 1);
2390 _item_unrealize(it);
2392 if ((it->minw != itminw) || (it->minh != itminh))
2401 itb->changed = EINA_TRUE;
2402 _item_block_recalc(itb, num0, 0, 1);
2403 _item_block_position(itb, num0);
2408 if (wd->calc_job) ecore_job_del(wd->calc_job);
2409 wd->calc_job = ecore_job_add(_calc_job, wd);
2414 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2416 Pan *sd = evas_object_smart_data_get(obj);
2417 // Evas_Coord ow, oh;
2418 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2419 // ow = sd->wd->minw - ow;
2420 // if (ow < 0) ow = 0;
2421 // oh = sd->wd->minh - oh;
2422 // if (oh < 0) oh = 0;
2423 // if (x < 0) x = 0;
2424 // if (y < 0) y = 0;
2425 // if (x > ow) x = ow;
2426 // if (y > oh) y = oh;
2427 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2430 evas_object_smart_changed(obj);
2434 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2436 Pan *sd = evas_object_smart_data_get(obj);
2438 if (x) *x = sd->wd->pan_x;
2439 if (y) *y = sd->wd->pan_y;
2443 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2445 Pan *sd = evas_object_smart_data_get(obj);
2448 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2449 ow = sd->wd->minw - ow;
2451 oh = sd->wd->minh - oh;
2458 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2460 Pan *sd = evas_object_smart_data_get(obj);
2462 if (w) *w = sd->wd->minw;
2463 if (h) *h = sd->wd->minh;
2467 _pan_add(Evas_Object *obj)
2470 Evas_Object_Smart_Clipped_Data *cd;
2473 cd = evas_object_smart_data_get(obj);
2476 sd->__clipped_data = *cd;
2478 evas_object_smart_data_set(obj, sd);
2482 _pan_del(Evas_Object *obj)
2484 Pan *sd = evas_object_smart_data_get(obj);
2491 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2493 Pan *sd = evas_object_smart_data_get(obj);
2496 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2497 if ((ow == w) && (oh == h)) return;
2498 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2499 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2503 _pan_calculate(Evas_Object *obj)
2505 Pan *sd = evas_object_smart_data_get(obj);
2507 Elm_Genlist_GroupItem *git;
2508 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2510 if( sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
2511 (void)_edit_mode_reset( sd->wd );
2512 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2514 git->visible = EINA_FALSE;
2517 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2518 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2519 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2521 itb->w = sd->wd->minw;
2522 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2523 itb->y - sd->wd->pan_y + oy,
2525 cvx, cvy, cvw, cvh))
2527 if ((!itb->realized) || (itb->changed))
2528 _item_block_realize(itb, in, 0);
2529 _item_block_position(itb, in);
2533 if (itb->realized) _item_block_unrealize(itb);
2537 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2541 evas_object_raise(git->base);
2542 evas_object_resize( git->base, git->w, git->h-1 );
2543 evas_object_move(git->base, git->x, git->y );
2544 evas_object_show(git->base);
2547 evas_object_hide(git->base);
2549 if( (sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) && (sd->wd->ed->reorder_item ) )
2551 evas_object_raise(sd->wd->ed->reorder_item->base);
2552 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2557 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2559 Pan *sd = evas_object_smart_data_get(obj);
2561 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2562 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2566 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2568 Widget_Data *wd = elm_widget_data_get(obj);
2570 elm_smart_scroller_hold_set(wd->scr, 1);
2574 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2576 Widget_Data *wd = elm_widget_data_get(obj);
2578 elm_smart_scroller_hold_set(wd->scr, 0);
2582 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2584 Widget_Data *wd = elm_widget_data_get(obj);
2586 elm_smart_scroller_freeze_set(wd->scr, 1);
2590 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2592 Widget_Data *wd = elm_widget_data_get(obj);
2594 elm_smart_scroller_freeze_set(wd->scr, 0);
2598 * Add a new Genlist object
2600 * @param parent The parent object
2601 * @return The new object or NULL if it cannot be created
2606 elm_genlist_add(Evas_Object *parent)
2611 Evas_Coord minw, minh;
2612 static Evas_Smart *smart = NULL;
2614 wd = ELM_NEW(Widget_Data);
2615 e = evas_object_evas_get(parent);
2616 obj = elm_widget_add(e);
2617 ELM_SET_WIDTYPE(widtype, "genlist");
2618 elm_widget_type_set(obj, "genlist");
2619 elm_widget_sub_object_add(parent, obj);
2620 elm_widget_data_set(obj, wd);
2621 elm_widget_del_hook_set(obj, _del_hook);
2622 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2623 elm_widget_theme_hook_set(obj, _theme_hook);
2625 wd->scr = elm_smart_scroller_add(e);
2626 elm_smart_scroller_widget_set(wd->scr, obj);
2627 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2628 elm_widget_resize_object_set(obj, wd->scr);
2630 elm_smart_scroller_bounce_allow_set(wd->scr, 0, 1);
2633 wd->mode = ELM_LIST_SCROLL;
2634 wd->max_items_per_block = 32;
2636 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2637 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2638 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2639 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2643 static Evas_Smart_Class sc;
2645 evas_object_smart_clipped_smart_set(&_pan_sc);
2647 sc.name = "elm_genlist_pan";
2648 sc.version = EVAS_SMART_CLASS_VERSION;
2651 sc.resize = _pan_resize;
2652 sc.move = _pan_move;
2653 sc.calculate = _pan_calculate;
2654 smart = evas_smart_class_new(&sc);
2658 wd->pan_smart = evas_object_smart_add(e, smart);
2659 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2663 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2665 _pan_max_get, _pan_child_size_get);
2667 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2669 evas_object_size_hint_min_set(obj, minw, minh);
2675 static Elm_Genlist_Item *
2676 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2677 const void *data, Elm_Genlist_Item *parent,
2678 Elm_Genlist_Item_Flags flags,
2680 const void *func_data)
2682 Elm_Genlist_Item *it;
2684 it = calloc(1, sizeof(Elm_Genlist_Item));
2685 if (!it) return NULL;
2689 it->parent = parent;
2691 it->func.func = func;
2692 it->func.data = func_data;
2698 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2700 Item_Block *itb = NULL;
2707 itb = calloc(1, sizeof(Item_Block));
2710 if (!it->rel->block)
2713 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2714 itb->items = eina_list_append(itb->items, it);
2721 eina_inlist_prepend_relative(wd->blocks,
2722 EINA_INLIST_GET(itb),
2723 EINA_INLIST_GET(it->rel->block));
2725 eina_list_prepend_relative(itb->items, it, it->rel);
2730 eina_inlist_append_relative(wd->blocks,
2731 EINA_INLIST_GET(itb),
2732 EINA_INLIST_GET(it->rel->block));
2734 eina_list_append_relative(itb->items, it, it->rel);
2744 itb = (Item_Block *)(wd->blocks);
2745 if (itb->count >= wd->max_items_per_block)
2747 itb = calloc(1, sizeof(Item_Block));
2751 eina_inlist_prepend(wd->blocks,
2752 EINA_INLIST_GET(itb));
2757 itb = calloc(1, sizeof(Item_Block));
2761 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2763 itb->items = eina_list_prepend(itb->items, it);
2769 itb = (Item_Block *)(wd->blocks->last);
2770 if (itb->count >= wd->max_items_per_block)
2772 itb = calloc(1, sizeof(Item_Block));
2776 eina_inlist_append(wd->blocks,
2777 EINA_INLIST_GET(itb));
2782 itb = calloc(1, sizeof(Item_Block));
2786 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2788 itb->items = eina_list_append(itb->items, it);
2794 itb = it->rel->block;
2795 if (!itb) goto newblock;
2797 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2799 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2802 itb->changed = EINA_TRUE;
2804 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2805 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2808 it->rel->relcount--;
2809 if ((it->rel->delete_me) && (it->rel->relcount == 0))
2813 if (itb->count > itb->wd->max_items_per_block)
2817 Elm_Genlist_Item *it2;
2819 newc = itb->count / 2;
2820 itb2 = calloc(1, sizeof(Item_Block));
2824 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2825 EINA_INLIST_GET(itb));
2826 itb2->changed = EINA_TRUE;
2827 while ((itb->count > newc) && (itb->items))
2831 l = eina_list_last(itb->items);
2833 itb->items = eina_list_remove_list(itb->items, l);
2836 itb2->items = eina_list_prepend(itb2->items, it2);
2846 _queue_proecess(Widget_Data *wd, int norender)
2851 t0 = ecore_time_get();
2852 for (n = 0; (wd->queue) && (n < 128); n++)
2854 Elm_Genlist_Item *it;
2856 it = wd->queue->data;
2857 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2858 it->queued = EINA_FALSE;
2859 _item_block_add(wd, it);
2860 t = ecore_time_get();
2861 if (it->block->changed)
2863 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2864 it->block->changed = 0;
2866 if (showme) it->block->showme = 1;
2867 if (eina_inlist_count(wd->blocks) > 1)
2869 if ((t - t0) > (ecore_animator_frametime_get())) break;
2876 _item_idler(void *data)
2878 Widget_Data *wd = data;
2880 if (_queue_proecess(wd, 1) > 0)
2882 if (wd->calc_job) ecore_job_del(wd->calc_job);
2883 wd->calc_job = ecore_job_add(_calc_job, wd);
2887 wd->queue_idler = NULL;
2894 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2896 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2898 if (wd->queue_idler)
2900 ecore_idler_del(wd->queue_idler);
2901 wd->queue_idler = NULL;
2903 _queue_proecess(wd, 0);
2906 if (it->queued) return;
2907 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2908 it->queued = EINA_TRUE;
2909 wd->queue = eina_list_append(wd->queue, it);
2914 _item_idler(void *data)
2916 Widget_Data *wd = data;
2920 t0 = ecore_time_get();
2921 for (n = 0; (wd->queue) && (n < 128); n++)
2923 Elm_Genlist_Item *it;
2925 it = wd->queue->data;
2926 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2927 it->queued = EINA_FALSE;
2928 _item_block_add(wd, it);
2929 t = ecore_time_get();
2930 if (it->block->changed)
2932 showme = _item_block_recalc(it->block, it->block->num, 1, 1);
2933 it->block->changed = 0;
2935 if (showme) it->block->showme = 1;
2936 if (eina_inlist_count(wd->blocks) > 1)
2938 if ((t - t0) > (ecore_animator_frametime_get())) break;
2943 if (wd->calc_job) ecore_job_del(wd->calc_job);
2944 wd->calc_job = ecore_job_add(_calc_job, wd);
2948 wd->queue_idler = NULL;
2955 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2959 // Add the initial set of Items directly to the Blocks, to show the genlist
2960 // without empty screen.
2961 itb = (Item_Block *)(wd->blocks);
2962 if( (NULL == itb) || (itb->count < wd->max_items_per_block) )
2964 _item_block_add(wd, it);
2968 if (it->queued) return;
2969 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2970 it->queued = EINA_TRUE;
2971 wd->queue = eina_list_append(wd->queue, it);
2978 * Add Group Item to the genlist
2980 * @param obj The genlist object
2981 * @param itc The item class for the item
2982 * @param data The group item data
2984 EAPI Elm_Genlist_GroupItem *
2985 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2988 Elm_Genlist_GroupItem *git;
2989 Widget_Data *wd = elm_widget_data_get(obj);
2991 git = calloc(1, sizeof(Elm_Genlist_GroupItem));
2992 if (!git) return NULL;
2997 wd->group_items = eina_inlist_append(wd->group_items, EINA_INLIST_GET(git) );
3002 * Delete a given groupitem
3004 * This deletes the group item from genlist and calls the genlist group item del class
3005 * callback defined in the item class, if it is set.
3007 * @param git The group item
3012 elm_genlist_groupitem_del(Elm_Genlist_GroupItem *git)
3014 _groupitem_remove( git, EINA_TRUE);
3018 * Append item to the end of the genlist
3020 * This appends the given item to the end of the list or the end of the
3021 * children if the parent is given.
3023 * @param obj The genlist object
3024 * @param itc The item class for the item
3025 * @param data The item data
3026 * @param parent The parent item, or NULL if none
3027 * @param flags Item flags
3028 * @param func Convenience function called when item selected
3029 * @param func_data Data passed to @p func above.
3030 * @return A handle to the item added or NULL if not possible
3034 EAPI Elm_Genlist_Item *
3035 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3036 const void *data, Elm_Genlist_Item *parent,
3037 Elm_Genlist_Item_Flags flags,
3038 Evas_Smart_Cb func, const void *func_data)
3040 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3041 Widget_Data *wd = elm_widget_data_get(obj);
3042 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
3043 if (!wd) return NULL;
3044 if (!it) return NULL;
3047 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3053 Elm_Genlist_Item *it2 = NULL;
3054 Eina_List *ll = eina_list_last(it->parent->items);
3055 if (ll) it2 = ll->data;
3056 it->parent->items = eina_list_append(it->parent->items, it);
3057 if (!it2) it2 = it->parent;
3059 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3060 EINA_INLIST_GET(it2));
3061 if( it->parent->group_item)
3062 _set_groupitem( it, it->parent->group_item );
3064 it->rel->relcount++;
3067 _item_queue(wd, it);
3072 * Append item to the end of the genlist with Group Item
3074 * This appends the given item to the end of the list or the end of the
3075 * children if the parent is given.
3077 * @param obj The genlist object
3078 * @param itc The item class for the item
3079 * @param data The item data
3080 * @param parent The parent item, or NULL if none
3081 * @param flags Item flags
3082 * @param git Group Item
3083 * @param func Convenience function called when item selected
3084 * @param func_data Data passed to @p func above.
3085 * @return A handle to the item added or NULL if not possible
3089 EAPI Elm_Genlist_Item *
3090 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3091 const void *data, Elm_Genlist_Item *parent,
3092 Elm_Genlist_Item_Flags flags, Elm_Genlist_GroupItem *git,
3093 Evas_Smart_Cb func, const void *func_data)
3095 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3096 Widget_Data *wd = elm_widget_data_get(obj);
3097 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
3098 if (!wd) return NULL;
3099 if (!it) return NULL;
3102 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3108 Elm_Genlist_Item *it2 = NULL;
3109 Eina_List *ll = eina_list_last(it->parent->items);
3110 if (ll) it2 = ll->data;
3111 it->parent->items = eina_list_append(it->parent->items, it);
3112 if (!it2) it2 = it->parent;
3114 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3115 EINA_INLIST_GET(it2));
3116 if( it->parent->group_item)
3117 _set_groupitem( it, it->parent->group_item );
3119 it->rel->relcount++;
3122 _set_groupitem( it, git );
3123 _item_queue(wd, it);
3128 * Prepend item at start of the genlist
3130 * This adds an item to the beginning of the list or beginning of the children
3131 * of the parent if given.
3133 * @param obj The genlist object
3134 * @param itc The item class for the item
3135 * @param data The item data
3136 * @param parent The parent item, or NULL if none
3137 * @param flags Item flags
3138 * @param func Convenience function called when item selected
3139 * @param func_data Data passed to @p func above.
3140 * @return A handle to the item added or NULL if not possible
3144 EAPI Elm_Genlist_Item *
3145 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3146 const void *data, Elm_Genlist_Item *parent,
3147 Elm_Genlist_Item_Flags flags,
3148 Evas_Smart_Cb func, const void *func_data)
3150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3151 Widget_Data *wd = elm_widget_data_get(obj);
3152 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
3153 if (!wd) return NULL;
3154 if (!it) return NULL;
3156 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3159 printf("FIXME: 12 tree not handled yet\n");
3163 _item_queue(wd, it);
3168 * Insert item before another in the genlist
3170 * This inserts an item before another in the list. It will be in the same tree
3171 * level as the item it is inseted before.
3173 * @param obj The genlist object
3174 * @param itc The item class for the item
3175 * @param data The item data
3176 * @param before The item to insert before
3177 * @param flags Item flags
3178 * @param func Convenience function called when item selected
3179 * @param func_data Data passed to @p func above.
3180 * @return A handle to the item added or NULL if not possible
3184 EAPI Elm_Genlist_Item *
3185 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3186 const void *data, Elm_Genlist_Item *before,
3187 Elm_Genlist_Item_Flags flags,
3188 Evas_Smart_Cb func, const void *func_data)
3190 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3191 Widget_Data *wd = elm_widget_data_get(obj);
3192 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3193 if (!wd) return NULL;
3194 if (!it) return NULL;
3196 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3197 EINA_INLIST_GET(before));
3200 printf("FIXME: 13 tree not handled yet\n");
3203 it->rel->relcount++;
3205 _item_queue(wd, it);
3210 * Insert and item after another in the genlst
3212 * This inserts an item after another in the list. It will be in the same tree
3213 * level as the item it is inseted after.
3215 * @param obj The genlist object
3216 * @param itc The item class for the item
3217 * @param data The item data
3218 * @param after The item to insert after
3219 * @param flags Item flags
3220 * @param func Convenience function called when item selected
3221 * @param func_data Data passed to @p func above.
3222 * @return A handle to the item added or NULL if not possible
3226 EAPI Elm_Genlist_Item *
3227 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3228 const void *data, Elm_Genlist_Item *after,
3229 Elm_Genlist_Item_Flags flags,
3230 Evas_Smart_Cb func, const void *func_data)
3232 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3233 Widget_Data *wd = elm_widget_data_get(obj);
3234 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3235 if (!wd) return NULL;
3236 if (!it) return NULL;
3238 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3239 EINA_INLIST_GET(after));
3242 printf("FIXME: 14 tree not handled yet\n");
3245 it->rel->relcount++;
3247 _item_queue(wd, it);
3252 * Moves the Genlist Item
3255 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after )
3259 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3260 _item_block_del(it);
3264 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
3265 EINA_INLIST_GET(after));
3267 it->rel->relcount++;
3271 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
3275 _item_queue(it->wd, it);
3281 * This clears all items in the list, leaving it empty.
3283 * @param obj The genlist object
3288 elm_genlist_clear(Evas_Object *obj)
3290 ELM_CHECK_WIDTYPE(obj, widtype);
3291 Widget_Data *wd = elm_widget_data_get(obj);
3294 while (wd->group_items)
3296 _groupitem_remove((Elm_Genlist_GroupItem *)wd->group_items, EINA_FALSE);
3301 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3303 wd->items = eina_inlist_remove(wd->items, wd->items);
3304 if (it->realized) _item_unrealize(it);
3305 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
3306 if (it->long_timer) ecore_timer_del(it->long_timer);
3311 Item_Block *itb = (Item_Block *)(wd->blocks);
3313 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3314 if (itb->items) eina_list_free(itb->items);
3319 ecore_job_del(wd->calc_job);
3320 wd->calc_job = NULL;
3322 if (wd->queue_idler)
3324 ecore_idler_del(wd->queue_idler);
3325 wd->queue_idler = NULL;
3329 eina_list_free(wd->queue);
3334 eina_list_free(wd->selected);
3335 wd->selected = NULL;
3337 wd->show_item = NULL;
3342 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3343 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3348 * Enable or disable multi-select in the genlist
3350 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3351 * more than 1 item to be selected.
3353 * @param obj The genlist object
3354 * @param multi Multi-select enable/disable
3359 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3361 ELM_CHECK_WIDTYPE(obj, widtype);
3362 Widget_Data *wd = elm_widget_data_get(obj);
3368 * Gets if multi-select in genlist is enable or disable
3370 * @param obj The genlist object
3371 * @return Multi-select enable/disable
3372 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3377 elm_genlist_multi_select_get(const Evas_Object *obj)
3379 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3380 Widget_Data *wd = elm_widget_data_get(obj);
3381 if (!wd) return EINA_FALSE;
3387 * Get the selectd item in the genlist
3389 * This gets the selected item in the list (if multi-select is enabled only
3390 * the first item in the list is selected - which is not very useful, so see
3391 * elm_genlist_selected_items_get()for when multi-select is used).
3393 * If no item is selected, NULL is returned.
3395 * @param obj The genlist object
3396 * @return The selected item, or NULL if none.
3400 EAPI Elm_Genlist_Item *
3401 elm_genlist_selected_item_get(const Evas_Object *obj)
3403 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3404 Widget_Data *wd = elm_widget_data_get(obj);
3405 if (!wd) return NULL;
3406 if (wd->selected) return wd->selected->data;
3411 * Get a list of selected items in the genlist
3413 * This retgurns a list of the selected items. This list pointer is only valid
3414 * so long as no items are selected or unselected (or unselected implicitly
3415 * by deletion). The list contains Elm_Genlist_Item pointers.
3417 * @param obj The genlist object
3418 * @return The list of selected items, nor NULL if none are selected.
3422 EAPI const Eina_List *
3423 elm_genlist_selected_items_get(const Evas_Object *obj)
3425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3426 Widget_Data *wd = elm_widget_data_get(obj);
3427 if (!wd) return NULL;
3428 return wd->selected;
3432 * Get a list of realized items in genlist
3434 * This returns a list of the realized items in the genlist. The list
3435 * contains Elm_Genlist_Item pointers. The list must be freed by the
3436 * caller when done with eina_list_free(). The item pointers in the list
3437 * are only vallid so long as those items are not deleted or the genlist is
3440 * @param obj The genlist object
3441 * @return The list of realized items, nor NULL if none are realized.
3446 elm_genlist_realized_items_get(const Evas_Object *obj)
3448 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3449 Widget_Data *wd = elm_widget_data_get(obj);
3450 Eina_List *list = NULL;
3452 Eina_Bool done = EINA_FALSE;
3453 if (!wd) return NULL;
3454 EINA_INLIST_FOREACH(wd->blocks, itb)
3459 Elm_Genlist_Item *it;
3462 EINA_LIST_FOREACH(itb->items, l, it)
3464 if (it->realized) list = eina_list_append(list, it);
3476 * Get the item that is at the x, y canvas coords
3478 * This returns the item at the given coordinates (which are canvas relative
3479 * not object-relative). If an item is at that coordinate, that item handle
3480 * is returned, and if @p posret is not NULL, the integer pointed to is set
3481 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3482 * portion of that item (-1), on the middle section (0) or on the lower part
3483 * (1). If NULL is returned as an item (no item found there), then posret
3484 * may indicate -1 or 1 based if the coordinate is above or below all items
3485 * respectively in the genlist.
3487 * @param it The item
3488 * @param x The input x coordinate
3489 * @param y The input y coordinate
3490 * @param posret The position relative to the item returned here
3491 * @return The item at the coordinates or NULL if none
3495 EAPI Elm_Genlist_Item *
3496 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3498 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3499 Widget_Data *wd = elm_widget_data_get(obj);
3500 Evas_Coord ox, oy, ow, oh;
3503 if (!wd) return NULL;
3504 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3506 EINA_INLIST_FOREACH(wd->blocks, itb)
3509 Elm_Genlist_Item *it;
3511 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3512 oy + itb->y - itb->wd->pan_y,
3513 itb->w, itb->h, x, y, 1, 1))
3515 EINA_LIST_FOREACH(itb->items, l, it)
3517 Evas_Coord itx, ity;
3519 itx = ox + itb->x + it->x - itb->wd->pan_x;
3520 ity = oy + itb->y + it->y - itb->wd->pan_y;
3521 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3525 if (y <= (ity + (it->h / 4))) *posret = -1;
3526 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3531 lasty = ity + it->h;
3536 if (y > lasty) *posret = 1;
3543 * Get the first item in the genlist
3545 * This returns the first item in the list.
3547 * @param obj The genlist object
3548 * @return The first item, or NULL if none
3552 EAPI Elm_Genlist_Item *
3553 elm_genlist_first_item_get(const Evas_Object *obj)
3555 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3556 Widget_Data *wd = elm_widget_data_get(obj);
3557 if (!wd) return NULL;
3558 if (!wd->items) return NULL;
3559 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3560 while ((it) && (it->delete_me))
3561 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3566 * Get the last item in the genlist
3568 * This returns the last item in the list.
3570 * @return The last item, or NULL if none
3574 EAPI Elm_Genlist_Item *
3575 elm_genlist_last_item_get(const Evas_Object *obj)
3577 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3578 Widget_Data *wd = elm_widget_data_get(obj);
3579 if (!wd->items) return NULL;
3580 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3581 if (!wd) return NULL;
3582 while ((it) && (it->delete_me))
3583 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3588 * Get the next item in the genlist
3590 * This returns the item after the item @p it.
3592 * @param it The item
3593 * @return The item after @p it, or NULL if none
3597 EAPI Elm_Genlist_Item *
3598 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3602 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3603 if ((it) && (!it->delete_me)) break;
3605 return (Elm_Genlist_Item *)it;
3609 * Get the previous item in the genlist
3611 * This returns the item before the item @p it.
3613 * @param it The item
3614 * @return The item before @p it, or NULL if none
3618 EAPI Elm_Genlist_Item *
3619 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3623 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3624 if ((it) && (!it->delete_me)) break;
3626 return (Elm_Genlist_Item *)it;
3630 * Get the genlist object from an item
3632 * This returns the genlist object itself that an item belongs to.
3634 * @param it The item
3635 * @return The genlist object
3640 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3642 if (!it) return NULL;
3647 * Get the parent item of the given item
3649 * This returns the prent item of the item @p it given.
3651 * @param it The item
3652 * @return The parent of the item or NULL if none
3656 EAPI Elm_Genlist_Item *
3657 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3659 if (!it) return NULL;
3664 * Clear all sub-items (children) of the given item
3666 * This clears all items that are children (or their descendants) of the
3669 * @param it The item
3674 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3676 Eina_List *tl = NULL, *l;
3677 Elm_Genlist_Item *it2;
3680 EINA_LIST_FOREACH(it->items, l, it2)
3681 tl = eina_list_append(tl, it2);
3682 EINA_LIST_FREE(tl, it2)
3683 elm_genlist_item_del(it2);
3687 * Set the selected state of an item
3689 * This sets the selected state (1 selected, 0 not selected) of the given
3692 * @param it The item
3693 * @param selected The slected state
3698 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3700 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3703 if (it->delete_me) return;
3704 selected = !!selected;
3705 if (it->selected == selected) return;
3711 while (wd->selected)
3712 _item_unselect(wd->selected->data);
3722 * Get the selected state of an item
3724 * This gets the selected state of an item (1 selected, 0 not selected).
3726 * @param it The item
3727 * @return The selected state
3732 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3734 if (!it) return EINA_FALSE;
3735 return it->selected;
3739 * Sets the expanded state of an item (if it's a parent)
3741 * This expands or contracts a parent iterm (thus showing or hiding the
3744 * @param it The item
3745 * @param expanded The expanded state (1 expanded, 0 not expanded).
3750 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3753 if (it->expanded == expanded) return;
3754 it->expanded = expanded;
3758 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3759 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3765 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3766 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3771 * Get the expanded state of an item
3773 * This gets the expanded state of an item
3775 * @param it The item
3776 * @return Thre expanded state
3781 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3783 if (!it) return EINA_FALSE;
3784 return it->expanded;
3788 * Sets the disabled state of an item.
3790 * A disabled item cannot be selected or unselected. It will also change
3791 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3794 * @param it The item
3795 * @param disabled The disabled state
3800 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3803 if (it->disabled == disabled) return;
3804 if (it->delete_me) return;
3805 it->disabled = disabled;
3809 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3811 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3816 * Get the disabled state of an item
3818 * This gets the disabld state of the given item.
3820 * @param it The item
3821 * @return The disabled state
3826 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3828 if (!it) return EINA_FALSE;
3829 if (it->delete_me) return EINA_FALSE;
3830 return it->disabled;
3834 * Sets the display only state of an item.
3836 * A display only item cannot be selected or unselected. It is for display
3837 * only and not selecting or otherwise clicking, dragging etc. by the user,
3838 * thus finger size rules will not be applied to this item.
3840 * @param it The item
3841 * @param display_only The display only state
3846 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3849 if (!it->block) return;
3850 if (it->display_only == display_only) return;
3851 if (it->delete_me) return;
3852 it->display_only = display_only;
3853 it->mincalcd = EINA_FALSE;
3854 it->updateme = EINA_TRUE;
3855 it->block->updateme = EINA_TRUE;
3856 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3857 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3861 * Get the display only state of an item
3863 * This gets the display only state of the given item.
3865 * @param it The item
3866 * @return The display only state
3871 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3873 if (!it) return EINA_FALSE;
3874 if (it->delete_me) return EINA_FALSE;
3875 return it->display_only;
3879 * Show the given item
3881 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3882 * if it is not fully visible.
3884 * @param it The item
3889 elm_genlist_item_show(Elm_Genlist_Item *it)
3892 if (it->delete_me) return;
3893 if ((it->queued) || (!it->mincalcd))
3895 it->wd->show_item = it;
3896 it->wd->bring_in = 1;
3897 it->showme = EINA_TRUE;
3900 if (it->wd->show_item)
3902 it->wd->show_item->showme = EINA_FALSE;
3903 it->wd->show_item = NULL;
3905 elm_smart_scroller_child_region_show(it->wd->scr,
3906 it->x + it->block->x,
3907 it->y + it->block->y,
3908 it->block->w, it->h);
3912 * Bring in the given item
3914 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3915 * if it is not fully visible. This may use animation to do so and take a
3918 * @param it The item
3923 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3926 if (it->delete_me) return;
3927 if ((it->queued) || (!it->mincalcd))
3929 it->wd->show_item = it;
3930 it->wd->bring_in = 1;
3931 it->showme = EINA_TRUE;
3934 if (it->wd->show_item)
3936 it->wd->show_item->showme = EINA_FALSE;
3937 it->wd->show_item = NULL;
3939 elm_smart_scroller_region_bring_in(it->wd->scr,
3940 it->x + it->block->x,
3941 it->y + it->block->y,
3942 it->block->w, it->h);
3946 * Show the given item at the top
3948 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3949 * if it is not fully visible.
3951 * @param it The item
3956 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3961 if (it->delete_me) return;
3962 if ((it->queued) || (!it->mincalcd))
3964 it->wd->show_item = it;
3965 it->wd->bring_in = 1;
3966 it->showme = EINA_TRUE;
3969 if (it->wd->show_item)
3971 it->wd->show_item->showme = EINA_FALSE;
3972 it->wd->show_item = NULL;
3974 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3975 elm_smart_scroller_child_region_show(it->wd->scr,
3976 it->x + it->block->x,
3977 it->y + it->block->y,
3982 * Bring in the given item at the top
3984 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3985 * if it is not fully visible. This may use animation to do so and take a
3988 * @param it The item
3993 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3998 if (it->delete_me) return;
3999 if ((it->queued) || (!it->mincalcd))
4001 it->wd->show_item = it;
4002 it->wd->bring_in = 1;
4003 it->showme = EINA_TRUE;
4006 if (it->wd->show_item)
4008 it->wd->show_item->showme = EINA_FALSE;
4009 it->wd->show_item = NULL;
4011 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4012 elm_smart_scroller_region_bring_in(it->wd->scr,
4013 it->x + it->block->x,
4014 it->y + it->block->y,
4019 * Show the given item at the middle
4021 * This causes genlist to jump to the given item @p it and show it (by scrolling),
4022 * if it is not fully visible.
4024 * @param it The item
4029 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4034 if (it->delete_me) return;
4035 if ((it->queued) || (!it->mincalcd))
4037 it->wd->show_item = it;
4038 it->wd->bring_in = 1;
4039 it->showme = EINA_TRUE;
4042 if (it->wd->show_item)
4044 it->wd->show_item->showme = EINA_FALSE;
4045 it->wd->show_item = NULL;
4047 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4048 elm_smart_scroller_child_region_show(it->wd->scr,
4049 it->x + it->block->x,
4050 it->y + it->block->y - oh/2 + it->h/2,
4056 * Bring in the given item at the middle
4058 * This causes genlist to jump to the given item @p it and show it (by scrolling),
4059 * if it is not fully visible. This may use animation to do so and take a
4062 * @param it The item
4067 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4072 if (it->delete_me) return;
4073 if ((it->queued) || (!it->mincalcd))
4075 it->wd->show_item = it;
4076 it->wd->bring_in = 1;
4077 it->showme = EINA_TRUE;
4080 if (it->wd->show_item)
4082 it->wd->show_item->showme = EINA_FALSE;
4083 it->wd->show_item = NULL;
4085 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4086 elm_smart_scroller_region_bring_in(it->wd->scr,
4087 it->x + it->block->x,
4088 it->y + it->block->y - oh/2 + it->h/2,
4093 * Delete a given item
4095 * This deletes the item from genlist and calls the genlist item del class
4096 * callback defined in the item class, if it is set.
4098 * @param it The item
4103 elm_genlist_item_del(Elm_Genlist_Item *it)
4106 if ((it->relcount > 0) || (it->walking > 0))
4108 elm_genlist_item_subitems_clear(it);
4109 it->delete_me = EINA_TRUE;
4110 if (it->wd->show_item == it) it->wd->show_item = NULL;
4111 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
4114 if (it->realized) _item_unrealize(it);
4115 it->block->changed = EINA_TRUE;
4116 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4117 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4119 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
4126 * Set the data item from the genlist item
4128 * This set the data value passed on the elm_genlist_item_append() and
4129 * related item addition calls. This function will also call
4130 * elm_genlist_item_update() so the item will be updated to reflect the
4133 * @param it The item
4134 * @param data The new data pointer to set
4139 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
4143 elm_genlist_item_update(it);
4147 * Get the data item from the genlist item
4149 * This returns the data value passed on the elm_genlist_item_append() and
4150 * related item addition calls.
4152 * @param it The item
4153 * @return The data pointer provided when created
4158 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4160 if (!it) return NULL;
4165 * Get the real evas object of the genlist item
4167 * This returns the actual evas object used for the specified genlist item.
4168 * This may be NULL as it may not be created, and ma be deleted at any time
4169 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
4170 * genlist is controlling it. This function is for querying, emitting
4171 * custom signals or hooking lower level callbacks for events. Do not
4172 * delete this object under any circumstances.
4174 * @param it The item
4175 * @return The objct pointer
4179 EAPI const Evas_Object *
4180 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4182 if (!it) return NULL;
4187 * Update the contents of an item
4189 * This updates an item by calling all the item class functions again to get
4190 * the icons, labels and states. Use this when he original item data has
4191 * changed and the changes are desired to be reflected.
4193 * @param it The item
4198 elm_genlist_item_update(Elm_Genlist_Item *it)
4200 if (!it->block) return;
4201 if (it->delete_me) return;
4202 it->mincalcd = EINA_FALSE;
4203 it->updateme = EINA_TRUE;
4204 it->block->updateme = EINA_TRUE;
4205 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4206 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4210 * This sets the horizontal stretching mode
4212 * This sets the mode used for sizing items horizontally. Valid modes are
4213 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
4214 * mode means that if items are too wide to fit, the scroller will scroll
4215 * horizontally. Otherwise items are expanded to fill the width of the
4216 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
4217 * to the viewport width and limited to that size.
4219 * @param obj The genlist object
4220 * @param mode The mode to use
4225 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
4227 ELM_CHECK_WIDTYPE(obj, widtype);
4228 Widget_Data *wd = elm_widget_data_get(obj);
4230 if (wd->mode == mode) return;
4236 * Gets the horizontal stretching mode
4238 * @param obj The genlist object
4239 * @return The mode to use
4240 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
4245 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4247 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4248 Widget_Data *wd = elm_widget_data_get(obj);
4249 if (!wd) return ELM_LIST_LAST;
4254 * Set the always select mode.
4256 * Items will only call their selection func and callback when first becoming
4257 * selected. Any further clicks will do nothing, unless you enable always
4258 * select with elm_genlist_always_select_mode_set(). This means even if
4259 * selected, every click will make the selected callbacks be called.
4261 * @param obj The genlist object
4262 * @param always_select The always select mode
4263 * (EINA_TRUE = on, EINA_FALSE = off)
4268 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
4270 ELM_CHECK_WIDTYPE(obj, widtype);
4271 Widget_Data *wd = elm_widget_data_get(obj);
4273 wd->always_select = always_select;
4277 * Get the always select mode.
4279 * @param obj The genlist object
4280 * @return The always select mode
4281 * (EINA_TRUE = on, EINA_FALSE = off)
4286 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4288 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4289 Widget_Data *wd = elm_widget_data_get(obj);
4290 if (!wd) return EINA_FALSE;
4291 return wd->always_select;
4295 * Set no select mode
4297 * This will turn off the ability to select items entirely and they will
4298 * neither appear selected nor call selected callback functions.
4300 * @param obj The genlist object
4301 * @param no_select The no select mode
4302 * (EINA_TRUE = on, EINA_FALSE = off)
4307 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4309 ELM_CHECK_WIDTYPE(obj, widtype);
4310 Widget_Data *wd = elm_widget_data_get(obj);
4312 wd->no_select = no_select;
4316 * Gets no select mode
4318 * @param obj The genlist object
4319 * @return The no select mode
4320 * (EINA_TRUE = on, EINA_FALSE = off)
4325 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4327 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4328 Widget_Data *wd = elm_widget_data_get(obj);
4329 if (!wd) return EINA_FALSE;
4330 return wd->no_select;
4336 * This will enable the compress mode where items are "compressed" horizontally
4337 * to fit the genlist scrollable viewport width.
4339 * @param obj The genlist object
4340 * @param no_select The compress mode
4341 * (EINA_TRUE = on, EINA_FALSE = off)
4346 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4348 ELM_CHECK_WIDTYPE(obj, widtype);
4349 Widget_Data *wd = elm_widget_data_get(obj);
4351 wd->compress = compress;
4355 * Get the compress mode
4357 * @param obj The genlist object
4358 * @return The compress mode
4359 * (EINA_TRUE = on, EINA_FALSE = off)
4364 elm_genlist_compress_mode_get(const Evas_Object *obj)
4366 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4367 Widget_Data *wd = elm_widget_data_get(obj);
4368 if (!wd) return EINA_FALSE;
4369 return wd->compress;
4375 * This will enable or disable the scroller bounce mode for the genlist. See
4376 * elm_scroller_bounce_set() for details
4378 * @param obj The genlist object
4379 * @param h_bounce Allow bounce horizontally
4380 * @param v_bounce Allow bounce vertically
4385 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4387 ELM_CHECK_WIDTYPE(obj, widtype);
4388 Widget_Data *wd = elm_widget_data_get(obj);
4390 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4394 * Get the bounce mode
4396 * @param obj The genlist object
4397 * @param h_bounce Allow bounce horizontally
4398 * @param v_bounce Allow bounce vertically
4403 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4405 ELM_CHECK_WIDTYPE(obj, widtype);
4406 Widget_Data *wd = elm_widget_data_get(obj);
4408 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4412 * Set homogenous mode
4414 * This will enable the homogeneous mode where items are of the same height and width
4415 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4417 * @param obj The genlist object
4418 * @param homogeneous Assume the items within the genlist are of the same height and width
4419 * (EINA_TRUE = on, EINA_FALSE = off)
4424 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4426 ELM_CHECK_WIDTYPE(obj, widtype);
4427 Widget_Data *wd = elm_widget_data_get(obj);
4429 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4430 wd->homogeneous = homogeneous;
4434 * Get the homogenous mode
4436 * @param obj The genlist object
4437 * @return Assume the items within the genlist are of the same height and width
4438 * (EINA_TRUE = on, EINA_FALSE = off)
4443 elm_genlist_homogeneous_get(const Evas_Object *obj)
4445 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4446 Widget_Data *wd = elm_widget_data_get(obj);
4447 if (!wd) return EINA_FALSE;
4448 return wd->homogeneous;
4452 * Set the maximum number of items within an item block
4454 * This will configure the block count to tune to the target with particular performance matrix.
4456 * @param obj The genlist object
4457 * @param n Maximum number of items within an item block
4462 elm_genlist_block_count_set(Evas_Object *obj, int n)
4464 ELM_CHECK_WIDTYPE(obj, widtype);
4465 Widget_Data *wd = elm_widget_data_get(obj);
4467 wd->max_items_per_block = n;
4471 * Get the maximum number of items within an item block
4473 * @param obj The genlist object
4474 * @return Maximum number of items within an item block
4479 elm_genlist_block_count_get(const Evas_Object *obj)
4481 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4482 Widget_Data *wd = elm_widget_data_get(obj);
4484 return wd->max_items_per_block;
4488 * Set the Genlist Internal scroller scrollbar policy
4490 * This sets the Genlist Internal scrollbar visibility policy.
4491 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it
4492 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4493 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4494 * This applies respectively for the horizontal and vertical scrollbars.
4496 * @param obj The Genlist object
4497 * @param policy_h Horizontal scrollbar policy
4498 * @param policy_v Vertical scrollbar policy
4503 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4505 ELM_CHECK_WIDTYPE(obj, widtype);
4506 Widget_Data *wd = elm_widget_data_get(obj);
4509 const Elm_Scroller_Policy map[3] =
4511 ELM_SMART_SCROLLER_POLICY_AUTO,
4512 ELM_SMART_SCROLLER_POLICY_ON,
4513 ELM_SMART_SCROLLER_POLICY_OFF
4515 if ((policy_h < 0) || (policy_h >= 3) || (policy_v < 0) || (policy_v >= 3))
4518 elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
4522 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
4524 fprintf(stderr, "=================> Caution!!! <========================\n");
4525 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
4526 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
4527 fprintf(stderr, "=======================================================\n");
4529 elm_genlist_edit_mode_set(obj, emode, edit_class);
4533 * Set Genlist edit mode
4535 * This sets Genlist edit mode.
4537 * @param obj The Genlist object
4538 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE}
4539 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
4544 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
4546 Eina_List * realized_list;
4547 Elm_Genlist_Item *it;
4550 Elm_Genlist_Item *it_new;
4551 static Elm_Genlist_Item_Class itc;
4553 ELM_CHECK_WIDTYPE(obj, widtype);
4554 Widget_Data *wd = elm_widget_data_get(obj);
4556 if( wd->edit_mode == emode ) return;
4558 wd->edit_mode = emode;
4560 wd->animate_edit_controls = 1;
4561 if( wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
4563 if( wd->ed ) free (wd->ed);
4569 wd->ed = calloc(1, sizeof(Edit_Data));
4571 wd->ed->ec = edit_class;
4573 if( (wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) && !wd->ed->del_confirm)
4575 wd->ed->del_confirm = elm_button_add(wd->obj);
4576 elm_button_label_set(wd->ed->del_confirm, "Delete");
4577 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
4578 edje_object_scale_set( wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
4579 _elm_config->scale);
4580 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd );
4584 realized_list = elm_genlist_realized_items_get(obj);
4585 EINA_LIST_FOREACH(realized_list, l, it)
4587 it->delete_check = 0;
4588 it->select_all_item = 0;
4589 it->del_confirm_state = 0;
4590 _edit_controls_eval(it);
4594 itc.item_style = "select_all";
4595 itc.func.label_get = NULL;
4596 itc.func.icon_get = NULL;
4597 itc.func.del = NULL;
4598 itc.func.editmode_get = NULL;
4600 it_new = _item_new(wd, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
4602 if (!wd) return NULL;
4603 if (!it_new) return NULL;
4604 if (!it_new->parent)
4605 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it_new));
4608 printf("FIXME: 12 tree not handled yet\n");
4613 it_new->select_all_item = 1;
4615 _item_queue(wd, it_new);
4617 // evas_object_event_callback_add(it_new->base, EVAS_CALLBACK_MOUSE_DOWN, _select_all_down, it);
4621 it_new = elm_genlist_first_item_get(obj);
4622 elm_genlist_item_del( it_new );
4625 edje_object_signal_emit(wd->scr, "elm,state,edit,animated,enable", "elm");
4627 if (wd->calc_job) ecore_job_del(wd->calc_job);
4628 wd->calc_job = ecore_job_add(_calc_job, wd);
4632 elm_genlist_item_expanded_depth_get(Elm_Genlist_Item *it)
4641 * Delete selected items in genlist edit mode.
4643 * @param obj The genlist object
4649 elm_genlist_selected_items_delete(Evas_Object *obj)
4651 Elm_Genlist_Item *it;
4654 ELM_CHECK_WIDTYPE(obj, widtype);
4655 Widget_Data *wd = elm_widget_data_get(obj);
4659 Eina_List *realized_list = elm_genlist_realized_items_get(obj);
4661 EINA_LIST_FOREACH(realized_list, l, it)
4664 if( it->select_all_item )
4667 if(it->delete_check)
4668 elm_genlist_item_del( it );
4671 if (wd->calc_job) ecore_job_del(wd->calc_job);
4672 wd->calc_job = ecore_job_add(_calc_job, wd);