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;
904 _edit_long_press(void *data)
906 Elm_Genlist_Item *it = data, *it_tmp;
908 static Eina_Bool contracted = EINA_FALSE;
912 it->edit_long_timer = NULL;
913 if ((it->disabled) || (it->dragging)) return 0;
915 EINA_INLIST_FOREACH(it->wd->blocks, itb)
917 EINA_LIST_FOREACH(itb->items, l, it_tmp)
919 if(!it_tmp->parent && elm_genlist_item_expanded_get(it_tmp))
921 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
922 contracted = EINA_TRUE;
929 contracted = EINA_FALSE;
933 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
935 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
937 it->dx = it->reoder_cavas_x - x;
938 it->dy = it->reoder_cavas_y - y;
940 evas_object_raise(it->base);
941 evas_object_raise(it->edit_obj);
943 it->wd->ed->reorder_item = it;
944 it->wd->ed->reorder_item->reordering = 1;
945 it->wd->ed->reorder_rel = NULL;
946 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
947 it->wd->reoder_pan_y = it->wd->pan_y;
948 it->wd->reoder_moved = EINA_TRUE;
955 _multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
957 Elm_Genlist_Item *it = data;
958 Evas_Event_Multi_Down *ev = event_info;
959 Evas_Coord dx, dy, adx, ady;
963 ecore_timer_del(it->long_timer);
964 it->long_timer = NULL;
967 dx = it->wd->td1_x - ev->canvas.x;
969 if (adx < 0) adx = -dx;
970 dy = it->wd->td1_y - ev->canvas.y;
972 if (ady < 0) ady = -dy;
974 if (adx < 60 && ady < 60)
977 it->wd->multi_down = 1;
978 it->wd->td2_x = ev->canvas.x;
979 it->wd->td2_y = ev->canvas.y;
981 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
983 evas_object_move(it->wd->point_rect, 2, (it->wd->td1_y + it->wd->td2_y) / 2);
984 evas_object_raise(it->wd->point_rect);
985 evas_object_show(it->wd->point_rect);
987 fprintf(stderr, "\n MULTI_DOWN - BUTTON ID = %d, x= %d, y= %d\n", ev->device, it->wd->td2_x, it->wd->td2_y);
992 _multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
994 Elm_Genlist_Item *it = data;
995 Evas_Event_Multi_Up *ev = event_info;
996 Evas_Coord dy, uy, ady, auy;
999 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);
1001 if (!it->wd->multi_down)
1004 it->wd->multi_down = 0;
1005 it->wd->tu2_x = ev->canvas.x;
1006 it->wd->tu2_y = ev->canvas.y;
1007 it->wd->d2_x = ev->canvas.x - it->wd->td2_x;
1008 it->wd->d2_y = ev->canvas.y - it->wd->td2_y;
1010 evas_object_lower(it->wd->point_rect);
1011 evas_object_hide(it->wd->point_rect);
1015 it->wd->multi_touch = EINA_TRUE;
1019 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);
1021 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1023 // Two finger : Left -> Right
1024 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1025 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1026 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1028 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1030 // Two finger : Top -> Bottom
1031 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1032 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1033 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1037 dy = it->wd->td1_y - it->wd->td2_y;
1043 uy = it->wd->tu1_y - it->wd->tu2_y;
1053 // Two finger : Pinch Out
1054 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1056 if (it->wd->effect_mode == EINA_TRUE)
1057 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1064 // Two finger : Pinch In
1065 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1067 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1069 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1071 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1072 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);
1073 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1083 it->wd->prev_multi_x = 0;
1084 it->wd->prev_multi_y = 0;
1089 _multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1091 Elm_Genlist_Item *it = data;
1092 Evas_Event_Multi_Move *ev = event_info;
1093 Evas_Coord acc_x, acc_y;
1095 if (!it->wd->prev_multi_x)
1097 it->wd->prev_multi_x = ev->cur.canvas.x;
1098 it->wd->prev_multi_y = ev->cur.canvas.y;
1102 acc_x = it->wd->prev_multi_x - ev->cur.canvas.x;
1104 it->wd->acc_x2 = it->wd->acc_x2 - acc_x;
1106 it->wd->acc_x2 = it->wd->acc_x2 + acc_x;
1108 acc_y = it->wd->prev_multi_y - ev->cur.canvas.y;
1110 it->wd->acc_y2 = it->wd->acc_y2 - acc_y;
1112 it->wd->acc_y2 = it->wd->acc_y2 + acc_y;
1114 it->wd->prev_multi_x = ev->cur.canvas.x;
1115 it->wd->prev_multi_y = ev->cur.canvas.y;
1119 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1121 Elm_Genlist_Item *it = data;
1122 Evas_Event_Mouse_Down *ev = event_info;
1125 it->wd->group_items_moved = EINA_FALSE;
1126 it->wd->td1_x = ev->canvas.x;
1127 it->wd->td1_y = ev->canvas.y;
1128 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
1130 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1134 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
1135 (void)_edit_mode_reset(it->wd);
1136 if (ev->button != 1) return;
1137 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1139 it->wd->on_hold = EINA_TRUE;
1142 if (it->wd->edit_field && !it->renamed)
1143 elm_genlist_item_rename_mode_set(it, 0);
1147 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1148 it->dx = ev->canvas.x - x;
1149 it->dy = ev->canvas.y - y;
1150 it->wd->longpressed = EINA_FALSE;
1151 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1152 else it->wd->on_hold = EINA_FALSE;
1153 if (it->wd->on_hold) return;
1154 it->wd->wasselected = it->selected;
1156 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1157 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
1158 if (it->long_timer) ecore_timer_del(it->long_timer);
1160 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it);
1162 it->long_timer = NULL;
1166 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1168 Elm_Genlist_Item *it = data;
1169 Evas_Event_Mouse_Up *ev = event_info;
1170 Eina_Bool dragged = EINA_FALSE;
1171 Evas_Coord dy, uy, ady, auy;
1174 if (ev->button != 1) return;
1179 it->wd->tu1_x = ev->canvas.x;
1180 it->wd->tu1_y = ev->canvas.y;
1181 it->wd->d1_x = ev->canvas.x - it->wd->td1_x;
1182 it->wd->d1_y = ev->canvas.y - it->wd->td1_y;
1184 // evas_object_lower(it->wd->point_rect);
1185 // evas_object_hide(it->wd->point_rect);
1186 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
1188 if (!it->wd->multi_down && it->wd->multi_touch == EINA_TRUE)
1190 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1192 // Two finger : Left -> Right
1193 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1194 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1195 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1197 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1199 // Two finger : Top -> Bottom
1200 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1201 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1202 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1206 dy = it->wd->td1_y - it->wd->td2_y;
1207 if (dy < 0) ady = -dy;
1210 uy = it->wd->tu1_y - it->wd->tu2_y;
1211 if (uy < 0) auy = -uy;
1218 // Two finger : Pinch Out
1219 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1220 if (it->wd->effect_mode == EINA_TRUE)
1221 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1228 // Two finger : Pinch In
1229 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1230 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1232 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1234 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1235 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);
1236 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1247 it->wd->prev_multi_x = 0;
1248 it->wd->prev_multi_y = 0;
1249 it->wd->multi_down = 0;
1252 it->wd->multi_touch = EINA_FALSE;
1254 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1255 else it->wd->on_hold = EINA_FALSE;
1258 ecore_timer_del(it->long_timer);
1259 it->long_timer = NULL;
1264 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
1267 if (it->wd->on_hold)
1269 it->wd->longpressed = EINA_FALSE;
1270 it->wd->on_hold = EINA_FALSE;
1273 if (it->wd->longpressed)
1275 it->wd->longpressed = EINA_FALSE;
1276 if (!it->wd->wasselected)
1278 it->wd->wasselected = 0;
1283 if (it->want_unrealize)
1285 _item_unrealize(it);
1286 if (it->block->want_unrealize)
1287 _item_block_unrealize(it->block);
1290 if ((it->disabled) || (dragged)) return;
1291 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1294 if (!it->selected && !it->menuopened)
1299 else _item_unselect(it);
1305 Widget_Data *wd = it->wd;
1308 while (wd->selected) _item_unselect(wd->selected->data);
1313 const Eina_List *l, *l_next;
1314 Elm_Genlist_Item *it2;
1316 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1317 if (it2 != it) _item_unselect(it2);
1318 //_item_hilight(it);
1321 if (!it->menuopened)
1330 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1332 Elm_Genlist_Item *it = data;
1335 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1337 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1341 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1343 Elm_Genlist_Item *it = data;
1346 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1350 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1352 Elm_Genlist_Item *it = data;
1355 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1359 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1361 Elm_Genlist_Item *it2;
1362 const char *stacking;
1363 const char *treesize;
1365 int depth, tsize = 20;
1367 if ((it->realized) || (it->delete_me)) return;
1368 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1369 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1370 _elm_config->scale);
1371 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1372 elm_widget_sub_object_add(it->wd->obj, it->base);
1374 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1375 else strncpy(buf, "item", sizeof(buf));
1376 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1378 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1379 strncat(buf, "/", sizeof(buf) - strlen(buf));
1380 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1382 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1383 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1384 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1385 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1386 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1388 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1390 it->expanded_depth = depth;
1391 treesize = edje_object_data_get(it->base, "treesize");
1392 if (treesize) tsize = atoi(treesize);
1393 evas_object_size_hint_min_set(it->spacer,
1394 (depth * tsize) * _elm_config->scale, 1);
1395 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1398 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1399 "elm", _signal_expand_toggle, it);
1400 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1401 _signal_expand, it);
1402 edje_object_signal_callback_add(it->base, "elm,action,contract",
1403 "elm", _signal_contract, it);
1404 stacking = edje_object_data_get(it->base, "stacking");
1407 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1408 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1410 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1412 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1414 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1416 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_DOWN,
1418 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_UP,
1420 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_MOVE,
1422 if (it->selected && !it->menuopened)
1423 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1425 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1427 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1430 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1432 /* homogenous genlist shortcut */
1435 it->w = it->minw = it->wd->item_width;
1436 it->h = it->minh = it->wd->item_height;
1437 it->mincalcd = EINA_TRUE;
1442 if (!strcmp(it->itc->item_style, "select_all"))
1447 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
1448 EINA_LIST_FOREACH(it->labels, l, key) {
1449 edje_object_part_text_set(it->base, l->data, "Select all");
1453 if (it->itc->func.label_get)
1458 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
1459 EINA_LIST_FOREACH(it->labels, l, key)
1461 char *s = it->itc->func.label_get
1462 ((void *)it->data, it->wd->obj, l->data);
1466 edje_object_part_text_set(it->base, l->data, s);
1470 edje_object_part_text_set(it->base, l->data, "");*/
1473 if (it->itc->func.icon_get)
1478 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->base, "icons"));
1479 EINA_LIST_FOREACH(it->icons, l, key)
1481 Evas_Object *ic = it->itc->func.icon_get
1482 ((void *)it->data, it->wd->obj, l->data);
1486 it->icon_objs = eina_list_append(it->icon_objs, ic);
1487 edje_object_part_swallow(it->base, key, ic);
1488 evas_object_show(ic);
1489 elm_widget_sub_object_add(it->wd->obj, ic);
1493 if (it->itc->func.state_get)
1498 it->states = elm_widget_stringlist_get(edje_object_data_get(it->base, "states"));
1499 EINA_LIST_FOREACH(it->states, l, key)
1501 Eina_Bool on = it->itc->func.state_get
1502 (it->data, it->wd->obj, l->data);
1506 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1507 edje_object_signal_emit(it->base, buf, "elm");
1511 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1512 edje_object_signal_emit(it->base, buf, "elm");
1518 Evas_Coord mw = -1, mh = -1;
1520 if (!it->display_only)
1521 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1522 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1523 if (!it->display_only)
1524 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1525 it->w = it->minw = mw;
1526 it->h = it->minh = mh;
1527 it->mincalcd = EINA_TRUE;
1529 if ((!in) && (it->wd->homogeneous))
1531 it->wd->item_width = mw;
1532 it->wd->item_height = mh;
1535 if (!calc) evas_object_show(it->base);
1538 it->realized = EINA_TRUE;
1539 it->want_unrealize = EINA_FALSE;
1540 if ((ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode) &&
1541 (it->flags != ELM_GENLIST_ITEM_GROUP))
1544 EINA_LIST_FREE(it->edit_icon_objs, icon)
1545 evas_object_del(icon);
1546 _edit_controls_eval(it);
1551 _item_unrealize(Elm_Genlist_Item *it)
1555 if (!it->realized) return;
1556 evas_object_smart_callback_call(it->wd->obj, "unrealized", it);
1557 it->menuopened = EINA_FALSE;
1558 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
1561 ecore_timer_del(it->long_timer);
1562 it->long_timer = NULL;
1564 evas_object_del(it->base);
1566 evas_object_del(it->spacer);
1569 evas_object_del(it->edit_obj);
1570 it->edit_obj = NULL;
1571 elm_widget_stringlist_free(it->labels);
1573 elm_widget_stringlist_free(it->icons);
1575 elm_widget_stringlist_free(it->states);
1577 EINA_LIST_FREE(it->icon_objs, icon)
1578 evas_object_del(icon);
1580 EINA_LIST_FREE(it->edit_icon_objs, icon)
1581 evas_object_del(icon);
1584 it->realized = EINA_FALSE;
1585 it->want_unrealize = EINA_FALSE;
1589 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1592 Elm_Genlist_Item *it;
1593 Evas_Coord minw = 0, minh = 0;
1594 int showme = 0, changed = 0;
1598 EINA_LIST_FOREACH(itb->items, l, it)
1600 if (it->delete_me) continue;
1601 showme |= it->showme;
1606 if (!it->mincalcd) changed = 1;
1609 _item_realize(it, in, 1);
1610 _item_unrealize(it);
1615 _item_realize(it, in, 1);
1616 _item_unrealize(it);
1621 Eina_Bool was_realized = it->realized;
1623 _item_realize(it, in, 0);
1625 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1628 if (minw < it->minw) minw = it->minw;
1637 itb->changed = EINA_FALSE;
1638 /* force an evas norender to garbage collect deleted objects */
1639 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1644 _item_block_realize(Item_Block *itb, int in, int full)
1647 Elm_Genlist_Item *it;
1649 if (itb->realized) return;
1650 EINA_LIST_FOREACH(itb->items, l, it)
1652 if (it->delete_me) continue;
1655 Eina_Bool was_realized = it->realized;
1657 _item_realize(it, in, 0);
1659 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1663 itb->realized = EINA_TRUE;
1664 itb->want_unrealize = EINA_FALSE;
1668 _item_block_unrealize(Item_Block *itb)
1671 Elm_Genlist_Item *it;
1674 if (!itb->realized) return;
1675 EINA_LIST_FOREACH(itb->items, l, it)
1677 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1679 if (it->dragging || it->reordering)
1682 it->want_unrealize = EINA_TRUE;
1685 _item_unrealize(it);
1690 itb->realized = EINA_FALSE;
1691 itb->want_unrealize = EINA_TRUE;
1694 itb->want_unrealize = EINA_FALSE;
1698 _group_items_recalc(void *data)
1700 Widget_Data *wd = data;
1702 Elm_Genlist_Item *git;
1704 EINA_LIST_FOREACH(wd->group_items, l, git)
1706 if (git->want_realize)
1710 _item_realize(git, 0, 0);
1711 evas_object_smart_callback_call(git->wd->obj, "realized", git);
1713 evas_object_resize(git->base, wd->minw, git->h);
1714 evas_object_move(git->base, git->scrl_x, git->scrl_y);
1715 evas_object_show(git->base);
1716 evas_object_raise(git->base);
1719 evas_object_resize(git->base.view, wd->minw, git->h);
1720 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
1721 evas_object_show(git->base.view);
1722 evas_object_raise(git->base.view);
1726 else if (!git->want_realize && git->realized)
1729 _item_unrealize(git);
1735 _item_block_position(Item_Block *itb, int in)
1738 Elm_Genlist_Item *it;
1739 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1742 Elm_Genlist_Item *git = NULL;
1743 Elm_Genlist_Item *select_all_item = NULL;
1745 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1746 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1748 if (itb->wd->select_all_item &&
1749 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1752 select_all_item = itb->wd->select_all_item;
1754 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
1755 evas_object_move(select_all_item->base, ox, oy);
1756 evas_object_raise(select_all_item->base);
1758 if (itb->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
1759 evas_object_show(select_all_item->base);
1761 evas_object_hide(select_all_item->base);
1762 y = select_all_item->h;
1765 EINA_LIST_FOREACH(itb->items, l, it)
1767 if (it->delete_me) continue;
1771 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
1772 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
1774 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
1775 cvx, cvy, cvw, cvh));
1776 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1778 if ((itb->realized) && (!it->realized))
1782 _item_realize(it, in, 0);
1783 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1789 _notify_item_position(it);
1792 git = it->group_item;
1795 if (git->scrl_y < oy)
1797 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
1798 git->scrl_y = (it->scrl_y + it->h) - git->h;
1799 git->want_realize = EINA_TRUE;
1801 evas_object_resize(it->base, it->w, it->h);
1802 evas_object_move(it->base,
1803 it->scrl_x, it->scrl_y);
1804 evas_object_show(it->base);
1807 is_reorder = _get_space_for_reorder_item(it);
1811 if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && !itb->reoder_y)
1813 itb->reoder_y -= it->h;
1814 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y + itb->reoder_y;
1816 else if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && itb->reoder_y)
1823 if (!it->reordering)
1825 if ((!it->wd->effect_mode ||
1826 (it->wd->effect_mode && it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE)) && !it->wd->pinch_zoom_reserve)
1828 _move_edit_controls(it,it->scrl_x, it->scrl_y);
1829 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
1831 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
1833 if (it->delete_check)
1835 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1836 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
1838 evas_object_show(it->base);
1839 it->old_pad_left = it->pad_left;
1840 it->old_scrl_y = it->scrl_y;
1848 _item_unrealize(it);
1856 if (vis) it->want_realize = EINA_TRUE;
1858 if (!it->reordering)
1862 if (itb->wd->select_all_item &&
1863 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1864 evas_object_raise(select_all_item->base);
1867 itb->wd->animate_edit_controls = 0;
1871 _calc_job(void *data)
1873 Widget_Data *wd = data;
1875 Evas_Coord minw = -1, minh = 0, y = 0, ow;
1876 Item_Block *chb = NULL;
1877 int in = 0, minw_change = 0;
1881 EINA_INLIST_FOREACH(wd->blocks, itb)
1886 showme = itb->showme;
1890 if (itb->realized) _item_block_unrealize(itb);
1894 if (itb->realized) _item_block_unrealize(itb);
1895 showme = _item_block_recalc(itb, in, 0, 1);
1901 if (minw == -1) minw = itb->minw;
1902 else if (minw < itb->minw)
1911 if ((showme) && (wd->show_item) && (wd->show_item->mincalcd))
1913 wd->show_item->showme = 0;
1915 elm_smart_scroller_region_bring_in(wd->scr,
1916 wd->show_item->x + wd->show_item->block->x,
1917 wd->show_item->y + wd->show_item->block->y,
1918 wd->show_item->block->w,
1921 elm_smart_scroller_child_region_show(wd->scr,
1922 wd->show_item->x + wd->show_item->block->x,
1923 wd->show_item->y + wd->show_item->block->y,
1924 wd->show_item->block->w,
1926 wd->show_item = NULL;
1931 EINA_INLIST_FOREACH(wd->blocks, itb)
1937 if ((chb) && (EINA_INLIST_GET(chb)->next))
1939 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1941 if (itb->realized) _item_block_unrealize(itb);
1944 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1945 if (minw < ow) minw = ow;
1946 if ((minw != wd->minw) || (minh != wd->minh) || wd->select_all_item)
1950 if (wd->select_all_item)
1951 wd->minh += wd->select_all_item->h;
1952 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1953 _sizing_eval(wd->obj);
1955 wd->calc_job = NULL;
1956 evas_object_smart_changed(wd->pan_smart);
1960 _update_job(void *data)
1962 Widget_Data *wd = data;
1965 int num, num0, position = 0, recalc = 0;
1967 wd->update_job = NULL;
1969 EINA_INLIST_FOREACH(wd->blocks, itb)
1971 Evas_Coord itminw, itminh;
1972 Elm_Genlist_Item *it;
1978 _item_block_position(itb, num);
1983 EINA_LIST_FOREACH(itb->items, l2, it)
1993 _item_unrealize(it);
1994 _item_realize(it, num, 0);
1995 evas_object_smart_callback_call(it->wd->obj,
2000 _item_realize(it, num, 1);
2001 _item_unrealize(it);
2003 if ((it->minw != itminw) || (it->minh != itminh))
2012 itb->changed = EINA_TRUE;
2013 _item_block_recalc(itb, num0, 0, 1);
2014 _item_block_position(itb, num0);
2019 if (wd->calc_job) ecore_job_del(wd->calc_job);
2020 wd->calc_job = ecore_job_add(_calc_job, wd);
2025 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2027 Pan *sd = evas_object_smart_data_get(obj);
2028 // Evas_Coord ow, oh;
2029 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2030 // ow = sd->wd->minw - ow;
2031 // if (ow < 0) ow = 0;
2032 // oh = sd->wd->minh - oh;
2033 // if (oh < 0) oh = 0;
2034 // if (x < 0) x = 0;
2035 // if (y < 0) y = 0;
2036 // if (x > ow) x = ow;
2037 // if (y > oh) y = oh;
2038 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2040 if(sd->wd->reoder_moved)
2043 if(sd->wd->pan_y >= sd->wd->minh)
2044 sd->wd->pan_y = sd->wd->minh;
2047 if(sd->wd->pan_y < y )
2048 sd->wd->pan_y = y + 5 + abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2050 sd->wd->pan_y = y - 5 - abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2058 evas_object_smart_changed(obj);
2062 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2064 Pan *sd = evas_object_smart_data_get(obj);
2066 if (x) *x = sd->wd->pan_x;
2067 if (y) *y = sd->wd->pan_y;
2069 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2071 int git_cnt = 0, git_h = 0;
2072 Elm_Genlist_Item *git;
2074 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2080 if (sd->wd->minh != (git_h+1) * git_cnt)
2082 sd->wd->minh = (git_h+1) * git_cnt;
2089 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2091 Pan *sd = evas_object_smart_data_get(obj);
2094 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2095 ow = sd->wd->minw - ow;
2097 oh = sd->wd->minh - oh;
2104 _pan_min_get(Evas_Object *obj __UNUSED__,
2113 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2115 Pan *sd = evas_object_smart_data_get(obj);
2117 if (w) *w = sd->wd->minw;
2118 if (h) *h = sd->wd->minh;
2122 _pan_add(Evas_Object *obj)
2125 Evas_Object_Smart_Clipped_Data *cd;
2128 cd = evas_object_smart_data_get(obj);
2131 sd->__clipped_data = *cd;
2133 evas_object_smart_data_set(obj, sd);
2137 _pan_del(Evas_Object *obj)
2139 Pan *sd = evas_object_smart_data_get(obj);
2146 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2148 Pan *sd = evas_object_smart_data_get(obj);
2151 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2152 if ((ow == w) && (oh == h)) return;
2153 /* don't do this... use wd->compress mode
2154 if (sd->wd->mode == ELM_LIST_COMPRESS)
2157 // this is nasty - but no choice. have to mark all as not mincalced.
2158 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2161 Elm_Genlist_Item *it;
2163 EINA_LIST_FOREACH(itb->items, l, it)
2164 it->mincalcd = EINA_FALSE;
2166 itb->changed = EINA_TRUE;
2170 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2171 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2175 _pan_calculate(Evas_Object *obj)
2177 Pan *sd = evas_object_smart_data_get(obj);
2179 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2181 Elm_Genlist_Item *git;
2184 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2185 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND) return;
2188 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2190 sd->wd->group_items_moved = EINA_TRUE;
2191 sd->wd->contract_pan_y = sd->wd->pan_y;
2192 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2194 evas_object_raise(git->base);
2195 evas_object_resize(git->base, sd->wd->minw, git->h);
2196 evas_object_move(git->base, git->x, git->y + sd->wd->pan_y * -1);
2197 evas_object_show(git->base);
2201 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2203 if (sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2204 (void)_edit_mode_reset(sd->wd);
2206 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2208 git->want_realize = EINA_FALSE;
2211 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2212 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2214 itb->w = sd->wd->minw;
2215 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2216 itb->y - sd->wd->pan_y + oy,
2218 cvx, cvy, cvw, cvh))
2220 if ((!itb->realized) || (itb->changed))
2221 _item_block_realize(itb, in, 0);
2222 _item_block_position(itb, in);
2226 if (itb->realized) _item_block_unrealize(itb);
2231 if (sd->wd->effect_mode &&
2232 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2234 _item_flip_effect_show(sd->wd);
2235 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2238 if (sd->wd->effect_mode && sd->wd->edit_mode_effect_mode)
2239 sd->wd->item_moving_effect_timer = ecore_animator_add(_edit_mode_item_moving_effect_cb, sd->wd);
2240 if ((sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) && (sd->wd->ed->reorder_item))
2242 evas_object_raise(sd->wd->ed->reorder_item->base);
2243 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2246 _group_items_recalc(sd->wd);
2247 if (sd->wd->select_all_item)
2248 evas_object_raise(sd->wd->select_all_item->base);
2252 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2254 Pan *sd = evas_object_smart_data_get(obj);
2256 if (sd->wd->effect_mode && sd->wd->multi_down) return;
2257 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2259 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2260 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2264 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2266 Widget_Data *wd = elm_widget_data_get(obj);
2268 elm_smart_scroller_hold_set(wd->scr, 1);
2272 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2274 Widget_Data *wd = elm_widget_data_get(obj);
2276 elm_smart_scroller_hold_set(wd->scr, 0);
2280 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2282 Widget_Data *wd = elm_widget_data_get(obj);
2284 elm_smart_scroller_freeze_set(wd->scr, 1);
2288 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2290 Widget_Data *wd = elm_widget_data_get(obj);
2292 elm_smart_scroller_freeze_set(wd->scr, 0);
2296 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2298 Evas_Object *obj = data;
2299 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2303 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2305 Evas_Object *obj = data;
2306 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2310 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2312 Evas_Object *obj = data;
2313 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2317 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2319 Evas_Object *obj = data;
2320 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2324 * Add a new Genlist object
2326 * @param parent The parent object
2327 * @return The new object or NULL if it cannot be created
2332 elm_genlist_add(Evas_Object *parent)
2337 Evas_Coord minw, minh;
2338 static Evas_Smart *smart = NULL;
2340 if (!parent) return NULL;
2343 static Evas_Smart_Class sc;
2345 evas_object_smart_clipped_smart_set(&_pan_sc);
2347 sc.name = "elm_genlist_pan";
2348 sc.version = EVAS_SMART_CLASS_VERSION;
2351 sc.resize = _pan_resize;
2352 sc.move = _pan_move;
2353 sc.calculate = _pan_calculate;
2354 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2356 wd = ELM_NEW(Widget_Data);
2357 e = evas_object_evas_get(parent);
2358 obj = elm_widget_add(e);
2359 ELM_SET_WIDTYPE(widtype, "genlist");
2360 elm_widget_type_set(obj, "genlist");
2361 elm_widget_sub_object_add(parent, obj);
2362 elm_widget_data_set(obj, wd);
2363 elm_widget_del_hook_set(obj, _del_hook);
2364 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2365 elm_widget_theme_hook_set(obj, _theme_hook);
2366 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2368 wd->scr = elm_smart_scroller_add(e);
2369 elm_smart_scroller_widget_set(wd->scr, obj);
2370 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2371 elm_widget_resize_object_set(obj, wd->scr);
2373 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2375 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2376 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
2377 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2378 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
2381 wd->mode = ELM_LIST_SCROLL;
2382 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2383 wd->max_items_per_block = 32;
2384 wd->longpress_timeout = _elm_config->longpress_timeout;
2385 wd->max_git_num = 0;
2387 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2388 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2389 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2390 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2392 wd->pan_smart = evas_object_smart_add(e, smart);
2393 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2396 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2397 _pan_set, _pan_get, _pan_max_get,
2398 _pan_min_get, _pan_child_size_get);
2400 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2402 evas_object_size_hint_min_set(obj, minw, minh);
2408 static Elm_Genlist_Item *
2409 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2410 const void *data, Elm_Genlist_Item *parent,
2411 Elm_Genlist_Item_Flags flags,
2413 const void *func_data)
2415 Elm_Genlist_Item *it;
2417 it = calloc(1, sizeof(Elm_Genlist_Item));
2418 if (!it) return NULL;
2422 it->parent = parent;
2424 it->func.func = func;
2425 it->func.data = func_data;
2426 it->expanded_depth = 0;
2431 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2433 Item_Block *itb = NULL;
2440 itb = calloc(1, sizeof(Item_Block));
2443 if (!it->rel->block)
2445 it->rel->block = itb;
2447 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2448 itb->items = eina_list_append(itb->items, it);
2455 eina_inlist_prepend_relative(wd->blocks,
2456 EINA_INLIST_GET(itb),
2457 EINA_INLIST_GET(it->rel->block));
2459 eina_list_prepend_relative(itb->items, it, it->rel);
2464 eina_inlist_append_relative(wd->blocks,
2465 EINA_INLIST_GET(itb),
2466 EINA_INLIST_GET(it->rel->block));
2468 eina_list_append_relative(itb->items, it, it->rel);
2478 itb = (Item_Block *)(wd->blocks);
2479 if (itb->count >= wd->max_items_per_block)
2481 itb = calloc(1, sizeof(Item_Block));
2485 eina_inlist_prepend(wd->blocks,
2486 EINA_INLIST_GET(itb));
2491 itb = calloc(1, sizeof(Item_Block));
2495 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2497 itb->items = eina_list_prepend(itb->items, it);
2503 itb = (Item_Block *)(wd->blocks->last);
2504 if (itb->count >= wd->max_items_per_block)
2506 itb = calloc(1, sizeof(Item_Block));
2510 eina_inlist_append(wd->blocks,
2511 EINA_INLIST_GET(itb));
2516 itb = calloc(1, sizeof(Item_Block));
2520 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2522 itb->items = eina_list_append(itb->items, it);
2528 itb = it->rel->block;
2529 if (!itb) goto newblock;
2531 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2533 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2536 itb->changed = EINA_TRUE;
2542 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2543 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2546 it->rel->relcount--;
2547 if ((it->rel->delete_me) && (!it->rel->relcount))
2551 if (itb->count > itb->wd->max_items_per_block)
2555 Elm_Genlist_Item *it2;
2557 newc = itb->count / 2;
2558 itb2 = calloc(1, sizeof(Item_Block));
2562 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2563 EINA_INLIST_GET(itb));
2564 itb2->changed = EINA_TRUE;
2565 while ((itb->count > newc) && (itb->items))
2569 l = eina_list_last(itb->items);
2571 itb->items = eina_list_remove_list(itb->items, l);
2574 itb2->items = eina_list_prepend(itb2->items, it2);
2582 _queue_proecess(Widget_Data *wd, int norender)
2587 t0 = ecore_time_get();
2588 for (n = 0; (wd->queue) && (n < 128); n++)
2590 Elm_Genlist_Item *it;
2592 it = wd->queue->data;
2593 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2594 it->queued = EINA_FALSE;
2595 _item_block_add(wd, it);
2596 t = ecore_time_get();
2597 if (it->block->changed)
2599 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2600 it->block->changed = 0;
2602 if (showme) it->block->showme = 1;
2603 if (eina_inlist_count(wd->blocks) > 1)
2605 if ((t - t0) > (ecore_animator_frametime_get())) break;
2612 _item_idler(void *data)
2614 Widget_Data *wd = data;
2617 //static double q_start = 0.0;
2618 //if (q_start == 0.0) q_start = ecore_time_get();
2621 if (_queue_proecess(wd, 1) > 0)
2623 if (wd->calc_job) ecore_job_del(wd->calc_job);
2624 wd->calc_job = ecore_job_add(_calc_job, wd);
2629 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2631 wd->queue_idler = NULL;
2632 if (wd->pinch_zoom_reserve)
2633 _elm_genlist_pinch_zoom_execute(wd->obj, 1);
2634 return ECORE_CALLBACK_CANCEL;
2636 return ECORE_CALLBACK_RENEW;
2640 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2642 if (!wd->queue_exception)
2644 if (it->queued) return;
2645 wd->queue = eina_list_append(wd->queue, it);
2646 it->queued = EINA_TRUE;
2649 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2651 if (wd->queue_idler)
2653 ecore_idler_del(wd->queue_idler);
2654 wd->queue_idler = NULL;
2656 _queue_proecess(wd, 0);
2658 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2659 if (wd->queue_exception)
2661 wd->queue = eina_list_append(wd->queue, it);
2662 it->queued = EINA_TRUE;
2667 * Append item to the end of the genlist
2669 * This appends the given item to the end of the list or the end of the
2670 * children if the parent is given.
2672 * @param obj The genlist object
2673 * @param itc The item class for the item
2674 * @param data The item data
2675 * @param parent The parent item, or NULL if none
2676 * @param flags Item flags
2677 * @param func Convenience function called when item selected
2678 * @param func_data Data passed to @p func above.
2679 * @return A handle to the item added or NULL if not possible
2683 EAPI Elm_Genlist_Item *
2684 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2685 const void *data, Elm_Genlist_Item *parent,
2686 Elm_Genlist_Item_Flags flags,
2687 Evas_Smart_Cb func, const void *func_data)
2689 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2690 Widget_Data *wd = elm_widget_data_get(obj);
2691 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2693 if (!wd) return NULL;
2694 if (!it) return NULL;
2697 if (flags & ELM_GENLIST_ITEM_GROUP)
2698 wd->group_items = eina_list_append(wd->group_items, it);
2699 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2704 Elm_Genlist_Item *it2 = NULL;
2705 Eina_List *ll = eina_list_last(it->parent->items);
2706 if (ll) it2 = ll->data;
2707 it->parent->items = eina_list_append(it->parent->items, it);
2708 if (!it2) it2 = it->parent;
2710 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2711 EINA_INLIST_GET(it2));
2713 it->rel->relcount++;
2715 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2716 it->group_item = parent;
2717 else if (it->parent->group_item)
2718 it->group_item = it->parent->group_item;
2720 it->before = EINA_FALSE;
2721 _item_queue(wd, it);
2726 * Prepend item at start of the genlist
2728 * This adds an item to the beginning of the list or beginning of the children
2729 * of the parent if given.
2731 * @param obj The genlist object
2732 * @param itc The item class for the item
2733 * @param data The item data
2734 * @param parent The parent item, or NULL if none
2735 * @param flags Item flags
2736 * @param func Convenience function called when item selected
2737 * @param func_data Data passed to @p func above.
2738 * @return A handle to the item added or NULL if not possible
2742 EAPI Elm_Genlist_Item *
2743 elm_genlist_item_prepend(Evas_Object *obj,
2744 const Elm_Genlist_Item_Class *itc,
2746 Elm_Genlist_Item *parent,
2747 Elm_Genlist_Item_Flags flags,
2749 const void *func_data)
2751 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2752 Widget_Data *wd = elm_widget_data_get(obj);
2753 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2755 if (!wd) return NULL;
2756 if (!it) return NULL;
2759 if (flags & ELM_GENLIST_ITEM_GROUP)
2760 wd->group_items = eina_list_prepend(wd->group_items, it);
2761 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2766 Elm_Genlist_Item *it2 = NULL;
2767 Eina_List *ll = it->parent->items;
2768 if (ll) it2 = ll->data;
2769 it->parent->items = eina_list_prepend(it->parent->items, it);
2770 if (!it2) it2 = it->parent;
2772 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2773 EINA_INLIST_GET(it2));
2775 it->rel->relcount++;
2777 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2778 it->group_item = parent;
2779 else if (it->parent->group_item)
2780 it->group_item = it->parent->group_item;
2782 it->before = EINA_TRUE;
2783 _item_queue(wd, it);
2788 * Insert item before another in the genlist
2790 * This inserts an item before another in the list. It will be in the same tree
2791 * level as the item it is inseted before.
2793 * @param obj The genlist object
2794 * @param itc The item class for the item
2795 * @param data The item data
2796 * @param parent The parent item
2797 * @param before The item to insert before
2798 * @param flags Item flags
2799 * @param func Convenience function called when item selected
2800 * @param func_data Data passed to @p func above.
2801 * @return A handle to the item added or NULL if not possible
2805 EAPI Elm_Genlist_Item *
2806 elm_genlist_item_insert_before(Evas_Object *obj,
2807 const Elm_Genlist_Item_Class *itc,
2809 Elm_Genlist_Item *parent,
2810 Elm_Genlist_Item *before,
2811 Elm_Genlist_Item_Flags flags,
2813 const void *func_data)
2815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2816 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
2817 Widget_Data *wd = elm_widget_data_get(obj);
2818 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2820 if (!wd) return NULL;
2821 if (!it) return NULL;
2824 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2825 (before->flags & ELM_GENLIST_ITEM_GROUP))
2826 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
2831 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
2833 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2834 it->group_item = parent;
2835 else if (it->parent->group_item)
2836 it->group_item = it->parent->group_item;
2838 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2839 EINA_INLIST_GET(before));
2841 it->rel->relcount++;
2842 it->before = EINA_TRUE;
2843 _item_queue(wd, it);
2848 * Insert and item after another in the genlst
2850 * This inserts an item after another in the list. It will be in the same tree
2851 * level as the item it is inseted after.
2853 * @param obj The genlist object
2854 * @param itc The item class for the item
2855 * @param data The item data
2856 * @param parent The parent item
2857 * @param after The item to insert after
2858 * @param flags Item flags
2859 * @param func Convenience function called when item selected
2860 * @param func_data Data passed to @p func above.
2861 * @return A handle to the item added or NULL if not possible
2865 EAPI Elm_Genlist_Item *
2866 elm_genlist_item_insert_after(Evas_Object *obj,
2867 const Elm_Genlist_Item_Class *itc,
2869 Elm_Genlist_Item *parent,
2870 Elm_Genlist_Item *after,
2871 Elm_Genlist_Item_Flags flags,
2873 const void *func_data)
2875 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2876 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
2877 Widget_Data *wd = elm_widget_data_get(obj);
2878 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2880 if (!wd) return NULL;
2881 if (!it) return NULL;
2884 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2885 (after->flags & ELM_GENLIST_ITEM_GROUP))
2886 wd->group_items = eina_list_append_relative(wd->group_items, it,
2891 it->parent->items = eina_list_append_relative(it->parent->items, it,
2893 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2894 it->group_item = parent;
2895 else if (it->parent->group_item)
2896 it->group_item = it->parent->group_item;
2898 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2899 EINA_INLIST_GET(after));
2901 it->rel->relcount++;
2902 it->before = EINA_FALSE;
2903 _item_queue(wd, it);
2910 * This clears all items in the list, leaving it empty.
2912 * @param obj The genlist object
2917 elm_genlist_clear(Evas_Object *obj)
2919 ELM_CHECK_WIDTYPE(obj, widtype);
2920 Widget_Data *wd = elm_widget_data_get(obj);
2923 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
2924 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
2925 elm_smart_scroller_hold_set(wd->scr, 0);
2926 elm_smart_scroller_freeze_set(wd->scr, 0);
2927 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
2928 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2929 wd->max_git_num = 0;
2930 wd->pinch_zoom_reserve = EINA_FALSE;
2932 if (wd->item_moving_effect_timer)
2934 // ecore_timer_del(wd->item_moving_effect_timer);
2935 wd->item_moving_effect_timer = NULL;
2937 if (wd->walking > 0)
2939 Elm_Genlist_Item *it;
2942 EINA_INLIST_FOREACH(wd->items, it)
2951 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2953 wd->items = eina_inlist_remove(wd->items, wd->items);
2954 if (it->realized) _item_unrealize(it);
2955 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2956 if (it->long_timer) ecore_timer_del(it->long_timer);
2957 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2958 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
2963 Item_Block *itb = (Item_Block *)(wd->blocks);
2965 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
2966 if (itb->items) eina_list_free(itb->items);
2971 ecore_job_del(wd->calc_job);
2972 wd->calc_job = NULL;
2974 if (wd->queue_idler)
2976 ecore_idler_del(wd->queue_idler);
2977 wd->queue_idler = NULL;
2981 eina_list_free(wd->queue);
2986 eina_list_free(wd->selected);
2987 wd->selected = NULL;
2989 wd->show_item = NULL;
2996 evas_object_del(wd->alpha_bg);
2997 wd->alpha_bg = NULL;
3001 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3002 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3008 * Enable or disable multi-select in the genlist
3010 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3011 * more than 1 item to be selected.
3013 * @param obj The genlist object
3014 * @param multi Multi-select enable/disable
3019 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3021 ELM_CHECK_WIDTYPE(obj, widtype);
3022 Widget_Data *wd = elm_widget_data_get(obj);
3028 * Gets if multi-select in genlist is enable or disable
3030 * @param obj The genlist object
3031 * @return Multi-select enable/disable
3032 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3037 elm_genlist_multi_select_get(const Evas_Object *obj)
3039 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3040 Widget_Data *wd = elm_widget_data_get(obj);
3041 if (!wd) return EINA_FALSE;
3046 * Get the selectd item in the genlist
3048 * This gets the selected item in the list (if multi-select is enabled only
3049 * the first item in the list is selected - which is not very useful, so see
3050 * elm_genlist_selected_items_get()for when multi-select is used).
3052 * If no item is selected, NULL is returned.
3054 * @param obj The genlist object
3055 * @return The selected item, or NULL if none.
3059 EAPI Elm_Genlist_Item *
3060 elm_genlist_selected_item_get(const Evas_Object *obj)
3062 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3063 Widget_Data *wd = elm_widget_data_get(obj);
3064 if (!wd) return NULL;
3065 if (wd->selected) return wd->selected->data;
3070 * Get a list of selected items in the genlist
3072 * This retgurns a list of the selected items. This list pointer is only valid
3073 * so long as no items are selected or unselected (or unselected implicitly
3074 * by deletion). The list contains Elm_Genlist_Item pointers.
3076 * @param obj The genlist object
3077 * @return The list of selected items, nor NULL if none are selected.
3081 EAPI const Eina_List *
3082 elm_genlist_selected_items_get(const Evas_Object *obj)
3084 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3085 Widget_Data *wd = elm_widget_data_get(obj);
3086 if (!wd) return NULL;
3087 return wd->selected;
3091 * Get a list of realized items in genlist
3093 * This returns a list of the realized items in the genlist. The list
3094 * contains Elm_Genlist_Item pointers. The list must be freed by the
3095 * caller when done with eina_list_free(). The item pointers in the list
3096 * are only vallid so long as those items are not deleted or the genlist is
3099 * @param obj The genlist object
3100 * @return The list of realized items, nor NULL if none are realized.
3105 elm_genlist_realized_items_get(const Evas_Object *obj)
3107 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3108 Widget_Data *wd = elm_widget_data_get(obj);
3109 Eina_List *list = NULL;
3111 Eina_Bool done = EINA_FALSE;
3112 if (!wd) return NULL;
3113 EINA_INLIST_FOREACH(wd->blocks, itb)
3118 Elm_Genlist_Item *it;
3121 EINA_LIST_FOREACH(itb->items, l, it)
3123 if (it->realized) list = eina_list_append(list, it);
3135 * Get the item that is at the x, y canvas coords
3137 * This returns the item at the given coordinates (which are canvas relative
3138 * not object-relative). If an item is at that coordinate, that item handle
3139 * is returned, and if @p posret is not NULL, the integer pointed to is set
3140 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3141 * portion of that item (-1), on the middle section (0) or on the lower part
3142 * (1). If NULL is returned as an item (no item found there), then posret
3143 * may indicate -1 or 1 based if the coordinate is above or below all items
3144 * respectively in the genlist.
3146 * @param it The item
3147 * @param x The input x coordinate
3148 * @param y The input y coordinate
3149 * @param posret The position relative to the item returned here
3150 * @return The item at the coordinates or NULL if none
3154 EAPI Elm_Genlist_Item *
3155 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3157 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3158 Widget_Data *wd = elm_widget_data_get(obj);
3159 Evas_Coord ox, oy, ow, oh;
3162 if (!wd) return NULL;
3163 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3165 EINA_INLIST_FOREACH(wd->blocks, itb)
3168 Elm_Genlist_Item *it;
3170 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3171 oy + itb->y - itb->wd->pan_y,
3172 itb->w, itb->h, x, y, 1, 1))
3174 EINA_LIST_FOREACH(itb->items, l, it)
3176 Evas_Coord itx, ity;
3178 itx = ox + itb->x + it->x - itb->wd->pan_x;
3179 ity = oy + itb->y + it->y - itb->wd->pan_y;
3180 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3184 if (y <= (ity + (it->h / 4))) *posret = -1;
3185 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3190 lasty = ity + it->h;
3195 if (y > lasty) *posret = 1;
3202 * Get the first item in the genlist
3204 * This returns the first item in the list.
3206 * @param obj The genlist object
3207 * @return The first item, or NULL if none
3211 EAPI Elm_Genlist_Item *
3212 elm_genlist_first_item_get(const Evas_Object *obj)
3214 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3215 Widget_Data *wd = elm_widget_data_get(obj);
3216 if (!wd) return NULL;
3217 if (!wd->items) return NULL;
3218 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3219 while ((it) && (it->delete_me))
3220 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3225 * Get the last item in the genlist
3227 * This returns the last item in the list.
3229 * @return The last item, or NULL if none
3233 EAPI Elm_Genlist_Item *
3234 elm_genlist_last_item_get(const Evas_Object *obj)
3236 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3237 Widget_Data *wd = elm_widget_data_get(obj);
3238 if (!wd) return NULL;
3239 if (!wd->items) return NULL;
3240 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3241 if (!wd) return NULL;
3242 while ((it) && (it->delete_me))
3243 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3248 * Get the next item in the genlist
3250 * This returns the item after the item @p it.
3252 * @param it The item
3253 * @return The item after @p it, or NULL if none
3257 EAPI Elm_Genlist_Item *
3258 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3262 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3263 if ((it) && (!it->delete_me)) break;
3265 return (Elm_Genlist_Item *)it;
3269 * Get the previous item in the genlist
3271 * This returns the item before the item @p it.
3273 * @param it The item
3274 * @return The item before @p it, or NULL if none
3278 EAPI Elm_Genlist_Item *
3279 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3283 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3284 if ((it) && (!it->delete_me)) break;
3286 return (Elm_Genlist_Item *)it;
3290 * Get the genlist object from an item
3292 * This returns the genlist object itself that an item belongs to.
3294 * @param it The item
3295 * @return The genlist object
3300 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3302 if (!it) return NULL;
3307 * Get the parent item of the given item
3309 * This returns the prent item of the item @p it given.
3311 * @param it The item
3312 * @return The parent of the item or NULL if none
3316 EAPI Elm_Genlist_Item *
3317 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3319 if (!it) return NULL;
3324 * Clear all sub-items (children) of the given item
3326 * This clears all items that are children (or their descendants) of the
3329 * @param it The item
3334 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3337 Eina_List *tl = NULL, *l;
3338 Elm_Genlist_Item *it2;
3340 EINA_LIST_FOREACH(it->items, l, it2)
3341 tl = eina_list_append(tl, it2);
3342 EINA_LIST_FREE(tl, it2)
3343 elm_genlist_item_del(it2);
3347 * Set the selected state of an item
3349 * This sets the selected state (1 selected, 0 not selected) of the given
3352 * @param it The item
3353 * @param selected The slected state
3358 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3361 ELM_CHECK_WIDTYPE(it->wd->obj, widtype);
3362 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3364 if (it->delete_me) return;
3365 selected = !!selected;
3366 if (it->selected == selected) return;
3372 while (wd->selected)
3373 _item_unselect(wd->selected->data);
3383 * Get the selected state of an item
3385 * This gets the selected state of an item (1 selected, 0 not selected).
3387 * @param it The item
3388 * @return The selected state
3393 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3395 if (!it) return EINA_FALSE;
3396 return it->selected;
3400 * Sets the expanded state of an item (if it's a parent)
3402 * This expands or contracts a parent iterm (thus showing or hiding the
3405 * @param it The item
3406 * @param expanded The expanded state (1 expanded, 0 not expanded).
3411 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3414 if (it->expanded == expanded || it->disabled) return;
3415 it->expanded = expanded;
3416 it->wd->expand_item = it;
3417 it->effect_done = EINA_FALSE;
3420 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
3422 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3423 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3428 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
3430 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3431 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3436 * Get the expanded state of an item
3438 * This gets the expanded state of an item
3440 * @param it The item
3441 * @return Thre expanded state
3446 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3448 if (!it) return EINA_FALSE;
3449 return it->expanded;
3453 * Get the depth of expanded item
3455 * @param it The genlist item object
3456 * @return The depth of expanded item
3461 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3464 return it->expanded_depth;
3468 * Sets the disabled state of an item.
3470 * A disabled item cannot be selected or unselected. It will also change
3471 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3474 * @param it The item
3475 * @param disabled The disabled state
3480 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3483 if (it->disabled == disabled) return;
3484 if (it->delete_me) return;
3485 it->disabled = disabled;
3489 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3491 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3496 * Get the disabled state of an item
3498 * This gets the disabld state of the given item.
3500 * @param it The item
3501 * @return The disabled state
3506 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3508 if (!it) return EINA_FALSE;
3509 if (it->delete_me) return EINA_FALSE;
3510 return it->disabled;
3514 * Sets the display only state of an item.
3516 * A display only item cannot be selected or unselected. It is for display
3517 * only and not selecting or otherwise clicking, dragging etc. by the user,
3518 * thus finger size rules will not be applied to this item.
3520 * @param it The item
3521 * @param display_only The display only state
3526 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3529 if (!it->block) return;
3530 if (it->display_only == display_only) return;
3531 if (it->delete_me) return;
3532 it->display_only = display_only;
3533 it->mincalcd = EINA_FALSE;
3534 it->updateme = EINA_TRUE;
3535 it->block->updateme = EINA_TRUE;
3536 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3537 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3541 * Get the display only state of an item
3543 * This gets the display only state of the given item.
3545 * @param it The item
3546 * @return The display only state
3551 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3553 if (!it) return EINA_FALSE;
3554 if (it->delete_me) return EINA_FALSE;
3555 return it->display_only;
3559 * Show the given item
3561 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3562 * if it is not fully visible.
3564 * @param it The item
3569 elm_genlist_item_show(Elm_Genlist_Item *it)
3572 if (it->delete_me) return;
3573 Evas_Coord gith = 0;
3574 if ((it->queued) || (!it->mincalcd))
3576 it->wd->show_item = it;
3577 it->wd->bring_in = 1;
3578 it->showme = EINA_TRUE;
3581 if (it->wd->show_item)
3583 it->wd->show_item->showme = EINA_FALSE;
3584 it->wd->show_item = NULL;
3586 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3587 gith = it->group_item->h;
3588 elm_smart_scroller_child_region_show(it->wd->scr,
3589 it->x + it->block->x,
3590 it->y + it->block->y - gith,
3591 it->block->w, it->h);
3595 * Bring in the given item
3597 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3598 * if it is not fully visible. This may use animation to do so and take a
3601 * @param it The item
3606 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3609 if (it->delete_me) return;
3610 Evas_Coord gith = 0;
3611 if ((it->queued) || (!it->mincalcd))
3613 it->wd->show_item = it;
3614 it->wd->bring_in = 1;
3615 it->showme = EINA_TRUE;
3618 if (it->wd->show_item)
3620 it->wd->show_item->showme = EINA_FALSE;
3621 it->wd->show_item = NULL;
3623 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3624 gith = it->group_item->h;
3625 elm_smart_scroller_region_bring_in(it->wd->scr,
3626 it->x + it->block->x,
3627 it->y + it->block->y - gith,
3628 it->block->w, it->h);
3632 * Show the given item at the top
3634 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3635 * if it is not fully visible.
3637 * @param it The item
3642 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3646 Evas_Coord gith = 0;
3648 if (it->delete_me) return;
3649 if ((it->queued) || (!it->mincalcd))
3651 it->wd->show_item = it;
3652 it->wd->bring_in = 1;
3653 it->showme = EINA_TRUE;
3656 if (it->wd->show_item)
3658 it->wd->show_item->showme = EINA_FALSE;
3659 it->wd->show_item = NULL;
3661 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3662 if (it->group_item) gith = it->group_item->h;
3663 elm_smart_scroller_child_region_show(it->wd->scr,
3664 it->x + it->block->x,
3665 it->y + it->block->y - gith,
3671 * Bring in the given item at the top
3673 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3674 * if it is not fully visible. This may use animation to do so and take a
3677 * @param it The item
3682 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3686 Evas_Coord gith = 0;
3688 if (it->delete_me) return;
3689 if ((it->queued) || (!it->mincalcd))
3691 it->wd->show_item = it;
3692 it->wd->bring_in = 1;
3693 it->showme = EINA_TRUE;
3696 if (it->wd->show_item)
3698 it->wd->show_item->showme = EINA_FALSE;
3699 it->wd->show_item = NULL;
3701 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3702 if (it->group_item) gith = it->group_item->h;
3703 elm_smart_scroller_region_bring_in(it->wd->scr,
3704 it->x + it->block->x,
3705 it->y + it->block->y - gith,
3711 * Show the given item at the middle
3713 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3714 * if it is not fully visible.
3716 * @param it The item
3721 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3726 if (it->delete_me) return;
3727 if ((it->queued) || (!it->mincalcd))
3729 it->wd->show_item = it;
3730 it->wd->bring_in = 1;
3731 it->showme = EINA_TRUE;
3734 if (it->wd->show_item)
3736 it->wd->show_item->showme = EINA_FALSE;
3737 it->wd->show_item = NULL;
3739 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3740 elm_smart_scroller_child_region_show(it->wd->scr,
3741 it->x + it->block->x,
3742 it->y + it->block->y - oh/2 + it->h/2,
3748 * Bring in the given item at the middle
3750 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3751 * if it is not fully visible. This may use animation to do so and take a
3754 * @param it The item
3759 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3764 if (it->delete_me) return;
3765 if ((it->queued) || (!it->mincalcd))
3767 it->wd->show_item = it;
3768 it->wd->bring_in = 1;
3769 it->showme = EINA_TRUE;
3772 if (it->wd->show_item)
3774 it->wd->show_item->showme = EINA_FALSE;
3775 it->wd->show_item = NULL;
3777 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3778 elm_smart_scroller_region_bring_in(it->wd->scr,
3779 it->x + it->block->x,
3780 it->y + it->block->y - oh/2 + it->h/2,
3785 * Delete a given item
3787 * This deletes the item from genlist and calls the genlist item del class
3788 * callback defined in the item class, if it is set.
3790 * @param it The item
3795 elm_genlist_item_del(Elm_Genlist_Item *it)
3798 if ((it->relcount > 0) || (it->walking > 0))
3800 elm_genlist_item_subitems_clear(it);
3801 it->delete_me = EINA_TRUE;
3802 if (it->wd->show_item == it) it->wd->show_item = NULL;
3803 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3806 if (it->realized) _item_unrealize(it);
3807 it->block->changed = EINA_TRUE;
3808 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3809 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3811 if (it->itc->func.del)
3812 it->itc->func.del((void *)it->data, it->wd->obj);
3819 * Set the data item from the genlist item
3821 * This set the data value passed on the elm_genlist_item_append() and
3822 * related item addition calls. This function will also call
3823 * elm_genlist_item_update() so the item will be updated to reflect the
3826 * @param it The item
3827 * @param data The new data pointer to set
3832 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3836 elm_genlist_item_update(it);
3840 * Get the data item from the genlist item
3842 * This returns the data value passed on the elm_genlist_item_append() and
3843 * related item addition calls.
3845 * @param it The item
3846 * @return The data pointer provided when created
3851 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
3853 if (!it) return NULL;
3858 * Get the real evas object of the genlist item
3860 * This returns the actual evas object used for the specified genlist item.
3861 * This may be NULL as it may not be created, and ma be deleted at any time
3862 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
3863 * genlist is controlling it. This function is for querying, emitting
3864 * custom signals or hooking lower level callbacks for events. Do not
3865 * delete this object under any circumstances.
3867 * @param it The item
3868 * @return The objct pointer
3872 EAPI const Evas_Object *
3873 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
3875 if (!it) return NULL;
3880 * Update the contents of an item
3882 * This updates an item by calling all the item class functions again to get
3883 * the icons, labels and states. Use this when the original item data has
3884 * changed and the changes are desired to be reflected.
3886 * @param it The item
3891 elm_genlist_item_update(Elm_Genlist_Item *it)
3894 if (!it->block) return;
3895 if (it->delete_me) return;
3896 it->mincalcd = EINA_FALSE;
3897 it->updateme = EINA_TRUE;
3898 it->block->updateme = EINA_TRUE;
3899 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3900 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3904 * Update the item class of an item
3906 * @param it The item
3907 * @parem itc The item class for the item
3912 elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc)
3915 if (!it->block) return;
3917 if (it->delete_me) return;
3919 elm_genlist_item_update(it);
3923 * This sets the horizontal stretching mode
3925 * This sets the mode used for sizing items horizontally. Valid modes are
3926 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
3927 * mode means that if items are too wide to fit, the scroller will scroll
3928 * horizontally. Otherwise items are expanded to fill the width of the
3929 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
3930 * to the viewport width and limited to that size.
3932 * @param obj The genlist object
3933 * @param mode The mode to use
3938 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
3940 ELM_CHECK_WIDTYPE(obj, widtype);
3941 Widget_Data *wd = elm_widget_data_get(obj);
3943 if (wd->mode == mode) return;
3949 * Gets the horizontal stretching mode
3951 * @param obj The genlist object
3952 * @return The mode to use
3953 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
3958 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
3960 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
3961 Widget_Data *wd = elm_widget_data_get(obj);
3962 if (!wd) return ELM_LIST_LAST;
3967 * Set the always select mode.
3969 * Items will only call their selection func and callback when first becoming
3970 * selected. Any further clicks will do nothing, unless you enable always
3971 * select with elm_genlist_always_select_mode_set(). This means even if
3972 * selected, every click will make the selected callbacks be called.
3974 * @param obj The genlist object
3975 * @param always_select The always select mode
3976 * (EINA_TRUE = on, EINA_FALSE = off)
3981 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
3983 ELM_CHECK_WIDTYPE(obj, widtype);
3984 Widget_Data *wd = elm_widget_data_get(obj);
3986 wd->always_select = always_select;
3990 * Get the always select mode.
3992 * @param obj The genlist object
3993 * @return The always select mode
3994 * (EINA_TRUE = on, EINA_FALSE = off)
3999 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4001 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4002 Widget_Data *wd = elm_widget_data_get(obj);
4003 if (!wd) return EINA_FALSE;
4004 return wd->always_select;
4008 * Set no select mode
4010 * This will turn off the ability to select items entirely and they will
4011 * neither appear selected nor call selected callback functions.
4013 * @param obj The genlist object
4014 * @param no_select The no select mode
4015 * (EINA_TRUE = on, EINA_FALSE = off)
4020 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4022 ELM_CHECK_WIDTYPE(obj, widtype);
4023 Widget_Data *wd = elm_widget_data_get(obj);
4025 wd->no_select = no_select;
4029 * Gets no select mode
4031 * @param obj The genlist object
4032 * @return The no select mode
4033 * (EINA_TRUE = on, EINA_FALSE = off)
4038 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4040 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4041 Widget_Data *wd = elm_widget_data_get(obj);
4042 if (!wd) return EINA_FALSE;
4043 return wd->no_select;
4049 * This will enable the compress mode where items are "compressed" horizontally
4050 * to fit the genlist scrollable viewport width. This is special for genlist.
4051 * Do not rely on elm_genlist_horizontal_mode_set() being set to
4052 * ELM_LIST_COMPRESS to work as genlist needs to handle it specially.
4054 * @param obj The genlist object
4055 * @param compress The compress mode
4056 * (EINA_TRUE = on, EINA_FALSE = off)
4061 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4063 ELM_CHECK_WIDTYPE(obj, widtype);
4064 Widget_Data *wd = elm_widget_data_get(obj);
4066 wd->compress = compress;
4070 * Get the compress mode
4072 * @param obj The genlist object
4073 * @return The compress mode
4074 * (EINA_TRUE = on, EINA_FALSE = off)
4079 elm_genlist_compress_mode_get(const Evas_Object *obj)
4081 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4082 Widget_Data *wd = elm_widget_data_get(obj);
4083 if (!wd) return EINA_FALSE;
4084 return wd->compress;
4090 * This will enable or disable the scroller bounce mode for the genlist. See
4091 * elm_scroller_bounce_set() for details
4093 * @param obj The genlist object
4094 * @param h_bounce Allow bounce horizontally
4095 * @param v_bounce Allow bounce vertically
4100 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4102 ELM_CHECK_WIDTYPE(obj, widtype);
4103 Widget_Data *wd = elm_widget_data_get(obj);
4105 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4109 * Get the bounce mode
4111 * @param obj The genlist object
4112 * @param h_bounce Allow bounce horizontally
4113 * @param v_bounce Allow bounce vertically
4118 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4120 ELM_CHECK_WIDTYPE(obj, widtype);
4121 Widget_Data *wd = elm_widget_data_get(obj);
4123 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4127 * Set homogenous mode
4129 * This will enable the homogeneous mode where items are of the same height and width
4130 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4132 * @param obj The genlist object
4133 * @param homogeneous Assume the items within the genlist are of the same height and width
4134 * (EINA_TRUE = on, EINA_FALSE = off)
4139 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4141 ELM_CHECK_WIDTYPE(obj, widtype);
4142 Widget_Data *wd = elm_widget_data_get(obj);
4144 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4145 wd->homogeneous = homogeneous;
4149 * Get the homogenous mode
4151 * @param obj The genlist object
4152 * @return Assume the items within the genlist are of the same height and width
4153 * (EINA_TRUE = on, EINA_FALSE = off)
4158 elm_genlist_homogeneous_get(const Evas_Object *obj)
4160 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4161 Widget_Data *wd = elm_widget_data_get(obj);
4162 if (!wd) return EINA_FALSE;
4163 return wd->homogeneous;
4167 * Set the maximum number of items within an item block
4169 * This will configure the block count to tune to the target with particular performance matrix.
4171 * @param obj The genlist object
4172 * @param n Maximum number of items within an item block
4177 elm_genlist_block_count_set(Evas_Object *obj, int n)
4179 ELM_CHECK_WIDTYPE(obj, widtype);
4180 Widget_Data *wd = elm_widget_data_get(obj);
4182 wd->max_items_per_block = n;
4186 * Get the maximum number of items within an item block
4188 * @param obj The genlist object
4189 * @return Maximum number of items within an item block
4194 elm_genlist_block_count_get(const Evas_Object *obj)
4196 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4197 Widget_Data *wd = elm_widget_data_get(obj);
4199 return wd->max_items_per_block;
4203 * Set the timeout in seconds for the longpress event
4205 * @param obj The genlist object
4206 * @param timeout timeout in seconds
4211 elm_genlist_longpress_timeout_set(Evas_Object *obj, double timeout)
4213 ELM_CHECK_WIDTYPE(obj, widtype);
4214 Widget_Data *wd = elm_widget_data_get(obj);
4216 wd->longpress_timeout = timeout;
4220 * Get the timeout in seconds for the longpress event
4222 * @param obj The genlist object
4223 * @return timeout in seconds
4228 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4230 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4231 Widget_Data *wd = elm_widget_data_get(obj);
4233 return wd->longpress_timeout;
4237 * Set the scrollbar policy
4239 * This sets the scrollbar visibility policy for the given genlist scroller.
4240 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
4241 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4242 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4243 * This applies respectively for the horizontal and vertical scrollbars.
4245 * @param obj The genlist object
4246 * @param policy_h Horizontal scrollbar policy
4247 * @param policy_v Vertical scrollbar policy
4252 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4254 ELM_CHECK_WIDTYPE(obj, widtype);
4255 Widget_Data *wd = elm_widget_data_get(obj);
4257 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4258 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4261 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4265 elm_genlist_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
4267 ELM_CHECK_WIDTYPE(obj, widtype);
4268 Widget_Data *wd = elm_widget_data_get(obj);
4269 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4270 if ((!wd) || (!wd->scr)) return;
4271 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4272 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
4273 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
4276 // added for item moving animation.
4278 _group_item_contract_moving_effect_timer_cb(void *data)
4280 Evas_Object *obj = (Evas_Object *)data;
4281 Widget_Data *wd = elm_widget_data_get(obj);
4283 Item_Block *itb = NULL;
4284 Elm_Genlist_Item *git;
4285 Elm_Genlist_Item *it;
4287 int cnt = 0, git_count = 0;
4288 double added_gy = 1;
4290 int hide_git = 0, git_cnt = 0, list_start_y = 0;
4292 int *git_array = NULL;
4293 int base_git = 0, base_git_num = 0;
4294 int tmp_y = 0, devide_size = 1;
4297 Eina_Bool finish = EINA_FALSE;
4299 Evas_Coord ox, oy, ow, oh;
4301 return ECORE_CALLBACK_CANCEL;
4303 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4304 return ECORE_CALLBACK_CANCEL;
4306 git_array = (int*)malloc(sizeof(int) * wd->max_git_num);
4307 t = ecore_loop_time_get();
4309 if (t - wd->effect_start >= 5.0)
4312 if (wd->item_count < 100)
4313 devide_size = 8 * _elm_config->scale;
4314 else if (wd->item_count < 500)
4315 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4317 devide_size = 2 * _elm_config->scale;
4319 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4322 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4323 list_start_y += wd->select_all_item->h;
4325 EINA_INLIST_FOREACH(wd->group_items, git)
4327 git_array[git_cnt++] = git->y;
4328 if (git->y < list_start_y)
4330 edje_object_signal_emit(git->base, "elm,state,alpha,disable", "elm");
4332 base_git_num = hide_git;
4334 EINA_INLIST_FOREACH(wd->group_items, git)
4336 base_git = list_start_y + git->h * (git->num - 1) + git->num;
4337 git->old_y = git->y;
4338 added_gy = abs(base_git - git->y) / devide_size;
4342 if (!git->down && git->old_y < list_start_y)
4344 git->finish_y = base_git;
4346 git->y = list_start_y - (git->h+1) * hide_git--;
4350 else if (!git->down && git->y < base_git)
4353 if (wd->pinch_zoom_reserve)
4360 if (git->y < base_git)
4363 if (git->y > base_git)
4369 if (git->y > base_git)
4372 if (git->y < base_git)
4376 if (git->num - 1 == cnt && git->y == base_git)
4379 evas_object_resize(git->base, wd->minw, git->h);
4380 evas_object_move(git->base, git->x, git->y);
4381 evas_object_raise(git->base);
4382 if (git->y < list_start_y)
4383 evas_object_lower(git->base);
4385 evas_object_raise(git->base);
4386 evas_object_show(git->base);
4388 EINA_INLIST_FOREACH(wd->blocks, itb)
4390 EINA_LIST_FOREACH(itb->items, l, it)
4392 if (it->group_item == git)
4394 if (it->group_item->old_y)
4395 it->old_scrl_y -= (it->group_item->old_y - it->group_item->y);
4397 if (git_array[it->group_item->num+1] <= it->old_scrl_y || added_gy == 1.0)
4399 evas_object_color_set(it->base, 0,0,0,0);
4400 evas_object_color_set(it->edit_obj, 0,0,0,0);
4402 _move_edit_controls(it,it->scrl_x, it->old_scrl_y);
4403 evas_object_resize(it->base, itb->wd->minw-(it->pad_left+it->pad_right), it->h);
4404 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4405 evas_object_raise(it->group_item->base);
4406 evas_object_show(it->base);
4410 if (git_count == git_cnt)
4415 if (wd->select_all_item) evas_object_raise(wd->select_all_item->base);
4420 if (finish) // finish animation
4423 EINA_INLIST_FOREACH(wd->group_items, git)
4427 wd->contract_pan_y = 0;
4428 wd->pinch_zoom_reserve = EINA_FALSE;
4429 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH;
4430 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4431 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4433 // fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT FINISH \n");
4437 EINA_INLIST_FOREACH(wd->blocks, itb)
4439 if (itb->realized) {
4440 EINA_LIST_FOREACH(itb->items, l, it)
4443 it->scrl_y = oy + tmp_y;
4445 // need to handle edit mode
4446 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4447 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
4448 evas_object_color_set(it->base, 0,0,0,0);
4449 evas_object_show(it->base);
4455 evas_object_lower(wd->alpha_bg);
4456 evas_object_hide(wd->alpha_bg);
4458 return ECORE_CALLBACK_CANCEL;
4461 return ECORE_CALLBACK_RENEW;
4464 // added for item moving animation.
4466 _group_item_expand_moving_effect_timer_cb(void *data)
4468 Evas_Object *obj = (Evas_Object *)data;
4469 Widget_Data *wd = elm_widget_data_get(obj);
4470 Elm_Genlist_Item *git, *tmp_git;
4471 Item_Block *itb = NULL;
4472 Elm_Genlist_Item *it;
4474 int cnt = 0, git_count = 0, git_cnt = 0, git_tmp_y = 0, in = 0, start_in = 0;
4475 int tmp = 0, show_git_cnt = 0, scroll_y = 0, top_git = 0 , git_h = 0, scroll_pan_y = 0, down = 0;
4476 int up_cnt = 1, down_cnt = 1, it_h = 0, devide_size = 1;
4477 static int last_git_y = 0;
4481 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4483 static double added_gy = 0; // temp value for animation speed
4484 static double added_gy2 = 0;
4485 Eina_Bool finish = EINA_FALSE;
4487 return ECORE_CALLBACK_CANCEL;
4489 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4490 return ECORE_CALLBACK_CANCEL;
4492 t = ecore_loop_time_get();
4494 top_git = wd->pinch_it;
4498 else if (top_git >= wd->max_git_num)
4499 top_git = wd->max_git_num - 1;
4501 if (wd->item_count < 100)
4502 devide_size = 8 * _elm_config->scale;
4503 else if (wd->item_count < 500)
4504 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4506 devide_size = 2 * _elm_config->scale;
4508 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4509 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4510 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4511 oy += wd->select_all_item->h;
4512 // calculate git count and srcroll move position
4513 EINA_INLIST_FOREACH(wd->group_items, git)
4515 if (git_cnt == top_git - 1)
4520 EINA_INLIST_FOREACH(wd->blocks, itb)
4522 EINA_LIST_FOREACH(itb->items, l, it)
4524 if (it->group_item == git)
4534 scroll_pan_y = scroll_y + git_h * (top_git-1) ;
4536 if (t - wd->effect_start >= 5.0)
4540 EINA_INLIST_FOREACH(wd->blocks, itb)
4542 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4543 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4548 EINA_LIST_FOREACH(itb->items, l, it)
4550 _item_realize(it, start_in, 0);
4551 it->realized = EINA_TRUE;
4554 itb->realized = EINA_TRUE;
4555 itb->want_unrealize = EINA_FALSE;
4561 if (itb->realized) _item_block_unrealize(itb);
4566 // set group item finish y and items y position of group item and items.
4569 EINA_INLIST_FOREACH(wd->group_items, git)
4571 if (git->num >= top_git)
4573 git->finish_y = git_tmp_y;
4574 git_tmp_y += git->h;
4575 tmp = git->y + git->h;
4579 git->finish_y = -1 * oh;
4581 EINA_INLIST_FOREACH(wd->blocks, itb)
4583 EINA_LIST_FOREACH(itb->items, l, it)
4585 if (it->group_item == git)
4587 if (git->finish_y != -1 * oh)
4589 it->old_scrl_y = tmp;
4591 added_gy2 = abs(git->finish_y - git->y) / devide_size;
4592 tmp += it->h - added_gy2;
4595 it->old_scrl_y = -1 * oh;
4600 if (git->finish_y >= oy && git->finish_y < oy+oh)
4604 EINA_INLIST_FOREACH(wd->group_items, git)
4608 evas_object_move(git->base, git->x, git->y);
4611 evas_object_raise(git->base);
4612 evas_object_show(git->base);
4616 evas_object_lower(git->base);
4617 evas_object_hide(git->base);
4620 added_gy = abs(git->finish_y - git->y) / devide_size;
4621 if (added_gy < 1.0) added_gy = 1.0;
4622 if (git->y > git->finish_y)
4626 if (git->num >= top_git)
4630 else if (git->y < git->finish_y)
4637 if ((!down && git->y < git->finish_y) || (down && git->y > git->finish_y))
4638 git->y = git->finish_y;
4640 if (git_cnt-1 == cnt)
4641 last_git_y = git->y;
4643 if (git->num == top_git && git->y == oy)
4645 evas_object_move(git->base, git->x, git->y);
4646 evas_object_show(git->base);
4648 EINA_INLIST_FOREACH(wd->group_items, tmp_git)
4650 if (tmp_git->y == tmp_git->finish_y && tmp_git->y > oy && tmp_git->y < oy+oh)
4657 EINA_INLIST_FOREACH(wd->blocks, itb)
4659 EINA_LIST_FOREACH(itb->items, l, it)
4661 if (it->group_item == git)
4664 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4665 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4667 evas_object_resize(it->base, wd->minw-(it->pad_left+it->pad_right), it->h);
4668 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4669 _move_edit_controls(it, it->scrl_x, it->old_scrl_y);
4670 evas_object_color_set(it->edit_obj, 255,255,255,255);
4671 evas_object_color_set(it->base, 255,255,255,255);
4672 evas_object_raise(it->base);
4673 evas_object_raise(it->group_item->base);
4681 if (git_count + 1 == show_git_cnt)
4690 wd->pan_y = scroll_y + (git_h) * (top_git-1) ;
4692 EINA_INLIST_FOREACH(wd->group_items, git)
4694 edje_object_signal_emit(git->base, "elm,state,alpha,enable", "elm");
4696 EINA_INLIST_FOREACH(wd->blocks, itb)
4698 EINA_LIST_FOREACH(itb->items, l, it)
4703 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
4704 fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND FINISH \n");
4705 elm_smart_scroller_hold_set(wd->scr, 0);
4706 elm_smart_scroller_freeze_set(wd->scr, 0);
4707 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4708 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4709 // printf("_group_item_expand_moving_effect_timer_cb FINISH \n");
4710 evas_object_lower(wd->alpha_bg);
4711 evas_object_hide(wd->alpha_bg);
4712 // evas_object_smart_changed(wd->pan_smart);
4713 if (wd->calc_job) ecore_job_del(wd->calc_job);
4714 wd->calc_job = ecore_job_add(_calc_job, wd);
4716 return ECORE_CALLBACK_CANCEL;
4719 return ECORE_CALLBACK_RENEW;
4723 _item_pinch_recalc(Evas_Object *obj, int emode)
4725 Item_Block *itb = NULL;
4727 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4728 Widget_Data *wd = elm_widget_data_get(obj);
4730 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND)
4733 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4734 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4738 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4740 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT;
4742 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4743 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE);
4744 evas_object_raise(wd->alpha_bg);
4745 evas_object_show(wd->alpha_bg);
4747 wd->effect_start = ecore_loop_time_get();
4748 wd->item_moving_effect_timer = ecore_animator_add(_group_item_contract_moving_effect_timer_cb, obj);
4751 else if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4753 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4755 evas_object_raise(wd->alpha_bg);
4756 evas_object_show(wd->alpha_bg);
4758 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND;
4759 EINA_INLIST_FOREACH(wd->blocks, itb)
4761 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4762 itb->y - wd->pan_y + oy,
4764 cvx, cvy, cvw, cvh))
4766 if (itb->realized) _item_block_unrealize(itb);
4767 itb->realized = EINA_FALSE;
4771 wd->effect_start = ecore_loop_time_get();
4772 wd->item_moving_effect_timer = ecore_animator_add(_group_item_expand_moving_effect_timer_cb, obj);
4779 create_tray_alpha_bg(const Evas_Object *obj)
4781 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4782 Widget_Data *wd = elm_widget_data_get(obj);
4783 if (!wd) return NULL;
4785 Evas_Object *bg = NULL;
4786 Evas_Coord ox, oy, ow, oh;
4788 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4789 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
4790 evas_object_color_set(bg , 0,0,0,0);
4791 evas_object_resize(bg , ow, oh);
4792 evas_object_move(bg , ox, oy);
4793 evas_object_show(bg);
4794 evas_object_hide(bg);
4799 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
4801 ELM_CHECK_WIDTYPE(obj, widtype);
4802 Widget_Data *wd = elm_widget_data_get(obj);
4803 if (!wd || !wd->pinch_zoom) return;
4804 if (!wd->queue_idler)
4807 wd->alpha_bg = create_tray_alpha_bg(obj);
4808 _item_pinch_recalc(obj, emode);
4813 * Set pinch zoom mode
4815 * @param obj The genlist object
4817 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4822 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
4824 ELM_CHECK_WIDTYPE(obj, widtype);
4825 Widget_Data *wd = elm_widget_data_get(obj);
4826 if (!wd || !wd->pinch_zoom) return;
4827 wd->pinch_zoom_reserve = emode;
4831 * Get pinch zoom mode
4833 * @param obj The genlist object
4834 * @return The pinch mode
4835 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4840 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
4842 Widget_Data *wd = elm_widget_data_get(obj);
4843 if (!wd) return EINA_FALSE;
4844 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4846 else return EINA_FALSE;
4850 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
4852 Widget_Data *wd = elm_widget_data_get(obj);
4854 wd->pinch_zoom = emode;
4857 // added for item moving animation.
4859 _item_moving_effect_timer_cb(void *data)
4861 Widget_Data *wd = data;
4863 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4864 Elm_Genlist_Item *it;
4866 int expanded_cnt = 0;
4868 static double added_gy =25;
4869 static int count = 0;
4870 if (!wd) return EINA_FALSE;
4871 if (added_gy < 1) added_gy = 1;
4874 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4875 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4877 EINA_INLIST_FOREACH(wd->blocks, itb)
4880 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4881 itb->y - wd->pan_y + oy,
4883 cvx, cvy, cvw, cvh))
4885 EINA_LIST_FOREACH(itb->items, l, it)
4887 if (!it->old_scrl_y)
4888 it->old_scrl_y = it->scrl_y;
4889 if (it->parent && it->parent->expanded && !it->showme)
4891 evas_object_hide(it->base);
4893 else evas_object_show(it->base);
4895 evas_object_show(it->base);
4897 if (itb && itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
4899 if (it->old_scrl_y && it->old_scrl_y < it->scrl_y) {
4900 it->old_scrl_y += added_gy;
4902 if (it->old_scrl_y >= it->scrl_y) {
4903 it->list_expanded = 1;
4904 it->old_scrl_y = it->scrl_y;
4907 else if (itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
4909 if (it->old_scrl_y && it->old_scrl_y > it->scrl_y)
4912 it->old_scrl_y -= added_gy;
4915 if (it->old_scrl_y <= it->scrl_y) {
4916 it->list_expanded = 1;
4917 it->old_scrl_y = it->scrl_y;
4920 expanded_cnt += it->list_expanded;
4923 _move_edit_controls(it,it->scrl_x, it->scrl_y);
4924 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
4925 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4926 evas_object_raise(it->base);
4930 if (expanded_cnt == cnt)
4932 if (wd->item_moving_effect_timer)
4936 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
4937 EINA_INLIST_FOREACH(wd->blocks, itb)
4939 EINA_LIST_FOREACH(itb->items, l, it)
4941 it->list_expanded = 0;
4946 return ECORE_CALLBACK_CANCEL;
4948 return ECORE_CALLBACK_RENEW;
4951 // added for edit mode item moving animation.
4953 _edit_mode_item_moving_effect_cb(void *data)
4955 Widget_Data *wd = data;
4957 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4958 Elm_Genlist_Item *it, *select_all_item;
4960 int expanded_cnt = 0;
4961 static double added_gy = 9;
4962 static float count = 0;
4964 static float select_all_y = 0;
4966 if (!wd) return EINA_FALSE;
4969 if (!wd->select_all_item)
4970 return ECORE_CALLBACK_CANCEL;
4972 static float dy = 9;
4977 select_all_y += (dy);
4979 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4980 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4982 EINA_INLIST_FOREACH(wd->blocks, itb)
4985 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4986 itb->y - wd->pan_y + oy,
4988 cvx, cvy, cvw, cvh))
4991 EINA_LIST_FOREACH(itb->items, l, it)
4994 evas_object_show(it->base);
4995 if (it->old_pad_left < it->pad_left)
4997 it->old_pad_left += dy;
4998 if (it->old_pad_left >= it->pad_left)
5000 it->list_expanded = 1;
5001 it->old_pad_left = it->pad_left;
5004 if (it->old_pad_left > it->pad_left)
5006 it->old_pad_left -= dy;
5007 if (it->old_pad_left <= it->pad_left)
5009 it->list_expanded = 1;
5010 it->old_pad_left = it->pad_left;
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;
5024 if (it->old_scrl_y > it->scrl_y)
5026 it->old_scrl_y -= (dy);
5027 if (it->old_scrl_y <= it->scrl_y)
5029 it->list_expanded = 1;
5030 it->old_scrl_y = it->scrl_y;
5035 select_all_item = itb->wd->select_all_item;
5036 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
5037 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5038 evas_object_move(select_all_item->base, ox, oy - select_all_y);
5039 else if (select_all_y <= select_all_item->h)
5040 evas_object_move(select_all_item->base, ox, oy - select_all_item->h + select_all_y);
5041 evas_object_raise(select_all_item->base);
5042 evas_object_show(select_all_item->base);
5044 expanded_cnt += it->list_expanded;
5046 evas_object_move(it->base, it->scrl_x+it->old_pad_left, it->old_scrl_y);
5047 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
5048 evas_object_raise(it->edit_obj);
5049 evas_object_raise(it->base);
5051 evas_object_show(it->edit_obj);
5052 evas_object_show(it->base);
5054 if (select_all_y >= wd->select_all_item->h && it->list_expanded == 1)
5057 evas_object_raise(it->edit_obj);
5066 if (wd->item_moving_effect_timer)
5072 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5073 EINA_INLIST_FOREACH(wd->blocks, itb)
5075 EINA_LIST_FOREACH(itb->items, l, it)
5077 it->list_expanded = 0;
5080 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5082 if (wd->select_all_item)
5084 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5085 free(wd->select_all_item);
5087 wd->select_all_item = NULL;
5090 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5091 wd->effect_mode = 0;
5093 if (wd->calc_job) ecore_job_del(wd->calc_job);
5094 wd->calc_job = ecore_job_add(_calc_job, wd);
5095 return ECORE_CALLBACK_CANCEL;
5097 return ECORE_CALLBACK_RENEW;
5101 // added for item moving animation.
5103 _item_flip_effect_show(void *data)
5105 Widget_Data *wd = data;
5107 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5109 if (!wd) return EINA_FALSE;
5111 Elm_Genlist_Item *it;
5114 int start = 0, end = 0;
5116 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5117 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5119 EINA_INLIST_FOREACH(wd->blocks, itb)
5122 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5123 itb->y - wd->pan_y + oy,
5125 cvx, cvy, cvw, cvh))
5127 EINA_LIST_FOREACH(itb->items, l, it)
5129 if (it->parent && it->wd->expand_item == it->parent && !it->effect_done)
5131 if (!start) start = it->scrl_y;
5132 base = (Evas_Object *) it->base;
5133 edje_object_signal_emit(it->base, "flip_item", "");
5134 end = it->scrl_y + it->h;
5135 it->effect_done = EINA_TRUE;
5140 wd->expand_item_cnt = end - start;
5141 return ECORE_CALLBACK_CANCEL;
5145 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5147 ELM_CHECK_WIDTYPE(obj, widtype);
5148 Widget_Data *wd = elm_widget_data_get(obj);
5150 wd->effect_mode = emode;
5151 wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5152 evas_object_resize(wd->point_rect, 10, 25);
5153 evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5154 evas_object_show(wd->point_rect);
5155 evas_object_hide(wd->point_rect);
5159 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
5161 Widget_Data *wd = data;
5162 evas_object_hide(wd->ed->del_confirm);
5163 if (wd->ed->ec && wd->ed->ec->remove)
5164 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
5165 wd->ed->del_item = NULL;
5169 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
5171 const char *del_icon_part;
5172 Elm_Genlist_Item *it = data;
5173 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5175 edje_object_part_unswallow(it->edit_obj, it->wd->ed->del_confirm);
5176 evas_object_hide(it->wd->ed->del_confirm);
5180 _edit_item_check_set(Elm_Genlist_Item *it, Eina_Bool del_confirm_state)
5182 if (del_confirm_state)
5184 it->del_confirm_state = 0;
5185 it->delete_check = 0;
5186 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5187 it->wd->selct_all = 0;
5188 if (elm_genlist_item_parent_get(it))
5189 edje_object_signal_emit(elm_genlist_item_parent_get(it)->edit_obj, "elm,state,del,animated,enable", "elm");
5190 if (it->wd->select_all_item)
5191 edje_object_signal_emit(it->wd->select_all_item->base, "elm,state,del,animated,enable", "elm");
5192 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5193 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5197 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5198 it->del_confirm_state = 1;
5199 it->delete_check = 1;
5204 _edit_subitems_check(Elm_Genlist_Item *it)
5207 Eina_List *tl = NULL, *l;
5208 Elm_Genlist_Item *it2;
5210 EINA_LIST_FOREACH(it->items, l, it2)
5211 tl = eina_list_append(tl, it2);
5212 EINA_LIST_FREE(tl, it2)
5213 _edit_item_check_set(it2, !elm_genlist_item_parent_get(it2)->del_confirm_state);
5217 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5219 const char *del_conf_style;
5220 Elm_Genlist_Item *it = data, *tmp_it;
5223 int check_cnt = 0, total_cnt = 0;
5225 if (_edit_mode_reset(it->wd))
5228 if (it->edit_long_timer)
5230 ecore_timer_del(it->edit_long_timer);
5231 it->edit_long_timer = NULL;
5233 _edit_item_check_set(it, it->del_confirm_state);
5234 _edit_subitems_check(it);
5235 it->wd->ed->del_item = it;
5237 EINA_INLIST_FOREACH(it->wd->blocks, itb)
5239 EINA_LIST_FOREACH(itb->items, l, tmp_it)
5241 if(tmp_it->delete_check)
5244 total_cnt += itb->count;
5247 if(check_cnt == total_cnt)
5248 edje_object_signal_emit(it->wd->select_all_item->base, "elm,state,del_confirm", "elm");
5250 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5251 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5252 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
5254 elm_object_style_set(it->wd->ed->del_confirm, del_conf_style);
5257 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5259 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
5260 evas_object_show(it->wd->ed->del_confirm);
5265 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5267 Elm_Genlist_Item *it = data;
5269 if (_edit_mode_reset(it->wd))
5272 if (it->wd->ed->ec && it->wd->ed->ec->insert_new)
5273 it->wd->ed->ec->insert_new(it->wd->obj, it);
5277 _edit_mode_reset(Widget_Data *wd)
5280 if (wd->ed->del_confirm_state)
5282 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
5283 //wd->ed->del_confirm_state = 0;
5284 //wd->ed->del_item = NULL;
5292 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5294 Elm_Genlist_Item *it = data;
5295 Evas_Event_Mouse_Down *ev = event_info;
5298 if (it->wd->edit_field && !it->renamed)
5299 elm_genlist_item_rename_mode_set(it, 0);
5301 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
5304 if (_edit_mode_reset(it->wd))
5309 it->reoder_cavas_x = ev->canvas.x;
5310 it->reoder_cavas_y = ev->canvas.y;
5312 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5313 it->dx = ev->canvas.x - x;
5314 it->dy = ev->canvas.y - y;
5316 if (it->edit_long_timer)
5318 ecore_timer_del(it->edit_long_timer);
5319 it->edit_long_timer = NULL;
5324 it->edit_long_timer = ecore_timer_add(0.3,_edit_long_press, it);
5326 it->edit_long_timer = NULL;
5328 fprintf(stderr, "genlist : reordering is temporary disabled.\n");
5332 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5334 Elm_Genlist_Item *it = data;
5337 EINA_INLIST_FOREACH(it->wd->blocks, itb)
5341 if (it->edit_long_timer)
5343 ecore_timer_del(it->edit_long_timer);
5344 it->edit_long_timer = NULL;
5348 it->wd->reoder_moved = EINA_FALSE;
5350 if (it->wd->ed->ec->selected)
5351 it->wd->ed->ec->selected(NULL, it, 1);
5353 if (it->reordering && it->wd->ed->reorder_item)
5355 it->wd->ed->reorder_item->reordering = 0;
5356 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
5357 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
5359 if ((!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
5360 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE)))
5362 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);
5363 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y);
5365 it->wd->ed->reorder_item = NULL;
5366 it->wd->ed->reorder_rel = NULL;
5372 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5374 Elm_Genlist_Item *it = data;
5375 Evas_Event_Mouse_Move *ev = event_info;
5377 if ((it->dragging) && (it->down))
5379 if (it->edit_long_timer)
5381 ecore_timer_del(it->edit_long_timer);
5382 it->edit_long_timer = NULL;
5385 evas_object_smart_callback_call(it->wd->obj, "drag", it);
5389 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
5391 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
5392 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5393 x = ev->cur.canvas.x - x;
5394 y = ev->cur.canvas.y - y;
5397 if (adx < 0) adx = -dx;
5400 if (ady < 0) ady = -dy;
5403 if ((adx > minw) || (ady > minh))
5406 if (it->edit_long_timer)
5408 ecore_timer_del(it->edit_long_timer);
5409 it->edit_long_timer = NULL;
5413 if (it->reordering && it->wd->ed->reorder_item)
5415 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
5416 evas_object_raise(it->wd->ed->reorder_item->base);
5417 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
5418 evas_object_show(it->wd->ed->reorder_item->base);
5419 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, y);
5421 it->block->updateme = EINA_TRUE;
5423 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5424 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5431 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5434 Elm_Genlist_Item *select_all_it = data, *it;
5436 Widget_Data *wd = select_all_it->wd;
5440 edje_object_signal_emit(select_all_it->base, "elm,state,del_confirm", "elm");
5442 edje_object_signal_emit(select_all_it->base, "elm,state,del,animated,enable", "elm");
5444 EINA_INLIST_FOREACH(wd->blocks, itb)
5446 EINA_LIST_FOREACH(itb->items, l, it)
5450 it->delete_check = 1;
5451 it->del_confirm_state = 1;
5452 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5456 it->delete_check = 0;
5457 it->del_confirm_state = 0;
5458 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5462 wd->selct_all ^= 0xFF;
5464 if (wd->ed->ec->item_selected)
5465 wd->ed->ec->item_selected(select_all_it->data, select_all_it, wd->selct_all);
5466 if (wd->calc_job) ecore_job_del(wd->calc_job);
5467 wd->calc_job = ecore_job_add(_calc_job, wd);
5471 _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity)
5473 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5475 evas_object_resize(it->edit_obj,it->w, it->h);
5476 evas_object_move(it->edit_obj, itx, ity);
5477 evas_object_raise(it->edit_obj);
5481 _edit_controls_eval(Elm_Genlist_Item *it)
5484 const char *pad_str;
5491 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj)
5494 if (it->itc->func.editmode_get)
5495 itmode = it->itc->func.editmode_get(it->data, it->wd->obj, it->wd->edit_mode);
5496 itmode &= it->wd->edit_mode;
5498 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5499 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5503 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
5504 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
5505 _elm_config->scale);
5506 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5507 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
5508 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5509 else strncpy(buf, "item", sizeof(buf));
5510 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5511 // if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
5512 strncat(buf, "/", sizeof(buf) - strlen(buf));
5514 if (it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5516 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5517 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
5521 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
5524 // edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
5525 // "elm", _edit_mode_reset, it);
5528 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
5529 if (pad_str) pad = atoi(pad_str);
5531 if ((itmode & ELM_GENLIST_EDIT_MODE_INSERT))
5533 if (it->wd->animate_edit_controls)
5534 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
5536 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
5538 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
5539 "elm", _insert_new_item_cb, it);
5540 it->pad_left += pad * _elm_config->scale;
5544 if (it->wd->animate_edit_controls)
5545 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
5547 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
5549 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
5550 "elm", _insert_new_item_cb);
5553 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
5555 if (it->wd->animate_edit_controls)
5556 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5558 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5560 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5561 "elm", _remove_item_cb);
5562 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5563 "elm", _hide_delete_confirm_object);
5565 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
5566 "elm", _remove_item_cb, it);
5568 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
5569 "elm", _hide_delete_confirm_object, it);
5570 it->pad_left += pad * _elm_config->scale;
5571 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5572 _reorder_mouse_down, it);
5576 if (it->wd->animate_edit_controls)
5577 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
5579 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
5581 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5582 "elm", _remove_item_cb);
5583 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5584 "elm", _hide_delete_confirm_object);
5585 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5586 _reorder_mouse_down);
5589 if ((itmode & ELM_GENLIST_EDIT_MODE_REORDER))
5591 const char* reorder_part;
5593 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5594 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5596 edje_object_part_object_get(it->edit_obj, reorder_part);
5598 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5599 _reorder_mouse_down);
5600 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5602 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5603 _reorder_mouse_move);
5605 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5606 _reorder_mouse_down, it);
5607 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5608 _reorder_mouse_up, it);
5609 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5610 _reorder_mouse_move, it);
5612 // it->pad_right += pad * _elm_config->scale;
5616 const char* reorder_part;
5618 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5619 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5622 if (itmode == ELM_GENLIST_EDIT_MODE_NONE)
5624 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5625 _reorder_mouse_down);
5626 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5628 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5629 _reorder_mouse_move);
5634 if (it->wd->edit_mode != 0xF0) {
5635 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
5637 if (it->itc->func.icon_get)
5639 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
5644 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
5645 EINA_LIST_FOREACH(it->icons, l, key)
5647 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
5651 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5652 edje_object_part_swallow(it->edit_obj, key, ic);
5653 evas_object_show(ic);
5654 // elm_widget_sub_object_add(it->wd->obj, ic);
5661 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5662 EINA_LIST_FREE(it->edit_icon_objs, icon)
5663 evas_object_del(icon);
5665 Evas_Object *editfield;
5666 EINA_LIST_FREE(it->wd->edit_field, editfield)
5667 evas_object_del(editfield);
5671 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)//Unrealize
5673 evas_object_del(it->edit_obj);
5674 it->edit_obj = NULL;
5677 _move_edit_controls(it,it->scrl_x, it->scrl_y);
5678 evas_object_show(it->edit_obj);
5682 _notify_item_position(Elm_Genlist_Item *it)
5687 l = eina_list_last(it->parent->items);
5689 //Check if the Item is First Node or Last node of its Parent & raise signal.
5690 if (it->parent->items->data != it && l->data != it)
5692 edje_object_signal_emit(it->base, "normal_item", "elm");
5696 if (it->parent->items->data == it)
5697 edje_object_signal_emit(it->base, "first_item", "elm");
5700 edje_object_signal_emit(it->base, "last_item", "elm");
5706 _get_space_for_reorder_item(Elm_Genlist_Item *it)
5709 Evas_Coord rox, roy, row, roh;
5710 if (!it->wd->ed) return 0;
5711 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) || !it->wd->ed->reorder_item)
5713 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
5714 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
5715 rox, roy+roh/2, row, 1));
5718 it->wd->ed->reorder_rel = it;
5719 it->scrl_y+=it->wd->ed->reorder_item->h;
5720 it->reorder_check = 1;
5721 return it->wd->ed->reorder_item->h;
5727 * Moves the Genlist Item
5730 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5735 Elm_Genlist_Item *next_item = elm_genlist_item_next_get(after);
5737 if (it->y == after->y && after->reorder_check && it->reorder_check)
5739 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5740 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5744 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5745 _item_block_del(it);
5747 if ((!next_item && after->reorder_check) || (next_item && !after->reorder_check))
5750 if (next_item && !after->reorder_check && it == after)
5752 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5753 EINA_INLIST_GET(next_item));
5754 it->rel = next_item;
5758 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5759 EINA_INLIST_GET(after));
5763 it->rel->relcount++;
5770 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
5771 EINA_INLIST_GET(after));
5773 it->rel->relcount++;
5777 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
5781 after->reorder_check = 0;
5782 _item_queue(it->wd, it);
5786 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5788 fprintf(stderr, "=================> Caution!!! <========================\n");
5789 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
5790 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
5791 fprintf(stderr, "=======================================================\n");
5793 elm_genlist_edit_mode_set(obj, emode, edit_class);
5797 * Set Genlist edit mode
5799 * This sets Genlist edit mode.
5801 * @param obj The Genlist object
5802 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5803 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5808 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5810 Elm_Genlist_Item *it;
5814 static Elm_Genlist_Item_Class itc;
5816 ELM_CHECK_WIDTYPE(obj, widtype);
5817 Widget_Data *wd = elm_widget_data_get(obj);
5819 if (wd->edit_mode == emode) return;
5821 wd->edit_mode = emode;
5822 wd->animate_edit_controls = 1;
5824 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5825 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
5827 if (wd->edit_mode_effect_mode)
5829 wd->effect_mode = EINA_TRUE;
5830 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE;
5833 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5835 if (wd->ed) free (wd->ed);
5841 wd->ed = calloc(1, sizeof(Edit_Data));
5843 wd->ed->ec = edit_class;
5845 if (((wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)) && !wd->ed->del_confirm)
5847 wd->ed->del_confirm = elm_button_add(wd->obj);
5848 elm_button_label_set(wd->ed->del_confirm, "Delete");
5849 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
5850 edje_object_scale_set(wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
5851 _elm_config->scale);
5852 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd);
5855 EINA_INLIST_FOREACH(wd->blocks, itb)
5857 EINA_LIST_FOREACH(itb->items, l, it)
5859 if (it->flags != ELM_GENLIST_ITEM_GROUP)
5861 it->delete_check = 0;
5862 it->del_confirm_state = 0;
5864 _edit_controls_eval(it);
5868 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5870 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
5871 itc.item_style = edit_class->select_all_item_style;
5873 itc.item_style = "select_all";
5874 itc.func.label_get = NULL;
5875 itc.func.icon_get = NULL;
5876 itc.func.del = NULL;
5877 itc.func.editmode_get = NULL;
5879 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
5882 if (!wd->select_all_item) return;
5884 _item_realize(wd->select_all_item, 0, 0);
5885 edje_object_signal_callback_add(wd->select_all_item->base, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
5887 wd->select_all_item->rel = NULL;
5888 wd->select_all_item->selected = 0;
5889 wd->select_all_item->before = 1;
5890 wd->select_all_item->block = NULL;
5891 wd->select_all_minh = wd->minh + wd->select_all_item->h;
5893 else if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
5895 if (wd->select_all_item)
5897 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5898 free(wd->select_all_item);
5900 wd->select_all_item = NULL;
5902 edje_object_signal_emit(wd->scr, "elm,state,edit,animated,enable", "elm");
5904 if (wd->calc_job) ecore_job_del(wd->calc_job);
5905 wd->calc_job = ecore_job_add(_calc_job, wd);
5909 * Delete selected items in genlist edit mode.
5911 * @param obj The genlist object
5916 elm_genlist_edit_selected_items_del(Evas_Object *obj)
5918 Elm_Genlist_Item *it;
5920 Item_Block *itb = NULL;
5922 ELM_CHECK_WIDTYPE(obj, widtype);
5923 Widget_Data *wd = elm_widget_data_get(obj);
5925 if (!wd->blocks) return;
5927 EINA_INLIST_FOREACH(wd->blocks, itb)
5929 if (!wd->blocks) break;
5933 EINA_LIST_FOREACH(itb->items, l, it)
5935 if (it->delete_check)
5937 it->wd->effect_mode = EINA_TRUE;
5941 itb->wd->minh -= it->h;
5942 itb->wd->select_all_minh -= it->h;
5945 if ((it->relcount > 0) || (it->walking > 0))
5947 elm_genlist_item_subitems_clear(it);
5948 it->delete_me = EINA_TRUE;
5949 if (it->wd->show_item == it) it->wd->show_item = NULL;
5950 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5953 if (it->realized) _item_unrealize(it);
5954 it->block->changed = EINA_TRUE;
5956 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
5960 it->wd->walking -= it->walking;
5961 if (it->wd->show_item == it) it->wd->show_item = NULL;
5962 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5963 if (it->realized) _item_unrealize(it);
5965 EINA_LIST_FREE(it->edit_icon_objs, icon)
5966 evas_object_del(icon);
5968 Evas_Object *editfield;
5969 EINA_LIST_FREE(it->wd->edit_field, editfield)
5970 evas_object_del(editfield);
5972 evas_object_del(it->edit_obj);
5973 it->edit_obj = NULL;
5975 itb->items = eina_list_remove(itb->items, it);
5977 itb->changed = EINA_TRUE;
5978 if ((!it->delete_me) && (it->itc->func.del))
5979 it->itc->func.del(it->data, it->wd->obj);
5980 it->delete_me = EINA_TRUE;
5982 it->wd->queue = eina_list_remove(it->wd->queue, it);
5983 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5985 it->parent->items = eina_list_remove(it->parent->items, it);
5986 if (it->long_timer) ecore_timer_del(it->long_timer);
5988 it->group_item->items = eina_list_remove(it->group_item->items,it);
5995 evas_render(evas_object_evas_get(wd->obj));
5996 if (wd->calc_job) ecore_job_del(wd->calc_job);
5997 wd->calc_job = ecore_job_add(_calc_job, wd);
6001 elm_genlist_selected_items_del(Evas_Object *obj)
6003 fprintf(stderr, "=================> Caution!!! <========================\n");
6004 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6005 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6006 fprintf(stderr, "=======================================================\n");
6007 elm_genlist_edit_selected_items_del(obj);
6011 * Get a list of selected items in genlist
6013 * This returns a list of the selected items in the genlist. The list
6014 * contains Elm_Genlist_Item pointers. The list must be freed by the
6015 * caller when done with eina_list_free(). The item pointers in the list
6016 * are only vallid so long as those items are not deleted or the genlist is
6019 * @param obj The genlist object
6020 * @return The list of selected items, nor NULL if none are selected.
6025 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6027 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6028 Widget_Data *wd = elm_widget_data_get(obj);
6029 Eina_List *list = NULL;
6031 if (!wd) return NULL;
6033 EINA_INLIST_FOREACH(wd->blocks, itb)
6036 Elm_Genlist_Item *it;
6038 EINA_LIST_FOREACH(itb->items, l, it)
6040 if (it->delete_check) list = eina_list_append(list, it);
6048 * Set a given item's rename mode
6050 * This renames the item's label from genlist
6052 * @param it The item
6053 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6058 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6062 const Eina_List *l, *list, *l2;
6063 const char *label, *rename_swallow_part;
6065 Eina_Bool done = EINA_FALSE;
6066 int label_cnt = 0 , swallow_part_cnt = 0;
6069 Evas_Object *editfield;
6070 Evas_Object *entry = NULL;
6071 int edit_field_cnt = 0;
6074 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6076 it->wd->edit_mode = 0xF0;
6077 _edit_controls_eval(it);
6080 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6085 Elm_Genlist_Item *it;
6088 EINA_LIST_FOREACH(itb->items, l, it)
6092 it->renamed = EINA_FALSE;
6094 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6096 entry = elm_editfield_entry_get(editfield);
6097 const char *text = elm_entry_entry_get(entry);
6099 if (it->itc->func.label_changed)
6100 it->itc->func.label_changed(it->data, it, text, edit_field_cnt++);
6102 Ecore_IMF_Context *imf = elm_entry_imf_context_get(entry);
6103 ecore_imf_context_input_panel_hide(imf);
6105 Evas_Object *editfield;
6106 EINA_LIST_FREE(it->wd->edit_field, editfield)
6107 evas_object_del(editfield);
6109 if (it->wd->edit_mode)
6111 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_INSERT))
6112 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
6114 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT))
6115 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6117 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
6118 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6122 evas_object_del(it->edit_obj);
6123 it->edit_obj = NULL;
6125 EINA_LIST_FREE(it->edit_icon_objs, icon)
6126 evas_object_del(icon);
6136 // if (emode != ELM_GENLIST_RENAME_MODE_NONE)
6139 it->renamed = EINA_TRUE;
6141 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
6142 EINA_LIST_FOREACH(it->labels, list, label)
6144 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6145 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6146 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6147 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6149 if (it->itc->func.label_get)
6151 it->renamed = EINA_TRUE;
6152 swallow_part_cnt = 0;
6154 EINA_LIST_FREE(it->edit_icon_objs, icon)
6155 evas_object_del(icon);
6156 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6157 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6159 if (label_cnt == swallow_part_cnt)
6161 editfield = elm_editfield_add(it->wd->obj);
6162 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6164 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6165 elm_editfield_eraser_set(editfield, EINA_TRUE);
6166 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6167 elm_widget_sub_object_add(it->edit_obj, editfield);
6169 evas_object_show(editfield);
6171 s = it->itc->func.label_get(it->data, it->wd->obj, list->data);
6175 Evas_Object *entry = elm_editfield_entry_get(editfield);
6176 elm_entry_entry_set(entry,s);
6181 elm_editfield_guide_text_set(editfield, "Text Input");
6190 if (it->wd->edit_mode == 0xF0)
6192 it->wd->edit_mode = 0;
6197 EAPI Elm_Genlist_Item *
6198 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6201 _print_deprecated("elm_genlist_groupitem_add", "elm_genlist_item_append");
6202 return elm_genlist_item_append(obj, itc, data, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
6205 EAPI Elm_Genlist_Item *
6206 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6207 const void *data, Elm_Genlist_Item *parent,
6208 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6209 Evas_Smart_Cb func, const void *func_data)
6211 _print_deprecated("elm_genlist_item_append_with_group", "elm_genlist_item_append");
6212 return elm_genlist_item_append(obj, itc, data, git, flags, func, func_data);
6215 EAPI Elm_Genlist_Item *
6216 elm_genlist_item_prepend_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6217 const void *data, Elm_Genlist_Item *parent,
6218 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6219 Evas_Smart_Cb func, const void *func_data)
6221 _print_deprecated("elm_genlist_item_prepend_with_group", "elm_genlist_item_prepend");
6222 return elm_genlist_item_prepend(obj, itc, data, git, flags, func, func_data);
6226 elm_genlist_groupitem_del(Elm_Genlist_Item *git)
6228 _print_deprecated("elm_genlist_groupitem_del", "elm_genlist_item_del");
6229 return elm_genlist_item_del(git);
6233 _print_deprecated(const char *deprecated, const char *new)
6235 fprintf(stderr, "=================> Caution!!! <========================\n");
6236 fprintf(stderr, "==> %s () is deprecated.\n", deprecated);
6237 fprintf(stderr, "==> Use %s() instead.\n", new);
6238 fprintf(stderr, "=======================================================\n");
6243 elm_genlist_queue_exception_set(const Evas_Object *obj, Eina_Bool emode)
6245 ELM_CHECK_WIDTYPE(obj, widtype);
6246 Widget_Data *wd = elm_widget_data_get(obj);
6248 wd->queue_exception = emode;
6250 fprintf(stderr, "=================> Caution!!! <========================\n");
6251 fprintf(stderr, "==> elm_genlist_queue_exception_set() is for demo. <===\n");
6252 fprintf(stderr, "==> Do not use this API <==\n");
6253 fprintf(stderr, "=======================================================\n");