3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list that the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complexity when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * drag,start,up - This is called when the item in the list has been dragged
60 * drag,start,down - This is called when the item in the list has been dragged
61 * (not scrolled) down.
63 * drag,start,left - This is called when the item in the list has been dragged
64 * (not scrolled) left.
66 * drag,start,right - This is called when the item in the list has been dragged
67 * (not scrolled) right.
69 * drag,stop - This is called when the item in the list has stopped being
72 * drag - This is called when the item in the list is being dragged.
74 * Genlist has a fairly large API, mostly because it's relatively complex,
75 * trying to be both expansive, powerful and efficient. First we will begin
76 * an overview o the theory behind genlist.
78 * Evas tracks every object you create. Every time it processes an event
79 * (mouse move, down, up etc.) it needs to walk through objects and find out
80 * what event that affects. Even worse every time it renders display updates,
81 * in order to just calculate what to re-draw, it needs to walk through many
82 * many many objects. Thus, the more objects you keep active, the more
83 * overhead Evas has in just doing its work. It is advisable to keep your
84 * active objects to the minimum working set you need. Also remember that
85 * object creation and deletion carries an overhead, so there is a
86 * middle-ground, which is not easily determined. But don't keep massive lists
87 * of objects you can't see or use. Genlist does this with list objects. It
88 * creates and destroys them dynamically as you scroll around. It groups them
89 * into blocks so it can determine the visibility etc. of a whole block at
90 * once as opposed to having to walk the whole list. This 2-level list allows
91 * for very large numbers of items to be in the list (tests have used up to
92 * 2,000,000 items). Also genlist employs a queue for adding items. As items
93 * may be different sizes, every item added needs to be calculated as to its
94 * size and thus this presents a lot of overhead on populating the list, this
95 * genlist employs a queue. Any item added is queued and spooled off over
96 * time, actually appearing some time later, so if your list has many members
97 * you may find it takes a while for them to all appear, with your process
98 * consuming a lot of CPU while it is busy spooling.
100 * Genlist also implements a tree structure, but it does so with callbacks to
101 * the application, with the application filling in tree structures when
102 * requested (allowing for efficient building of a very deep tree that could
103 * even be used for file-management). See the above smart signal callbacks for
106 * An item in the genlist world can have 0 or more text labels (they can be
107 * regular text or textblock ??that's up to the style to determine), 0 or
108 * more icons (which are simply objects swallowed into the genlist item) and
109 * 0 or more boolean states that can be used for check, radio or other
110 * indicators by the edje theme style. An item may be one of several styles
111 * (Elementary provides 2 by default - ?
\9cdefault??and ?
\9cdouble_label?? but this
112 * can be extended by system or application custom themes/overlays/extensions).
114 * In order to implement the ability to add and delete items on the fly,
115 * Genlist implements a class/callback system where the application provides
116 * a structure with information about that type of item (genlist may contain
117 * multiple different items with different classes, states and styles).
118 * Genlist will call the functions in this struct (methods) when an item is
119 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
120 * simply be deleted when no longer needed with evas_object_del(). The
121 * Elm_Genlist_Item_Class structure contains the following members:
123 * item_style - This is a constant string and simply defines the name of the
124 * item style. It must be specified and the default should be ?
\9cdefault??
126 * func.label_get - This function is called when an actual item object is
127 * created. The data parameter is the data parameter passed to
128 * elm_genlist_item_append() and related item creation functions. The obj
129 * parameter is the genlist object and the part parameter is the string name
130 * of the text part in the edje design that is listed as one of the possible
131 * labels that can be set. This function must return a strudup()'ed string as
132 * the caller will free() it when done.
134 * func.icon_get - This function is called when an actual item object is
135 * created. The data parameter is the data parameter passed to
136 * elm_genlist_item_append() and related item creation functions. The obj
137 * parameter is the genlist object and the part parameter is the string name
138 * of the icon part in the edje design that is listed as one of the possible
139 * icons that can be set. This must return NULL for no object or a valid
140 * object. The object will be deleted by genlist on shutdown or when the item
143 * func.state_get - This function is called when an actual item object is
144 * created. The data parameter is the data parameter passed to
145 * elm_genlist_item_append() and related item creation functions. The obj
146 * parameter is the genlist object and the part parameter is the string name
147 * of the state part in the edje design that is listed as one of the possible
148 * states that can be set. Return 0 for false or 1 for true. Genlist will
149 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
150 * true (the default is false), where XXX is the name of the part.
152 * func.del - This is called when elm_genlist_item_del() is called on an
153 * item, elm_genlist_clear() is called on the genlist, or
154 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
155 * intended for use when actual genlist items are deleted, so any backing
156 * data attached to the item (e.g. its data parameter on creation) can be
159 * Items can be added by several calls. All of them return a Elm_Genlist_Item
160 * handle that is an internal member inside the genlist. They all take a data
161 * parameter that is meant to be used for a handle to the applications
162 * internal data (eg the struct with the original item data). The parent
163 * parameter is the parent genlist item this belongs to if it is a tree, and
164 * NULL if there is no parent. The flags can be a bitmask of
165 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
166 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
167 * that is able to expand and have child items. The func parameter is a
168 * convenience callback that is called when the item is selected and the data
169 * parameter will be the func_data parameter, obj be the genlist object and
170 * vent_info will be the genlist item.
172 * elm_genlist_item_append() appends an item to the end of the list, or if
173 * there is a parent, to the end of all the child items of the parent.
174 * elm_genlist_item_prepend() is the same but prepends to the beginning of
175 * the list or children list. elm_genlist_item_insert_before() inserts at
176 * item before another item and elm_genlist_item_insert_after() inserts after
177 * the indicated item.
179 * The application can clear the list with elm_genlist_clear() which deletes
180 * all the items in the list and elm_genlist_item_del() will delete a specific
181 * item. elm_genlist_item_subitems_clear() will clear all items that are
182 * children of the indicated parent item.
184 * If the application wants multiple items to be able to be selected,
185 * elm_genlist_multi_select_set() can enable this. If the list is
186 * single-selection only (the default), then elm_genlist_selected_item_get()
187 * will return the selected item, if any, or NULL I none is selected. If the
188 * list is multi-select then elm_genlist_selected_items_get() will return a
189 * list (that is only valid as long as no items are modified (added, deleted,
190 * selected or unselected).
192 * To help inspect list items you can jump to the item at the top of the list
193 * with elm_genlist_first_item_get() which will return the item pointer, and
194 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
195 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
196 * and previous items respectively relative to the indicated item. Using
197 * these calls you can walk the entire item list/tree. Note that as a tree
198 * the items are flattened in the list, so elm_genlist_item_parent_get() will
199 * let you know which item is the parent (and thus know how to skip them if
202 * There are also convenience functions. elm_genlist_item_genlist_get() will
203 * return the genlist object the item belongs to. elm_genlist_item_show()
204 * will make the scroller scroll to show that specific item so its visible.
205 * elm_genlist_item_data_get() returns the data pointer set by the item
206 * creation functions.
208 * If an item changes (state of boolean changes, label or icons change),
209 * then use elm_genlist_item_update() to have genlist update the item with
210 * the new state. Genlist will re-realize the item thus call the functions
211 * in the _Elm_Genlist_Item_Class for that item.
213 * To programmatically (un)select an item use elm_genlist_item_selected_set().
214 * To get its selected state use elm_genlist_item_selected_get(). Similarly
215 * to expand/contract and item and get its expanded state, use
216 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
217 * again to make an item disabled (unable to be selected and appear
218 * differently) use elm_genlist_item_disabled_set() to set this and
219 * elm_genlist_item_disabled_get() to get the disabled state.
221 * In general to indicate how the genlist should expand items horizontally to
222 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
223 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
224 * mode means that if items are too wide to fit, the scroller will scroll
225 * horizontally. Otherwise items are expanded to fill the width of the
226 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
227 * to the viewport width and limited to that size. This can be combined with
228 * a different style that uses edjes' ellipsis feature (cutting text off like
229 * this: ?
\9ctex...??.
231 * Items will only call their selection func and callback when first becoming
232 * selected. Any further clicks will do nothing, unless you enable always
233 * select with elm_genlist_always_select_mode_set(). This means even if
234 * selected, every click will make the selected callbacks be called.
235 * elm_genlist_no_select_mode_set() will turn off the ability to select
236 * items entirely and they will neither appear selected nor call selected
237 * callback functions.
239 * Remember that you can create new styles and add you own theme augmentation
240 * per application with elm_theme_extension_add(). If you absolutely must
241 * have a specific style that overrides any theme the user or system sets up
242 * you can use elm_theme_overlay_add() to add such a file.
245 typedef struct _Widget_Data Widget_Data;
246 typedef struct _Item_Block Item_Block;
247 typedef struct _Pan Pan;
248 typedef struct _Edit_Data Edit_Data;
250 #define GROUP_ALIGN_NORTH 1
251 #define GROUP_ALIGN_WEST 2
254 Evas_Object *obj, *scr, *pan_smart;
255 Eina_Inlist *items, *blocks, *group_items;
257 Evas_Coord pan_x, pan_y, minw, minh;
258 Ecore_Job *calc_job, *update_job;
259 Ecore_Idler *queue_idler;
260 Eina_List *queue, *selected, *menuopened;
261 Elm_Genlist_Item *show_item;
263 Eina_Bool on_hold : 1;
265 Eina_Bool always_select : 1;
266 Eina_Bool longpressed : 1;
267 Eina_Bool wasselected : 1;
268 Eina_Bool no_select : 1;
269 Eina_Bool bring_in : 1;
270 Eina_Bool compress : 1;
271 Eina_Bool homogeneous : 1;
274 int max_items_per_block;
276 Eina_Bool animate_edit_controls :1;
279 Evas_Coord td1_x, td1_y, tu1_x, tu1_y;
280 Evas_Coord td2_x, td2_y, tu2_x, tu2_y;
281 Evas_Coord d1_x, d1_y, d2_x, d2_y;
282 Evas_Coord acc_x1, acc_y1, acc_x2, acc_y2;
283 Evas_Coord prev_multi_x, prev_multi_y;
284 Eina_Bool multi_down : 1;
285 Eina_Bool multi_touch : 1;
289 Elm_Genlist_Edit_Class *ec;
290 Elm_Genlist_Item *del_item;
291 Elm_Genlist_Item *reorder_item;
292 Elm_Genlist_Item *reorder_rel;
293 Eina_Bool del_confirm_state : 1;
294 Evas_Object *del_confirm;
304 Evas_Coord x, y, w, h, minw, minh;
305 Eina_Bool want_unrealize : 1;
306 Eina_Bool realized : 1;
307 Eina_Bool changed : 1;
308 Eina_Bool updateme : 1;
309 Eina_Bool showme : 1;
312 struct _Elm_Genlist_Item
318 Evas_Coord x, y, w, h, minw, minh, edx;
319 const Elm_Genlist_Item_Class *itc;
321 Elm_Genlist_Item *parent;
322 Elm_Genlist_Item_Flags flags;
323 Elm_Genlist_GroupItem *group_item;
330 Evas_Object *base, *spacer, *edit_obj;
331 Eina_List *labels, *icons, *states, *icon_objs;
332 Ecore_Timer *long_timer;
333 Evas_Coord dx, dy, scrl_x, scrl_y;
335 Elm_Genlist_Item *rel;
338 Eina_Bool before : 1;
340 Eina_Bool want_unrealize : 1;
341 Eina_Bool realized : 1;
342 Eina_Bool selected : 1;
343 Eina_Bool hilighted : 1;
344 Eina_Bool expanded : 1;
345 Eina_Bool disabled : 1;
346 Eina_Bool display_only : 1;
347 Eina_Bool mincalcd : 1;
348 Eina_Bool queued : 1;
349 Eina_Bool showme : 1;
350 Eina_Bool delete_me : 1;
352 Eina_Bool dragging : 1;
353 Eina_Bool updateme : 1;
354 Eina_Bool reordering : 1;
355 Eina_Bool menuopened : 1;
357 int pad_left, pad_right;
361 struct _Elm_Genlist_GroupItem
366 Evas_Coord x, y, w, h, minw, minh;
367 const Elm_Genlist_Item_Class *itc;
376 Eina_List *labels, *icons, *states, *icon_objs;
378 Eina_Bool realized : 1;
379 Eina_Bool delete_me : 1;
380 Eina_Bool visible : 1;
381 Eina_Bool mincalcd : 1;
386 Evas_Object_Smart_Clipped_Data __clipped_data;
390 static const char *widtype = NULL;
391 static void _del_hook(Evas_Object *obj);
392 static void _theme_hook(Evas_Object *obj);
393 //static void _show_region_hook(void *data, Evas_Object *obj);
394 static void _sizing_eval(Evas_Object *obj);
395 static void _item_unrealize(Elm_Genlist_Item *it);
396 static void _item_block_unrealize(Item_Block *itb);
397 static void _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items);
398 static void _groupitem_unrealize(Elm_Genlist_GroupItem *git);
399 static void _calc_job(void *data);
400 static Eina_Bool _edit_mode_reset(Widget_Data *wd);
401 static void _edit_controls_eval( Elm_Genlist_Item *it );
402 static void _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity );
405 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
408 _del_hook(Evas_Object *obj)
410 Widget_Data *wd = elm_widget_data_get(obj);
412 if (wd->calc_job) ecore_job_del(wd->calc_job);
413 if (wd->update_job) ecore_job_del(wd->update_job);
418 _del_pre_hook(Evas_Object *obj)
420 Widget_Data *wd = elm_widget_data_get(obj);
422 evas_object_del(wd->pan_smart);
423 wd->pan_smart = NULL;
424 elm_genlist_clear(obj);
428 _theme_hook(Evas_Object *obj)
430 Widget_Data *wd = elm_widget_data_get(obj);
432 Elm_Genlist_GroupItem *git;
434 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
435 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
436 EINA_INLIST_FOREACH(wd->group_items, git)
438 _groupitem_unrealize(git);
440 EINA_INLIST_FOREACH(wd->blocks, itb)
443 Elm_Genlist_Item *it;
445 if (itb->realized) _item_block_unrealize(itb);
446 EINA_LIST_FOREACH(itb->items, l, it)
447 it->mincalcd = EINA_FALSE;
449 itb->changed = EINA_TRUE;
451 if (wd->calc_job) ecore_job_del(wd->calc_job);
452 wd->calc_job = ecore_job_add(_calc_job, wd);
458 _show_region_hook(void *data, Evas_Object *obj)
460 Widget_Data *wd = elm_widget_data_get(data);
461 Evas_Coord x, y, w, h;
463 elm_widget_show_region_get(obj, &x, &y, &w, &h);
464 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
469 _sizing_eval(Evas_Object *obj)
471 Widget_Data *wd = elm_widget_data_get(obj);
472 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
474 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
475 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
477 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
480 Evas_Coord vmw, vmh, vw, vh;
484 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
485 if ((minw > 0) && (vw < minw)) vw = minw;
486 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
488 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
491 evas_object_size_hint_min_set(obj, minw, minh);
492 evas_object_size_hint_max_set(obj, maxw, maxh);
496 _item_hilight(Elm_Genlist_Item *it)
498 const char *selectraise;
500 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
501 (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
502 if( !it->menuopened )
503 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
504 selectraise = edje_object_data_get(it->base, "selectraise");
505 if ((selectraise) && (!strcmp(selectraise, "on")))
507 evas_object_raise(it->base);
508 if( it->group_item && it->group_item->realized )
509 evas_object_raise(it->group_item->base);
511 it->hilighted = EINA_TRUE;
515 _item_block_del(Elm_Genlist_Item *it)
518 Item_Block *itb = it->block;
520 itb->items = eina_list_remove(itb->items, it);
522 itb->changed = EINA_TRUE;
523 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
524 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
527 il = EINA_INLIST_GET(itb);
528 Item_Block *itbn = (Item_Block *)(il->next);
530 it->parent->items = eina_list_remove(it->parent->items, it);
532 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
534 if (itbn) itbn->changed = EINA_TRUE;
540 il = EINA_INLIST_GET(itb);
541 Item_Block *itbp = (Item_Block *)(il->prev);
542 Item_Block *itbn = (Item_Block *)(il->next);
543 if ((itbp) && ((itbp->count + itb->count) < 48))
545 Elm_Genlist_Item *it2;
547 EINA_LIST_FREE(itb->items, it2)
550 itbp->items = eina_list_append(itbp->items, it2);
552 itbp->changed = EINA_TRUE;
554 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
557 else if ((itbn) && ((itbn->count + itb->count) < 48))
561 Eina_List *last = eina_list_last(itb->items);
562 Elm_Genlist_Item *it2 = last->data;
565 itb->items = eina_list_remove_list(itb->items, last);
566 itbn->items = eina_list_prepend(itbn->items, it2);
568 itbn->changed = EINA_TRUE;
571 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
579 _item_del(Elm_Genlist_Item *it)
581 elm_genlist_item_subitems_clear(it);
582 if (it->wd->show_item == it) it->wd->show_item = NULL;
583 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
584 if (it->realized) _item_unrealize(it);
585 if (it->block) _item_block_del(it);
586 if ((!it->delete_me) && (it->itc->func.del))
587 it->itc->func.del(it->data, it->wd->obj);
588 it->delete_me = EINA_TRUE;
590 it->wd->queue = eina_list_remove(it->wd->queue, it);
591 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
593 it->parent->items = eina_list_remove(it->parent->items, it);
594 if (it->long_timer) ecore_timer_del(it->long_timer);
597 it->group_item->items = eina_list_remove(it->group_item->items,it);
603 _item_select(Elm_Genlist_Item *it)
605 if ((it->wd->no_select) || (it->delete_me) || (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
608 if (it->wd->always_select) goto call;
611 it->selected = EINA_TRUE;
612 it->wd->selected = eina_list_append(it->wd->selected, it);
615 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
617 evas_object_smart_callback_call(it->wd->obj, "selected", it);
619 if ((it->walking == 0) && (it->delete_me))
621 if (it->relcount == 0) _item_del(it);
626 _item_unselect(Elm_Genlist_Item *it)
628 const char *stacking, *selectraise;
630 if ((it->delete_me) || (!it->hilighted)) return;
631 if( !it->menuopened )
632 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
633 stacking = edje_object_data_get(it->base, "stacking");
634 selectraise = edje_object_data_get(it->base, "selectraise");
635 if ((selectraise) && (!strcmp(selectraise, "on")))
637 if ((stacking) && (!strcmp(stacking, "below")))
638 evas_object_lower(it->base);
640 it->hilighted = EINA_FALSE;
643 it->selected = EINA_FALSE;
644 it->wd->selected = eina_list_remove(it->wd->selected, it);
645 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
650 _slide_item(Elm_Genlist_Item *it, bool slide_to_left)
652 const Eina_List *l, *l_next;
653 Elm_Genlist_Item *it2;
654 const char *allow_slide;
656 allow_slide = edje_object_data_get(it->base, "allow_slide");
660 if ( atoi(allow_slide) != 1 )
666 if( !it->menuopened )
667 edje_object_signal_emit(it->base, "elm,state,slide,left", "elm");
668 it->wd->menuopened = eina_list_append(it->wd->menuopened, it);
670 EINA_LIST_FOREACH(it->wd->menuopened, l, it2)
675 edje_object_signal_emit(it2->base, "elm,state,slide,right", "elm");
676 it2->wd->menuopened = eina_list_remove(it2->wd->menuopened, it2);
683 edje_object_signal_emit(it->base, "elm,state,slide,right", "elm");
684 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
687 it->menuopened = slide_to_left;
692 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
694 Elm_Genlist_Item *it = data;
695 Evas_Event_Mouse_Move *ev = event_info;
696 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
697 Evas_Coord acc_x, acc_y;
699 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
701 if (!it->wd->on_hold)
703 it->wd->on_hold = EINA_TRUE;
707 if ((it->dragging) && (it->down))
711 ecore_timer_del(it->long_timer);
712 it->long_timer = NULL;
714 evas_object_smart_callback_call(it->wd->obj, "drag", it);
717 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
721 ecore_timer_del(it->long_timer);
722 it->long_timer = NULL;
727 if (it->wd->multi_down)
729 acc_x = ev->prev.canvas.x - ev->cur.canvas.x;
731 it->wd->acc_x1 = it->wd->acc_x1 - acc_x;
733 it->wd->acc_x1 = it->wd->acc_x1 + acc_x;
735 acc_y = ev->prev.canvas.y - ev->cur.canvas.y;
737 it->wd->acc_y1 = it->wd->acc_y1 - acc_y;
739 it->wd->acc_y1 = it->wd->acc_y1 + acc_y;
744 if (!it->display_only)
745 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
746 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
747 x = ev->cur.canvas.x - x;
748 y = ev->cur.canvas.y - y;
751 if (adx < 0) adx = -dx;
754 if (ady < 0) ady = -dy;
757 if ((adx > minw) || (ady > minh))
762 ecore_timer_del(it->long_timer);
763 it->long_timer = NULL;
765 if (!it->wd->wasselected)
767 it->wd->wasselected = 0;
771 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
776 evas_object_smart_callback_call(it->wd->obj,
777 "drag,start,left", it);
778 _slide_item( it, 1 );
782 evas_object_smart_callback_call(it->wd->obj,
783 "drag,start,right", it);
784 _slide_item( it, 0 );
791 evas_object_smart_callback_call(it->wd->obj,
792 "drag,start,down", it);
797 evas_object_smart_callback_call(it->wd->obj,
798 "drag,start,left", it);
799 _slide_item( it, 1 );
803 evas_object_smart_callback_call(it->wd->obj,
804 "drag,start,right", it);
805 _slide_item( it, 0 );
813 _long_press(void *data)
815 Elm_Genlist_Item *it = data;
817 it->long_timer = NULL;
818 if ((it->disabled) || (it->dragging)) return 0;
819 it->wd->longpressed = EINA_TRUE;
820 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
825 _multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
827 Elm_Genlist_Item *it = data;
828 Evas_Event_Multi_Down *ev = event_info;
829 Evas_Coord dx, dy, adx, ady;
833 ecore_timer_del(it->long_timer);
834 it->long_timer = NULL;
837 dx = it->wd->td1_x - ev->canvas.x;
839 if (adx < 0) adx = -dx;
840 dy = it->wd->td1_y - ev->canvas.y;
842 if (ady < 0) ady = -dy;
844 if (adx < 60 && ady < 60)
847 it->wd->multi_down = 1;
848 it->wd->td2_x = ev->canvas.x;
849 it->wd->td2_y = ev->canvas.y;
851 fprintf(stderr, "\n MULTI_DOWN - BUTTON ID = %d, x= %d, y= %d\n", ev->device, it->wd->td2_x, it->wd->td2_y);
855 _multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
857 Elm_Genlist_Item *it = data;
858 Evas_Event_Multi_Up *ev = event_info;
859 Evas_Coord x, y, dy, uy, ady, auy;
861 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);
863 if (!it->wd->multi_down)
866 it->wd->multi_down = 0;
867 it->wd->tu2_x = ev->canvas.x;
868 it->wd->tu2_y = ev->canvas.y;
869 it->wd->d2_x = ev->canvas.x - it->wd->td2_x;
870 it->wd->d2_y = ev->canvas.y - it->wd->td2_y;
874 it->wd->multi_touch = EINA_TRUE;
878 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);
880 if ( (it->wd->d1_x > 180) && (it->wd->d2_x > 180) )
882 // Two finger : Left -> Right
883 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
884 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
885 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
887 else if ( (it->wd->d1_y > 180) && (it->wd->d2_y > 180) )
889 // Two finger : Top -> Bottom
890 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
891 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
892 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
896 dy = it->wd->td1_y - it->wd->td2_y;
902 uy = it->wd->tu1_y - it->wd->tu2_y;
912 // Two finger : Pinch Out
913 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
920 // Two finger : Pinch In
921 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
930 it->wd->prev_multi_x = 0;
931 it->wd->prev_multi_y = 0;
936 _multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
938 Elm_Genlist_Item *it = data;
939 Evas_Event_Multi_Move *ev = event_info;
940 Evas_Coord acc_x, acc_y;
942 if (it->wd->prev_multi_x == 0)
944 it->wd->prev_multi_x = ev->cur.canvas.x;
945 it->wd->prev_multi_y = ev->cur.canvas.y;
949 acc_x = it->wd->prev_multi_x - ev->cur.canvas.x;
951 it->wd->acc_x2 = it->wd->acc_x2 - acc_x;
953 it->wd->acc_x2 = it->wd->acc_x2 + acc_x;
955 acc_y = it->wd->prev_multi_y - ev->cur.canvas.y;
957 it->wd->acc_y2 = it->wd->acc_y2 - acc_y;
959 it->wd->acc_y2 = it->wd->acc_y2 + acc_y;
961 it->wd->prev_multi_x = ev->cur.canvas.x;
962 it->wd->prev_multi_y = ev->cur.canvas.y;
966 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
968 Elm_Genlist_Item *it = data;
969 Evas_Event_Mouse_Down *ev = event_info;
972 if( it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
973 (void)_edit_mode_reset( it->wd );
974 if (ev->button != 1) return;
977 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
978 it->dx = ev->canvas.x - x;
979 it->dy = ev->canvas.y - y;
980 it->wd->td1_x = ev->canvas.x;
981 it->wd->td1_y = ev->canvas.y;
982 it->wd->longpressed = EINA_FALSE;
983 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
984 else it->wd->on_hold = EINA_FALSE;
985 it->wd->wasselected = it->selected;
987 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
988 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
989 if (it->long_timer) ecore_timer_del(it->long_timer);
991 it->long_timer = ecore_timer_add(1.0, _long_press, it);
993 it->long_timer = NULL;
997 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
999 Elm_Genlist_Item *it = data;
1000 Evas_Event_Mouse_Up *ev = event_info;
1001 Eina_Bool dragged = EINA_FALSE;
1002 Evas_Coord x, y, dy, uy, ady, auy;
1004 if (ev->button != 1) return;
1009 it->wd->tu1_x = ev->canvas.x;
1010 it->wd->tu1_y = ev->canvas.y;
1011 it->wd->d1_x = ev->canvas.x - it->wd->td1_x;
1012 it->wd->d1_y = ev->canvas.y - it->wd->td1_y;
1014 if (it->wd->multi_down == 0 && it->wd->multi_touch == EINA_TRUE)
1016 if ( (it->wd->d1_x > 180) && (it->wd->d2_x > 180) )
1018 // Two finger : Left -> Right
1019 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1020 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1021 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1023 else if ( (it->wd->d1_y > 180) && (it->wd->d2_y > 180) )
1025 // Two finger : Top -> Bottom
1026 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1027 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1028 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1032 dy = it->wd->td1_y - it->wd->td2_y;
1038 uy = it->wd->tu1_y - it->wd->tu2_y;
1048 // Two finger : Pinch Out
1049 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1056 // Two finger : Pinch In
1057 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1067 it->wd->prev_multi_x = 0;
1068 it->wd->prev_multi_y = 0;
1069 it->wd->multi_down = 0;
1072 it->wd->multi_touch = EINA_FALSE;
1074 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1075 else it->wd->on_hold = EINA_FALSE;
1078 ecore_timer_del(it->long_timer);
1079 it->long_timer = NULL;
1084 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
1087 if (it->wd->on_hold)
1089 it->wd->longpressed = EINA_FALSE;
1090 it->wd->on_hold = EINA_FALSE;
1093 if (it->wd->longpressed)
1095 it->wd->longpressed = EINA_FALSE;
1096 if (!it->wd->wasselected)
1098 it->wd->wasselected = 0;
1103 if (it->want_unrealize)
1105 _item_unrealize(it);
1106 if (it->block->want_unrealize)
1107 _item_block_unrealize(it->block);
1110 if ((it->disabled) || (dragged)) return;
1118 else _item_unselect(it);
1124 Widget_Data *wd = it->wd;
1127 while (wd->selected) _item_unselect(wd->selected->data);
1132 const Eina_List *l, *l_next;
1133 Elm_Genlist_Item *it2;
1135 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1136 if (it2 != it) _item_unselect(it2);
1137 // _item_hilight(it);
1138 // _item_select(it);
1146 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1148 Elm_Genlist_Item *it = data;
1151 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1153 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1157 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1159 Elm_Genlist_Item *it = data;
1162 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1166 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1168 Elm_Genlist_Item *it = data;
1171 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1175 _set_groupitem( Elm_Genlist_Item *it, Elm_Genlist_GroupItem *git)
1179 it->group_item = git;
1180 git->items = eina_list_append(git->items, it);
1185 _groupitem_realize(Elm_Genlist_GroupItem *git)
1190 if ((git->realized) || (git->delete_me)) return;
1191 git->base = edje_object_add(evas_object_evas_get(git->wd->obj));
1192 edje_object_scale_set(git->base, elm_widget_scale_get(git->wd->obj) *
1193 _elm_config->scale);
1194 evas_object_smart_member_add(git->base, git->wd->pan_smart);
1195 elm_widget_sub_object_add(git->wd->obj, git->base);
1197 strncpy(buf, "item/", sizeof(buf));
1198 strncat(buf, git->itc->item_style, sizeof(buf) - strlen(buf));
1199 _elm_theme_object_set(git->wd->obj, git->base, "genlist", buf, elm_widget_style_get(git->wd->obj));
1201 align = edje_object_data_get(git->base, "orientation");
1202 git->align = GROUP_ALIGN_NORTH;
1205 if( !strcmp(align, "top") )
1206 git->align = GROUP_ALIGN_NORTH;
1207 else if( !strcmp(align, "left") )
1208 git->align = GROUP_ALIGN_WEST;
1209 else git->align = GROUP_ALIGN_NORTH;
1212 if (git->itc->func.label_get)
1217 git->labels = _elm_stringlist_get(edje_object_data_get(git->base, "labels"));
1218 EINA_LIST_FOREACH(git->labels, l, key)
1220 char *s = git->itc->func.label_get(git->data, git->wd->obj, l->data);
1224 edje_object_part_text_set(git->base, l->data, s);
1230 if (git->itc->func.icon_get)
1235 git->icons = _elm_stringlist_get(edje_object_data_get(git->base, "icons"));
1236 EINA_LIST_FOREACH(git->icons, l, key)
1238 Evas_Object *ic = git->itc->func.icon_get(git->data, git->wd->obj, l->data);
1242 git->icon_objs = eina_list_append(git->icon_objs, ic);
1243 edje_object_part_swallow(git->base, key, ic);
1244 evas_object_show(ic);
1245 elm_widget_sub_object_add(git->wd->obj, ic);
1250 if (git->itc->func.state_get)
1255 git->states = _elm_stringlist_get(edje_object_data_get(git->base, "states"));
1256 EINA_LIST_FOREACH(git->states, l, key)
1258 Eina_Bool on = git->itc->func.state_get(git->data, git->wd->obj, l->data);
1262 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1263 edje_object_signal_emit(git->base, buf, "elm");
1269 Evas_Coord mw = -1, mh = -1;
1271 edje_object_size_min_restricted_calc(git->base, &mw, &mh, mw, mh);
1273 git->w = git->minw = mw;
1274 git->h = git->minh = mh;
1275 git->mincalcd = EINA_TRUE;
1277 git->y = git->y = -1;
1278 evas_object_show(git->base);
1280 git->realized = EINA_TRUE;
1285 _groupitem_unrealize(Elm_Genlist_GroupItem *git)
1289 if (!git->realized) return;
1290 evas_object_del(git->base);
1292 _elm_stringlist_free(git->labels);
1294 _elm_stringlist_free(git->icons);
1296 _elm_stringlist_free(git->states);
1298 EINA_LIST_FREE(git->icon_objs, icon)
1299 evas_object_del(icon);
1302 git->realized = EINA_FALSE;
1306 _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items)
1308 Elm_Genlist_Item *it;
1314 _groupitem_unrealize( git );
1316 git->wd->group_items = eina_inlist_remove(git->wd->group_items,EINA_INLIST_GET(git));
1320 EINA_LIST_FOREACH(git->items,l, it)
1322 it->group_item = NULL;
1323 elm_genlist_item_update(it);
1327 if (git->itc->func.del) git->itc->func.del(git->data, git->wd->obj);
1332 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1334 Elm_Genlist_Item *it2;
1335 const char *stacking;
1336 const char *treesize;
1338 int depth, tsize = 20;
1340 if ((it->realized) || (it->delete_me)) return;
1341 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1342 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1343 _elm_config->scale);
1344 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1345 elm_widget_sub_object_add(it->wd->obj, it->base);
1347 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1348 else strncpy(buf, "item", sizeof(buf));
1349 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1351 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1352 strncat(buf, "/", sizeof(buf) - strlen(buf));
1353 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1355 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1356 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1357 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1358 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1359 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
1360 treesize = edje_object_data_get(it->base, "treesize");
1361 if (treesize) tsize = atoi(treesize);
1362 evas_object_size_hint_min_set(it->spacer,
1363 (depth * tsize) * _elm_config->scale, 1);
1364 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1367 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1368 "elm", _signal_expand_toggle, it);
1369 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1370 _signal_expand, it);
1371 edje_object_signal_callback_add(it->base, "elm,action,contract",
1372 "elm", _signal_contract, it);
1373 stacking = edje_object_data_get(it->base, "stacking");
1376 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1377 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1379 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1381 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1383 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1385 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_DOWN,
1387 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_UP,
1389 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_MOVE,
1391 if (it->selected && !it->menuopened)
1392 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1394 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1396 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1399 if (calc && it->wd->homogeneous && it->wd->item_width)
1401 /* homogenous genlist shortcut */
1404 it->w = it->minw = it->wd->item_width;
1405 it->h = it->minh = it->wd->item_height;
1406 it->mincalcd = EINA_TRUE;
1411 if (it->itc->func.label_get)
1416 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1417 EINA_LIST_FOREACH(it->labels, l, key)
1419 char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
1423 edje_object_part_text_set(it->base, l->data, s);
1428 if (it->itc->func.icon_get)
1433 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
1434 EINA_LIST_FOREACH(it->icons, l, key)
1436 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
1440 it->icon_objs = eina_list_append(it->icon_objs, ic);
1441 edje_object_part_swallow(it->base, key, ic);
1442 evas_object_show(ic);
1443 elm_widget_sub_object_add(it->wd->obj, ic);
1447 if (it->itc->func.state_get)
1452 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
1453 EINA_LIST_FOREACH(it->states, l, key)
1455 Eina_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
1459 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1460 edje_object_signal_emit(it->base, buf, "elm");
1466 Evas_Coord mw = -1, mh = -1;
1468 if (!it->display_only)
1469 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1470 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1471 if (!it->display_only)
1472 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1473 it->w = it->minw = mw;
1474 it->h = it->minh = mh;
1475 it->mincalcd = EINA_TRUE;
1477 if (in == 0 && it->wd->homogeneous)
1479 it->wd->item_width = mw;
1480 it->wd->item_height = mh;
1483 if (!calc) evas_object_show(it->base);
1485 it->realized = EINA_TRUE;
1486 it->want_unrealize = EINA_FALSE;
1487 if(it->group_item && !it->group_item->realized)
1488 _groupitem_realize(it->group_item);
1489 if( ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode )
1490 _edit_controls_eval(it);
1494 _item_unrealize(Elm_Genlist_Item *it)
1498 if (!it->realized) return;
1501 ecore_timer_del(it->long_timer);
1502 it->long_timer = NULL;
1504 evas_object_del(it->base);
1506 evas_object_del(it->spacer);
1509 evas_object_del(it->edit_obj);
1510 it->edit_obj = NULL;
1511 _elm_stringlist_free(it->labels);
1513 _elm_stringlist_free(it->icons);
1515 _elm_stringlist_free(it->states);
1517 EINA_LIST_FREE(it->icon_objs, icon)
1518 evas_object_del(icon);
1521 it->realized = EINA_FALSE;
1522 it->want_unrealize = EINA_FALSE;
1526 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1529 Elm_Genlist_Item *it;
1530 Elm_Genlist_GroupItem *git = NULL;
1531 Evas_Coord minw = 0, minh = 0;
1532 int showme = 0, changed = 0;
1536 EINA_LIST_FOREACH(itb->items, l, it)
1538 if (it->delete_me) continue;
1539 showme |= it->showme;
1544 if (!it->mincalcd) changed = 1;
1547 _item_realize(it, in, 1);
1548 _item_unrealize(it);
1553 _item_realize(it, in, 1);
1554 _item_unrealize(it);
1559 Eina_Bool was_realized = it->realized;
1561 _item_realize(it, in, 0);
1563 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1566 if (minw < it->minw) minw = it->minw;
1571 if( git != it->group_item )
1573 git = it->group_item;
1574 if( git && git->align == GROUP_ALIGN_NORTH && git->items->data == it) //Add Place holder for Group title
1584 itb->changed = EINA_FALSE;
1585 /* force an evas norender to garbage collect deleted objects */
1586 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1591 _item_block_realize(Item_Block *itb, int in, int full)
1594 Elm_Genlist_Item *it;
1596 if (itb->realized) return;
1597 EINA_LIST_FOREACH(itb->items, l, it)
1599 if (it->delete_me) continue;
1602 Eina_Bool was_realized = it->realized;
1604 _item_realize(it, in, 0);
1606 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1610 itb->realized = EINA_TRUE;
1611 itb->want_unrealize = EINA_FALSE;
1615 _item_block_unrealize(Item_Block *itb)
1618 Elm_Genlist_Item *it;
1621 if (!itb->realized) return;
1622 EINA_LIST_FOREACH(itb->items, l, it)
1624 if (it->dragging || it->reordering)
1627 it->want_unrealize = EINA_TRUE;
1630 _item_unrealize(it);
1634 itb->realized = EINA_FALSE;
1635 itb->want_unrealize = EINA_TRUE;
1638 itb->want_unrealize = EINA_FALSE;
1642 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
1644 Widget_Data *wd = data;
1645 wd->ed->del_confirm_state = 0;
1646 evas_object_hide( wd->ed->del_confirm );
1647 if( wd->ed->ec && wd->ed->ec->remove )
1648 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
1649 wd->ed->del_item = NULL;
1653 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
1655 const char *del_icon_part;
1656 Elm_Genlist_Item *it = data;
1657 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
1659 edje_object_part_unswallow( it->edit_obj, it->wd->ed->del_confirm );
1661 evas_object_hide( it->wd->ed->del_confirm );
1665 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1667 const char *del_icon_part, *del_conf_style;
1668 Elm_Genlist_Item *it = data;
1669 if(_edit_mode_reset( it->wd ))
1672 if( it->wd->ed->del_confirm_state )
1674 it->wd->ed->del_confirm_state = 0;
1675 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
1679 it->wd->ed->del_confirm_state = 1;
1680 it->wd->ed->del_item = it;
1682 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
1684 elm_object_style_set( it->wd->ed->del_confirm, del_conf_style);
1687 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
1689 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
1690 evas_object_show( it->wd->ed->del_confirm );
1691 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1695 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1697 Elm_Genlist_Item *it = data;
1699 if(_edit_mode_reset( it->wd ))
1702 if( it->wd->ed->ec && it->wd->ed->ec->insert_new )
1703 it->wd->ed->ec->insert_new(it->wd->obj, it);
1707 _edit_mode_reset(Widget_Data *wd)
1710 if(wd->ed->del_confirm_state)
1712 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
1713 //wd->ed->del_confirm_state = 0;
1714 //wd->ed->del_item = NULL;
1722 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1724 Elm_Genlist_Item *it = data;
1725 Evas_Event_Mouse_Down *ev = event_info;
1728 if(_edit_mode_reset( it->wd ) )
1731 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1733 evas_object_raise(it->base);
1734 evas_object_raise( it->edit_obj );
1736 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
1737 it->dx = ev->canvas.x - x;
1738 it->dy = ev->canvas.y - y;
1739 it->wd->ed->reorder_item = it;
1740 it->wd->ed->reorder_item->reordering = 1;
1741 it->wd->ed->reorder_rel = NULL;
1742 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1746 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1748 Elm_Genlist_Item *it = data;
1749 Elm_Genlist_Item *rel_it;
1751 if( it->reordering && it->wd->ed->reorder_item )
1754 it->wd->ed->reorder_item->reordering = 0;
1755 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
1756 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1758 if( (!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
1759 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE ) ) )
1761 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);
1762 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y );
1764 it->wd->ed->reorder_item = NULL;
1765 it->wd->ed->reorder_rel = NULL;
1771 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1773 Elm_Genlist_Item *it = data;
1774 Evas_Event_Mouse_Move *ev = event_info;
1776 if( it->reordering && it->wd->ed->reorder_item )
1778 Elm_Genlist_Item *rel_it;
1779 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
1780 evas_object_raise(it->wd->ed->reorder_item->base);
1781 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
1782 evas_object_show(it->wd->ed->reorder_item->base);
1783 _move_edit_controls( it,it->wd->ed->reorder_item->scrl_x, y );
1785 it->block->updateme = EINA_TRUE;
1787 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1788 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1795 _move_edit_controls( Elm_Genlist_Item *it, int itx, int ity )
1797 if(it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )
1800 evas_object_resize(it->edit_obj,it->w, it->h );
1801 evas_object_move(it->edit_obj, itx, ity );
1802 evas_object_raise( it->edit_obj );
1806 _edit_controls_eval( Elm_Genlist_Item *it )
1809 const char *pad_str;
1814 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj )
1817 if( it->itc->func.editmode_get )
1818 itmode = it->itc->func.editmode_get( it->data, it->wd->obj, it->wd->edit_mode );
1819 itmode &= it->wd->edit_mode;
1823 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
1824 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
1825 _elm_config->scale);
1826 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
1827 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
1828 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
1830 edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
1831 "elm", _edit_mode_reset, it);
1834 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
1835 if (pad_str) pad = atoi(pad_str);
1837 if( (itmode & ELM_GENLIST_EDIT_MODE_INSERT) )
1839 if(it->wd->animate_edit_controls)
1840 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
1842 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
1844 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
1845 "elm", _insert_new_item_cb, it);
1846 it->pad_left += pad;
1849 if(it->wd->animate_edit_controls)
1850 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
1852 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
1854 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
1855 "elm", _insert_new_item_cb );
1858 if( (itmode & ELM_GENLIST_EDIT_MODE_DELETE) )
1860 if(it->wd->animate_edit_controls)
1861 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
1863 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
1865 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
1866 "elm", _remove_item_cb, it);
1868 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
1869 "elm", _hide_delete_confirm_object, it );
1870 it->pad_left += pad;
1874 if(it->wd->animate_edit_controls)
1875 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
1877 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
1879 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
1880 "elm", _remove_item_cb );
1881 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
1882 "elm", _hide_delete_confirm_object );
1886 if( (itmode & ELM_GENLIST_EDIT_MODE_REORDER) )
1888 Evas_Object *reorder_icon;
1889 const char* reorder_part;
1891 if(it->wd->animate_edit_controls)
1892 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,animated,enable", "elm");
1894 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,enable", "elm");
1896 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
1897 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
1899 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
1901 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_DOWN,
1902 _reorder_mouse_down, it);
1903 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_UP,
1904 _reorder_mouse_up, it);
1905 evas_object_event_callback_add(reorder_icon, EVAS_CALLBACK_MOUSE_MOVE,
1906 _reorder_mouse_move, it);
1908 it->pad_right += pad;
1912 Evas_Object *reorder_icon;
1913 const char* reorder_part;
1915 if(it->wd->animate_edit_controls)
1916 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,animated,disable", "elm");
1918 edje_object_signal_emit(it->edit_obj, "elm,state,reorder,disable", "elm");
1920 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
1921 if( reorder_part && edje_object_part_exists(it->edit_obj, reorder_part ) )
1923 reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
1925 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_DOWN,
1926 _reorder_mouse_down);
1927 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_UP,
1929 evas_object_event_callback_del(reorder_icon, EVAS_CALLBACK_MOUSE_MOVE,
1930 _reorder_mouse_move);
1934 if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE )//Unrealize
1936 evas_object_del(it->edit_obj);
1937 it->edit_obj = NULL;
1940 _move_edit_controls(it,it->scrl_x, it->scrl_y );
1941 evas_object_show( it->edit_obj );
1945 _notify_item_position( Elm_Genlist_Item *it )
1950 l = eina_list_last(it->parent->items);
1952 //Check if the Item is First Node or Last node of its Parent & raise signal.
1953 if( it->parent->items->data != it && l->data != it )
1955 edje_object_signal_emit(it->base, "normal_item", "elm");
1957 if(it->parent->items->data == it )
1958 edje_object_signal_emit(it->base, "first_item", "elm");
1961 edje_object_signal_emit(it->base, "last_item", "elm");
1968 _get_space_for_reorder_item( Elm_Genlist_Item *it )
1970 int top=0, bottom=0;
1971 Evas_Coord rox, roy, row, roh;
1973 if( !(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) || !it->wd->ed->reorder_item )
1976 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
1978 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
1979 rox, roy+roh/2, row, 1));
1983 it->wd->ed->reorder_rel = it;
1984 it->scrl_y+=it->wd->ed->reorder_item->h;
1985 return it->wd->ed->reorder_item->h;
1992 _item_block_position(Item_Block *itb, int in)
1995 Elm_Genlist_Item *it;
1996 Elm_Genlist_GroupItem *git = NULL;
1997 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1998 int vis=0, new_mov_y = 0;
2000 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2001 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
2002 EINA_LIST_FOREACH(itb->items, l, it)
2004 if (it->delete_me) continue;
2008 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
2009 itb->y - it->wd->pan_y + oy,
2011 cvx, cvy, cvw, cvh));
2012 if ((itb->realized) && (!it->realized))
2016 Eina_Bool was_realized = it->realized;
2018 _item_realize(it, in, 0);
2020 evas_object_smart_callback_call(it->wd->obj,
2026 _notify_item_position( it );
2029 it->scrl_x = ox + itb->x + it->x - itb->wd->pan_x;
2030 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y;
2031 if( git != it->group_item )
2033 git = it->group_item;
2036 git->visible = EINA_TRUE; //Mark Group Item to make it visible
2037 if( git->items->data == it)
2038 git->y = it->scrl_y;
2039 if( GROUP_ALIGN_NORTH == git->align )
2042 if( git->items->data == it)
2044 it->scrl_y += git->minh;
2052 git->x = ox + itb->x - itb->wd->pan_x;
2057 if( git->align == GROUP_ALIGN_WEST )
2060 it->scrl_x += git->x + git->w;
2061 git->h = (it->scrl_y + it->h) - git->y ;
2062 if( git->h < it->h )
2064 git->y = it->scrl_y;
2068 if( git->align == GROUP_ALIGN_NORTH )
2071 if( (git->y + git->h) > (it->scrl_y + it->h) )
2072 git->y = (it->scrl_y + it->h) - git->minh;
2077 y+=_get_space_for_reorder_item( it );
2079 if(!it->reordering )
2081 _move_edit_controls( it,it->scrl_x, it->scrl_y );
2082 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
2083 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
2084 evas_object_show(it->base);
2090 _item_unrealize(it);
2094 if(!it->reordering )
2102 itb->wd->animate_edit_controls = 0;
2104 git->visible = EINA_TRUE;
2109 _calc_job(void *data)
2111 Widget_Data *wd = data;
2113 Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
2114 Item_Block *chb = NULL;
2115 int in = 0, minw_change = 0;
2117 EINA_INLIST_FOREACH(wd->blocks, itb)
2122 showme = itb->showme;
2126 if (itb->realized) _item_block_unrealize(itb);
2130 if (itb->realized) _item_block_unrealize(itb);
2131 showme = _item_block_recalc(itb, in, 0, 1);
2137 if (minw == -1) minw = itb->minw;
2138 else if (minw < itb->minw)
2149 wd->show_item->showme = 0;
2151 elm_smart_scroller_region_bring_in(wd->scr,
2152 wd->show_item->x + wd->show_item->block->x,
2153 wd->show_item->y + wd->show_item->block->y,
2154 wd->show_item->block->w,
2157 elm_smart_scroller_child_region_show(wd->scr,
2158 wd->show_item->x + wd->show_item->block->x,
2159 wd->show_item->y + wd->show_item->block->y,
2160 wd->show_item->block->w,
2162 wd->show_item = NULL;
2168 EINA_INLIST_FOREACH(wd->blocks, itb)
2174 if ((chb) && (EINA_INLIST_GET(chb)->next))
2176 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2177 if (itb->realized) _item_block_unrealize(itb);
2179 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2180 if (minw < ow) minw = ow;
2181 if ((minw != wd->minw) || (minh != wd->minh))
2185 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2186 _sizing_eval(wd->obj);
2188 wd->calc_job = NULL;
2189 evas_object_smart_changed(wd->pan_smart);
2193 _update_job(void *data)
2195 Widget_Data *wd = data;
2198 int num, num0, position = 0, recalc = 0;
2200 wd->update_job = NULL;
2202 EINA_INLIST_FOREACH(wd->blocks, itb)
2204 Evas_Coord itminw, itminh;
2205 Elm_Genlist_Item *it;
2211 _item_block_position(itb, num);
2216 EINA_LIST_FOREACH(itb->items, l2, it)
2226 _item_unrealize(it);
2227 _item_realize(it, num, 0);
2228 evas_object_smart_callback_call(it->wd->obj,
2233 _item_realize(it, num, 1);
2234 _item_unrealize(it);
2236 if ((it->minw != itminw) || (it->minh != itminh))
2245 itb->changed = EINA_TRUE;
2246 _item_block_recalc(itb, num0, 0, 1);
2247 _item_block_position(itb, num0);
2252 if (wd->calc_job) ecore_job_del(wd->calc_job);
2253 wd->calc_job = ecore_job_add(_calc_job, wd);
2258 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2260 Pan *sd = evas_object_smart_data_get(obj);
2261 // Evas_Coord ow, oh;
2262 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2263 // ow = sd->wd->minw - ow;
2264 // if (ow < 0) ow = 0;
2265 // oh = sd->wd->minh - oh;
2266 // if (oh < 0) oh = 0;
2267 // if (x < 0) x = 0;
2268 // if (y < 0) y = 0;
2269 // if (x > ow) x = ow;
2270 // if (y > oh) y = oh;
2271 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2274 evas_object_smart_changed(obj);
2278 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2280 Pan *sd = evas_object_smart_data_get(obj);
2282 if (x) *x = sd->wd->pan_x;
2283 if (y) *y = sd->wd->pan_y;
2287 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2289 Pan *sd = evas_object_smart_data_get(obj);
2292 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2293 ow = sd->wd->minw - ow;
2295 oh = sd->wd->minh - oh;
2302 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2304 Pan *sd = evas_object_smart_data_get(obj);
2306 if (w) *w = sd->wd->minw;
2307 if (h) *h = sd->wd->minh;
2311 _pan_add(Evas_Object *obj)
2314 Evas_Object_Smart_Clipped_Data *cd;
2317 cd = evas_object_smart_data_get(obj);
2320 sd->__clipped_data = *cd;
2322 evas_object_smart_data_set(obj, sd);
2326 _pan_del(Evas_Object *obj)
2328 Pan *sd = evas_object_smart_data_get(obj);
2335 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2337 Pan *sd = evas_object_smart_data_get(obj);
2340 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2341 if ((ow == w) && (oh == h)) return;
2342 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2343 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2347 _pan_calculate(Evas_Object *obj)
2349 Pan *sd = evas_object_smart_data_get(obj);
2351 Elm_Genlist_GroupItem *git;
2352 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2354 if( sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE )
2355 (void)_edit_mode_reset( sd->wd );
2356 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2358 git->visible = EINA_FALSE;
2361 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2362 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2363 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2365 itb->w = sd->wd->minw;
2366 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2367 itb->y - sd->wd->pan_y + oy,
2369 cvx, cvy, cvw, cvh))
2371 if ((!itb->realized) || (itb->changed))
2372 _item_block_realize(itb, in, 0);
2373 _item_block_position(itb, in);
2377 if (itb->realized) _item_block_unrealize(itb);
2381 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2385 evas_object_raise(git->base);
2386 evas_object_resize( git->base, git->w, git->h-1 );
2387 evas_object_move(git->base, git->x, git->y );
2388 evas_object_show(git->base);
2391 evas_object_hide(git->base);
2393 if( (sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER ) && (sd->wd->ed->reorder_item ) )
2395 evas_object_raise(sd->wd->ed->reorder_item->base);
2396 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2401 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2403 Pan *sd = evas_object_smart_data_get(obj);
2405 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2406 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2410 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2412 Widget_Data *wd = elm_widget_data_get(obj);
2414 elm_smart_scroller_hold_set(wd->scr, 1);
2418 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2420 Widget_Data *wd = elm_widget_data_get(obj);
2422 elm_smart_scroller_hold_set(wd->scr, 0);
2426 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2428 Widget_Data *wd = elm_widget_data_get(obj);
2430 elm_smart_scroller_freeze_set(wd->scr, 1);
2434 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2436 Widget_Data *wd = elm_widget_data_get(obj);
2438 elm_smart_scroller_freeze_set(wd->scr, 0);
2442 * Add a new Genlist object
2444 * @param parent The parent object
2445 * @return The new object or NULL if it cannot be created
2450 elm_genlist_add(Evas_Object *parent)
2455 Evas_Coord minw, minh;
2456 static Evas_Smart *smart = NULL;
2458 wd = ELM_NEW(Widget_Data);
2459 e = evas_object_evas_get(parent);
2460 obj = elm_widget_add(e);
2461 ELM_SET_WIDTYPE(widtype, "genlist");
2462 elm_widget_type_set(obj, "genlist");
2463 elm_widget_sub_object_add(parent, obj);
2464 elm_widget_data_set(obj, wd);
2465 elm_widget_del_hook_set(obj, _del_hook);
2466 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2467 elm_widget_theme_hook_set(obj, _theme_hook);
2469 wd->scr = elm_smart_scroller_add(e);
2470 elm_smart_scroller_widget_set(wd->scr, obj);
2471 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2472 elm_widget_resize_object_set(obj, wd->scr);
2474 elm_smart_scroller_bounce_allow_set(wd->scr, 0, 1);
2477 wd->mode = ELM_LIST_SCROLL;
2478 wd->max_items_per_block = 32;
2480 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2481 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2482 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2483 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2487 static Evas_Smart_Class sc;
2489 evas_object_smart_clipped_smart_set(&_pan_sc);
2491 sc.name = "elm_genlist_pan";
2492 sc.version = EVAS_SMART_CLASS_VERSION;
2495 sc.resize = _pan_resize;
2496 sc.move = _pan_move;
2497 sc.calculate = _pan_calculate;
2498 smart = evas_smart_class_new(&sc);
2502 wd->pan_smart = evas_object_smart_add(e, smart);
2503 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2507 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2509 _pan_max_get, _pan_child_size_get);
2511 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2513 evas_object_size_hint_min_set(obj, minw, minh);
2519 static Elm_Genlist_Item *
2520 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2521 const void *data, Elm_Genlist_Item *parent,
2522 Elm_Genlist_Item_Flags flags,
2524 const void *func_data)
2526 Elm_Genlist_Item *it;
2528 it = calloc(1, sizeof(Elm_Genlist_Item));
2529 if (!it) return NULL;
2533 it->parent = parent;
2535 it->func.func = func;
2536 it->func.data = func_data;
2541 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2543 Item_Block *itb = NULL;
2550 itb = calloc(1, sizeof(Item_Block));
2553 if (!it->rel->block)
2556 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2557 itb->items = eina_list_append(itb->items, it);
2564 eina_inlist_prepend_relative(wd->blocks,
2565 EINA_INLIST_GET(itb),
2566 EINA_INLIST_GET(it->rel->block));
2568 eina_list_prepend_relative(itb->items, it, it->rel);
2573 eina_inlist_append_relative(wd->blocks,
2574 EINA_INLIST_GET(itb),
2575 EINA_INLIST_GET(it->rel->block));
2577 eina_list_append_relative(itb->items, it, it->rel);
2587 itb = (Item_Block *)(wd->blocks);
2588 if (itb->count >= wd->max_items_per_block)
2590 itb = calloc(1, sizeof(Item_Block));
2594 eina_inlist_prepend(wd->blocks,
2595 EINA_INLIST_GET(itb));
2600 itb = calloc(1, sizeof(Item_Block));
2604 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2606 itb->items = eina_list_prepend(itb->items, it);
2612 itb = (Item_Block *)(wd->blocks->last);
2613 if (itb->count >= wd->max_items_per_block)
2615 itb = calloc(1, sizeof(Item_Block));
2619 eina_inlist_append(wd->blocks,
2620 EINA_INLIST_GET(itb));
2625 itb = calloc(1, sizeof(Item_Block));
2629 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2631 itb->items = eina_list_append(itb->items, it);
2637 itb = it->rel->block;
2638 if (!itb) goto newblock;
2640 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2642 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2645 itb->changed = EINA_TRUE;
2647 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2648 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2651 it->rel->relcount--;
2652 if ((it->rel->delete_me) && (it->rel->relcount == 0))
2656 if (itb->count > itb->wd->max_items_per_block)
2660 Elm_Genlist_Item *it2;
2662 newc = itb->count / 2;
2663 itb2 = calloc(1, sizeof(Item_Block));
2667 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2668 EINA_INLIST_GET(itb));
2669 itb2->changed = EINA_TRUE;
2670 while ((itb->count > newc) && (itb->items))
2674 l = eina_list_last(itb->items);
2676 itb->items = eina_list_remove_list(itb->items, l);
2679 itb2->items = eina_list_prepend(itb2->items, it2);
2689 _queue_proecess(Widget_Data *wd, int norender)
2694 t0 = ecore_time_get();
2695 for (n = 0; (wd->queue) && (n < 128); n++)
2697 Elm_Genlist_Item *it;
2699 it = wd->queue->data;
2700 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2701 it->queued = EINA_FALSE;
2702 _item_block_add(wd, it);
2703 t = ecore_time_get();
2704 if (it->block->changed)
2706 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2707 it->block->changed = 0;
2709 if (showme) it->block->showme = 1;
2710 if (eina_inlist_count(wd->blocks) > 1)
2712 if ((t - t0) > (ecore_animator_frametime_get())) break;
2719 _item_idler(void *data)
2721 Widget_Data *wd = data;
2723 if (_queue_proecess(wd, 1) > 0)
2725 if (wd->calc_job) ecore_job_del(wd->calc_job);
2726 wd->calc_job = ecore_job_add(_calc_job, wd);
2730 wd->queue_idler = NULL;
2737 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2739 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2741 if (wd->queue_idler)
2743 ecore_idler_del(wd->queue_idler);
2744 wd->queue_idler = NULL;
2746 _queue_proecess(wd, 0);
2749 if (it->queued) return;
2750 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2751 it->queued = EINA_TRUE;
2752 wd->queue = eina_list_append(wd->queue, it);
2757 _item_idler(void *data)
2759 Widget_Data *wd = data;
2763 t0 = ecore_time_get();
2764 for (n = 0; (wd->queue) && (n < 128); n++)
2766 Elm_Genlist_Item *it;
2768 it = wd->queue->data;
2769 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2770 it->queued = EINA_FALSE;
2771 _item_block_add(wd, it);
2772 t = ecore_time_get();
2773 if (it->block->changed)
2775 showme = _item_block_recalc(it->block, it->block->num, 1, 1);
2776 it->block->changed = 0;
2778 if (showme) it->block->showme = 1;
2779 if (eina_inlist_count(wd->blocks) > 1)
2781 if ((t - t0) > (ecore_animator_frametime_get())) break;
2786 if (wd->calc_job) ecore_job_del(wd->calc_job);
2787 wd->calc_job = ecore_job_add(_calc_job, wd);
2791 wd->queue_idler = NULL;
2798 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2802 // Add the initial set of Items directly to the Blocks, to show the genlist
2803 // without empty screen.
2804 itb = (Item_Block *)(wd->blocks);
2805 if( (NULL == itb) || (itb->count < wd->max_items_per_block) )
2807 _item_block_add(wd, it);
2811 if (it->queued) return;
2812 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2813 it->queued = EINA_TRUE;
2814 wd->queue = eina_list_append(wd->queue, it);
2821 * Add Group Item to the genlist
2823 * @param obj The genlist object
2824 * @param itc The item class for the item
2825 * @param data The group item data
2827 EAPI Elm_Genlist_GroupItem *
2828 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2831 Elm_Genlist_GroupItem *git;
2832 Widget_Data *wd = elm_widget_data_get(obj);
2834 git = calloc(1, sizeof(Elm_Genlist_GroupItem));
2835 if (!git) return NULL;
2840 wd->group_items = eina_inlist_append(wd->group_items, EINA_INLIST_GET(git) );
2845 * Delete a given groupitem
2847 * This deletes the group item from genlist and calls the genlist group item del class
2848 * callback defined in the item class, if it is set.
2850 * @param git The group item
2855 elm_genlist_groupitem_del(Elm_Genlist_GroupItem *git)
2857 _groupitem_remove( git, EINA_TRUE);
2861 * Append item to the end of the genlist
2863 * This appends the given item to the end of the list or the end of the
2864 * children if the parent is given.
2866 * @param obj The genlist object
2867 * @param itc The item class for the item
2868 * @param data The item data
2869 * @param parent The parent item, or NULL if none
2870 * @param flags Item flags
2871 * @param func Convenience function called when item selected
2872 * @param func_data Data passed to @p func above.
2873 * @return A handle to the item added or NULL if not possible
2877 EAPI Elm_Genlist_Item *
2878 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2879 const void *data, Elm_Genlist_Item *parent,
2880 Elm_Genlist_Item_Flags flags,
2881 Evas_Smart_Cb func, const void *func_data)
2883 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2884 Widget_Data *wd = elm_widget_data_get(obj);
2885 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2886 if (!wd) return NULL;
2887 if (!it) return NULL;
2890 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2896 Elm_Genlist_Item *it2 = NULL;
2897 Eina_List *ll = eina_list_last(it->parent->items);
2898 if (ll) it2 = ll->data;
2899 it->parent->items = eina_list_append(it->parent->items, it);
2900 if (!it2) it2 = it->parent;
2902 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2903 EINA_INLIST_GET(it2));
2904 if( it->parent->group_item)
2905 _set_groupitem( it, it->parent->group_item );
2907 it->rel->relcount++;
2910 _item_queue(wd, it);
2915 * Append item to the end of the genlist with Group Item
2917 * This appends the given item to the end of the list or the end of the
2918 * children if the parent is given.
2920 * @param obj The genlist object
2921 * @param itc The item class for the item
2922 * @param data The item data
2923 * @param parent The parent item, or NULL if none
2924 * @param flags Item flags
2925 * @param git Group Item
2926 * @param func Convenience function called when item selected
2927 * @param func_data Data passed to @p func above.
2928 * @return A handle to the item added or NULL if not possible
2932 EAPI Elm_Genlist_Item *
2933 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2934 const void *data, Elm_Genlist_Item *parent,
2935 Elm_Genlist_Item_Flags flags, Elm_Genlist_GroupItem *git,
2936 Evas_Smart_Cb func, const void *func_data)
2938 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2939 Widget_Data *wd = elm_widget_data_get(obj);
2940 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2941 if (!wd) return NULL;
2942 if (!it) return NULL;
2945 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2951 Elm_Genlist_Item *it2 = NULL;
2952 Eina_List *ll = eina_list_last(it->parent->items);
2953 if (ll) it2 = ll->data;
2954 it->parent->items = eina_list_append(it->parent->items, it);
2955 if (!it2) it2 = it->parent;
2957 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2958 EINA_INLIST_GET(it2));
2959 if( it->parent->group_item)
2960 _set_groupitem( it, it->parent->group_item );
2962 it->rel->relcount++;
2965 _set_groupitem( it, git );
2966 _item_queue(wd, it);
2971 * Prepend item at start of the genlist
2973 * This adds an item to the beginning of the list or beginning of the children
2974 * of the parent if given.
2976 * @param obj The genlist object
2977 * @param itc The item class for the item
2978 * @param data The item data
2979 * @param parent The parent item, or NULL if none
2980 * @param flags Item flags
2981 * @param func Convenience function called when item selected
2982 * @param func_data Data passed to @p func above.
2983 * @return A handle to the item added or NULL if not possible
2987 EAPI Elm_Genlist_Item *
2988 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2989 const void *data, Elm_Genlist_Item *parent,
2990 Elm_Genlist_Item_Flags flags,
2991 Evas_Smart_Cb func, const void *func_data)
2993 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2994 Widget_Data *wd = elm_widget_data_get(obj);
2995 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2996 if (!wd) return NULL;
2997 if (!it) return NULL;
2999 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3002 printf("FIXME: 12 tree not handled yet\n");
3006 _item_queue(wd, it);
3011 * Insert item before another in the genlist
3013 * This inserts an item before another in the list. It will be in the same tree
3014 * level as the item it is inseted before.
3016 * @param obj The genlist object
3017 * @param itc The item class for the item
3018 * @param data The item data
3019 * @param before The item to insert before
3020 * @param flags Item flags
3021 * @param func Convenience function called when item selected
3022 * @param func_data Data passed to @p func above.
3023 * @return A handle to the item added or NULL if not possible
3027 EAPI Elm_Genlist_Item *
3028 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3029 const void *data, Elm_Genlist_Item *before,
3030 Elm_Genlist_Item_Flags flags,
3031 Evas_Smart_Cb func, const void *func_data)
3033 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3034 Widget_Data *wd = elm_widget_data_get(obj);
3035 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3036 if (!wd) return NULL;
3037 if (!it) return NULL;
3039 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3040 EINA_INLIST_GET(before));
3043 printf("FIXME: 13 tree not handled yet\n");
3046 it->rel->relcount++;
3048 _item_queue(wd, it);
3053 * Insert and item after another in the genlst
3055 * This inserts an item after another in the list. It will be in the same tree
3056 * level as the item it is inseted after.
3058 * @param obj The genlist object
3059 * @param itc The item class for the item
3060 * @param data The item data
3061 * @param after The item to insert after
3062 * @param flags Item flags
3063 * @param func Convenience function called when item selected
3064 * @param func_data Data passed to @p func above.
3065 * @return A handle to the item added or NULL if not possible
3069 EAPI Elm_Genlist_Item *
3070 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3071 const void *data, Elm_Genlist_Item *after,
3072 Elm_Genlist_Item_Flags flags,
3073 Evas_Smart_Cb func, const void *func_data)
3075 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3076 Widget_Data *wd = elm_widget_data_get(obj);
3077 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3078 if (!wd) return NULL;
3079 if (!it) return NULL;
3081 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3082 EINA_INLIST_GET(after));
3085 printf("FIXME: 14 tree not handled yet\n");
3088 it->rel->relcount++;
3090 _item_queue(wd, it);
3095 * Moves the Genlist Item
3098 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after )
3102 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
3103 _item_block_del(it);
3107 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
3108 EINA_INLIST_GET(after));
3110 it->rel->relcount++;
3114 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
3118 _item_queue(it->wd, it);
3124 * This clears all items in the list, leaving it empty.
3126 * @param obj The genlist object
3131 elm_genlist_clear(Evas_Object *obj)
3133 ELM_CHECK_WIDTYPE(obj, widtype);
3134 Widget_Data *wd = elm_widget_data_get(obj);
3137 while (wd->group_items)
3139 _groupitem_remove((Elm_Genlist_GroupItem *)wd->group_items, EINA_FALSE);
3144 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3146 wd->items = eina_inlist_remove(wd->items, wd->items);
3147 if (it->realized) _item_unrealize(it);
3148 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
3149 if (it->long_timer) ecore_timer_del(it->long_timer);
3154 Item_Block *itb = (Item_Block *)(wd->blocks);
3156 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3157 if (itb->items) eina_list_free(itb->items);
3162 ecore_job_del(wd->calc_job);
3163 wd->calc_job = NULL;
3165 if (wd->queue_idler)
3167 ecore_idler_del(wd->queue_idler);
3168 wd->queue_idler = NULL;
3172 eina_list_free(wd->queue);
3177 eina_list_free(wd->selected);
3178 wd->selected = NULL;
3180 wd->show_item = NULL;
3185 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3186 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3191 * Enable or disable multi-select in the genlist
3193 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3194 * more than 1 item to be selected.
3196 * @param obj The genlist object
3197 * @param multi Multi-select enable/disable
3202 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3204 ELM_CHECK_WIDTYPE(obj, widtype);
3205 Widget_Data *wd = elm_widget_data_get(obj);
3211 * Gets if multi-select in genlist is enable or disable
3213 * @param obj The genlist object
3214 * @return Multi-select enable/disable
3215 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3220 elm_genlist_multi_select_get(const Evas_Object *obj)
3222 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3223 Widget_Data *wd = elm_widget_data_get(obj);
3224 if (!wd) return EINA_FALSE;
3230 * Get the selectd item in the genlist
3232 * This gets the selected item in the list (if multi-select is enabled only
3233 * the first item in the list is selected - which is not very useful, so see
3234 * elm_genlist_selected_items_get()for when multi-select is used).
3236 * If no item is selected, NULL is returned.
3238 * @param obj The genlist object
3239 * @return The selected item, or NULL if none.
3243 EAPI Elm_Genlist_Item *
3244 elm_genlist_selected_item_get(const Evas_Object *obj)
3246 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3247 Widget_Data *wd = elm_widget_data_get(obj);
3248 if (!wd) return NULL;
3249 if (wd->selected) return wd->selected->data;
3254 * Get a list of selected items in the genlist
3256 * This retgurns a list of the selected items. This list pointer is only valid
3257 * so long as no items are selected or unselected (or unselected implicitly
3258 * by deletion). The list contains Elm_Genlist_Item pointers.
3260 * @param obj The genlist object
3261 * @return The list of selected items, nor NULL if none are selected.
3265 EAPI const Eina_List *
3266 elm_genlist_selected_items_get(const Evas_Object *obj)
3268 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3269 Widget_Data *wd = elm_widget_data_get(obj);
3270 if (!wd) return NULL;
3271 return wd->selected;
3275 * Get a list of realized items in genlist
3277 * This returns a list of the realized items in the genlist. The list
3278 * contains Elm_Genlist_Item pointers. The list must be freed by the
3279 * caller when done with eina_list_free(). The item pointers in the list
3280 * are only vallid so long as those items are not deleted or the genlist is
3283 * @param obj The genlist object
3284 * @return The list of realized items, nor NULL if none are realized.
3289 elm_genlist_realized_items_get(const Evas_Object *obj)
3291 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3292 Widget_Data *wd = elm_widget_data_get(obj);
3293 Eina_List *list = NULL;
3295 Eina_Bool done = EINA_FALSE;
3296 if (!wd) return NULL;
3297 EINA_INLIST_FOREACH(wd->blocks, itb)
3302 Elm_Genlist_Item *it;
3305 EINA_LIST_FOREACH(itb->items, l, it)
3307 if (it->realized) list = eina_list_append(list, it);
3319 * Get the item that is at the x, y canvas coords
3321 * This returns the item at the given coordinates (which are canvas relative
3322 * not object-relative). If an item is at that coordinate, that item handle
3323 * is returned, and if @p posret is not NULL, the integer pointed to is set
3324 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3325 * portion of that item (-1), on the middle section (0) or on the lower part
3326 * (1). If NULL is returned as an item (no item found there), then posret
3327 * may indicate -1 or 1 based if the coordinate is above or below all items
3328 * respectively in the genlist.
3330 * @param it The item
3331 * @param x The input x coordinate
3332 * @param y The input y coordinate
3333 * @param posret The position relative to the item returned here
3334 * @return The item at the coordinates or NULL if none
3338 EAPI Elm_Genlist_Item *
3339 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3341 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3342 Widget_Data *wd = elm_widget_data_get(obj);
3343 Evas_Coord ox, oy, ow, oh;
3346 if (!wd) return NULL;
3347 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3349 EINA_INLIST_FOREACH(wd->blocks, itb)
3352 Elm_Genlist_Item *it;
3354 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3355 oy + itb->y - itb->wd->pan_y,
3356 itb->w, itb->h, x, y, 1, 1))
3358 EINA_LIST_FOREACH(itb->items, l, it)
3360 Evas_Coord itx, ity;
3362 itx = ox + itb->x + it->x - itb->wd->pan_x;
3363 ity = oy + itb->y + it->y - itb->wd->pan_y;
3364 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3368 if (y <= (ity + (it->h / 4))) *posret = -1;
3369 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3374 lasty = ity + it->h;
3379 if (y > lasty) *posret = 1;
3386 * Get the first item in the genlist
3388 * This returns the first item in the list.
3390 * @param obj The genlist object
3391 * @return The first item, or NULL if none
3395 EAPI Elm_Genlist_Item *
3396 elm_genlist_first_item_get(const Evas_Object *obj)
3398 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3399 Widget_Data *wd = elm_widget_data_get(obj);
3400 if (!wd) return NULL;
3401 if (!wd->items) return NULL;
3402 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3403 while ((it) && (it->delete_me))
3404 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3409 * Get the last item in the genlist
3411 * This returns the last item in the list.
3413 * @return The last item, or NULL if none
3417 EAPI Elm_Genlist_Item *
3418 elm_genlist_last_item_get(const Evas_Object *obj)
3420 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3421 Widget_Data *wd = elm_widget_data_get(obj);
3422 if (!wd->items) return NULL;
3423 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3424 if (!wd) return NULL;
3425 while ((it) && (it->delete_me))
3426 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3431 * Get the next item in the genlist
3433 * This returns the item after the item @p it.
3435 * @param it The item
3436 * @return The item after @p it, or NULL if none
3440 EAPI Elm_Genlist_Item *
3441 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3445 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3446 if ((it) && (!it->delete_me)) break;
3448 return (Elm_Genlist_Item *)it;
3452 * Get the previous item in the genlist
3454 * This returns the item before the item @p it.
3456 * @param it The item
3457 * @return The item before @p it, or NULL if none
3461 EAPI Elm_Genlist_Item *
3462 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3466 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3467 if ((it) && (!it->delete_me)) break;
3469 return (Elm_Genlist_Item *)it;
3473 * Get the genlist object from an item
3475 * This returns the genlist object itself that an item belongs to.
3477 * @param it The item
3478 * @return The genlist object
3483 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3485 if (!it) return NULL;
3490 * Get the parent item of the given item
3492 * This returns the prent item of the item @p it given.
3494 * @param it The item
3495 * @return The parent of the item or NULL if none
3499 EAPI Elm_Genlist_Item *
3500 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3502 if (!it) return NULL;
3507 * Clear all sub-items (children) of the given item
3509 * This clears all items that are children (or their descendants) of the
3512 * @param it The item
3517 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3519 Eina_List *tl = NULL, *l;
3520 Elm_Genlist_Item *it2;
3523 EINA_LIST_FOREACH(it->items, l, it2)
3524 tl = eina_list_append(tl, it2);
3525 EINA_LIST_FREE(tl, it2)
3526 elm_genlist_item_del(it2);
3530 * Set the selected state of an item
3532 * This sets the selected state (1 selected, 0 not selected) of the given
3535 * @param it The item
3536 * @param selected The slected state
3541 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3543 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3546 if (it->delete_me) return;
3547 selected = !!selected;
3548 if (it->selected == selected) return;
3554 while (wd->selected)
3555 _item_unselect(wd->selected->data);
3565 * Get the selected state of an item
3567 * This gets the selected state of an item (1 selected, 0 not selected).
3569 * @param it The item
3570 * @return The selected state
3575 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3577 if (!it) return EINA_FALSE;
3578 return it->selected;
3582 * Sets the expanded state of an item (if it's a parent)
3584 * This expands or contracts a parent iterm (thus showing or hiding the
3587 * @param it The item
3588 * @param expanded The expanded state (1 expanded, 0 not expanded).
3593 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3596 if (it->expanded == expanded) return;
3597 it->expanded = expanded;
3601 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3602 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3607 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3608 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3613 * Get the expanded state of an item
3615 * This gets the expanded state of an item
3617 * @param it The item
3618 * @return Thre expanded state
3623 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3625 if (!it) return EINA_FALSE;
3626 return it->expanded;
3630 * Sets the disabled state of an item.
3632 * A disabled item cannot be selected or unselected. It will also change
3633 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3636 * @param it The item
3637 * @param disabled The disabled state
3642 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3645 if (it->disabled == disabled) return;
3646 if (it->delete_me) return;
3647 it->disabled = disabled;
3651 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3653 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3658 * Get the disabled state of an item
3660 * This gets the disabld state of the given item.
3662 * @param it The item
3663 * @return The disabled state
3668 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3670 if (!it) return EINA_FALSE;
3671 if (it->delete_me) return EINA_FALSE;
3672 return it->disabled;
3676 * Sets the display only state of an item.
3678 * A display only item cannot be selected or unselected. It is for display
3679 * only and not selecting or otherwise clicking, dragging etc. by the user,
3680 * thus finger size rules will not be applied to this item.
3682 * @param it The item
3683 * @param display_only The display only state
3688 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3691 if (!it->block) return;
3692 if (it->display_only == display_only) return;
3693 if (it->delete_me) return;
3694 it->display_only = display_only;
3695 it->mincalcd = EINA_FALSE;
3696 it->updateme = EINA_TRUE;
3697 it->block->updateme = EINA_TRUE;
3698 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3699 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3703 * Get the display only state of an item
3705 * This gets the display only state of the given item.
3707 * @param it The item
3708 * @return The display only state
3713 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3715 if (!it) return EINA_FALSE;
3716 if (it->delete_me) return EINA_FALSE;
3717 return it->display_only;
3721 * Show the given item
3723 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3724 * if it is not fully visible.
3726 * @param it The item
3731 elm_genlist_item_show(Elm_Genlist_Item *it)
3734 if (it->delete_me) return;
3735 if ((it->queued) || (!it->mincalcd))
3737 it->wd->show_item = it;
3738 it->wd->bring_in = 1;
3739 it->showme = EINA_TRUE;
3742 if (it->wd->show_item)
3744 it->wd->show_item->showme = EINA_FALSE;
3745 it->wd->show_item = NULL;
3747 elm_smart_scroller_child_region_show(it->wd->scr,
3748 it->x + it->block->x,
3749 it->y + it->block->y,
3750 it->block->w, it->h);
3754 * Bring in the given item
3756 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3757 * if it is not fully visible. This may use animation to do so and take a
3760 * @param it The item
3765 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3768 if (it->delete_me) return;
3769 if ((it->queued) || (!it->mincalcd))
3771 it->wd->show_item = it;
3772 it->wd->bring_in = 1;
3773 it->showme = EINA_TRUE;
3776 if (it->wd->show_item)
3778 it->wd->show_item->showme = EINA_FALSE;
3779 it->wd->show_item = NULL;
3781 elm_smart_scroller_region_bring_in(it->wd->scr,
3782 it->x + it->block->x,
3783 it->y + it->block->y,
3784 it->block->w, it->h);
3788 * Show the given item at the top
3790 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3791 * if it is not fully visible.
3793 * @param it The item
3798 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3803 if (it->delete_me) return;
3804 if ((it->queued) || (!it->mincalcd))
3806 it->wd->show_item = it;
3807 it->wd->bring_in = 1;
3808 it->showme = EINA_TRUE;
3811 if (it->wd->show_item)
3813 it->wd->show_item->showme = EINA_FALSE;
3814 it->wd->show_item = NULL;
3816 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3817 elm_smart_scroller_child_region_show(it->wd->scr,
3818 it->x + it->block->x,
3819 it->y + it->block->y,
3824 * Bring in the given item at the top
3826 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3827 * if it is not fully visible. This may use animation to do so and take a
3830 * @param it The item
3835 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3840 if (it->delete_me) return;
3841 if ((it->queued) || (!it->mincalcd))
3843 it->wd->show_item = it;
3844 it->wd->bring_in = 1;
3845 it->showme = EINA_TRUE;
3848 if (it->wd->show_item)
3850 it->wd->show_item->showme = EINA_FALSE;
3851 it->wd->show_item = NULL;
3853 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3854 elm_smart_scroller_region_bring_in(it->wd->scr,
3855 it->x + it->block->x,
3856 it->y + it->block->y,
3861 * Show the given item at the middle
3863 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3864 * if it is not fully visible.
3866 * @param it The item
3871 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3876 if (it->delete_me) return;
3877 if ((it->queued) || (!it->mincalcd))
3879 it->wd->show_item = it;
3880 it->wd->bring_in = 1;
3881 it->showme = EINA_TRUE;
3884 if (it->wd->show_item)
3886 it->wd->show_item->showme = EINA_FALSE;
3887 it->wd->show_item = NULL;
3889 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3890 elm_smart_scroller_child_region_show(it->wd->scr,
3891 it->x + it->block->x,
3892 it->y + it->block->y - oh/2 + it->h/2,
3898 * Bring in the given item at the middle
3900 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3901 * if it is not fully visible. This may use animation to do so and take a
3904 * @param it The item
3909 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3914 if (it->delete_me) return;
3915 if ((it->queued) || (!it->mincalcd))
3917 it->wd->show_item = it;
3918 it->wd->bring_in = 1;
3919 it->showme = EINA_TRUE;
3922 if (it->wd->show_item)
3924 it->wd->show_item->showme = EINA_FALSE;
3925 it->wd->show_item = NULL;
3927 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3928 elm_smart_scroller_region_bring_in(it->wd->scr,
3929 it->x + it->block->x,
3930 it->y + it->block->y - oh/2 + it->h/2,
3935 * Delete a given item
3937 * This deletes the item from genlist and calls the genlist item del class
3938 * callback defined in the item class, if it is set.
3940 * @param it The item
3945 elm_genlist_item_del(Elm_Genlist_Item *it)
3948 if ((it->relcount > 0) || (it->walking > 0))
3950 elm_genlist_item_subitems_clear(it);
3951 it->delete_me = EINA_TRUE;
3952 if (it->wd->show_item == it) it->wd->show_item = NULL;
3953 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3956 if (it->realized) _item_unrealize(it);
3957 it->block->changed = EINA_TRUE;
3958 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3959 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3961 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
3968 * Set the data item from the genlist item
3970 * This set the data value passed on the elm_genlist_item_append() and
3971 * related item addition calls. This function will also call
3972 * elm_genlist_item_update() so the item will be updated to reflect the
3975 * @param it The item
3976 * @param data The new data pointer to set
3981 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3985 elm_genlist_item_update(it);
3989 * Get the data item from the genlist item
3991 * This returns the data value passed on the elm_genlist_item_append() and
3992 * related item addition calls.
3994 * @param it The item
3995 * @return The data pointer provided when created
4000 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4002 if (!it) return NULL;
4007 * Get the real evas object of the genlist item
4009 * This returns the actual evas object used for the specified genlist item.
4010 * This may be NULL as it may not be created, and ma be deleted at any time
4011 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
4012 * genlist is controlling it. This function is for querying, emitting
4013 * custom signals or hooking lower level callbacks for events. Do not
4014 * delete this object under any circumstances.
4016 * @param it The item
4017 * @return The objct pointer
4021 EAPI const Evas_Object *
4022 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4024 if (!it) return NULL;
4029 * Update the contents of an item
4031 * This updates an item by calling all the item class functions again to get
4032 * the icons, labels and states. Use this when he original item data has
4033 * changed and the changes are desired to be reflected.
4035 * @param it The item
4040 elm_genlist_item_update(Elm_Genlist_Item *it)
4042 if (!it->block) return;
4043 if (it->delete_me) return;
4044 it->mincalcd = EINA_FALSE;
4045 it->updateme = EINA_TRUE;
4046 it->block->updateme = EINA_TRUE;
4047 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4048 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4052 * This sets the horizontal stretching mode
4054 * This sets the mode used for sizing items horizontally. Valid modes are
4055 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
4056 * mode means that if items are too wide to fit, the scroller will scroll
4057 * horizontally. Otherwise items are expanded to fill the width of the
4058 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
4059 * to the viewport width and limited to that size.
4061 * @param obj The genlist object
4062 * @param mode The mode to use
4067 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
4069 ELM_CHECK_WIDTYPE(obj, widtype);
4070 Widget_Data *wd = elm_widget_data_get(obj);
4072 if (wd->mode == mode) return;
4078 * Gets the horizontal stretching mode
4080 * @param obj The genlist object
4081 * @return The mode to use
4082 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
4087 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4089 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4090 Widget_Data *wd = elm_widget_data_get(obj);
4091 if (!wd) return ELM_LIST_LAST;
4096 * Set the always select mode.
4098 * Items will only call their selection func and callback when first becoming
4099 * selected. Any further clicks will do nothing, unless you enable always
4100 * select with elm_genlist_always_select_mode_set(). This means even if
4101 * selected, every click will make the selected callbacks be called.
4103 * @param obj The genlist object
4104 * @param always_select The always select mode
4105 * (EINA_TRUE = on, EINA_FALSE = off)
4110 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
4112 ELM_CHECK_WIDTYPE(obj, widtype);
4113 Widget_Data *wd = elm_widget_data_get(obj);
4115 wd->always_select = always_select;
4119 * Get the always select mode.
4121 * @param obj The genlist object
4122 * @return The always select mode
4123 * (EINA_TRUE = on, EINA_FALSE = off)
4128 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4130 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4131 Widget_Data *wd = elm_widget_data_get(obj);
4132 if (!wd) return EINA_FALSE;
4133 return wd->always_select;
4137 * Set no select mode
4139 * This will turn off the ability to select items entirely and they will
4140 * neither appear selected nor call selected callback functions.
4142 * @param obj The genlist object
4143 * @param no_select The no select mode
4144 * (EINA_TRUE = on, EINA_FALSE = off)
4149 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4151 ELM_CHECK_WIDTYPE(obj, widtype);
4152 Widget_Data *wd = elm_widget_data_get(obj);
4154 wd->no_select = no_select;
4158 * Gets no select mode
4160 * @param obj The genlist object
4161 * @return The no select mode
4162 * (EINA_TRUE = on, EINA_FALSE = off)
4167 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4169 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4170 Widget_Data *wd = elm_widget_data_get(obj);
4171 if (!wd) return EINA_FALSE;
4172 return wd->no_select;
4178 * This will enable the compress mode where items are "compressed" horizontally
4179 * to fit the genlist scrollable viewport width.
4181 * @param obj The genlist object
4182 * @param no_select The compress mode
4183 * (EINA_TRUE = on, EINA_FALSE = off)
4188 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4190 ELM_CHECK_WIDTYPE(obj, widtype);
4191 Widget_Data *wd = elm_widget_data_get(obj);
4193 wd->compress = compress;
4197 * Get the compress mode
4199 * @param obj The genlist object
4200 * @return The compress mode
4201 * (EINA_TRUE = on, EINA_FALSE = off)
4206 elm_genlist_compress_mode_get(const Evas_Object *obj)
4208 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4209 Widget_Data *wd = elm_widget_data_get(obj);
4210 if (!wd) return EINA_FALSE;
4211 return wd->compress;
4217 * This will enable or disable the scroller bounce mode for the genlist. See
4218 * elm_scroller_bounce_set() for details
4220 * @param obj The genlist object
4221 * @param h_bounce Allow bounce horizontally
4222 * @param v_bounce Allow bounce vertically
4227 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4229 ELM_CHECK_WIDTYPE(obj, widtype);
4230 Widget_Data *wd = elm_widget_data_get(obj);
4232 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4236 * Get the bounce mode
4238 * @param obj The genlist object
4239 * @param h_bounce Allow bounce horizontally
4240 * @param v_bounce Allow bounce vertically
4245 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4247 ELM_CHECK_WIDTYPE(obj, widtype);
4248 Widget_Data *wd = elm_widget_data_get(obj);
4250 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4254 * Set homogenous mode
4256 * This will enable the homogeneous mode where items are of the same height and width
4257 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4259 * @param obj The genlist object
4260 * @param homogeneous Assume the items within the genlist are of the same height and width
4261 * (EINA_TRUE = on, EINA_FALSE = off)
4266 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4268 ELM_CHECK_WIDTYPE(obj, widtype);
4269 Widget_Data *wd = elm_widget_data_get(obj);
4271 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4272 wd->homogeneous = homogeneous;
4276 * Get the homogenous mode
4278 * @param obj The genlist object
4279 * @return Assume the items within the genlist are of the same height and width
4280 * (EINA_TRUE = on, EINA_FALSE = off)
4285 elm_genlist_homogeneous_get(const Evas_Object *obj)
4287 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4288 Widget_Data *wd = elm_widget_data_get(obj);
4289 if (!wd) return EINA_FALSE;
4290 return wd->homogeneous;
4294 * Set the maximum number of items within an item block
4296 * This will configure the block count to tune to the target with particular performance matrix.
4298 * @param obj The genlist object
4299 * @param n Maximum number of items within an item block
4304 elm_genlist_block_count_set(Evas_Object *obj, int n)
4306 ELM_CHECK_WIDTYPE(obj, widtype);
4307 Widget_Data *wd = elm_widget_data_get(obj);
4309 wd->max_items_per_block = n;
4313 * Get the maximum number of items within an item block
4315 * @param obj The genlist object
4316 * @return Maximum number of items within an item block
4321 elm_genlist_block_count_get(const Evas_Object *obj)
4323 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4324 Widget_Data *wd = elm_widget_data_get(obj);
4326 return wd->max_items_per_block;
4330 * Set the Genlist Internal scroller scrollbar policy
4332 * This sets the Genlist Internal scrollbar visibility policy.
4333 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it
4334 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4335 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4336 * This applies respectively for the horizontal and vertical scrollbars.
4338 * @param obj The Genlist object
4339 * @param policy_h Horizontal scrollbar policy
4340 * @param policy_v Vertical scrollbar policy
4345 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4347 ELM_CHECK_WIDTYPE(obj, widtype);
4348 Widget_Data *wd = elm_widget_data_get(obj);
4351 const Elm_Scroller_Policy map[3] =
4353 ELM_SMART_SCROLLER_POLICY_AUTO,
4354 ELM_SMART_SCROLLER_POLICY_ON,
4355 ELM_SMART_SCROLLER_POLICY_OFF
4357 if ((policy_h < 0) || (policy_h >= 3) || (policy_v < 0) || (policy_v >= 3))
4360 elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
4365 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class )
4367 Eina_List * realized_list;
4368 Elm_Genlist_Item *it;
4371 ELM_CHECK_WIDTYPE(obj, widtype);
4372 Widget_Data *wd = elm_widget_data_get(obj);
4374 if( wd->edit_mode == emode ) return;
4376 wd->edit_mode = emode;
4378 wd->animate_edit_controls = 1;
4379 if( wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
4381 if( wd->ed ) free (wd->ed);
4387 wd->ed = calloc(1, sizeof(Edit_Data));
4389 wd->ed->ec = edit_class;
4391 if( (wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) && !wd->ed->del_confirm)
4393 wd->ed->del_confirm = elm_button_add(wd->obj);
4394 elm_button_label_set(wd->ed->del_confirm, "Delete");
4395 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
4396 edje_object_scale_set( wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
4397 _elm_config->scale);
4398 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd );
4402 realized_list = elm_genlist_realized_items_get(obj);
4404 EINA_LIST_FOREACH(realized_list, l, it)
4406 _edit_controls_eval(it);
4409 if (wd->calc_job) ecore_job_del(wd->calc_job);
4410 wd->calc_job = ecore_job_add(_calc_job, wd);