1 #include <Elementary.h>
5 #define MAX_ITEMS_PER_BLOCK 32
6 #define LONGPRESS_TIMEOUT 1.0
9 * @defgroup Genlist Genlist
12 * The Aim was to have more expansive list that the simple list in
13 * Elementary that could have more flexible items and allow many more entries
14 * while still being fast and low on memory usage. At the same time it was
15 * also made to be able to do tree structures. But the price to pay is more
16 * complexity when it comes to usage. If all you want is a simple list with
17 * icons and a single label, use the normal List object.
19 * Signals that you can add callbacks for are:
21 * clicked - This is called when a user has double-clicked an item. The
22 * event_info parameter is the genlist item that was double-clicked.
24 * selected - This is called when a user has made an item selected. The
25 * event_info parameter is the genlist item that was selected.
27 * unselected - This is called when a user has made an item unselected. The
28 * event_info parameter is the genlist item that was unselected.
30 * expanded - This is called when elm_genlist_item_expanded_set() is called
31 * and the item is now meant to be expanded. The event_info parameter is the
32 * genlist item that was indicated to expand. It is the job of this callback
33 * to then fill in the child items.
35 * contracted - This is called when elm_genlist_item_expanded_set() is called
36 * and the item is now meant to be contracted. The event_info parameter is
37 * the genlist item that was indicated to contract. It is the job of this
38 * callback to then delete the child items
40 * expand,request - This is called when a user has indicated they want to
41 * expand a tree branch item. The callback should decide if the item can
42 * expand (has any children) and then call elm_genlist_item_expanded_set()
43 * appropriately to set the state. The event_info parameter is the genlist
44 * item that was indicated to expand.
46 * contract,request - This is called when a user has indicated they want to
47 * contract a tree branch item. The callback should decide if the item can
48 * contract (has any children) and then call elm_genlist_item_expanded_set()
49 * appropriately to set the state. The event_info parameter is the genlist
50 * item that was indicated to contract.
52 * realized - This is called when the item in the list is created as a real
53 * evas object. event_info parameter is the genlist item that was created.
54 * The object may be deleted at any time, so it is up to the caller to
55 * not use the object pointer from elm_genlist_item_object_get() in a way
56 * where it may point to freed objects.
58 * unrealized - This is called just before an item is unrealized. After
59 * this call icon objects provideed will be deleted and the item object
60 * itself delete or be put into a floating cache.
62 * drag,start,up - This is called when the item in the list has been dragged
65 * drag,start,down - This is called when the item in the list has been dragged
66 * (not scrolled) down.
68 * drag,start,left - This is called when the item in the list has been dragged
69 * (not scrolled) left.
71 * drag,start,right - This is called when the item in the list has been dragged
72 * (not scrolled) right.
74 * drag,stop - This is called when the item in the list has stopped being
77 * drag - This is called when the item in the list is being dragged.
79 * longpressed - This is called when the item is pressed for a certain amount
80 * of time. By default it's 1 second.
82 * scroll,edge,top - This is called when the genlist is scrolled until the top
85 * scroll,edge,bottom - This is called when the genlist is scrolled until the
88 * scroll,edge,left - This is called when the genlist is scrolled until the
91 * scroll,edge,right - This is called when the genlist is scrolled until the
94 * Genlist has a fairly large API, mostly because it's relatively complex,
95 * trying to be both expansive, powerful and efficient. First we will begin
96 * an overview o the theory behind genlist.
98 * Evas tracks every object you create. Every time it processes an event
99 * (mouse move, down, up etc.) it needs to walk through objects and find out
100 * what event that affects. Even worse every time it renders display updates,
101 * in order to just calculate what to re-draw, it needs to walk through many
102 * many many objects. Thus, the more objects you keep active, the more
103 * overhead Evas has in just doing its work. It is advisable to keep your
104 * active objects to the minimum working set you need. Also remember that
105 * object creation and deletion carries an overhead, so there is a
106 * middle-ground, which is not easily determined. But don't keep massive lists
107 * of objects you can't see or use. Genlist does this with list objects. It
108 * creates and destroys them dynamically as you scroll around. It groups them
109 * into blocks so it can determine the visibility etc. of a whole block at
110 * once as opposed to having to walk the whole list. This 2-level list allows
111 * for very large numbers of items to be in the list (tests have used up to
112 * 2,000,000 items). Also genlist employs a queue for adding items. As items
113 * may be different sizes, every item added needs to be calculated as to its
114 * size and thus this presents a lot of overhead on populating the list, this
115 * genlist employs a queue. Any item added is queued and spooled off over
116 * time, actually appearing some time later, so if your list has many members
117 * you may find it takes a while for them to all appear, with your process
118 * consuming a lot of CPU while it is busy spooling.
120 * Genlist also implements a tree structure, but it does so with callbacks to
121 * the application, with the application filling in tree structures when
122 * requested (allowing for efficient building of a very deep tree that could
123 * even be used for file-management). See the above smart signal callbacks for
126 * An item in the genlist world can have 0 or more text labels (they can be
127 * regular text or textblock ??that's up to the style to determine), 0 or
128 * more icons (which are simply objects swallowed into the genlist item) and
129 * 0 or more boolean states that can be used for check, radio or other
130 * indicators by the edje theme style. An item may be one of several styles
131 * (Elementary provides 2 by default - ?
\9cdefault??and ?
\9cdouble_label?? but this
132 * can be extended by system or application custom themes/overlays/extensions).
134 * In order to implement the ability to add and delete items on the fly,
135 * Genlist implements a class/callback system where the application provides
136 * a structure with information about that type of item (genlist may contain
137 * multiple different items with different classes, states and styles).
138 * Genlist will call the functions in this struct (methods) when an item is
139 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
140 * simply be deleted when no longer needed with evas_object_del(). The
141 * Elm_Genlist_Item_Class structure contains the following members:
143 * item_style - This is a constant string and simply defines the name of the
144 * item style. It must be specified and the default should be ?
\9cdefault??
146 * func.label_get - This function is called when an actual item object is
147 * created. The data parameter is the data parameter passed to
148 * elm_genlist_item_append() and related item creation functions. The obj
149 * parameter is the genlist object and the part parameter is the string name
150 * of the text part in the edje design that is listed as one of the possible
151 * labels that can be set. This function must return a strudup()'ed string as
152 * the caller will free() it when done.
154 * func.icon_get - This function is called when an actual item object is
155 * created. The data parameter is the data parameter passed to
156 * elm_genlist_item_append() and related item creation functions. The obj
157 * parameter is the genlist object and the part parameter is the string name
158 * of the icon part in the edje design that is listed as one of the possible
159 * icons that can be set. This must return NULL for no object or a valid
160 * object. The object will be deleted by genlist on shutdown or when the item
163 * func.state_get - This function is called when an actual item object is
164 * created. The data parameter is the data parameter passed to
165 * elm_genlist_item_append() and related item creation functions. The obj
166 * parameter is the genlist object and the part parameter is the string name
167 * of the state part in the edje design that is listed as one of the possible
168 * states that can be set. Return 0 for false or 1 for true. Genlist will
169 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
170 * true (the default is false), where XXX is the name of the part.
172 * func.del - This is called when elm_genlist_item_del() is called on an
173 * item, elm_genlist_clear() is called on the genlist, or
174 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
175 * intended for use when actual genlist items are deleted, so any backing
176 * data attached to the item (e.g. its data parameter on creation) can be
179 * Items can be added by several calls. All of them return a Elm_Genlist_Item
180 * handle that is an internal member inside the genlist. They all take a data
181 * parameter that is meant to be used for a handle to the applications
182 * internal data (eg the struct with the original item data). The parent
183 * parameter is the parent genlist item this belongs to if it is a tree, and
184 * NULL if there is no parent. The flags can be a bitmask of
185 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
186 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
187 * that is able to expand and have child items. The func parameter is a
188 * convenience callback that is called when the item is selected and the data
189 * parameter will be the func_data parameter, obj be the genlist object and
190 * vent_info will be the genlist item.
192 * elm_genlist_item_append() appends an item to the end of the list, or if
193 * there is a parent, to the end of all the child items of the parent.
194 * elm_genlist_item_prepend() is the same but prepends to the beginning of
195 * the list or children list. elm_genlist_item_insert_before() inserts at
196 * item before another item and elm_genlist_item_insert_after() inserts after
197 * the indicated item.
199 * The application can clear the list with elm_genlist_clear() which deletes
200 * all the items in the list and elm_genlist_item_del() will delete a specific
201 * item. elm_genlist_item_subitems_clear() will clear all items that are
202 * children of the indicated parent item.
204 * If the application wants multiple items to be able to be selected,
205 * elm_genlist_multi_select_set() can enable this. If the list is
206 * single-selection only (the default), then elm_genlist_selected_item_get()
207 * will return the selected item, if any, or NULL I none is selected. If the
208 * list is multi-select then elm_genlist_selected_items_get() will return a
209 * list (that is only valid as long as no items are modified (added, deleted,
210 * selected or unselected).
212 * To help inspect list items you can jump to the item at the top of the list
213 * with elm_genlist_first_item_get() which will return the item pointer, and
214 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
215 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
216 * and previous items respectively relative to the indicated item. Using
217 * these calls you can walk the entire item list/tree. Note that as a tree
218 * the items are flattened in the list, so elm_genlist_item_parent_get() will
219 * let you know which item is the parent (and thus know how to skip them if
222 * There are also convenience functions. elm_genlist_item_genlist_get() will
223 * return the genlist object the item belongs to. elm_genlist_item_show()
224 * will make the scroller scroll to show that specific item so its visible.
225 * elm_genlist_item_data_get() returns the data pointer set by the item
226 * creation functions.
228 * If an item changes (state of boolean changes, label or icons change),
229 * then use elm_genlist_item_update() to have genlist update the item with
230 * the new state. Genlist will re-realize the item thus call the functions
231 * in the _Elm_Genlist_Item_Class for that item.
233 * To programmatically (un)select an item use elm_genlist_item_selected_set().
234 * To get its selected state use elm_genlist_item_selected_get(). Similarly
235 * to expand/contract and item and get its expanded state, use
236 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
237 * again to make an item disabled (unable to be selected and appear
238 * differently) use elm_genlist_item_disabled_set() to set this and
239 * elm_genlist_item_disabled_get() to get the disabled state.
241 * In general to indicate how the genlist should expand items horizontally to
242 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
243 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
244 * mode means that if items are too wide to fit, the scroller will scroll
245 * horizontally. Otherwise items are expanded to fill the width of the
246 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
247 * to the viewport width and limited to that size. This can be combined with
248 * a different style that uses edjes' ellipsis feature (cutting text off like
249 * this: ?
\9ctex...??.
251 * Items will only call their selection func and callback when first becoming
252 * selected. Any further clicks will do nothing, unless you enable always
253 * select with elm_genlist_always_select_mode_set(). This means even if
254 * selected, every click will make the selected callbacks be called.
255 * elm_genlist_no_select_mode_set() will turn off the ability to select
256 * items entirely and they will neither appear selected nor call selected
257 * callback functions.
259 * Remember that you can create new styles and add you own theme augmentation
260 * per application with elm_theme_extension_add(). If you absolutely must
261 * have a specific style that overrides any theme the user or system sets up
262 * you can use elm_theme_overlay_add() to add such a file.
265 typedef struct _Widget_Data Widget_Data;
266 typedef struct _Item_Block Item_Block;
267 typedef struct _Pan Pan;
268 typedef struct _Edit_Data Edit_Data;
270 typedef enum _Elm_Genlist_Item_Move_effect_Mode
272 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
273 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
274 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
275 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
276 } Elm_Genlist_Item_Move_effect_Mode;
278 typedef enum _Elm_Genlist_Item_Pinchzoom_effect_Mode
280 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE = 0,
281 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND = (1 << 0),
282 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT = (1 << 1),
283 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH = (1 << 2),
284 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND_FINISH = (1 << 3),
285 } Elm_Genlist_Item_Pinchzoom_effect_Mode;
287 #define GROUP_ALIGN_NORTH 1
288 #define GROUP_ALIGN_WEST 2
292 Evas_Object *obj, *scr, *pan_smart;
293 Eina_Inlist *items, *blocks;
295 Evas_Coord pan_x, pan_y, minw, minh;
296 Ecore_Job *calc_job, *update_job;
297 Ecore_Idler *queue_idler;
298 Eina_List *queue, *selected;
299 Elm_Genlist_Item *show_item;
301 Eina_Bool on_hold : 1;
303 Eina_Bool always_select : 1;
304 Eina_Bool longpressed : 1;
305 Eina_Bool wasselected : 1;
306 Eina_Bool no_select : 1;
307 Eina_Bool bring_in : 1;
308 Eina_Bool compress : 1;
309 Eina_Bool homogeneous : 1;
310 Eina_Bool clear_me : 1;
314 int max_items_per_block;
315 double longpress_timeout;
316 Eina_List *group_items;
317 Eina_List *menuopened;
320 Eina_Bool animate_edit_controls :1;
323 Evas_Coord td1_x, td1_y, tu1_x, tu1_y;
324 Evas_Coord td2_x, td2_y, tu2_x, tu2_y;
325 Evas_Coord d1_x, d1_y, d2_x, d2_y;
326 Evas_Coord acc_x1, acc_y1, acc_x2, acc_y2;
327 Evas_Coord prev_multi_x, prev_multi_y;
328 Eina_Bool multi_down : 1;
329 Eina_Bool multi_touch : 1;
330 Eina_List *edit_field;
331 Eina_Bool selct_all : 1;
332 Elm_Genlist_Item *select_all_item;
334 Eina_Bool effect_mode : 1;
335 Eina_Bool edit_mode_effect_mode : 1;
336 Eina_Bool pinch_zoom : 1;
337 Eina_Bool pinch_zoom_reserve : 1;
338 int move_effect_mode;
339 int pinchzoom_effect_mode;
342 Ecore_Animator *item_moving_effect_timer;
343 Evas_Object *alpha_bg;
344 Evas_Object *point_rect;
345 Elm_Genlist_Item *expand_item;
348 Evas_Coord start_y_pos;
350 Eina_Bool queue_exception : 1;
352 Eina_Bool reoder_moved : 1;
354 Eina_Bool group_items_moved : 1;
359 Elm_Genlist_Edit_Class *ec;
360 Elm_Genlist_Item *del_item;
361 Elm_Genlist_Item *reorder_item;
362 Elm_Genlist_Item *reorder_rel;
363 Evas_Object *del_confirm;
373 Evas_Coord x, y, w, h, minw, minh;
374 Eina_Bool want_unrealize : 1;
375 Eina_Bool realized : 1;
376 Eina_Bool changed : 1;
377 Eina_Bool updateme : 1;
378 Eina_Bool showme : 1;
382 struct _Elm_Genlist_Item
388 Evas_Coord x, y, w, h, minw, minh;
389 const Elm_Genlist_Item_Class *itc;
391 Elm_Genlist_Item *parent;
392 Elm_Genlist_Item *group_item;
393 Elm_Genlist_Item_Flags flags;
399 Evas_Object *spacer, *base;
400 Eina_List *labels, *icons, *states, *icon_objs;
401 Ecore_Timer *long_timer;
402 Evas_Coord dx, dy, scrl_x, scrl_y;
403 Evas_Coord old_y, finish_y;
404 Evas_Coord reoder_cavas_x, reoder_cavas_y;
406 Elm_Genlist_Item *rel;
412 Eina_Bool before : 1;
414 Eina_Bool want_unrealize : 1;
415 Eina_Bool want_realize : 1;
416 Eina_Bool realized : 1;
417 Eina_Bool selected : 1;
418 Eina_Bool hilighted : 1;
419 Eina_Bool expanded : 1;
420 Eina_Bool disabled : 1;
421 Eina_Bool display_only : 1;
422 Eina_Bool mincalcd : 1;
423 Eina_Bool queued : 1;
424 Eina_Bool showme : 1;
425 Eina_Bool delete_me : 1;
427 Eina_Bool dragging : 1;
428 Eina_Bool updateme : 1;
429 Eina_Bool delete_check : 1;
430 Eina_Bool del_confirm_state : 1;
431 Eina_Bool reordering : 1;
432 Eina_Bool menuopened : 1;
433 Eina_Bool select_all_item : 1;
434 Eina_Bool reorder_check: 1;
435 Eina_Bool renamed : 1;
437 int pad_left, pad_right;
439 Evas_Coord old_scrl_y;
440 Evas_Coord old_pad_left;
442 Eina_Bool effect_done : 1;
443 Evas_Object *edit_obj;
444 Eina_List *edit_icon_objs;
445 Ecore_Timer *edit_long_timer;
448 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
449 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
453 Evas_Object_Smart_Clipped_Data __clipped_data;
457 static const char *widtype = NULL;
458 static void _del_hook(Evas_Object *obj);
459 static void _theme_hook(Evas_Object *obj);
460 static void _show_region_hook(void *data, Evas_Object *obj);
461 static void _sizing_eval(Evas_Object *obj);
462 static void _item_unrealize(Elm_Genlist_Item *it);
463 static void _item_block_unrealize(Item_Block *itb);
464 static void _calc_job(void *data);
465 static Eina_Bool _edit_mode_reset(Widget_Data *wd);
466 static void _edit_controls_eval(Elm_Genlist_Item *it);
467 static void _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity);
468 static Eina_Bool _item_moving_effect_timer_cb(void *data);
469 static Eina_Bool _edit_mode_item_moving_effect_cb(void *data);
470 static int _item_flip_effect_show(void *data);
471 static void _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode);
472 static void _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info);
473 static void _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
474 static void _notify_item_position(Elm_Genlist_Item *it);
475 static void _notify_item_position(Elm_Genlist_Item *it);
476 static int _get_space_for_reorder_item(Elm_Genlist_Item *it);
477 static void _print_deprecated(const char *deprecated, const char *new);
479 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
482 _del_hook(Evas_Object *obj)
484 Widget_Data *wd = elm_widget_data_get(obj);
486 if (wd->calc_job) ecore_job_del(wd->calc_job);
487 if (wd->update_job) ecore_job_del(wd->update_job);
492 _del_pre_hook(Evas_Object *obj)
494 Widget_Data *wd = elm_widget_data_get(obj);
496 evas_object_del(wd->pan_smart);
497 wd->pan_smart = NULL;
498 elm_genlist_clear(obj);
502 _theme_hook(Evas_Object *obj)
504 Widget_Data *wd = elm_widget_data_get(obj);
507 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
508 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
509 EINA_INLIST_FOREACH(wd->blocks, itb)
512 Elm_Genlist_Item *it;
514 if (itb->realized) _item_block_unrealize(itb);
515 EINA_LIST_FOREACH(itb->items, l, it)
516 it->mincalcd = EINA_FALSE;
518 itb->changed = EINA_TRUE;
520 if (wd->calc_job) ecore_job_del(wd->calc_job);
521 wd->calc_job = ecore_job_add(_calc_job, wd);
526 _show_region_hook(void *data, Evas_Object *obj)
528 Widget_Data *wd = elm_widget_data_get(data);
529 Evas_Coord x, y, w, h;
531 elm_widget_show_region_get(obj, &x, &y, &w, &h);
532 //x & y are screen coordinates, Add with pan coordinates
535 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
539 _sizing_eval(Evas_Object *obj)
541 Widget_Data *wd = elm_widget_data_get(obj);
542 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
544 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
545 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
547 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
550 Evas_Coord vmw, vmh, vw, vh;
554 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
555 if ((minw > 0) && (vw < minw)) vw = minw;
556 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
558 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
561 evas_object_size_hint_min_set(obj, minw, minh);
562 evas_object_size_hint_max_set(obj, maxw, maxh);
566 _item_hilight(Elm_Genlist_Item *it)
568 const char *selectraise;
570 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) || (it->disabled) ||
571 (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
573 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
574 selectraise = edje_object_data_get(it->base, "selectraise");
575 if ((selectraise) && (!strcmp(selectraise, "on")))
577 evas_object_raise(it->base);
578 if (it->group_item && it->group_item->realized)
579 evas_object_raise(it->group_item->base);
581 it->hilighted = EINA_TRUE;
585 _item_block_del(Elm_Genlist_Item *it)
588 Item_Block *itb = it->block;
590 itb->items = eina_list_remove(itb->items, it);
592 itb->changed = EINA_TRUE;
593 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
594 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
597 il = EINA_INLIST_GET(itb);
598 Item_Block *itbn = (Item_Block *)(il->next);
600 it->parent->items = eina_list_remove(it->parent->items, it);
602 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
604 if (itbn) itbn->changed = EINA_TRUE;
608 if (itb->count < itb->wd->max_items_per_block/2)
610 il = EINA_INLIST_GET(itb);
611 Item_Block *itbp = (Item_Block *)(il->prev);
612 Item_Block *itbn = (Item_Block *)(il->next);
613 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
615 Elm_Genlist_Item *it2;
617 EINA_LIST_FREE(itb->items, it2)
620 itbp->items = eina_list_append(itbp->items, it2);
622 itbp->changed = EINA_TRUE;
624 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
627 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
631 Eina_List *last = eina_list_last(itb->items);
632 Elm_Genlist_Item *it2 = last->data;
635 itb->items = eina_list_remove_list(itb->items, last);
636 itbn->items = eina_list_prepend(itbn->items, it2);
638 itbn->changed = EINA_TRUE;
641 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
649 _item_del(Elm_Genlist_Item *it)
651 elm_genlist_item_subitems_clear(it);
652 it->wd->walking -= it->walking;
653 if (it->wd->show_item == it) it->wd->show_item = NULL;
654 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
655 if (it->realized) _item_unrealize(it);
656 if (it->block) _item_block_del(it);
657 if ((!it->delete_me) && (it->itc->func.del))
658 it->itc->func.del(it->data, it->wd->obj);
659 it->delete_me = EINA_TRUE;
661 it->wd->queue = eina_list_remove(it->wd->queue, it);
662 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
664 it->parent->items = eina_list_remove(it->parent->items, it);
665 if (it->flags & ELM_GENLIST_ITEM_GROUP)
666 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
667 if (it->long_timer) ecore_timer_del(it->long_timer);
670 it->group_item->items = eina_list_remove(it->group_item->items,it);
676 _item_select(Elm_Genlist_Item *it)
678 if ((it->wd->no_select) || (it->delete_me) || (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
681 if (it->wd->always_select) goto call;
684 it->selected = EINA_TRUE;
685 it->wd->selected = eina_list_append(it->wd->selected, it);
689 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
691 evas_object_smart_callback_call(it->wd->obj, "selected", it);
694 if ((it->wd->clear_me) && (!it->wd->walking))
695 elm_genlist_clear(it->wd->obj);
698 if ((!it->walking) && (it->delete_me))
700 if (!it->relcount) _item_del(it);
706 _item_unselect(Elm_Genlist_Item *it)
708 const char *stacking, *selectraise;
710 if ((it->delete_me) || (!it->hilighted)) return;
712 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
713 stacking = edje_object_data_get(it->base, "stacking");
714 selectraise = edje_object_data_get(it->base, "selectraise");
715 if ((selectraise) && (!strcmp(selectraise, "on")))
717 if ((stacking) && (!strcmp(stacking, "below")))
718 evas_object_lower(it->base);
720 it->hilighted = EINA_FALSE;
723 it->selected = EINA_FALSE;
724 it->wd->selected = eina_list_remove(it->wd->selected, it);
725 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
730 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
733 Elm_Genlist_Item *it2;
734 const char *allow_slide;
736 allow_slide = edje_object_data_get(it->base, "allow_slide");
740 if (atoi(allow_slide) != 1)
746 edje_object_signal_emit(it->base, "elm,state,slide,right", "elm");
747 it->wd->menuopened = eina_list_append(it->wd->menuopened, it);
749 EINA_LIST_FOREACH(it->wd->menuopened, l, it2)
753 it2->menuopened = EINA_FALSE;
754 edje_object_signal_emit(it2->base, "elm,state,slide,left", "elm");
755 it2->wd->menuopened = eina_list_remove(it2->wd->menuopened, it2);
762 edje_object_signal_emit(it->base, "elm,state,slide,left", "elm");
763 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
766 it->menuopened = slide_to_right;
770 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
772 Elm_Genlist_Item *it = data;
773 Evas_Event_Mouse_Move *ev = event_info;
774 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
775 Evas_Coord acc_x, acc_y;
777 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
779 if (!it->wd->on_hold)
781 it->wd->on_hold = EINA_TRUE;
782 if (!it->wd->wasselected)
786 if ((it->dragging) && (it->down))
790 ecore_timer_del(it->long_timer);
791 it->long_timer = NULL;
793 evas_object_smart_callback_call(it->wd->obj, "drag", it);
796 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
800 ecore_timer_del(it->long_timer);
801 it->long_timer = NULL;
806 if (it->wd->multi_down)
808 acc_x = ev->prev.canvas.x - ev->cur.canvas.x;
810 it->wd->acc_x1 = it->wd->acc_x1 - acc_x;
812 it->wd->acc_x1 = it->wd->acc_x1 + acc_x;
814 acc_y = ev->prev.canvas.y - ev->cur.canvas.y;
816 it->wd->acc_y1 = it->wd->acc_y1 - acc_y;
818 it->wd->acc_y1 = it->wd->acc_y1 + acc_y;
823 if (!it->display_only)
824 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
825 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
826 x = ev->cur.canvas.x - x;
827 y = ev->cur.canvas.y - y;
830 if (adx < 0) adx = -dx;
833 if (ady < 0) ady = -dy;
836 if ((adx > minw) || (ady > minh))
841 ecore_timer_del(it->long_timer);
842 it->long_timer = NULL;
844 if (!it->wd->wasselected)
849 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
854 evas_object_smart_callback_call(it->wd->obj,
855 "drag,start,left", it);
860 evas_object_smart_callback_call(it->wd->obj,
861 "drag,start,right", it);
869 evas_object_smart_callback_call(it->wd->obj,
870 "drag,start,down", it);
875 evas_object_smart_callback_call(it->wd->obj,
876 "drag,start,left", it);
881 evas_object_smart_callback_call(it->wd->obj,
882 "drag,start,right", it);
891 _long_press(void *data)
893 Elm_Genlist_Item *it = data;
895 it->long_timer = NULL;
896 if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
897 it->wd->longpressed = EINA_TRUE;
898 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
899 return ECORE_CALLBACK_CANCEL;
903 _edit_long_press(void *data)
905 Elm_Genlist_Item *it = data, *it_tmp;
907 static Eina_Bool contracted = EINA_FALSE;
911 it->edit_long_timer = NULL;
912 if ((it->disabled) || (it->dragging)) return 0;
914 EINA_INLIST_FOREACH(it->wd->blocks, itb)
916 EINA_LIST_FOREACH(itb->items, l, it_tmp)
918 if(!it_tmp->parent && elm_genlist_item_expanded_get(it_tmp))
920 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
921 contracted = EINA_TRUE;
928 contracted = EINA_FALSE;
932 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
934 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
936 it->dx = it->reoder_cavas_x - x;
937 it->dy = it->reoder_cavas_y - y;
939 evas_object_raise(it->base);
940 evas_object_raise(it->edit_obj);
942 it->wd->ed->reorder_item = it;
943 it->wd->ed->reorder_item->reordering = 1;
944 it->wd->ed->reorder_rel = NULL;
945 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
946 it->wd->reoder_pan_y = it->wd->pan_y;
947 it->wd->reoder_moved = EINA_TRUE;
953 _multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
955 Elm_Genlist_Item *it = data;
956 Evas_Event_Multi_Down *ev = event_info;
957 Evas_Coord dx, dy, adx, ady;
961 ecore_timer_del(it->long_timer);
962 it->long_timer = NULL;
965 dx = it->wd->td1_x - ev->canvas.x;
967 if (adx < 0) adx = -dx;
968 dy = it->wd->td1_y - ev->canvas.y;
970 if (ady < 0) ady = -dy;
972 if (adx < 60 && ady < 60)
975 it->wd->multi_down = 1;
976 it->wd->td2_x = ev->canvas.x;
977 it->wd->td2_y = ev->canvas.y;
979 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
981 evas_object_move(it->wd->point_rect, 2, (it->wd->td1_y + it->wd->td2_y) / 2);
982 evas_object_raise(it->wd->point_rect);
983 evas_object_show(it->wd->point_rect);
985 fprintf(stderr, "\n MULTI_DOWN - BUTTON ID = %d, x= %d, y= %d\n", ev->device, it->wd->td2_x, it->wd->td2_y);
990 _multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
992 Elm_Genlist_Item *it = data;
993 Evas_Event_Multi_Up *ev = event_info;
994 Evas_Coord dy, uy, ady, auy;
997 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);
999 if (!it->wd->multi_down)
1002 it->wd->multi_down = 0;
1003 it->wd->tu2_x = ev->canvas.x;
1004 it->wd->tu2_y = ev->canvas.y;
1005 it->wd->d2_x = ev->canvas.x - it->wd->td2_x;
1006 it->wd->d2_y = ev->canvas.y - it->wd->td2_y;
1008 evas_object_lower(it->wd->point_rect);
1009 evas_object_hide(it->wd->point_rect);
1013 it->wd->multi_touch = EINA_TRUE;
1017 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);
1019 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1021 // Two finger : Left -> Right
1022 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1023 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1024 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1026 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1028 // Two finger : Top -> Bottom
1029 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1030 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1031 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1035 dy = it->wd->td1_y - it->wd->td2_y;
1041 uy = it->wd->tu1_y - it->wd->tu2_y;
1051 // Two finger : Pinch Out
1052 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1054 if (it->wd->effect_mode == EINA_TRUE)
1055 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1062 // Two finger : Pinch In
1063 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1065 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1067 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1069 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1070 fprintf(stderr," pinch,in!! it ================ it->y = %d it->old_y = %d it = %d it->wd->td1_y = %d it->wd->td2_y = %d pinch_it = %d it->wd->contract_pan_y = %d\n", it->y, it->old_scrl_y, it->old_scrl_y / 30, it->wd->td1_y, it->wd->td2_y, it->wd->pinch_it, it->wd->contract_pan_y);
1071 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1081 it->wd->prev_multi_x = 0;
1082 it->wd->prev_multi_y = 0;
1087 _multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1089 Elm_Genlist_Item *it = data;
1090 Evas_Event_Multi_Move *ev = event_info;
1091 Evas_Coord acc_x, acc_y;
1093 if (!it->wd->prev_multi_x)
1095 it->wd->prev_multi_x = ev->cur.canvas.x;
1096 it->wd->prev_multi_y = ev->cur.canvas.y;
1100 acc_x = it->wd->prev_multi_x - ev->cur.canvas.x;
1102 it->wd->acc_x2 = it->wd->acc_x2 - acc_x;
1104 it->wd->acc_x2 = it->wd->acc_x2 + acc_x;
1106 acc_y = it->wd->prev_multi_y - ev->cur.canvas.y;
1108 it->wd->acc_y2 = it->wd->acc_y2 - acc_y;
1110 it->wd->acc_y2 = it->wd->acc_y2 + acc_y;
1112 it->wd->prev_multi_x = ev->cur.canvas.x;
1113 it->wd->prev_multi_y = ev->cur.canvas.y;
1117 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1119 Elm_Genlist_Item *it = data;
1120 Evas_Event_Mouse_Down *ev = event_info;
1123 it->wd->group_items_moved = EINA_FALSE;
1124 it->wd->td1_x = ev->canvas.x;
1125 it->wd->td1_y = ev->canvas.y;
1126 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
1128 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1132 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
1133 (void)_edit_mode_reset(it->wd);
1134 if (ev->button != 1) return;
1135 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1137 it->wd->on_hold = EINA_TRUE;
1140 if (it->wd->edit_field && !it->renamed)
1141 elm_genlist_item_rename_mode_set(it, 0);
1145 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1146 it->dx = ev->canvas.x - x;
1147 it->dy = ev->canvas.y - y;
1148 it->wd->longpressed = EINA_FALSE;
1149 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1150 else it->wd->on_hold = EINA_FALSE;
1151 if (it->wd->on_hold) return;
1152 it->wd->wasselected = it->selected;
1154 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1155 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
1156 if (it->long_timer) ecore_timer_del(it->long_timer);
1158 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it);
1160 it->long_timer = NULL;
1164 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1166 Elm_Genlist_Item *it = data;
1167 Evas_Event_Mouse_Up *ev = event_info;
1168 Eina_Bool dragged = EINA_FALSE;
1169 Evas_Coord dy, uy, ady, auy;
1172 if (ev->button != 1) return;
1177 it->wd->tu1_x = ev->canvas.x;
1178 it->wd->tu1_y = ev->canvas.y;
1179 it->wd->d1_x = ev->canvas.x - it->wd->td1_x;
1180 it->wd->d1_y = ev->canvas.y - it->wd->td1_y;
1182 // evas_object_lower(it->wd->point_rect);
1183 // evas_object_hide(it->wd->point_rect);
1184 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
1186 if (!it->wd->multi_down && it->wd->multi_touch == EINA_TRUE)
1188 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1190 // Two finger : Left -> Right
1191 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1192 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1193 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1195 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1197 // Two finger : Top -> Bottom
1198 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1199 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1200 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1204 dy = it->wd->td1_y - it->wd->td2_y;
1205 if (dy < 0) ady = -dy;
1208 uy = it->wd->tu1_y - it->wd->tu2_y;
1209 if (uy < 0) auy = -uy;
1216 // Two finger : Pinch Out
1217 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1218 if (it->wd->effect_mode == EINA_TRUE)
1219 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1226 // Two finger : Pinch In
1227 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1228 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1230 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1232 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1233 fprintf(stderr,"mouse up pinch,in!! it ================ it->y = %d it->old_y = %d it = %d it->wd->td1_y = %d it->wd->td2_y = %d pinch_it = %d it->wd->contract_pan_y = %d \n", it->y, it->old_scrl_y, it->old_scrl_y / 30, it->wd->td1_y, it->wd->td2_y, it->wd->pinch_it, it->wd->contract_pan_y);
1234 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1245 it->wd->prev_multi_x = 0;
1246 it->wd->prev_multi_y = 0;
1247 it->wd->multi_down = 0;
1250 it->wd->multi_touch = EINA_FALSE;
1252 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1253 else it->wd->on_hold = EINA_FALSE;
1256 ecore_timer_del(it->long_timer);
1257 it->long_timer = NULL;
1262 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
1265 if (it->wd->on_hold)
1267 it->wd->longpressed = EINA_FALSE;
1268 it->wd->on_hold = EINA_FALSE;
1271 if (it->wd->longpressed)
1273 it->wd->longpressed = EINA_FALSE;
1274 if (!it->wd->wasselected)
1276 it->wd->wasselected = 0;
1281 if (it->want_unrealize)
1283 _item_unrealize(it);
1284 if (it->block->want_unrealize)
1285 _item_block_unrealize(it->block);
1288 if ((it->disabled) || (dragged)) return;
1289 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1292 if (!it->selected && !it->menuopened)
1297 else _item_unselect(it);
1303 Widget_Data *wd = it->wd;
1306 while (wd->selected) _item_unselect(wd->selected->data);
1311 const Eina_List *l, *l_next;
1312 Elm_Genlist_Item *it2;
1314 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1315 if (it2 != it) _item_unselect(it2);
1316 //_item_hilight(it);
1319 if (!it->menuopened)
1328 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1330 Elm_Genlist_Item *it = data;
1333 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1335 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1339 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1341 Elm_Genlist_Item *it = data;
1344 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1348 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1350 Elm_Genlist_Item *it = data;
1353 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1357 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1359 Elm_Genlist_Item *it2;
1360 const char *stacking;
1361 const char *treesize;
1363 int depth, tsize = 20;
1365 if ((it->realized) || (it->delete_me)) return;
1366 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1367 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1368 _elm_config->scale);
1369 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1370 elm_widget_sub_object_add(it->wd->obj, it->base);
1372 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1373 else strncpy(buf, "item", sizeof(buf));
1374 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1376 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1377 strncat(buf, "/", sizeof(buf) - strlen(buf));
1378 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1380 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1381 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1382 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1383 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1384 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1386 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1388 it->expanded_depth = depth;
1389 treesize = edje_object_data_get(it->base, "treesize");
1390 if (treesize) tsize = atoi(treesize);
1391 evas_object_size_hint_min_set(it->spacer,
1392 (depth * tsize) * _elm_config->scale, 1);
1393 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1396 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1397 "elm", _signal_expand_toggle, it);
1398 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1399 _signal_expand, it);
1400 edje_object_signal_callback_add(it->base, "elm,action,contract",
1401 "elm", _signal_contract, it);
1402 stacking = edje_object_data_get(it->base, "stacking");
1405 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1406 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1408 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1410 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1412 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1414 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_DOWN,
1416 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_UP,
1418 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_MOVE,
1420 if (it->selected && !it->menuopened)
1421 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1423 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1425 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1428 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1430 /* homogenous genlist shortcut */
1433 it->w = it->minw = it->wd->item_width;
1434 it->h = it->minh = it->wd->item_height;
1435 it->mincalcd = EINA_TRUE;
1440 if (!strcmp(it->itc->item_style, "select_all"))
1445 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
1446 EINA_LIST_FOREACH(it->labels, l, key) {
1447 edje_object_part_text_set(it->base, l->data, "Select all");
1451 if (it->itc->func.label_get)
1456 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
1457 EINA_LIST_FOREACH(it->labels, l, key)
1459 char *s = it->itc->func.label_get
1460 ((void *)it->data, it->wd->obj, l->data);
1464 edje_object_part_text_set(it->base, l->data, s);
1468 edje_object_part_text_set(it->base, l->data, "");*/
1471 if (it->itc->func.icon_get)
1476 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->base, "icons"));
1477 EINA_LIST_FOREACH(it->icons, l, key)
1479 Evas_Object *ic = it->itc->func.icon_get
1480 ((void *)it->data, it->wd->obj, l->data);
1484 it->icon_objs = eina_list_append(it->icon_objs, ic);
1485 edje_object_part_swallow(it->base, key, ic);
1486 evas_object_show(ic);
1487 elm_widget_sub_object_add(it->wd->obj, ic);
1491 if (it->itc->func.state_get)
1496 it->states = elm_widget_stringlist_get(edje_object_data_get(it->base, "states"));
1497 EINA_LIST_FOREACH(it->states, l, key)
1499 Eina_Bool on = it->itc->func.state_get
1500 (it->data, it->wd->obj, l->data);
1504 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1505 edje_object_signal_emit(it->base, buf, "elm");
1509 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1510 edje_object_signal_emit(it->base, buf, "elm");
1516 Evas_Coord mw = -1, mh = -1;
1518 if (!it->display_only)
1519 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1520 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1521 if (!it->display_only)
1522 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1523 it->w = it->minw = mw;
1524 it->h = it->minh = mh;
1525 it->mincalcd = EINA_TRUE;
1527 if ((!in) && (it->wd->homogeneous))
1529 it->wd->item_width = mw;
1530 it->wd->item_height = mh;
1533 if (!calc) evas_object_show(it->base);
1536 it->realized = EINA_TRUE;
1537 it->want_unrealize = EINA_FALSE;
1538 if (ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode)
1541 EINA_LIST_FREE(it->edit_icon_objs, icon)
1542 evas_object_del(icon);
1543 _edit_controls_eval(it);
1548 _item_unrealize(Elm_Genlist_Item *it)
1552 if (!it->realized) return;
1553 it->menuopened = EINA_FALSE;
1554 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
1557 ecore_timer_del(it->long_timer);
1558 it->long_timer = NULL;
1560 evas_object_del(it->base);
1562 evas_object_del(it->spacer);
1565 evas_object_del(it->edit_obj);
1566 it->edit_obj = NULL;
1567 elm_widget_stringlist_free(it->labels);
1569 elm_widget_stringlist_free(it->icons);
1571 elm_widget_stringlist_free(it->states);
1573 EINA_LIST_FREE(it->icon_objs, icon)
1574 evas_object_del(icon);
1576 EINA_LIST_FREE(it->edit_icon_objs, icon)
1577 evas_object_del(icon);
1580 it->realized = EINA_FALSE;
1581 it->want_unrealize = EINA_FALSE;
1585 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1588 Elm_Genlist_Item *it;
1589 Evas_Coord minw = 0, minh = 0;
1590 int showme = 0, changed = 0;
1594 EINA_LIST_FOREACH(itb->items, l, it)
1596 if (it->delete_me) continue;
1597 showme |= it->showme;
1602 if (!it->mincalcd) changed = 1;
1605 _item_realize(it, in, 1);
1606 _item_unrealize(it);
1611 _item_realize(it, in, 1);
1612 _item_unrealize(it);
1617 Eina_Bool was_realized = it->realized;
1619 _item_realize(it, in, 0);
1621 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1624 if (minw < it->minw) minw = it->minw;
1633 itb->changed = EINA_FALSE;
1634 /* force an evas norender to garbage collect deleted objects */
1635 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1640 _item_block_realize(Item_Block *itb, int in, int full)
1643 Elm_Genlist_Item *it;
1645 if (itb->realized) return;
1646 EINA_LIST_FOREACH(itb->items, l, it)
1648 if (it->delete_me) continue;
1651 Eina_Bool was_realized = it->realized;
1653 _item_realize(it, in, 0);
1655 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1659 itb->realized = EINA_TRUE;
1660 itb->want_unrealize = EINA_FALSE;
1664 _item_block_unrealize(Item_Block *itb)
1667 Elm_Genlist_Item *it;
1670 if (!itb->realized) return;
1671 EINA_LIST_FOREACH(itb->items, l, it)
1673 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1675 if (it->dragging || it->reordering)
1678 it->want_unrealize = EINA_TRUE;
1681 _item_unrealize(it);
1686 itb->realized = EINA_FALSE;
1687 itb->want_unrealize = EINA_TRUE;
1690 itb->want_unrealize = EINA_FALSE;
1694 _group_items_recalc(void *data)
1696 Widget_Data *wd = data;
1698 Elm_Genlist_Item *git;
1700 EINA_LIST_FOREACH(wd->group_items, l, git)
1702 if (git->want_realize)
1705 _item_realize(git, 0, 0);
1706 evas_object_resize(git->base, wd->minw, git->h);
1707 evas_object_move(git->base, git->scrl_x, git->scrl_y);
1708 evas_object_show(git->base);
1709 evas_object_raise(git->base);
1712 evas_object_resize(git->base.view, wd->minw, git->h);
1713 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
1714 evas_object_show(git->base.view);
1715 evas_object_raise(git->base.view);
1719 else if (!git->want_realize && git->realized)
1722 _item_unrealize(git);
1728 _item_block_position(Item_Block *itb, int in)
1731 Elm_Genlist_Item *it;
1732 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1735 Elm_Genlist_Item *git = NULL;
1736 Elm_Genlist_Item *select_all_item = NULL;
1738 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1739 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1741 if (itb->wd->select_all_item &&
1742 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1745 select_all_item = itb->wd->select_all_item;
1747 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
1748 evas_object_move(select_all_item->base, ox, oy);
1749 evas_object_raise(select_all_item->base);
1751 if (itb->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
1752 evas_object_show(select_all_item->base);
1754 evas_object_hide(select_all_item->base);
1755 y = select_all_item->h;
1758 EINA_LIST_FOREACH(itb->items, l, it)
1760 if (it->delete_me) continue;
1764 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
1765 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
1767 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
1768 cvx, cvy, cvw, cvh));
1769 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1771 if ((itb->realized) && (!it->realized))
1773 if (vis) _item_realize(it, in, 0);
1778 _notify_item_position(it);
1781 git = it->group_item;
1784 if (git->scrl_y < oy)
1786 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
1787 git->scrl_y = (it->scrl_y + it->h) - git->h;
1788 git->want_realize = EINA_TRUE;
1790 evas_object_resize(it->base, it->w, it->h);
1791 evas_object_move(it->base,
1792 it->scrl_x, it->scrl_y);
1793 evas_object_show(it->base);
1796 is_reorder = _get_space_for_reorder_item(it);
1800 if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && !itb->reoder_y)
1802 itb->reoder_y -= it->h;
1803 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y + itb->reoder_y;
1805 else if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && itb->reoder_y)
1812 if (!it->reordering)
1814 if ((!it->wd->effect_mode ||
1815 (it->wd->effect_mode && it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE)) && !it->wd->pinch_zoom_reserve)
1817 _move_edit_controls(it,it->scrl_x, it->scrl_y);
1818 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
1820 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
1822 if (it->delete_check)
1824 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1825 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
1827 evas_object_show(it->base);
1828 it->old_pad_left = it->pad_left;
1829 it->old_scrl_y = it->scrl_y;
1837 _item_unrealize(it);
1845 if (vis) it->want_realize = EINA_TRUE;
1847 if (!it->reordering)
1851 if (itb->wd->select_all_item &&
1852 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1853 evas_object_raise(select_all_item->base);
1856 itb->wd->animate_edit_controls = 0;
1860 _calc_job(void *data)
1862 Widget_Data *wd = data;
1864 Evas_Coord minw = -1, minh = 0, y = 0, ow;
1865 Item_Block *chb = NULL;
1866 int in = 0, minw_change = 0;
1870 EINA_INLIST_FOREACH(wd->blocks, itb)
1875 showme = itb->showme;
1879 if (itb->realized) _item_block_unrealize(itb);
1883 if (itb->realized) _item_block_unrealize(itb);
1884 showme = _item_block_recalc(itb, in, 0, 1);
1890 if (minw == -1) minw = itb->minw;
1891 else if (minw < itb->minw)
1900 if ((showme) && (wd->show_item) && (wd->show_item->mincalcd))
1902 wd->show_item->showme = 0;
1904 elm_smart_scroller_region_bring_in(wd->scr,
1905 wd->show_item->x + wd->show_item->block->x,
1906 wd->show_item->y + wd->show_item->block->y,
1907 wd->show_item->block->w,
1910 elm_smart_scroller_child_region_show(wd->scr,
1911 wd->show_item->x + wd->show_item->block->x,
1912 wd->show_item->y + wd->show_item->block->y,
1913 wd->show_item->block->w,
1915 wd->show_item = NULL;
1920 EINA_INLIST_FOREACH(wd->blocks, itb)
1926 if ((chb) && (EINA_INLIST_GET(chb)->next))
1928 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1930 if (itb->realized) _item_block_unrealize(itb);
1933 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1934 if (minw < ow) minw = ow;
1935 if ((minw != wd->minw) || (minh != wd->minh) || wd->select_all_item)
1939 if (wd->select_all_item)
1940 wd->minh += wd->select_all_item->h;
1941 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1942 _sizing_eval(wd->obj);
1944 wd->calc_job = NULL;
1945 evas_object_smart_changed(wd->pan_smart);
1949 _update_job(void *data)
1951 Widget_Data *wd = data;
1954 int num, num0, position = 0, recalc = 0;
1956 wd->update_job = NULL;
1958 EINA_INLIST_FOREACH(wd->blocks, itb)
1960 Evas_Coord itminw, itminh;
1961 Elm_Genlist_Item *it;
1967 _item_block_position(itb, num);
1972 EINA_LIST_FOREACH(itb->items, l2, it)
1982 _item_unrealize(it);
1983 _item_realize(it, num, 0);
1984 evas_object_smart_callback_call(it->wd->obj,
1989 _item_realize(it, num, 1);
1990 _item_unrealize(it);
1992 if ((it->minw != itminw) || (it->minh != itminh))
2001 itb->changed = EINA_TRUE;
2002 _item_block_recalc(itb, num0, 0, 1);
2003 _item_block_position(itb, num0);
2008 if (wd->calc_job) ecore_job_del(wd->calc_job);
2009 wd->calc_job = ecore_job_add(_calc_job, wd);
2014 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2016 Pan *sd = evas_object_smart_data_get(obj);
2017 // Evas_Coord ow, oh;
2018 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2019 // ow = sd->wd->minw - ow;
2020 // if (ow < 0) ow = 0;
2021 // oh = sd->wd->minh - oh;
2022 // if (oh < 0) oh = 0;
2023 // if (x < 0) x = 0;
2024 // if (y < 0) y = 0;
2025 // if (x > ow) x = ow;
2026 // if (y > oh) y = oh;
2027 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2029 if(sd->wd->reoder_moved)
2032 if(sd->wd->pan_y >= sd->wd->minh)
2033 sd->wd->pan_y = sd->wd->minh;
2036 if(sd->wd->pan_y < y )
2037 sd->wd->pan_y = y + 5 + abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2039 sd->wd->pan_y = y - 5 - abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2047 evas_object_smart_changed(obj);
2051 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2053 Pan *sd = evas_object_smart_data_get(obj);
2055 if (x) *x = sd->wd->pan_x;
2056 if (y) *y = sd->wd->pan_y;
2058 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2060 int git_cnt = 0, git_h = 0;
2061 Elm_Genlist_Item *git;
2063 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2069 if (sd->wd->minh != (git_h+1) * git_cnt)
2071 sd->wd->minh = (git_h+1) * git_cnt;
2078 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2080 Pan *sd = evas_object_smart_data_get(obj);
2083 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2084 ow = sd->wd->minw - ow;
2086 oh = sd->wd->minh - oh;
2093 _pan_min_get(Evas_Object *obj __UNUSED__,
2102 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2104 Pan *sd = evas_object_smart_data_get(obj);
2106 if (w) *w = sd->wd->minw;
2107 if (h) *h = sd->wd->minh;
2111 _pan_add(Evas_Object *obj)
2114 Evas_Object_Smart_Clipped_Data *cd;
2117 cd = evas_object_smart_data_get(obj);
2120 sd->__clipped_data = *cd;
2122 evas_object_smart_data_set(obj, sd);
2126 _pan_del(Evas_Object *obj)
2128 Pan *sd = evas_object_smart_data_get(obj);
2135 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2137 Pan *sd = evas_object_smart_data_get(obj);
2140 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2141 if ((ow == w) && (oh == h)) return;
2142 /* don't do this... use wd->compress mode
2143 if (sd->wd->mode == ELM_LIST_COMPRESS)
2146 // this is nasty - but no choice. have to mark all as not mincalced.
2147 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2150 Elm_Genlist_Item *it;
2152 EINA_LIST_FOREACH(itb->items, l, it)
2153 it->mincalcd = EINA_FALSE;
2155 itb->changed = EINA_TRUE;
2159 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2160 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2164 _pan_calculate(Evas_Object *obj)
2166 Pan *sd = evas_object_smart_data_get(obj);
2168 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2170 Elm_Genlist_Item *git;
2173 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2174 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND) return;
2177 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2179 sd->wd->group_items_moved = EINA_TRUE;
2180 sd->wd->contract_pan_y = sd->wd->pan_y;
2181 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2183 evas_object_raise(git->base);
2184 evas_object_resize(git->base, sd->wd->minw, git->h);
2185 evas_object_move(git->base, git->x, git->y + sd->wd->pan_y * -1);
2186 evas_object_show(git->base);
2190 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2192 if (sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2193 (void)_edit_mode_reset(sd->wd);
2195 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2197 git->want_realize = EINA_FALSE;
2200 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2201 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2203 itb->w = sd->wd->minw;
2204 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2205 itb->y - sd->wd->pan_y + oy,
2207 cvx, cvy, cvw, cvh))
2209 if ((!itb->realized) || (itb->changed))
2210 _item_block_realize(itb, in, 0);
2211 _item_block_position(itb, in);
2215 if (itb->realized) _item_block_unrealize(itb);
2220 if (sd->wd->effect_mode &&
2221 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2223 _item_flip_effect_show(sd->wd);
2224 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2227 if (sd->wd->effect_mode && sd->wd->edit_mode_effect_mode)
2228 sd->wd->item_moving_effect_timer = ecore_animator_add(_edit_mode_item_moving_effect_cb, sd->wd);
2229 if ((sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) && (sd->wd->ed->reorder_item))
2231 evas_object_raise(sd->wd->ed->reorder_item->base);
2232 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2235 _group_items_recalc(sd->wd);
2236 if (sd->wd->select_all_item)
2237 evas_object_raise(sd->wd->select_all_item->base);
2241 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2243 Pan *sd = evas_object_smart_data_get(obj);
2245 if (sd->wd->effect_mode && sd->wd->multi_down) return;
2246 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2248 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2249 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2253 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2255 Widget_Data *wd = elm_widget_data_get(obj);
2257 elm_smart_scroller_hold_set(wd->scr, 1);
2261 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2263 Widget_Data *wd = elm_widget_data_get(obj);
2265 elm_smart_scroller_hold_set(wd->scr, 0);
2269 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2271 Widget_Data *wd = elm_widget_data_get(obj);
2273 elm_smart_scroller_freeze_set(wd->scr, 1);
2277 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2279 Widget_Data *wd = elm_widget_data_get(obj);
2281 elm_smart_scroller_freeze_set(wd->scr, 0);
2285 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2287 Evas_Object *obj = data;
2288 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2292 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2294 Evas_Object *obj = data;
2295 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2299 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2301 Evas_Object *obj = data;
2302 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2306 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2308 Evas_Object *obj = data;
2309 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2313 * Add a new Genlist object
2315 * @param parent The parent object
2316 * @return The new object or NULL if it cannot be created
2321 elm_genlist_add(Evas_Object *parent)
2326 Evas_Coord minw, minh;
2327 static Evas_Smart *smart = NULL;
2329 if (!parent) return NULL;
2332 static Evas_Smart_Class sc;
2334 evas_object_smart_clipped_smart_set(&_pan_sc);
2336 sc.name = "elm_genlist_pan";
2337 sc.version = EVAS_SMART_CLASS_VERSION;
2340 sc.resize = _pan_resize;
2341 sc.move = _pan_move;
2342 sc.calculate = _pan_calculate;
2343 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2345 wd = ELM_NEW(Widget_Data);
2346 e = evas_object_evas_get(parent);
2347 obj = elm_widget_add(e);
2348 ELM_SET_WIDTYPE(widtype, "genlist");
2349 elm_widget_type_set(obj, "genlist");
2350 elm_widget_sub_object_add(parent, obj);
2351 elm_widget_data_set(obj, wd);
2352 elm_widget_del_hook_set(obj, _del_hook);
2353 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2354 elm_widget_theme_hook_set(obj, _theme_hook);
2355 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2357 wd->scr = elm_smart_scroller_add(e);
2358 elm_smart_scroller_widget_set(wd->scr, obj);
2359 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2360 elm_widget_resize_object_set(obj, wd->scr);
2362 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2364 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2365 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
2366 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2367 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
2370 wd->mode = ELM_LIST_SCROLL;
2371 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2372 wd->max_items_per_block = 32;
2373 wd->longpress_timeout = _elm_config->longpress_timeout;
2374 wd->max_git_num = 0;
2376 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2377 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2378 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2379 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2381 wd->pan_smart = evas_object_smart_add(e, smart);
2382 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2385 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2386 _pan_set, _pan_get, _pan_max_get,
2387 _pan_min_get, _pan_child_size_get);
2389 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2391 evas_object_size_hint_min_set(obj, minw, minh);
2397 static Elm_Genlist_Item *
2398 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2399 const void *data, Elm_Genlist_Item *parent,
2400 Elm_Genlist_Item_Flags flags,
2402 const void *func_data)
2404 Elm_Genlist_Item *it;
2406 it = calloc(1, sizeof(Elm_Genlist_Item));
2407 if (!it) return NULL;
2411 it->parent = parent;
2413 it->func.func = func;
2414 it->func.data = func_data;
2415 it->expanded_depth = 0;
2420 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2422 Item_Block *itb = NULL;
2429 itb = calloc(1, sizeof(Item_Block));
2432 if (!it->rel->block)
2434 it->rel->block = itb;
2436 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2437 itb->items = eina_list_append(itb->items, it);
2444 eina_inlist_prepend_relative(wd->blocks,
2445 EINA_INLIST_GET(itb),
2446 EINA_INLIST_GET(it->rel->block));
2448 eina_list_prepend_relative(itb->items, it, it->rel);
2453 eina_inlist_append_relative(wd->blocks,
2454 EINA_INLIST_GET(itb),
2455 EINA_INLIST_GET(it->rel->block));
2457 eina_list_append_relative(itb->items, it, it->rel);
2467 itb = (Item_Block *)(wd->blocks);
2468 if (itb->count >= wd->max_items_per_block)
2470 itb = calloc(1, sizeof(Item_Block));
2474 eina_inlist_prepend(wd->blocks,
2475 EINA_INLIST_GET(itb));
2480 itb = calloc(1, sizeof(Item_Block));
2484 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2486 itb->items = eina_list_prepend(itb->items, it);
2492 itb = (Item_Block *)(wd->blocks->last);
2493 if (itb->count >= wd->max_items_per_block)
2495 itb = calloc(1, sizeof(Item_Block));
2499 eina_inlist_append(wd->blocks,
2500 EINA_INLIST_GET(itb));
2505 itb = calloc(1, sizeof(Item_Block));
2509 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2511 itb->items = eina_list_append(itb->items, it);
2517 itb = it->rel->block;
2518 if (!itb) goto newblock;
2520 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2522 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2525 itb->changed = EINA_TRUE;
2531 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2532 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2535 it->rel->relcount--;
2536 if ((it->rel->delete_me) && (!it->rel->relcount))
2540 if (itb->count > itb->wd->max_items_per_block)
2544 Elm_Genlist_Item *it2;
2546 newc = itb->count / 2;
2547 itb2 = calloc(1, sizeof(Item_Block));
2551 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2552 EINA_INLIST_GET(itb));
2553 itb2->changed = EINA_TRUE;
2554 while ((itb->count > newc) && (itb->items))
2558 l = eina_list_last(itb->items);
2560 itb->items = eina_list_remove_list(itb->items, l);
2563 itb2->items = eina_list_prepend(itb2->items, it2);
2571 _queue_proecess(Widget_Data *wd, int norender)
2576 t0 = ecore_time_get();
2577 for (n = 0; (wd->queue) && (n < 128); n++)
2579 Elm_Genlist_Item *it;
2581 it = wd->queue->data;
2582 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2583 it->queued = EINA_FALSE;
2584 _item_block_add(wd, it);
2585 t = ecore_time_get();
2586 if (it->block->changed)
2588 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2589 it->block->changed = 0;
2591 if (showme) it->block->showme = 1;
2592 if (eina_inlist_count(wd->blocks) > 1)
2594 if ((t - t0) > (ecore_animator_frametime_get())) break;
2601 _item_idler(void *data)
2603 Widget_Data *wd = data;
2606 //static double q_start = 0.0;
2607 //if (q_start == 0.0) q_start = ecore_time_get();
2610 if (_queue_proecess(wd, 1) > 0)
2612 if (wd->calc_job) ecore_job_del(wd->calc_job);
2613 wd->calc_job = ecore_job_add(_calc_job, wd);
2618 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2620 wd->queue_idler = NULL;
2621 if (wd->pinch_zoom_reserve)
2622 _elm_genlist_pinch_zoom_execute(wd->obj, 1);
2623 return ECORE_CALLBACK_CANCEL;
2625 return ECORE_CALLBACK_RENEW;
2629 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2631 if (!wd->queue_exception)
2633 if (it->queued) return;
2634 wd->queue = eina_list_append(wd->queue, it);
2635 it->queued = EINA_TRUE;
2638 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2640 if (wd->queue_idler)
2642 ecore_idler_del(wd->queue_idler);
2643 wd->queue_idler = NULL;
2645 _queue_proecess(wd, 0);
2647 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2648 if (wd->queue_exception)
2650 wd->queue = eina_list_append(wd->queue, it);
2651 it->queued = EINA_TRUE;
2656 * Append item to the end of the genlist
2658 * This appends the given item to the end of the list or the end of the
2659 * children if the parent is given.
2661 * @param obj The genlist object
2662 * @param itc The item class for the item
2663 * @param data The item data
2664 * @param parent The parent item, or NULL if none
2665 * @param flags Item flags
2666 * @param func Convenience function called when item selected
2667 * @param func_data Data passed to @p func above.
2668 * @return A handle to the item added or NULL if not possible
2672 EAPI Elm_Genlist_Item *
2673 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2674 const void *data, Elm_Genlist_Item *parent,
2675 Elm_Genlist_Item_Flags flags,
2676 Evas_Smart_Cb func, const void *func_data)
2678 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2679 Widget_Data *wd = elm_widget_data_get(obj);
2680 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2682 if (!wd) return NULL;
2683 if (!it) return NULL;
2686 if (flags & ELM_GENLIST_ITEM_GROUP)
2687 wd->group_items = eina_list_append(wd->group_items, it);
2688 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2693 Elm_Genlist_Item *it2 = NULL;
2694 Eina_List *ll = eina_list_last(it->parent->items);
2695 if (ll) it2 = ll->data;
2696 it->parent->items = eina_list_append(it->parent->items, it);
2697 if (!it2) it2 = it->parent;
2699 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2700 EINA_INLIST_GET(it2));
2702 it->rel->relcount++;
2704 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2705 it->group_item = parent;
2706 else if (it->parent->group_item)
2707 it->group_item = it->parent->group_item;
2709 it->before = EINA_FALSE;
2710 _item_queue(wd, it);
2715 * Prepend item at start of the genlist
2717 * This adds an item to the beginning of the list or beginning of the children
2718 * of the parent if given.
2720 * @param obj The genlist object
2721 * @param itc The item class for the item
2722 * @param data The item data
2723 * @param parent The parent item, or NULL if none
2724 * @param flags Item flags
2725 * @param func Convenience function called when item selected
2726 * @param func_data Data passed to @p func above.
2727 * @return A handle to the item added or NULL if not possible
2731 EAPI Elm_Genlist_Item *
2732 elm_genlist_item_prepend(Evas_Object *obj,
2733 const Elm_Genlist_Item_Class *itc,
2735 Elm_Genlist_Item *parent,
2736 Elm_Genlist_Item_Flags flags,
2738 const void *func_data)
2740 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2741 Widget_Data *wd = elm_widget_data_get(obj);
2742 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2744 if (!wd) return NULL;
2745 if (!it) return NULL;
2748 if (flags & ELM_GENLIST_ITEM_GROUP)
2749 wd->group_items = eina_list_prepend(wd->group_items, it);
2750 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2755 Elm_Genlist_Item *it2 = NULL;
2756 Eina_List *ll = it->parent->items;
2757 if (ll) it2 = ll->data;
2758 it->parent->items = eina_list_prepend(it->parent->items, it);
2759 if (!it2) it2 = it->parent;
2761 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2762 EINA_INLIST_GET(it2));
2764 it->rel->relcount++;
2766 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2767 it->group_item = parent;
2768 else if (it->parent->group_item)
2769 it->group_item = it->parent->group_item;
2771 it->before = EINA_TRUE;
2772 _item_queue(wd, it);
2777 * Insert item before another in the genlist
2779 * This inserts an item before another in the list. It will be in the same tree
2780 * level as the item it is inseted before.
2782 * @param obj The genlist object
2783 * @param itc The item class for the item
2784 * @param data The item data
2785 * @param parent The parent item
2786 * @param before The item to insert before
2787 * @param flags Item flags
2788 * @param func Convenience function called when item selected
2789 * @param func_data Data passed to @p func above.
2790 * @return A handle to the item added or NULL if not possible
2794 EAPI Elm_Genlist_Item *
2795 elm_genlist_item_insert_before(Evas_Object *obj,
2796 const Elm_Genlist_Item_Class *itc,
2798 Elm_Genlist_Item *parent,
2799 Elm_Genlist_Item *before,
2800 Elm_Genlist_Item_Flags flags,
2802 const void *func_data)
2804 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2805 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
2806 Widget_Data *wd = elm_widget_data_get(obj);
2807 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2809 if (!wd) return NULL;
2810 if (!it) return NULL;
2813 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2814 (before->flags & ELM_GENLIST_ITEM_GROUP))
2815 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
2820 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
2822 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2823 it->group_item = parent;
2824 else if (it->parent->group_item)
2825 it->group_item = it->parent->group_item;
2827 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2828 EINA_INLIST_GET(before));
2830 it->rel->relcount++;
2831 it->before = EINA_TRUE;
2832 _item_queue(wd, it);
2837 * Insert and item after another in the genlst
2839 * This inserts an item after another in the list. It will be in the same tree
2840 * level as the item it is inseted after.
2842 * @param obj The genlist object
2843 * @param itc The item class for the item
2844 * @param data The item data
2845 * @param parent The parent item
2846 * @param after The item to insert after
2847 * @param flags Item flags
2848 * @param func Convenience function called when item selected
2849 * @param func_data Data passed to @p func above.
2850 * @return A handle to the item added or NULL if not possible
2854 EAPI Elm_Genlist_Item *
2855 elm_genlist_item_insert_after(Evas_Object *obj,
2856 const Elm_Genlist_Item_Class *itc,
2858 Elm_Genlist_Item *parent,
2859 Elm_Genlist_Item *after,
2860 Elm_Genlist_Item_Flags flags,
2862 const void *func_data)
2864 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2865 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
2866 Widget_Data *wd = elm_widget_data_get(obj);
2867 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2869 if (!wd) return NULL;
2870 if (!it) return NULL;
2873 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2874 (after->flags & ELM_GENLIST_ITEM_GROUP))
2875 wd->group_items = eina_list_append_relative(wd->group_items, it,
2880 it->parent->items = eina_list_append_relative(it->parent->items, it,
2882 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2883 it->group_item = parent;
2884 else if (it->parent->group_item)
2885 it->group_item = it->parent->group_item;
2887 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2888 EINA_INLIST_GET(after));
2890 it->rel->relcount++;
2891 it->before = EINA_FALSE;
2892 _item_queue(wd, it);
2899 * This clears all items in the list, leaving it empty.
2901 * @param obj The genlist object
2906 elm_genlist_clear(Evas_Object *obj)
2908 ELM_CHECK_WIDTYPE(obj, widtype);
2909 Widget_Data *wd = elm_widget_data_get(obj);
2912 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
2913 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
2914 elm_smart_scroller_hold_set(wd->scr, 0);
2915 elm_smart_scroller_freeze_set(wd->scr, 0);
2916 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
2917 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2918 wd->max_git_num = 0;
2919 wd->pinch_zoom_reserve = EINA_FALSE;
2921 if (wd->item_moving_effect_timer)
2923 // ecore_timer_del(wd->item_moving_effect_timer);
2924 wd->item_moving_effect_timer = NULL;
2928 if (wd->walking > 0)
2930 Elm_Genlist_Item *it;
2933 EINA_INLIST_FOREACH(wd->items, it)
2942 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2944 wd->items = eina_inlist_remove(wd->items, wd->items);
2945 if (it->realized) _item_unrealize(it);
2946 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2947 if (it->long_timer) ecore_timer_del(it->long_timer);
2948 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2949 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
2954 Item_Block *itb = (Item_Block *)(wd->blocks);
2956 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
2957 if (itb->items) eina_list_free(itb->items);
2962 ecore_job_del(wd->calc_job);
2963 wd->calc_job = NULL;
2965 if (wd->queue_idler)
2967 ecore_idler_del(wd->queue_idler);
2968 wd->queue_idler = NULL;
2972 eina_list_free(wd->queue);
2977 eina_list_free(wd->selected);
2978 wd->selected = NULL;
2980 wd->show_item = NULL;
2987 evas_object_del(wd->alpha_bg);
2988 wd->alpha_bg = NULL;
2992 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
2993 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2999 * Enable or disable multi-select in the genlist
3001 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3002 * more than 1 item to be selected.
3004 * @param obj The genlist object
3005 * @param multi Multi-select enable/disable
3010 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3012 ELM_CHECK_WIDTYPE(obj, widtype);
3013 Widget_Data *wd = elm_widget_data_get(obj);
3019 * Gets if multi-select in genlist is enable or disable
3021 * @param obj The genlist object
3022 * @return Multi-select enable/disable
3023 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3028 elm_genlist_multi_select_get(const Evas_Object *obj)
3030 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3031 Widget_Data *wd = elm_widget_data_get(obj);
3032 if (!wd) return EINA_FALSE;
3037 * Get the selectd item in the genlist
3039 * This gets the selected item in the list (if multi-select is enabled only
3040 * the first item in the list is selected - which is not very useful, so see
3041 * elm_genlist_selected_items_get()for when multi-select is used).
3043 * If no item is selected, NULL is returned.
3045 * @param obj The genlist object
3046 * @return The selected item, or NULL if none.
3050 EAPI Elm_Genlist_Item *
3051 elm_genlist_selected_item_get(const Evas_Object *obj)
3053 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3054 Widget_Data *wd = elm_widget_data_get(obj);
3055 if (!wd) return NULL;
3056 if (wd->selected) return wd->selected->data;
3061 * Get a list of selected items in the genlist
3063 * This retgurns a list of the selected items. This list pointer is only valid
3064 * so long as no items are selected or unselected (or unselected implicitly
3065 * by deletion). The list contains Elm_Genlist_Item pointers.
3067 * @param obj The genlist object
3068 * @return The list of selected items, nor NULL if none are selected.
3072 EAPI const Eina_List *
3073 elm_genlist_selected_items_get(const Evas_Object *obj)
3075 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3076 Widget_Data *wd = elm_widget_data_get(obj);
3077 if (!wd) return NULL;
3078 return wd->selected;
3082 * Get a list of realized items in genlist
3084 * This returns a list of the realized items in the genlist. The list
3085 * contains Elm_Genlist_Item pointers. The list must be freed by the
3086 * caller when done with eina_list_free(). The item pointers in the list
3087 * are only vallid so long as those items are not deleted or the genlist is
3090 * @param obj The genlist object
3091 * @return The list of realized items, nor NULL if none are realized.
3096 elm_genlist_realized_items_get(const Evas_Object *obj)
3098 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3099 Widget_Data *wd = elm_widget_data_get(obj);
3100 Eina_List *list = NULL;
3102 Eina_Bool done = EINA_FALSE;
3103 if (!wd) return NULL;
3104 EINA_INLIST_FOREACH(wd->blocks, itb)
3109 Elm_Genlist_Item *it;
3112 EINA_LIST_FOREACH(itb->items, l, it)
3114 if (it->realized) list = eina_list_append(list, it);
3126 * Get the item that is at the x, y canvas coords
3128 * This returns the item at the given coordinates (which are canvas relative
3129 * not object-relative). If an item is at that coordinate, that item handle
3130 * is returned, and if @p posret is not NULL, the integer pointed to is set
3131 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3132 * portion of that item (-1), on the middle section (0) or on the lower part
3133 * (1). If NULL is returned as an item (no item found there), then posret
3134 * may indicate -1 or 1 based if the coordinate is above or below all items
3135 * respectively in the genlist.
3137 * @param it The item
3138 * @param x The input x coordinate
3139 * @param y The input y coordinate
3140 * @param posret The position relative to the item returned here
3141 * @return The item at the coordinates or NULL if none
3145 EAPI Elm_Genlist_Item *
3146 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3148 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3149 Widget_Data *wd = elm_widget_data_get(obj);
3150 Evas_Coord ox, oy, ow, oh;
3153 if (!wd) return NULL;
3154 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3156 EINA_INLIST_FOREACH(wd->blocks, itb)
3159 Elm_Genlist_Item *it;
3161 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3162 oy + itb->y - itb->wd->pan_y,
3163 itb->w, itb->h, x, y, 1, 1))
3165 EINA_LIST_FOREACH(itb->items, l, it)
3167 Evas_Coord itx, ity;
3169 itx = ox + itb->x + it->x - itb->wd->pan_x;
3170 ity = oy + itb->y + it->y - itb->wd->pan_y;
3171 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3175 if (y <= (ity + (it->h / 4))) *posret = -1;
3176 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3181 lasty = ity + it->h;
3186 if (y > lasty) *posret = 1;
3193 * Get the first item in the genlist
3195 * This returns the first item in the list.
3197 * @param obj The genlist object
3198 * @return The first item, or NULL if none
3202 EAPI Elm_Genlist_Item *
3203 elm_genlist_first_item_get(const Evas_Object *obj)
3205 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3206 Widget_Data *wd = elm_widget_data_get(obj);
3207 if (!wd) return NULL;
3208 if (!wd->items) return NULL;
3209 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3210 while ((it) && (it->delete_me))
3211 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3216 * Get the last item in the genlist
3218 * This returns the last item in the list.
3220 * @return The last item, or NULL if none
3224 EAPI Elm_Genlist_Item *
3225 elm_genlist_last_item_get(const Evas_Object *obj)
3227 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3228 Widget_Data *wd = elm_widget_data_get(obj);
3229 if (!wd->items) return NULL;
3230 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3231 if (!wd) return NULL;
3232 while ((it) && (it->delete_me))
3233 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3238 * Get the next item in the genlist
3240 * This returns the item after the item @p it.
3242 * @param it The item
3243 * @return The item after @p it, or NULL if none
3247 EAPI Elm_Genlist_Item *
3248 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3252 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3253 if ((it) && (!it->delete_me)) break;
3255 return (Elm_Genlist_Item *)it;
3259 * Get the previous item in the genlist
3261 * This returns the item before the item @p it.
3263 * @param it The item
3264 * @return The item before @p it, or NULL if none
3268 EAPI Elm_Genlist_Item *
3269 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3273 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3274 if ((it) && (!it->delete_me)) break;
3276 return (Elm_Genlist_Item *)it;
3280 * Get the genlist object from an item
3282 * This returns the genlist object itself that an item belongs to.
3284 * @param it The item
3285 * @return The genlist object
3290 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3292 if (!it) return NULL;
3297 * Get the parent item of the given item
3299 * This returns the prent item of the item @p it given.
3301 * @param it The item
3302 * @return The parent of the item or NULL if none
3306 EAPI Elm_Genlist_Item *
3307 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3309 if (!it) return NULL;
3314 * Clear all sub-items (children) of the given item
3316 * This clears all items that are children (or their descendants) of the
3319 * @param it The item
3324 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3327 Eina_List *tl = NULL, *l;
3328 Elm_Genlist_Item *it2;
3330 EINA_LIST_FOREACH(it->items, l, it2)
3331 tl = eina_list_append(tl, it2);
3332 EINA_LIST_FREE(tl, it2)
3333 elm_genlist_item_del(it2);
3337 * Set the selected state of an item
3339 * This sets the selected state (1 selected, 0 not selected) of the given
3342 * @param it The item
3343 * @param selected The slected state
3348 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3351 ELM_CHECK_WIDTYPE(it->wd->obj, widtype);
3352 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3354 if (it->delete_me) return;
3355 selected = !!selected;
3356 if (it->selected == selected) return;
3362 while (wd->selected)
3363 _item_unselect(wd->selected->data);
3373 * Get the selected state of an item
3375 * This gets the selected state of an item (1 selected, 0 not selected).
3377 * @param it The item
3378 * @return The selected state
3383 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3385 if (!it) return EINA_FALSE;
3386 return it->selected;
3390 * Sets the expanded state of an item (if it's a parent)
3392 * This expands or contracts a parent iterm (thus showing or hiding the
3395 * @param it The item
3396 * @param expanded The expanded state (1 expanded, 0 not expanded).
3401 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3404 if (it->expanded == expanded || it->disabled) return;
3405 it->expanded = expanded;
3406 it->wd->expand_item = it;
3407 it->effect_done = EINA_FALSE;
3410 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
3412 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3413 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3418 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
3420 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3421 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3426 * Get the expanded state of an item
3428 * This gets the expanded state of an item
3430 * @param it The item
3431 * @return Thre expanded state
3436 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3438 if (!it) return EINA_FALSE;
3439 return it->expanded;
3443 * Get the depth of expanded item
3445 * @param it The genlist item object
3446 * @return The depth of expanded item
3451 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3454 return it->expanded_depth;
3458 * Sets the disabled state of an item.
3460 * A disabled item cannot be selected or unselected. It will also change
3461 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3464 * @param it The item
3465 * @param disabled The disabled state
3470 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3473 if (it->disabled == disabled) return;
3474 if (it->delete_me) return;
3475 it->disabled = disabled;
3479 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3481 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3486 * Get the disabled state of an item
3488 * This gets the disabld state of the given item.
3490 * @param it The item
3491 * @return The disabled state
3496 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3498 if (!it) return EINA_FALSE;
3499 if (it->delete_me) return EINA_FALSE;
3500 return it->disabled;
3504 * Sets the display only state of an item.
3506 * A display only item cannot be selected or unselected. It is for display
3507 * only and not selecting or otherwise clicking, dragging etc. by the user,
3508 * thus finger size rules will not be applied to this item.
3510 * @param it The item
3511 * @param display_only The display only state
3516 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3519 if (!it->block) return;
3520 if (it->display_only == display_only) return;
3521 if (it->delete_me) return;
3522 it->display_only = display_only;
3523 it->mincalcd = EINA_FALSE;
3524 it->updateme = EINA_TRUE;
3525 it->block->updateme = EINA_TRUE;
3526 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3527 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3531 * Get the display only state of an item
3533 * This gets the display only state of the given item.
3535 * @param it The item
3536 * @return The display only state
3541 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3543 if (!it) return EINA_FALSE;
3544 if (it->delete_me) return EINA_FALSE;
3545 return it->display_only;
3549 * Show the given item
3551 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3552 * if it is not fully visible.
3554 * @param it The item
3559 elm_genlist_item_show(Elm_Genlist_Item *it)
3562 if (it->delete_me) return;
3563 Evas_Coord gith = 0;
3564 if ((it->queued) || (!it->mincalcd))
3566 it->wd->show_item = it;
3567 it->wd->bring_in = 1;
3568 it->showme = EINA_TRUE;
3571 if (it->wd->show_item)
3573 it->wd->show_item->showme = EINA_FALSE;
3574 it->wd->show_item = NULL;
3576 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3577 gith = it->group_item->h;
3578 elm_smart_scroller_child_region_show(it->wd->scr,
3579 it->x + it->block->x,
3580 it->y + it->block->y - gith,
3581 it->block->w, it->h);
3585 * Bring in the given item
3587 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3588 * if it is not fully visible. This may use animation to do so and take a
3591 * @param it The item
3596 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3599 if (it->delete_me) return;
3600 Evas_Coord gith = 0;
3601 if ((it->queued) || (!it->mincalcd))
3603 it->wd->show_item = it;
3604 it->wd->bring_in = 1;
3605 it->showme = EINA_TRUE;
3608 if (it->wd->show_item)
3610 it->wd->show_item->showme = EINA_FALSE;
3611 it->wd->show_item = NULL;
3613 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3614 gith = it->group_item->h;
3615 elm_smart_scroller_region_bring_in(it->wd->scr,
3616 it->x + it->block->x,
3617 it->y + it->block->y - gith,
3618 it->block->w, it->h);
3622 * Show the given item at the top
3624 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3625 * if it is not fully visible.
3627 * @param it The item
3632 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3636 Evas_Coord gith = 0;
3638 if (it->delete_me) return;
3639 if ((it->queued) || (!it->mincalcd))
3641 it->wd->show_item = it;
3642 it->wd->bring_in = 1;
3643 it->showme = EINA_TRUE;
3646 if (it->wd->show_item)
3648 it->wd->show_item->showme = EINA_FALSE;
3649 it->wd->show_item = NULL;
3651 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3652 if (it->group_item) gith = it->group_item->h;
3653 elm_smart_scroller_child_region_show(it->wd->scr,
3654 it->x + it->block->x,
3655 it->y + it->block->y - gith,
3661 * Bring in the given item at the top
3663 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3664 * if it is not fully visible. This may use animation to do so and take a
3667 * @param it The item
3672 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3676 Evas_Coord gith = 0;
3678 if (it->delete_me) return;
3679 if ((it->queued) || (!it->mincalcd))
3681 it->wd->show_item = it;
3682 it->wd->bring_in = 1;
3683 it->showme = EINA_TRUE;
3686 if (it->wd->show_item)
3688 it->wd->show_item->showme = EINA_FALSE;
3689 it->wd->show_item = NULL;
3691 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3692 if (it->group_item) gith = it->group_item->h;
3693 elm_smart_scroller_region_bring_in(it->wd->scr,
3694 it->x + it->block->x,
3695 it->y + it->block->y - gith,
3701 * Show the given item at the middle
3703 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3704 * if it is not fully visible.
3706 * @param it The item
3711 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3716 if (it->delete_me) return;
3717 if ((it->queued) || (!it->mincalcd))
3719 it->wd->show_item = it;
3720 it->wd->bring_in = 1;
3721 it->showme = EINA_TRUE;
3724 if (it->wd->show_item)
3726 it->wd->show_item->showme = EINA_FALSE;
3727 it->wd->show_item = NULL;
3729 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3730 elm_smart_scroller_child_region_show(it->wd->scr,
3731 it->x + it->block->x,
3732 it->y + it->block->y - oh/2 + it->h/2,
3738 * Bring in the given item at the middle
3740 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3741 * if it is not fully visible. This may use animation to do so and take a
3744 * @param it The item
3749 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3754 if (it->delete_me) return;
3755 if ((it->queued) || (!it->mincalcd))
3757 it->wd->show_item = it;
3758 it->wd->bring_in = 1;
3759 it->showme = EINA_TRUE;
3762 if (it->wd->show_item)
3764 it->wd->show_item->showme = EINA_FALSE;
3765 it->wd->show_item = NULL;
3767 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3768 elm_smart_scroller_region_bring_in(it->wd->scr,
3769 it->x + it->block->x,
3770 it->y + it->block->y - oh/2 + it->h/2,
3775 * Delete a given item
3777 * This deletes the item from genlist and calls the genlist item del class
3778 * callback defined in the item class, if it is set.
3780 * @param it The item
3785 elm_genlist_item_del(Elm_Genlist_Item *it)
3788 if ((it->relcount > 0) || (it->walking > 0))
3790 elm_genlist_item_subitems_clear(it);
3791 it->delete_me = EINA_TRUE;
3792 if (it->wd->show_item == it) it->wd->show_item = NULL;
3793 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3796 if (it->realized) _item_unrealize(it);
3797 it->block->changed = EINA_TRUE;
3798 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3799 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3801 if (it->itc->func.del)
3802 it->itc->func.del((void *)it->data, it->wd->obj);
3809 * Set the data item from the genlist item
3811 * This set the data value passed on the elm_genlist_item_append() and
3812 * related item addition calls. This function will also call
3813 * elm_genlist_item_update() so the item will be updated to reflect the
3816 * @param it The item
3817 * @param data The new data pointer to set
3822 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3826 elm_genlist_item_update(it);
3830 * Get the data item from the genlist item
3832 * This returns the data value passed on the elm_genlist_item_append() and
3833 * related item addition calls.
3835 * @param it The item
3836 * @return The data pointer provided when created
3841 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
3843 if (!it) return NULL;
3848 * Get the real evas object of the genlist item
3850 * This returns the actual evas object used for the specified genlist item.
3851 * This may be NULL as it may not be created, and ma be deleted at any time
3852 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
3853 * genlist is controlling it. This function is for querying, emitting
3854 * custom signals or hooking lower level callbacks for events. Do not
3855 * delete this object under any circumstances.
3857 * @param it The item
3858 * @return The objct pointer
3862 EAPI const Evas_Object *
3863 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
3865 if (!it) return NULL;
3870 * Update the contents of an item
3872 * This updates an item by calling all the item class functions again to get
3873 * the icons, labels and states. Use this when the original item data has
3874 * changed and the changes are desired to be reflected.
3876 * @param it The item
3881 elm_genlist_item_update(Elm_Genlist_Item *it)
3884 if (!it->block) return;
3885 if (it->delete_me) return;
3886 it->mincalcd = EINA_FALSE;
3887 it->updateme = EINA_TRUE;
3888 it->block->updateme = EINA_TRUE;
3889 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3890 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3894 * Update the item class of an item
3896 * @param it The item
3897 * @parem itc The item class for the item
3902 elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc)
3905 if (!it->block) return;
3907 if (it->delete_me) return;
3909 elm_genlist_item_update(it);
3913 * This sets the horizontal stretching mode
3915 * This sets the mode used for sizing items horizontally. Valid modes are
3916 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
3917 * mode means that if items are too wide to fit, the scroller will scroll
3918 * horizontally. Otherwise items are expanded to fill the width of the
3919 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
3920 * to the viewport width and limited to that size.
3922 * @param obj The genlist object
3923 * @param mode The mode to use
3928 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
3930 ELM_CHECK_WIDTYPE(obj, widtype);
3931 Widget_Data *wd = elm_widget_data_get(obj);
3933 if (wd->mode == mode) return;
3939 * Gets the horizontal stretching mode
3941 * @param obj The genlist object
3942 * @return The mode to use
3943 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
3948 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
3950 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
3951 Widget_Data *wd = elm_widget_data_get(obj);
3952 if (!wd) return ELM_LIST_LAST;
3957 * Set the always select mode.
3959 * Items will only call their selection func and callback when first becoming
3960 * selected. Any further clicks will do nothing, unless you enable always
3961 * select with elm_genlist_always_select_mode_set(). This means even if
3962 * selected, every click will make the selected callbacks be called.
3964 * @param obj The genlist object
3965 * @param always_select The always select mode
3966 * (EINA_TRUE = on, EINA_FALSE = off)
3971 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
3973 ELM_CHECK_WIDTYPE(obj, widtype);
3974 Widget_Data *wd = elm_widget_data_get(obj);
3976 wd->always_select = always_select;
3980 * Get the always select mode.
3982 * @param obj The genlist object
3983 * @return The always select mode
3984 * (EINA_TRUE = on, EINA_FALSE = off)
3989 elm_genlist_always_select_mode_get(const Evas_Object *obj)
3991 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3992 Widget_Data *wd = elm_widget_data_get(obj);
3993 if (!wd) return EINA_FALSE;
3994 return wd->always_select;
3998 * Set no select mode
4000 * This will turn off the ability to select items entirely and they will
4001 * neither appear selected nor call selected callback functions.
4003 * @param obj The genlist object
4004 * @param no_select The no select mode
4005 * (EINA_TRUE = on, EINA_FALSE = off)
4010 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4012 ELM_CHECK_WIDTYPE(obj, widtype);
4013 Widget_Data *wd = elm_widget_data_get(obj);
4015 wd->no_select = no_select;
4019 * Gets no select mode
4021 * @param obj The genlist object
4022 * @return The no select mode
4023 * (EINA_TRUE = on, EINA_FALSE = off)
4028 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4030 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4031 Widget_Data *wd = elm_widget_data_get(obj);
4032 if (!wd) return EINA_FALSE;
4033 return wd->no_select;
4039 * This will enable the compress mode where items are "compressed" horizontally
4040 * to fit the genlist scrollable viewport width. This is special for genlist.
4041 * Do not rely on elm_genlist_horizontal_mode_set() being set to
4042 * ELM_LIST_COMPRESS to work as genlist needs to handle it specially.
4044 * @param obj The genlist object
4045 * @param compress The compress mode
4046 * (EINA_TRUE = on, EINA_FALSE = off)
4051 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4053 ELM_CHECK_WIDTYPE(obj, widtype);
4054 Widget_Data *wd = elm_widget_data_get(obj);
4056 wd->compress = compress;
4060 * Get the compress mode
4062 * @param obj The genlist object
4063 * @return The compress mode
4064 * (EINA_TRUE = on, EINA_FALSE = off)
4069 elm_genlist_compress_mode_get(const Evas_Object *obj)
4071 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4072 Widget_Data *wd = elm_widget_data_get(obj);
4073 if (!wd) return EINA_FALSE;
4074 return wd->compress;
4080 * This will enable or disable the scroller bounce mode for the genlist. See
4081 * elm_scroller_bounce_set() for details
4083 * @param obj The genlist object
4084 * @param h_bounce Allow bounce horizontally
4085 * @param v_bounce Allow bounce vertically
4090 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4092 ELM_CHECK_WIDTYPE(obj, widtype);
4093 Widget_Data *wd = elm_widget_data_get(obj);
4095 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4099 * Get the bounce mode
4101 * @param obj The genlist object
4102 * @param h_bounce Allow bounce horizontally
4103 * @param v_bounce Allow bounce vertically
4108 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4110 ELM_CHECK_WIDTYPE(obj, widtype);
4111 Widget_Data *wd = elm_widget_data_get(obj);
4113 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4117 * Set homogenous mode
4119 * This will enable the homogeneous mode where items are of the same height and width
4120 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4122 * @param obj The genlist object
4123 * @param homogeneous Assume the items within the genlist are of the same height and width
4124 * (EINA_TRUE = on, EINA_FALSE = off)
4129 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4131 ELM_CHECK_WIDTYPE(obj, widtype);
4132 Widget_Data *wd = elm_widget_data_get(obj);
4134 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4135 wd->homogeneous = homogeneous;
4139 * Get the homogenous mode
4141 * @param obj The genlist object
4142 * @return Assume the items within the genlist are of the same height and width
4143 * (EINA_TRUE = on, EINA_FALSE = off)
4148 elm_genlist_homogeneous_get(const Evas_Object *obj)
4150 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4151 Widget_Data *wd = elm_widget_data_get(obj);
4152 if (!wd) return EINA_FALSE;
4153 return wd->homogeneous;
4157 * Set the maximum number of items within an item block
4159 * This will configure the block count to tune to the target with particular performance matrix.
4161 * @param obj The genlist object
4162 * @param n Maximum number of items within an item block
4167 elm_genlist_block_count_set(Evas_Object *obj, int n)
4169 ELM_CHECK_WIDTYPE(obj, widtype);
4170 Widget_Data *wd = elm_widget_data_get(obj);
4172 wd->max_items_per_block = n;
4176 * Get the maximum number of items within an item block
4178 * @param obj The genlist object
4179 * @return Maximum number of items within an item block
4184 elm_genlist_block_count_get(const Evas_Object *obj)
4186 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4187 Widget_Data *wd = elm_widget_data_get(obj);
4189 return wd->max_items_per_block;
4193 * Set the timeout in seconds for the longpress event
4195 * @param obj The genlist object
4196 * @param timeout timeout in seconds
4201 elm_genlist_longpress_timeout_set(Evas_Object *obj, double timeout)
4203 ELM_CHECK_WIDTYPE(obj, widtype);
4204 Widget_Data *wd = elm_widget_data_get(obj);
4206 wd->longpress_timeout = timeout;
4210 * Get the timeout in seconds for the longpress event
4212 * @param obj The genlist object
4213 * @return timeout in seconds
4218 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4220 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4221 Widget_Data *wd = elm_widget_data_get(obj);
4223 return wd->longpress_timeout;
4227 * Set the scrollbar policy
4229 * This sets the scrollbar visibility policy for the given genlist scroller.
4230 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
4231 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4232 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4233 * This applies respectively for the horizontal and vertical scrollbars.
4235 * @param obj The genlist object
4236 * @param policy_h Horizontal scrollbar policy
4237 * @param policy_v Vertical scrollbar policy
4242 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4244 ELM_CHECK_WIDTYPE(obj, widtype);
4245 Widget_Data *wd = elm_widget_data_get(obj);
4247 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4248 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4251 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4255 elm_genlist_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
4257 ELM_CHECK_WIDTYPE(obj, widtype);
4258 Widget_Data *wd = elm_widget_data_get(obj);
4259 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4260 if ((!wd) || (!wd->scr)) return;
4261 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4262 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
4263 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
4266 // added for item moving animation.
4268 _group_item_contract_moving_effect_timer_cb(void *data)
4270 Evas_Object *obj = (Evas_Object *)data;
4271 Widget_Data *wd = elm_widget_data_get(obj);
4273 Item_Block *itb = NULL;
4274 Elm_Genlist_Item *git;
4275 Elm_Genlist_Item *it;
4277 int cnt = 0, git_count = 0;
4278 double added_gy = 1;
4280 int hide_git = 0, git_cnt = 0, list_start_y = 0;
4282 int *git_array = NULL;
4283 int base_git = 0, base_git_num = 0;
4284 int tmp_y = 0, devide_size = 1;
4287 Eina_Bool finish = EINA_FALSE;
4289 Evas_Coord ox, oy, ow, oh;
4291 return ECORE_CALLBACK_CANCEL;
4293 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4294 return ECORE_CALLBACK_CANCEL;
4296 git_array = (int*)malloc(sizeof(int) * wd->max_git_num);
4297 t = ecore_loop_time_get();
4299 if (t - wd->effect_start >= 5.0)
4302 if (wd->item_count < 100)
4303 devide_size = 8 * _elm_config->scale;
4304 else if (wd->item_count < 500)
4305 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4307 devide_size = 2 * _elm_config->scale;
4309 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4312 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4313 list_start_y += wd->select_all_item->h;
4315 EINA_INLIST_FOREACH(wd->group_items, git)
4317 git_array[git_cnt++] = git->y;
4318 if (git->y < list_start_y)
4320 edje_object_signal_emit(git->base, "elm,state,alpha,disable", "elm");
4322 base_git_num = hide_git;
4324 EINA_INLIST_FOREACH(wd->group_items, git)
4326 base_git = list_start_y + git->h * (git->num - 1) + git->num;
4327 git->old_y = git->y;
4328 added_gy = abs(base_git - git->y) / devide_size;
4332 if (!git->down && git->old_y < list_start_y)
4334 git->finish_y = base_git;
4336 git->y = list_start_y - (git->h+1) * hide_git--;
4340 else if (!git->down && git->y < base_git)
4343 if (wd->pinch_zoom_reserve)
4350 if (git->y < base_git)
4353 if (git->y > base_git)
4359 if (git->y > base_git)
4362 if (git->y < base_git)
4366 if (git->num - 1 == cnt && git->y == base_git)
4369 evas_object_resize(git->base, wd->minw, git->h);
4370 evas_object_move(git->base, git->x, git->y);
4371 evas_object_raise(git->base);
4372 if (git->y < list_start_y)
4373 evas_object_lower(git->base);
4375 evas_object_raise(git->base);
4376 evas_object_show(git->base);
4378 EINA_INLIST_FOREACH(wd->blocks, itb)
4380 EINA_LIST_FOREACH(itb->items, l, it)
4382 if (it->group_item == git)
4384 if (it->group_item->old_y)
4385 it->old_scrl_y -= (it->group_item->old_y - it->group_item->y);
4387 if (git_array[it->group_item->num+1] <= it->old_scrl_y || added_gy == 1.0)
4389 evas_object_color_set(it->base, 0,0,0,0);
4390 evas_object_color_set(it->edit_obj, 0,0,0,0);
4392 _move_edit_controls(it,it->scrl_x, it->old_scrl_y);
4393 evas_object_resize(it->base, itb->wd->minw-(it->pad_left+it->pad_right), it->h);
4394 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4395 evas_object_raise(it->group_item->base);
4396 evas_object_show(it->base);
4400 if (git_count == git_cnt)
4405 if (wd->select_all_item) evas_object_raise(wd->select_all_item->base);
4410 if (finish) // finish animation
4413 EINA_INLIST_FOREACH(wd->group_items, git)
4417 wd->contract_pan_y = 0;
4418 wd->pinch_zoom_reserve = EINA_FALSE;
4419 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH;
4420 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4421 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4423 // fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT FINISH \n");
4427 EINA_INLIST_FOREACH(wd->blocks, itb)
4429 if (itb->realized) {
4430 EINA_LIST_FOREACH(itb->items, l, it)
4433 it->scrl_y = oy + tmp_y;
4435 // need to handle edit mode
4436 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4437 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
4438 evas_object_color_set(it->base, 0,0,0,0);
4439 evas_object_show(it->base);
4445 evas_object_lower(wd->alpha_bg);
4446 evas_object_hide(wd->alpha_bg);
4448 return ECORE_CALLBACK_CANCEL;
4451 return ECORE_CALLBACK_RENEW;
4454 // added for item moving animation.
4456 _group_item_expand_moving_effect_timer_cb(void *data)
4458 Evas_Object *obj = (Evas_Object *)data;
4459 Widget_Data *wd = elm_widget_data_get(obj);
4460 Elm_Genlist_Item *git, *tmp_git;
4461 Item_Block *itb = NULL;
4462 Elm_Genlist_Item *it;
4464 int cnt = 0, git_count = 0, git_cnt = 0, git_tmp_y = 0, in = 0, start_in = 0;
4465 int tmp = 0, show_git_cnt = 0, scroll_y = 0, top_git = 0 , git_h = 0, scroll_pan_y = 0, down = 0;
4466 int up_cnt = 1, down_cnt = 1, it_h = 0, devide_size = 1;
4467 static int last_git_y = 0;
4471 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4473 static double added_gy = 0; // temp value for animation speed
4474 static double added_gy2 = 0;
4475 Eina_Bool finish = EINA_FALSE;
4477 return ECORE_CALLBACK_CANCEL;
4479 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4480 return ECORE_CALLBACK_CANCEL;
4482 t = ecore_loop_time_get();
4484 top_git = wd->pinch_it;
4488 else if (top_git >= wd->max_git_num)
4489 top_git = wd->max_git_num - 1;
4491 if (wd->item_count < 100)
4492 devide_size = 8 * _elm_config->scale;
4493 else if (wd->item_count < 500)
4494 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4496 devide_size = 2 * _elm_config->scale;
4498 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4499 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4500 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4501 oy += wd->select_all_item->h;
4502 // calculate git count and srcroll move position
4503 EINA_INLIST_FOREACH(wd->group_items, git)
4505 if (git_cnt == top_git - 1)
4510 EINA_INLIST_FOREACH(wd->blocks, itb)
4512 EINA_LIST_FOREACH(itb->items, l, it)
4514 if (it->group_item == git)
4524 scroll_pan_y = scroll_y + git_h * (top_git-1) ;
4526 if (t - wd->effect_start >= 5.0)
4530 EINA_INLIST_FOREACH(wd->blocks, itb)
4532 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4533 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4538 EINA_LIST_FOREACH(itb->items, l, it)
4540 _item_realize(it, start_in, 0);
4541 it->realized = EINA_TRUE;
4544 itb->realized = EINA_TRUE;
4545 itb->want_unrealize = EINA_FALSE;
4551 if (itb->realized) _item_block_unrealize(itb);
4556 // set group item finish y and items y position of group item and items.
4559 EINA_INLIST_FOREACH(wd->group_items, git)
4561 if (git->num >= top_git)
4563 git->finish_y = git_tmp_y;
4564 git_tmp_y += git->h;
4565 tmp = git->y + git->h;
4569 git->finish_y = -1 * oh;
4571 EINA_INLIST_FOREACH(wd->blocks, itb)
4573 EINA_LIST_FOREACH(itb->items, l, it)
4575 if (it->group_item == git)
4577 if (git->finish_y != -1 * oh)
4579 it->old_scrl_y = tmp;
4581 added_gy2 = abs(git->finish_y - git->y) / devide_size;
4582 tmp += it->h - added_gy2;
4585 it->old_scrl_y = -1 * oh;
4590 if (git->finish_y >= oy && git->finish_y < oy+oh)
4594 EINA_INLIST_FOREACH(wd->group_items, git)
4598 evas_object_move(git->base, git->x, git->y);
4601 evas_object_raise(git->base);
4602 evas_object_show(git->base);
4606 evas_object_lower(git->base);
4607 evas_object_hide(git->base);
4610 added_gy = abs(git->finish_y - git->y) / devide_size;
4611 if (added_gy < 1.0) added_gy = 1.0;
4612 if (git->y > git->finish_y)
4616 if (git->num >= top_git)
4620 else if (git->y < git->finish_y)
4627 if ((!down && git->y < git->finish_y) || (down && git->y > git->finish_y))
4628 git->y = git->finish_y;
4630 if (git_cnt-1 == cnt)
4631 last_git_y = git->y;
4633 if (git->num == top_git && git->y == oy)
4635 evas_object_move(git->base, git->x, git->y);
4636 evas_object_show(git->base);
4638 EINA_INLIST_FOREACH(wd->group_items, tmp_git)
4640 if (tmp_git->y == tmp_git->finish_y && tmp_git->y > oy && tmp_git->y < oy+oh)
4647 EINA_INLIST_FOREACH(wd->blocks, itb)
4649 EINA_LIST_FOREACH(itb->items, l, it)
4651 if (it->group_item == git)
4654 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4655 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4657 evas_object_resize(it->base, wd->minw-(it->pad_left+it->pad_right), it->h);
4658 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4659 _move_edit_controls(it, it->scrl_x, it->old_scrl_y);
4660 evas_object_color_set(it->edit_obj, 255,255,255,255);
4661 evas_object_color_set(it->base, 255,255,255,255);
4662 evas_object_raise(it->base);
4663 evas_object_raise(it->group_item->base);
4671 if (git_count + 1 == show_git_cnt)
4680 wd->pan_y = scroll_y + (git_h) * (top_git-1) ;
4682 EINA_INLIST_FOREACH(wd->group_items, git)
4684 edje_object_signal_emit(git->base, "elm,state,alpha,enable", "elm");
4686 EINA_INLIST_FOREACH(wd->blocks, itb)
4688 EINA_LIST_FOREACH(itb->items, l, it)
4693 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
4694 fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND FINISH \n");
4695 elm_smart_scroller_hold_set(wd->scr, 0);
4696 elm_smart_scroller_freeze_set(wd->scr, 0);
4697 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4698 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4699 // printf("_group_item_expand_moving_effect_timer_cb FINISH \n");
4700 evas_object_lower(wd->alpha_bg);
4701 evas_object_hide(wd->alpha_bg);
4702 // evas_object_smart_changed(wd->pan_smart);
4703 if (wd->calc_job) ecore_job_del(wd->calc_job);
4704 wd->calc_job = ecore_job_add(_calc_job, wd);
4706 return ECORE_CALLBACK_CANCEL;
4709 return ECORE_CALLBACK_RENEW;
4713 _item_pinch_recalc(Evas_Object *obj, int emode)
4715 Item_Block *itb = NULL;
4717 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4718 Widget_Data *wd = elm_widget_data_get(obj);
4720 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND)
4723 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4724 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4728 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4730 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT;
4732 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4733 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE);
4734 evas_object_raise(wd->alpha_bg);
4735 evas_object_show(wd->alpha_bg);
4737 wd->effect_start = ecore_loop_time_get();
4738 wd->item_moving_effect_timer = ecore_animator_add(_group_item_contract_moving_effect_timer_cb, obj);
4741 else if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4743 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4745 evas_object_raise(wd->alpha_bg);
4746 evas_object_show(wd->alpha_bg);
4748 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND;
4749 EINA_INLIST_FOREACH(wd->blocks, itb)
4751 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4752 itb->y - wd->pan_y + oy,
4754 cvx, cvy, cvw, cvh))
4756 if (itb->realized) _item_block_unrealize(itb);
4757 itb->realized = EINA_FALSE;
4761 wd->effect_start = ecore_loop_time_get();
4762 wd->item_moving_effect_timer = ecore_animator_add(_group_item_expand_moving_effect_timer_cb, obj);
4769 create_tray_alpha_bg(const Evas_Object *obj)
4771 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4772 Widget_Data *wd = elm_widget_data_get(obj);
4773 if (!wd) return NULL;
4775 Evas_Object *bg = NULL;
4776 Evas_Coord ox, oy, ow, oh;
4778 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4779 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
4780 evas_object_color_set(bg , 0,0,0,0);
4781 evas_object_resize(bg , ow, oh);
4782 evas_object_move(bg , ox, oy);
4783 evas_object_show(bg);
4784 evas_object_hide(bg);
4789 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
4791 ELM_CHECK_WIDTYPE(obj, widtype);
4792 Widget_Data *wd = elm_widget_data_get(obj);
4793 if (!wd || !wd->pinch_zoom) return;
4794 if (!wd->queue_idler)
4797 wd->alpha_bg = create_tray_alpha_bg(obj);
4798 _item_pinch_recalc(obj, emode);
4803 * Set pinch zoom mode
4805 * @param obj The genlist object
4807 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4812 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
4814 ELM_CHECK_WIDTYPE(obj, widtype);
4815 Widget_Data *wd = elm_widget_data_get(obj);
4816 if (!wd || !wd->pinch_zoom) return;
4817 wd->pinch_zoom_reserve = emode;
4821 * Get pinch zoom mode
4823 * @param obj The genlist object
4824 * @return The pinch mode
4825 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4830 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
4832 Widget_Data *wd = elm_widget_data_get(obj);
4833 if (!wd) return EINA_FALSE;
4834 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4836 else return EINA_FALSE;
4840 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
4842 Widget_Data *wd = elm_widget_data_get(obj);
4844 wd->pinch_zoom = emode;
4847 // added for item moving animation.
4849 _item_moving_effect_timer_cb(void *data)
4851 Widget_Data *wd = data;
4853 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4854 Elm_Genlist_Item *it;
4856 int expanded_cnt = 0;
4858 static double added_gy =25;
4859 static int count = 0;
4860 if (!wd) return EINA_FALSE;
4861 if (added_gy < 1) added_gy = 1;
4864 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4865 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4867 EINA_INLIST_FOREACH(wd->blocks, itb)
4870 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4871 itb->y - wd->pan_y + oy,
4873 cvx, cvy, cvw, cvh))
4875 EINA_LIST_FOREACH(itb->items, l, it)
4877 if (!it->old_scrl_y)
4878 it->old_scrl_y = it->scrl_y;
4879 if (it->parent && it->parent->expanded && !it->showme)
4881 evas_object_hide(it->base);
4883 else evas_object_show(it->base);
4885 evas_object_show(it->base);
4887 if (itb && itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
4889 if (it->old_scrl_y && it->old_scrl_y < it->scrl_y) {
4890 it->old_scrl_y += added_gy;
4892 if (it->old_scrl_y >= it->scrl_y) {
4893 it->list_expanded = 1;
4894 it->old_scrl_y = it->scrl_y;
4897 else if (itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
4899 if (it->old_scrl_y && it->old_scrl_y > it->scrl_y)
4902 it->old_scrl_y -= added_gy;
4905 if (it->old_scrl_y <= it->scrl_y) {
4906 it->list_expanded = 1;
4907 it->old_scrl_y = it->scrl_y;
4910 expanded_cnt += it->list_expanded;
4913 _move_edit_controls(it,it->scrl_x, it->scrl_y);
4914 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
4915 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4916 evas_object_raise(it->base);
4920 if (expanded_cnt == cnt)
4922 if (wd->item_moving_effect_timer)
4926 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
4927 EINA_INLIST_FOREACH(wd->blocks, itb)
4929 EINA_LIST_FOREACH(itb->items, l, it)
4931 it->list_expanded = 0;
4936 return ECORE_CALLBACK_CANCEL;
4938 return ECORE_CALLBACK_RENEW;
4941 // added for edit mode item moving animation.
4943 _edit_mode_item_moving_effect_cb(void *data)
4945 Widget_Data *wd = data;
4947 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4948 Elm_Genlist_Item *it, *select_all_item;
4950 int expanded_cnt = 0;
4951 static double added_gy = 9;
4952 static float count = 0;
4954 static float select_all_y = 0;
4956 if (!wd) return EINA_FALSE;
4959 if (!wd->select_all_item)
4960 return ECORE_CALLBACK_CANCEL;
4962 static float dy = 9;
4967 select_all_y += (dy);
4969 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4970 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4972 EINA_INLIST_FOREACH(wd->blocks, itb)
4975 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4976 itb->y - wd->pan_y + oy,
4978 cvx, cvy, cvw, cvh))
4981 EINA_LIST_FOREACH(itb->items, l, it)
4984 evas_object_show(it->base);
4985 if (it->old_pad_left < it->pad_left)
4987 it->old_pad_left += dy;
4988 if (it->old_pad_left >= it->pad_left)
4990 it->list_expanded = 1;
4991 it->old_pad_left = it->pad_left;
4994 if (it->old_pad_left > it->pad_left)
4996 it->old_pad_left -= dy;
4997 if (it->old_pad_left <= it->pad_left)
4999 it->list_expanded = 1;
5000 it->old_pad_left = it->pad_left;
5004 if (it->old_scrl_y < it->scrl_y)
5006 it->old_scrl_y += (dy) ;
5007 if (it->old_scrl_y >= it->scrl_y)
5009 it->list_expanded = 1;
5010 it->old_scrl_y = it->scrl_y;
5014 if (it->old_scrl_y > it->scrl_y)
5016 it->old_scrl_y -= (dy);
5017 if (it->old_scrl_y <= it->scrl_y)
5019 it->list_expanded = 1;
5020 it->old_scrl_y = it->scrl_y;
5025 select_all_item = itb->wd->select_all_item;
5026 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
5027 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5028 evas_object_move(select_all_item->base, ox, oy - select_all_y);
5029 else if (select_all_y <= select_all_item->h)
5030 evas_object_move(select_all_item->base, ox, oy - select_all_item->h + select_all_y);
5031 evas_object_raise(select_all_item->base);
5032 evas_object_show(select_all_item->base);
5034 expanded_cnt += it->list_expanded;
5036 evas_object_move(it->base, it->scrl_x+it->old_pad_left, it->old_scrl_y);
5037 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
5038 evas_object_raise(it->edit_obj);
5039 evas_object_raise(it->base);
5041 evas_object_show(it->edit_obj);
5042 evas_object_show(it->base);
5044 if (select_all_y >= wd->select_all_item->h && it->list_expanded == 1)
5047 evas_object_raise(it->edit_obj);
5056 if (wd->item_moving_effect_timer)
5062 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5063 EINA_INLIST_FOREACH(wd->blocks, itb)
5065 EINA_LIST_FOREACH(itb->items, l, it)
5067 it->list_expanded = 0;
5070 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5072 if (wd->select_all_item)
5074 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5075 free(wd->select_all_item);
5077 wd->select_all_item = NULL;
5080 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5081 wd->effect_mode = 0;
5083 if (wd->calc_job) ecore_job_del(wd->calc_job);
5084 wd->calc_job = ecore_job_add(_calc_job, wd);
5085 return ECORE_CALLBACK_CANCEL;
5087 return ECORE_CALLBACK_RENEW;
5091 // added for item moving animation.
5093 _item_flip_effect_show(void *data)
5095 Widget_Data *wd = data;
5097 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5099 if (!wd) return EINA_FALSE;
5101 Elm_Genlist_Item *it;
5104 int start = 0, end = 0;
5106 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5107 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5109 EINA_INLIST_FOREACH(wd->blocks, itb)
5112 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5113 itb->y - wd->pan_y + oy,
5115 cvx, cvy, cvw, cvh))
5117 EINA_LIST_FOREACH(itb->items, l, it)
5119 if (it->parent && it->wd->expand_item == it->parent && !it->effect_done)
5121 if (!start) start = it->scrl_y;
5122 base = (Evas_Object *) it->base;
5123 edje_object_signal_emit(it->base, "flip_item", "");
5124 end = it->scrl_y + it->h;
5125 it->effect_done = EINA_TRUE;
5130 wd->expand_item_cnt = end - start;
5131 return ECORE_CALLBACK_CANCEL;
5135 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5137 ELM_CHECK_WIDTYPE(obj, widtype);
5138 Widget_Data *wd = elm_widget_data_get(obj);
5140 wd->effect_mode = emode;
5141 wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5142 evas_object_resize(wd->point_rect, 10, 25);
5143 evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5144 evas_object_show(wd->point_rect);
5145 evas_object_hide(wd->point_rect);
5149 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
5151 Widget_Data *wd = data;
5152 evas_object_hide(wd->ed->del_confirm);
5153 if (wd->ed->ec && wd->ed->ec->remove)
5154 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
5155 wd->ed->del_item = NULL;
5159 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
5161 const char *del_icon_part;
5162 Elm_Genlist_Item *it = data;
5163 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5165 edje_object_part_unswallow(it->edit_obj, it->wd->ed->del_confirm);
5166 evas_object_hide(it->wd->ed->del_confirm);
5170 _edit_item_check_set(Elm_Genlist_Item *it, Eina_Bool del_confirm_state)
5172 if (del_confirm_state)
5174 it->del_confirm_state = 0;
5175 it->delete_check = 0;
5176 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5177 it->wd->selct_all = 0;
5178 if (elm_genlist_item_parent_get(it))
5179 edje_object_signal_emit(elm_genlist_item_parent_get(it)->edit_obj, "elm,state,del,animated,enable", "elm");
5180 if (it->wd->select_all_item)
5181 edje_object_signal_emit(it->wd->select_all_item->base, "elm,state,del,animated,enable", "elm");
5182 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5183 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5187 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5188 it->del_confirm_state = 1;
5189 it->delete_check = 1;
5194 _edit_subitems_check(Elm_Genlist_Item *it)
5197 Eina_List *tl = NULL, *l;
5198 Elm_Genlist_Item *it2;
5200 EINA_LIST_FOREACH(it->items, l, it2)
5201 tl = eina_list_append(tl, it2);
5202 EINA_LIST_FREE(tl, it2)
5203 _edit_item_check_set(it2, !elm_genlist_item_parent_get(it2)->del_confirm_state);
5207 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5209 const char *del_conf_style;
5210 Elm_Genlist_Item *it = data;
5211 if (_edit_mode_reset(it->wd))
5214 if (it->edit_long_timer)
5216 ecore_timer_del(it->edit_long_timer);
5217 it->edit_long_timer = NULL;
5219 _edit_item_check_set(it, it->del_confirm_state);
5220 _edit_subitems_check(it);
5221 it->wd->ed->del_item = it;
5223 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5224 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5225 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
5227 elm_object_style_set(it->wd->ed->del_confirm, del_conf_style);
5230 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5232 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
5233 evas_object_show(it->wd->ed->del_confirm);
5238 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5240 Elm_Genlist_Item *it = data;
5242 if (_edit_mode_reset(it->wd))
5245 if (it->wd->ed->ec && it->wd->ed->ec->insert_new)
5246 it->wd->ed->ec->insert_new(it->wd->obj, it);
5250 _edit_mode_reset(Widget_Data *wd)
5253 if (wd->ed->del_confirm_state)
5255 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
5256 //wd->ed->del_confirm_state = 0;
5257 //wd->ed->del_item = NULL;
5265 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5267 Elm_Genlist_Item *it = data;
5268 Evas_Event_Mouse_Down *ev = event_info;
5271 if (it->wd->edit_field && !it->renamed)
5272 elm_genlist_item_rename_mode_set(it, 0);
5274 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
5277 if (_edit_mode_reset(it->wd))
5282 it->reoder_cavas_x = ev->canvas.x;
5283 it->reoder_cavas_y = ev->canvas.y;
5285 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5286 it->dx = ev->canvas.x - x;
5287 it->dy = ev->canvas.y - y;
5289 if (it->edit_long_timer)
5291 ecore_timer_del(it->edit_long_timer);
5292 it->edit_long_timer = NULL;
5295 it->edit_long_timer = ecore_timer_add(0.3,_edit_long_press, it);
5297 it->edit_long_timer = NULL;
5301 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5303 Elm_Genlist_Item *it = data;
5306 EINA_INLIST_FOREACH(it->wd->blocks, itb)
5310 if (it->edit_long_timer)
5312 ecore_timer_del(it->edit_long_timer);
5313 it->edit_long_timer = NULL;
5317 it->wd->reoder_moved = EINA_FALSE;
5319 if (it->wd->ed->ec->selected)
5320 it->wd->ed->ec->selected(NULL, it, 1);
5322 if (it->reordering && it->wd->ed->reorder_item)
5324 it->wd->ed->reorder_item->reordering = 0;
5325 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
5326 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
5328 if ((!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
5329 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE)))
5331 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);
5332 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y);
5334 it->wd->ed->reorder_item = NULL;
5335 it->wd->ed->reorder_rel = NULL;
5341 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5343 Elm_Genlist_Item *it = data;
5344 Evas_Event_Mouse_Move *ev = event_info;
5346 if ((it->dragging) && (it->down))
5348 if (it->edit_long_timer)
5350 ecore_timer_del(it->edit_long_timer);
5351 it->edit_long_timer = NULL;
5354 evas_object_smart_callback_call(it->wd->obj, "drag", it);
5358 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
5360 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
5361 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5362 x = ev->cur.canvas.x - x;
5363 y = ev->cur.canvas.y - y;
5366 if (adx < 0) adx = -dx;
5369 if (ady < 0) ady = -dy;
5372 if ((adx > minw) || (ady > minh))
5375 if (it->edit_long_timer)
5377 ecore_timer_del(it->edit_long_timer);
5378 it->edit_long_timer = NULL;
5382 if (it->reordering && it->wd->ed->reorder_item)
5384 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
5385 evas_object_raise(it->wd->ed->reorder_item->base);
5386 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
5387 evas_object_show(it->wd->ed->reorder_item->base);
5388 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, y);
5390 it->block->updateme = EINA_TRUE;
5392 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5393 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5400 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5403 Elm_Genlist_Item *select_all_it = data, *it;
5405 Widget_Data *wd = select_all_it->wd;
5409 edje_object_signal_emit(select_all_it->base, "elm,state,del_confirm", "elm");
5411 edje_object_signal_emit(select_all_it->base, "elm,state,del,animated,enable", "elm");
5413 EINA_INLIST_FOREACH(wd->blocks, itb)
5415 EINA_LIST_FOREACH(itb->items, l, it)
5419 it->delete_check = 1;
5420 it->del_confirm_state = 1;
5421 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5425 it->delete_check = 0;
5426 it->del_confirm_state = 0;
5427 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5431 wd->selct_all ^= 0xFF;
5433 if (wd->ed->ec->item_selected)
5434 wd->ed->ec->item_selected(select_all_it->data, select_all_it, wd->selct_all);
5435 if (wd->calc_job) ecore_job_del(wd->calc_job);
5436 wd->calc_job = ecore_job_add(_calc_job, wd);
5440 _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity)
5442 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5444 evas_object_resize(it->edit_obj,it->w, it->h);
5445 evas_object_move(it->edit_obj, itx, ity);
5446 evas_object_raise(it->edit_obj);
5450 _edit_controls_eval(Elm_Genlist_Item *it)
5453 const char *pad_str;
5460 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj)
5463 if (it->itc->func.editmode_get)
5464 itmode = it->itc->func.editmode_get(it->data, it->wd->obj, it->wd->edit_mode);
5465 itmode &= it->wd->edit_mode;
5467 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5468 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5472 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
5473 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
5474 _elm_config->scale);
5475 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5476 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
5477 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5478 else strncpy(buf, "item", sizeof(buf));
5479 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5480 // if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
5481 strncat(buf, "/", sizeof(buf) - strlen(buf));
5483 if (it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5485 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5486 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
5490 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
5493 // edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
5494 // "elm", _edit_mode_reset, it);
5497 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
5498 if (pad_str) pad = atoi(pad_str);
5500 if ((itmode & ELM_GENLIST_EDIT_MODE_INSERT))
5502 if (it->wd->animate_edit_controls)
5503 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
5505 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
5507 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
5508 "elm", _insert_new_item_cb, it);
5509 it->pad_left += pad * _elm_config->scale;
5513 if (it->wd->animate_edit_controls)
5514 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
5516 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
5518 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
5519 "elm", _insert_new_item_cb);
5522 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
5524 if (it->wd->animate_edit_controls)
5525 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5527 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5529 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5530 "elm", _remove_item_cb);
5531 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5532 "elm", _hide_delete_confirm_object);
5534 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
5535 "elm", _remove_item_cb, it);
5537 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
5538 "elm", _hide_delete_confirm_object, it);
5539 it->pad_left += pad * _elm_config->scale;
5540 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5541 _reorder_mouse_down, it);
5545 if (it->wd->animate_edit_controls)
5546 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
5548 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
5550 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5551 "elm", _remove_item_cb);
5552 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5553 "elm", _hide_delete_confirm_object);
5554 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5555 _reorder_mouse_down);
5558 if ((itmode & ELM_GENLIST_EDIT_MODE_REORDER))
5560 const char* reorder_part;
5562 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5563 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5565 edje_object_part_object_get(it->edit_obj, reorder_part);
5567 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5568 _reorder_mouse_down);
5569 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5571 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5572 _reorder_mouse_move);
5574 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5575 _reorder_mouse_down, it);
5576 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5577 _reorder_mouse_up, it);
5578 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5579 _reorder_mouse_move, it);
5581 // it->pad_right += pad * _elm_config->scale;
5585 const char* reorder_part;
5587 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5588 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5591 if (itmode == ELM_GENLIST_EDIT_MODE_NONE)
5593 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5594 _reorder_mouse_down);
5595 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5597 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5598 _reorder_mouse_move);
5603 if (it->wd->edit_mode != 0xF0) {
5604 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
5606 if (it->itc->func.icon_get)
5608 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
5613 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
5614 EINA_LIST_FOREACH(it->icons, l, key)
5616 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
5620 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5621 edje_object_part_swallow(it->edit_obj, key, ic);
5622 evas_object_show(ic);
5623 // elm_widget_sub_object_add(it->wd->obj, ic);
5630 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5631 EINA_LIST_FREE(it->edit_icon_objs, icon)
5632 evas_object_del(icon);
5634 Evas_Object *editfield;
5635 EINA_LIST_FREE(it->wd->edit_field, editfield)
5636 evas_object_del(editfield);
5640 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)//Unrealize
5642 evas_object_del(it->edit_obj);
5643 it->edit_obj = NULL;
5646 _move_edit_controls(it,it->scrl_x, it->scrl_y);
5647 evas_object_show(it->edit_obj);
5651 _notify_item_position(Elm_Genlist_Item *it)
5656 l = eina_list_last(it->parent->items);
5658 //Check if the Item is First Node or Last node of its Parent & raise signal.
5659 if (it->parent->items->data != it && l->data != it)
5661 edje_object_signal_emit(it->base, "normal_item", "elm");
5665 if (it->parent->items->data == it)
5666 edje_object_signal_emit(it->base, "first_item", "elm");
5669 edje_object_signal_emit(it->base, "last_item", "elm");
5675 _get_space_for_reorder_item(Elm_Genlist_Item *it)
5678 Evas_Coord rox, roy, row, roh;
5679 if (!it->wd->ed) return 0;
5680 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) || !it->wd->ed->reorder_item)
5682 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
5683 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
5684 rox, roy+roh/2, row, 1));
5687 it->wd->ed->reorder_rel = it;
5688 it->scrl_y+=it->wd->ed->reorder_item->h;
5689 it->reorder_check = 1;
5690 return it->wd->ed->reorder_item->h;
5696 * Moves the Genlist Item
5699 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5704 Elm_Genlist_Item *next_item = elm_genlist_item_next_get(after);
5706 if (it->y == after->y && after->reorder_check && it->reorder_check)
5708 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5709 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5713 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5714 _item_block_del(it);
5716 if ((!next_item && after->reorder_check) || (next_item && !after->reorder_check))
5719 if (next_item && !after->reorder_check && it == after)
5721 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5722 EINA_INLIST_GET(next_item));
5723 it->rel = next_item;
5727 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5728 EINA_INLIST_GET(after));
5732 it->rel->relcount++;
5739 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
5740 EINA_INLIST_GET(after));
5742 it->rel->relcount++;
5746 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
5750 after->reorder_check = 0;
5751 _item_queue(it->wd, it);
5755 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5757 fprintf(stderr, "=================> Caution!!! <========================\n");
5758 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
5759 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
5760 fprintf(stderr, "=======================================================\n");
5762 elm_genlist_edit_mode_set(obj, emode, edit_class);
5766 * Set Genlist edit mode
5768 * This sets Genlist edit mode.
5770 * @param obj The Genlist object
5771 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5772 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5777 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5779 Elm_Genlist_Item *it;
5783 static Elm_Genlist_Item_Class itc;
5785 ELM_CHECK_WIDTYPE(obj, widtype);
5786 Widget_Data *wd = elm_widget_data_get(obj);
5788 if (wd->edit_mode == emode) return;
5790 wd->edit_mode = emode;
5791 wd->animate_edit_controls = 1;
5793 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5794 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
5796 if (wd->edit_mode_effect_mode)
5798 wd->effect_mode = EINA_TRUE;
5799 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE;
5802 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5804 if (wd->ed) free (wd->ed);
5810 wd->ed = calloc(1, sizeof(Edit_Data));
5812 wd->ed->ec = edit_class;
5814 if (((wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)) && !wd->ed->del_confirm)
5816 wd->ed->del_confirm = elm_button_add(wd->obj);
5817 elm_button_label_set(wd->ed->del_confirm, "Delete");
5818 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
5819 edje_object_scale_set(wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
5820 _elm_config->scale);
5821 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd);
5824 EINA_INLIST_FOREACH(wd->blocks, itb)
5826 EINA_LIST_FOREACH(itb->items, l, it)
5828 if (it->flags != ELM_GENLIST_ITEM_GROUP)
5830 it->delete_check = 0;
5831 it->del_confirm_state = 0;
5833 _edit_controls_eval(it);
5837 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5839 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
5840 itc.item_style = edit_class->select_all_item_style;
5842 itc.item_style = "select_all";
5843 itc.func.label_get = NULL;
5844 itc.func.icon_get = NULL;
5845 itc.func.del = NULL;
5846 itc.func.editmode_get = NULL;
5848 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
5851 if (!wd->select_all_item) return;
5853 _item_realize(wd->select_all_item, 0, 0);
5854 edje_object_signal_callback_add(wd->select_all_item->base, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
5856 wd->select_all_item->rel = NULL;
5857 wd->select_all_item->selected = 0;
5858 wd->select_all_item->before = 1;
5859 wd->select_all_item->block = NULL;
5860 wd->select_all_minh = wd->minh + wd->select_all_item->h;
5862 else if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
5864 if (wd->select_all_item)
5866 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5867 free(wd->select_all_item);
5869 wd->select_all_item = NULL;
5871 edje_object_signal_emit(wd->scr, "elm,state,edit,animated,enable", "elm");
5873 if (wd->calc_job) ecore_job_del(wd->calc_job);
5874 wd->calc_job = ecore_job_add(_calc_job, wd);
5878 * Delete selected items in genlist edit mode.
5880 * @param obj The genlist object
5885 elm_genlist_edit_selected_items_del(Evas_Object *obj)
5887 Elm_Genlist_Item *it;
5889 Item_Block *itb = NULL;
5891 ELM_CHECK_WIDTYPE(obj, widtype);
5892 Widget_Data *wd = elm_widget_data_get(obj);
5894 if (!wd->blocks) return;
5896 EINA_INLIST_FOREACH(wd->blocks, itb)
5898 if (!wd->blocks) break;
5902 EINA_LIST_FOREACH(itb->items, l, it)
5904 if (it->delete_check)
5906 it->wd->effect_mode = EINA_TRUE;
5910 itb->wd->minh -= it->h;
5911 itb->wd->select_all_minh -= it->h;
5914 if ((it->relcount > 0) || (it->walking > 0))
5916 elm_genlist_item_subitems_clear(it);
5917 it->delete_me = EINA_TRUE;
5918 if (it->wd->show_item == it) it->wd->show_item = NULL;
5919 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5922 if (it->realized) _item_unrealize(it);
5923 it->block->changed = EINA_TRUE;
5925 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
5929 it->wd->walking -= it->walking;
5930 if (it->wd->show_item == it) it->wd->show_item = NULL;
5931 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5932 if (it->realized) _item_unrealize(it);
5934 EINA_LIST_FREE(it->edit_icon_objs, icon)
5935 evas_object_del(icon);
5937 Evas_Object *editfield;
5938 EINA_LIST_FREE(it->wd->edit_field, editfield)
5939 evas_object_del(editfield);
5941 evas_object_del(it->edit_obj);
5942 it->edit_obj = NULL;
5944 itb->items = eina_list_remove(itb->items, it);
5946 itb->changed = EINA_TRUE;
5947 if ((!it->delete_me) && (it->itc->func.del))
5948 it->itc->func.del(it->data, it->wd->obj);
5949 it->delete_me = EINA_TRUE;
5951 it->wd->queue = eina_list_remove(it->wd->queue, it);
5952 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5954 it->parent->items = eina_list_remove(it->parent->items, it);
5955 if (it->long_timer) ecore_timer_del(it->long_timer);
5957 it->group_item->items = eina_list_remove(it->group_item->items,it);
5964 evas_render(evas_object_evas_get(wd->obj));
5965 if (wd->calc_job) ecore_job_del(wd->calc_job);
5966 wd->calc_job = ecore_job_add(_calc_job, wd);
5970 elm_genlist_selected_items_del(Evas_Object *obj)
5972 fprintf(stderr, "=================> Caution!!! <========================\n");
5973 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
5974 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
5975 fprintf(stderr, "=======================================================\n");
5976 elm_genlist_edit_selected_items_del(obj);
5980 * Get a list of selected items in genlist
5982 * This returns a list of the selected items in the genlist. The list
5983 * contains Elm_Genlist_Item pointers. The list must be freed by the
5984 * caller when done with eina_list_free(). The item pointers in the list
5985 * are only vallid so long as those items are not deleted or the genlist is
5988 * @param obj The genlist object
5989 * @return The list of selected items, nor NULL if none are selected.
5994 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
5996 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5997 Widget_Data *wd = elm_widget_data_get(obj);
5998 Eina_List *list = NULL;
6000 if (!wd) return NULL;
6002 EINA_INLIST_FOREACH(wd->blocks, itb)
6005 Elm_Genlist_Item *it;
6007 EINA_LIST_FOREACH(itb->items, l, it)
6009 if (it->delete_check) list = eina_list_append(list, it);
6017 * Set a given item's rename mode
6019 * This renames the item's label from genlist
6021 * @param it The item
6022 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6027 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6031 const Eina_List *l, *list, *l2;
6032 const char *label, *rename_swallow_part;
6034 Eina_Bool done = EINA_FALSE;
6035 int label_cnt = 0 , swallow_part_cnt = 0;
6038 Evas_Object *editfield;
6039 Evas_Object *entry = NULL;
6040 int edit_field_cnt = 0;
6043 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6045 it->wd->edit_mode = 0xF0;
6046 _edit_controls_eval(it);
6049 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6054 Elm_Genlist_Item *it;
6057 EINA_LIST_FOREACH(itb->items, l, it)
6061 it->renamed = EINA_FALSE;
6063 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6065 entry = elm_editfield_entry_get(editfield);
6066 const char *text = elm_entry_entry_get(entry);
6068 if (it->itc->func.label_changed)
6069 it->itc->func.label_changed(it->data, it, text, edit_field_cnt++);
6071 Ecore_IMF_Context *imf = elm_entry_imf_context_get(entry);
6072 ecore_imf_context_input_panel_hide(imf);
6074 Evas_Object *editfield;
6075 EINA_LIST_FREE(it->wd->edit_field, editfield)
6076 evas_object_del(editfield);
6078 if (it->wd->edit_mode)
6080 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_INSERT))
6081 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
6083 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT))
6084 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6086 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
6087 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6091 evas_object_del(it->edit_obj);
6092 it->edit_obj = NULL;
6094 EINA_LIST_FREE(it->edit_icon_objs, icon)
6095 evas_object_del(icon);
6105 // if (emode != ELM_GENLIST_RENAME_MODE_NONE)
6108 it->renamed = EINA_TRUE;
6110 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
6111 EINA_LIST_FOREACH(it->labels, list, label)
6113 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6114 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6115 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6116 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6118 if (it->itc->func.label_get)
6120 it->renamed = EINA_TRUE;
6121 swallow_part_cnt = 0;
6123 EINA_LIST_FREE(it->edit_icon_objs, icon)
6124 evas_object_del(icon);
6125 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6126 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6128 if (label_cnt == swallow_part_cnt)
6130 editfield = elm_editfield_add(it->wd->obj);
6131 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6133 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6134 elm_editfield_eraser_set(editfield, EINA_TRUE);
6135 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6136 elm_widget_sub_object_add(it->edit_obj, editfield);
6138 evas_object_show(editfield);
6140 s = it->itc->func.label_get(it->data, it->wd->obj, list->data);
6144 Evas_Object *entry = elm_editfield_entry_get(editfield);
6145 elm_entry_entry_set(entry,s);
6150 elm_editfield_guide_text_set(editfield, "Text Input");
6159 if (it->wd->edit_mode == 0xF0)
6161 it->wd->edit_mode = 0;
6165 EAPI Elm_Genlist_Item *
6166 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6169 _print_deprecated("elm_genlist_groupitem_add", "elm_genlist_item_append");
6170 return elm_genlist_item_append(obj, itc, data, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
6173 EAPI Elm_Genlist_Item *
6174 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6175 const void *data, Elm_Genlist_Item *parent,
6176 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6177 Evas_Smart_Cb func, const void *func_data)
6179 _print_deprecated("elm_genlist_item_append_with_group", "elm_genlist_item_append");
6180 return elm_genlist_item_append(obj, itc, data, git, flags, func, func_data);
6183 EAPI Elm_Genlist_Item *
6184 elm_genlist_item_prepend_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6185 const void *data, Elm_Genlist_Item *parent,
6186 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6187 Evas_Smart_Cb func, const void *func_data)
6189 _print_deprecated("elm_genlist_item_prepend_with_group", "elm_genlist_item_prepend");
6190 return elm_genlist_item_prepend(obj, itc, data, git, flags, func, func_data);
6194 elm_genlist_groupitem_del(Elm_Genlist_Item *git)
6196 _print_deprecated("elm_genlist_groupitem_del", "elm_genlist_item_del");
6197 return elm_genlist_item_del(git);
6201 _print_deprecated(const char *deprecated, const char *new)
6203 fprintf(stderr, "=================> Caution!!! <========================\n");
6204 fprintf(stderr, "==> %s () is deprecated.\n", deprecated);
6205 fprintf(stderr, "==> Use %s() instead.\n", new);
6206 fprintf(stderr, "=======================================================\n");
6210 elm_genlist_queue_exception_set(const Evas_Object *obj, Eina_Bool emode)
6212 ELM_CHECK_WIDTYPE(obj, widtype);
6213 Widget_Data *wd = elm_widget_data_get(obj);
6215 wd->queue_exception = emode;
6217 fprintf(stderr, "=================> Caution!!! <========================\n");
6218 fprintf(stderr, "==> elm_genlist_queue_exception_set() is for demo. <===\n");
6219 fprintf(stderr, "==> Do not use this API <==\n");
6220 fprintf(stderr, "=======================================================\n");