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 it->menuopened = EINA_FALSE;
1557 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
1560 ecore_timer_del(it->long_timer);
1561 it->long_timer = NULL;
1563 evas_object_del(it->base);
1565 evas_object_del(it->spacer);
1568 evas_object_del(it->edit_obj);
1569 it->edit_obj = NULL;
1570 elm_widget_stringlist_free(it->labels);
1572 elm_widget_stringlist_free(it->icons);
1574 elm_widget_stringlist_free(it->states);
1576 EINA_LIST_FREE(it->icon_objs, icon)
1577 evas_object_del(icon);
1579 EINA_LIST_FREE(it->edit_icon_objs, icon)
1580 evas_object_del(icon);
1583 it->realized = EINA_FALSE;
1584 it->want_unrealize = EINA_FALSE;
1588 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1591 Elm_Genlist_Item *it;
1592 Evas_Coord minw = 0, minh = 0;
1593 int showme = 0, changed = 0;
1597 EINA_LIST_FOREACH(itb->items, l, it)
1599 if (it->delete_me) continue;
1600 showme |= it->showme;
1605 if (!it->mincalcd) changed = 1;
1608 _item_realize(it, in, 1);
1609 _item_unrealize(it);
1614 _item_realize(it, in, 1);
1615 _item_unrealize(it);
1620 Eina_Bool was_realized = it->realized;
1622 _item_realize(it, in, 0);
1624 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1627 if (minw < it->minw) minw = it->minw;
1636 itb->changed = EINA_FALSE;
1637 /* force an evas norender to garbage collect deleted objects */
1638 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1643 _item_block_realize(Item_Block *itb, int in, int full)
1646 Elm_Genlist_Item *it;
1648 if (itb->realized) return;
1649 EINA_LIST_FOREACH(itb->items, l, it)
1651 if (it->delete_me) continue;
1654 Eina_Bool was_realized = it->realized;
1656 _item_realize(it, in, 0);
1658 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1662 itb->realized = EINA_TRUE;
1663 itb->want_unrealize = EINA_FALSE;
1667 _item_block_unrealize(Item_Block *itb)
1670 Elm_Genlist_Item *it;
1673 if (!itb->realized) return;
1674 EINA_LIST_FOREACH(itb->items, l, it)
1676 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1678 if (it->dragging || it->reordering)
1681 it->want_unrealize = EINA_TRUE;
1684 _item_unrealize(it);
1689 itb->realized = EINA_FALSE;
1690 itb->want_unrealize = EINA_TRUE;
1693 itb->want_unrealize = EINA_FALSE;
1697 _group_items_recalc(void *data)
1699 Widget_Data *wd = data;
1701 Elm_Genlist_Item *git;
1703 EINA_LIST_FOREACH(wd->group_items, l, git)
1705 if (git->want_realize)
1709 _item_realize(git, 0, 0);
1710 evas_object_smart_callback_call(git->wd->obj, "realized", git);
1712 evas_object_resize(git->base, wd->minw, git->h);
1713 evas_object_move(git->base, git->scrl_x, git->scrl_y);
1714 evas_object_show(git->base);
1715 evas_object_raise(git->base);
1718 evas_object_resize(git->base.view, wd->minw, git->h);
1719 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
1720 evas_object_show(git->base.view);
1721 evas_object_raise(git->base.view);
1725 else if (!git->want_realize && git->realized)
1728 _item_unrealize(git);
1734 _item_block_position(Item_Block *itb, int in)
1737 Elm_Genlist_Item *it;
1738 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1741 Elm_Genlist_Item *git = NULL;
1742 Elm_Genlist_Item *select_all_item = NULL;
1744 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1745 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1747 if (itb->wd->select_all_item &&
1748 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1751 select_all_item = itb->wd->select_all_item;
1753 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
1754 evas_object_move(select_all_item->base, ox, oy);
1755 evas_object_raise(select_all_item->base);
1757 if (itb->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
1758 evas_object_show(select_all_item->base);
1760 evas_object_hide(select_all_item->base);
1761 y = select_all_item->h;
1764 EINA_LIST_FOREACH(itb->items, l, it)
1766 if (it->delete_me) continue;
1770 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
1771 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
1773 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
1774 cvx, cvy, cvw, cvh));
1775 if (it->flags != ELM_GENLIST_ITEM_GROUP)
1777 if ((itb->realized) && (!it->realized))
1781 _item_realize(it, in, 0);
1782 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1788 _notify_item_position(it);
1791 git = it->group_item;
1794 if (git->scrl_y < oy)
1796 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
1797 git->scrl_y = (it->scrl_y + it->h) - git->h;
1798 git->want_realize = EINA_TRUE;
1800 evas_object_resize(it->base, it->w, it->h);
1801 evas_object_move(it->base,
1802 it->scrl_x, it->scrl_y);
1803 evas_object_show(it->base);
1806 is_reorder = _get_space_for_reorder_item(it);
1810 if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && !itb->reoder_y)
1812 itb->reoder_y -= it->h;
1813 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y + itb->reoder_y;
1815 else if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && itb->reoder_y)
1822 if (!it->reordering)
1824 if ((!it->wd->effect_mode ||
1825 (it->wd->effect_mode && it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE)) && !it->wd->pinch_zoom_reserve)
1827 _move_edit_controls(it,it->scrl_x, it->scrl_y);
1828 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
1830 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
1832 if (it->delete_check)
1834 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
1835 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
1837 evas_object_show(it->base);
1838 it->old_pad_left = it->pad_left;
1839 it->old_scrl_y = it->scrl_y;
1847 _item_unrealize(it);
1855 if (vis) it->want_realize = EINA_TRUE;
1857 if (!it->reordering)
1861 if (itb->wd->select_all_item &&
1862 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1863 evas_object_raise(select_all_item->base);
1866 itb->wd->animate_edit_controls = 0;
1870 _calc_job(void *data)
1872 Widget_Data *wd = data;
1874 Evas_Coord minw = -1, minh = 0, y = 0, ow;
1875 Item_Block *chb = NULL;
1876 int in = 0, minw_change = 0;
1880 EINA_INLIST_FOREACH(wd->blocks, itb)
1885 showme = itb->showme;
1889 if (itb->realized) _item_block_unrealize(itb);
1893 if (itb->realized) _item_block_unrealize(itb);
1894 showme = _item_block_recalc(itb, in, 0, 1);
1900 if (minw == -1) minw = itb->minw;
1901 else if (minw < itb->minw)
1910 if ((showme) && (wd->show_item) && (wd->show_item->mincalcd))
1912 wd->show_item->showme = 0;
1914 elm_smart_scroller_region_bring_in(wd->scr,
1915 wd->show_item->x + wd->show_item->block->x,
1916 wd->show_item->y + wd->show_item->block->y,
1917 wd->show_item->block->w,
1920 elm_smart_scroller_child_region_show(wd->scr,
1921 wd->show_item->x + wd->show_item->block->x,
1922 wd->show_item->y + wd->show_item->block->y,
1923 wd->show_item->block->w,
1925 wd->show_item = NULL;
1930 EINA_INLIST_FOREACH(wd->blocks, itb)
1936 if ((chb) && (EINA_INLIST_GET(chb)->next))
1938 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
1940 if (itb->realized) _item_block_unrealize(itb);
1943 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
1944 if (minw < ow) minw = ow;
1945 if ((minw != wd->minw) || (minh != wd->minh) || wd->select_all_item)
1949 if (wd->select_all_item)
1950 wd->minh += wd->select_all_item->h;
1951 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1952 _sizing_eval(wd->obj);
1954 wd->calc_job = NULL;
1955 evas_object_smart_changed(wd->pan_smart);
1959 _update_job(void *data)
1961 Widget_Data *wd = data;
1964 int num, num0, position = 0, recalc = 0;
1966 wd->update_job = NULL;
1968 EINA_INLIST_FOREACH(wd->blocks, itb)
1970 Evas_Coord itminw, itminh;
1971 Elm_Genlist_Item *it;
1977 _item_block_position(itb, num);
1982 EINA_LIST_FOREACH(itb->items, l2, it)
1992 _item_unrealize(it);
1993 _item_realize(it, num, 0);
1994 evas_object_smart_callback_call(it->wd->obj,
1999 _item_realize(it, num, 1);
2000 _item_unrealize(it);
2002 if ((it->minw != itminw) || (it->minh != itminh))
2011 itb->changed = EINA_TRUE;
2012 _item_block_recalc(itb, num0, 0, 1);
2013 _item_block_position(itb, num0);
2018 if (wd->calc_job) ecore_job_del(wd->calc_job);
2019 wd->calc_job = ecore_job_add(_calc_job, wd);
2024 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2026 Pan *sd = evas_object_smart_data_get(obj);
2027 // Evas_Coord ow, oh;
2028 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2029 // ow = sd->wd->minw - ow;
2030 // if (ow < 0) ow = 0;
2031 // oh = sd->wd->minh - oh;
2032 // if (oh < 0) oh = 0;
2033 // if (x < 0) x = 0;
2034 // if (y < 0) y = 0;
2035 // if (x > ow) x = ow;
2036 // if (y > oh) y = oh;
2037 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2039 if(sd->wd->reoder_moved)
2042 if(sd->wd->pan_y >= sd->wd->minh)
2043 sd->wd->pan_y = sd->wd->minh;
2046 if(sd->wd->pan_y < y )
2047 sd->wd->pan_y = y + 5 + abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2049 sd->wd->pan_y = y - 5 - abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2057 evas_object_smart_changed(obj);
2061 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2063 Pan *sd = evas_object_smart_data_get(obj);
2065 if (x) *x = sd->wd->pan_x;
2066 if (y) *y = sd->wd->pan_y;
2068 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2070 int git_cnt = 0, git_h = 0;
2071 Elm_Genlist_Item *git;
2073 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2079 if (sd->wd->minh != (git_h+1) * git_cnt)
2081 sd->wd->minh = (git_h+1) * git_cnt;
2088 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2090 Pan *sd = evas_object_smart_data_get(obj);
2093 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2094 ow = sd->wd->minw - ow;
2096 oh = sd->wd->minh - oh;
2103 _pan_min_get(Evas_Object *obj __UNUSED__,
2112 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2114 Pan *sd = evas_object_smart_data_get(obj);
2116 if (w) *w = sd->wd->minw;
2117 if (h) *h = sd->wd->minh;
2121 _pan_add(Evas_Object *obj)
2124 Evas_Object_Smart_Clipped_Data *cd;
2127 cd = evas_object_smart_data_get(obj);
2130 sd->__clipped_data = *cd;
2132 evas_object_smart_data_set(obj, sd);
2136 _pan_del(Evas_Object *obj)
2138 Pan *sd = evas_object_smart_data_get(obj);
2145 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2147 Pan *sd = evas_object_smart_data_get(obj);
2150 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2151 if ((ow == w) && (oh == h)) return;
2152 /* don't do this... use wd->compress mode
2153 if (sd->wd->mode == ELM_LIST_COMPRESS)
2156 // this is nasty - but no choice. have to mark all as not mincalced.
2157 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2160 Elm_Genlist_Item *it;
2162 EINA_LIST_FOREACH(itb->items, l, it)
2163 it->mincalcd = EINA_FALSE;
2165 itb->changed = EINA_TRUE;
2169 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2170 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2174 _pan_calculate(Evas_Object *obj)
2176 Pan *sd = evas_object_smart_data_get(obj);
2178 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2180 Elm_Genlist_Item *git;
2183 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2184 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND) return;
2187 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2189 sd->wd->group_items_moved = EINA_TRUE;
2190 sd->wd->contract_pan_y = sd->wd->pan_y;
2191 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2193 evas_object_raise(git->base);
2194 evas_object_resize(git->base, sd->wd->minw, git->h);
2195 evas_object_move(git->base, git->x, git->y + sd->wd->pan_y * -1);
2196 evas_object_show(git->base);
2200 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2202 if (sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2203 (void)_edit_mode_reset(sd->wd);
2205 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2207 git->want_realize = EINA_FALSE;
2210 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2211 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2213 itb->w = sd->wd->minw;
2214 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2215 itb->y - sd->wd->pan_y + oy,
2217 cvx, cvy, cvw, cvh))
2219 if ((!itb->realized) || (itb->changed))
2220 _item_block_realize(itb, in, 0);
2221 _item_block_position(itb, in);
2225 if (itb->realized) _item_block_unrealize(itb);
2230 if (sd->wd->effect_mode &&
2231 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2233 _item_flip_effect_show(sd->wd);
2234 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2237 if (sd->wd->effect_mode && sd->wd->edit_mode_effect_mode)
2238 sd->wd->item_moving_effect_timer = ecore_animator_add(_edit_mode_item_moving_effect_cb, sd->wd);
2239 if ((sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) && (sd->wd->ed->reorder_item))
2241 evas_object_raise(sd->wd->ed->reorder_item->base);
2242 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2245 _group_items_recalc(sd->wd);
2246 if (sd->wd->select_all_item)
2247 evas_object_raise(sd->wd->select_all_item->base);
2251 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2253 Pan *sd = evas_object_smart_data_get(obj);
2255 if (sd->wd->effect_mode && sd->wd->multi_down) return;
2256 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2258 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2259 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2263 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2265 Widget_Data *wd = elm_widget_data_get(obj);
2267 elm_smart_scroller_hold_set(wd->scr, 1);
2271 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2273 Widget_Data *wd = elm_widget_data_get(obj);
2275 elm_smart_scroller_hold_set(wd->scr, 0);
2279 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2281 Widget_Data *wd = elm_widget_data_get(obj);
2283 elm_smart_scroller_freeze_set(wd->scr, 1);
2287 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2289 Widget_Data *wd = elm_widget_data_get(obj);
2291 elm_smart_scroller_freeze_set(wd->scr, 0);
2295 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2297 Evas_Object *obj = data;
2298 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2302 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2304 Evas_Object *obj = data;
2305 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2309 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2311 Evas_Object *obj = data;
2312 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2316 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2318 Evas_Object *obj = data;
2319 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2323 * Add a new Genlist object
2325 * @param parent The parent object
2326 * @return The new object or NULL if it cannot be created
2331 elm_genlist_add(Evas_Object *parent)
2336 Evas_Coord minw, minh;
2337 static Evas_Smart *smart = NULL;
2339 if (!parent) return NULL;
2342 static Evas_Smart_Class sc;
2344 evas_object_smart_clipped_smart_set(&_pan_sc);
2346 sc.name = "elm_genlist_pan";
2347 sc.version = EVAS_SMART_CLASS_VERSION;
2350 sc.resize = _pan_resize;
2351 sc.move = _pan_move;
2352 sc.calculate = _pan_calculate;
2353 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2355 wd = ELM_NEW(Widget_Data);
2356 e = evas_object_evas_get(parent);
2357 obj = elm_widget_add(e);
2358 ELM_SET_WIDTYPE(widtype, "genlist");
2359 elm_widget_type_set(obj, "genlist");
2360 elm_widget_sub_object_add(parent, obj);
2361 elm_widget_data_set(obj, wd);
2362 elm_widget_del_hook_set(obj, _del_hook);
2363 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2364 elm_widget_theme_hook_set(obj, _theme_hook);
2365 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2367 wd->scr = elm_smart_scroller_add(e);
2368 elm_smart_scroller_widget_set(wd->scr, obj);
2369 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2370 elm_widget_resize_object_set(obj, wd->scr);
2372 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2374 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2375 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
2376 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2377 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
2380 wd->mode = ELM_LIST_SCROLL;
2381 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2382 wd->max_items_per_block = 32;
2383 wd->longpress_timeout = _elm_config->longpress_timeout;
2384 wd->max_git_num = 0;
2386 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2387 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2388 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2389 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2391 wd->pan_smart = evas_object_smart_add(e, smart);
2392 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2395 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2396 _pan_set, _pan_get, _pan_max_get,
2397 _pan_min_get, _pan_child_size_get);
2399 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2401 evas_object_size_hint_min_set(obj, minw, minh);
2407 static Elm_Genlist_Item *
2408 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2409 const void *data, Elm_Genlist_Item *parent,
2410 Elm_Genlist_Item_Flags flags,
2412 const void *func_data)
2414 Elm_Genlist_Item *it;
2416 it = calloc(1, sizeof(Elm_Genlist_Item));
2417 if (!it) return NULL;
2421 it->parent = parent;
2423 it->func.func = func;
2424 it->func.data = func_data;
2425 it->expanded_depth = 0;
2430 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2432 Item_Block *itb = NULL;
2439 itb = calloc(1, sizeof(Item_Block));
2442 if (!it->rel->block)
2444 it->rel->block = itb;
2446 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2447 itb->items = eina_list_append(itb->items, it);
2454 eina_inlist_prepend_relative(wd->blocks,
2455 EINA_INLIST_GET(itb),
2456 EINA_INLIST_GET(it->rel->block));
2458 eina_list_prepend_relative(itb->items, it, it->rel);
2463 eina_inlist_append_relative(wd->blocks,
2464 EINA_INLIST_GET(itb),
2465 EINA_INLIST_GET(it->rel->block));
2467 eina_list_append_relative(itb->items, it, it->rel);
2477 itb = (Item_Block *)(wd->blocks);
2478 if (itb->count >= wd->max_items_per_block)
2480 itb = calloc(1, sizeof(Item_Block));
2484 eina_inlist_prepend(wd->blocks,
2485 EINA_INLIST_GET(itb));
2490 itb = calloc(1, sizeof(Item_Block));
2494 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2496 itb->items = eina_list_prepend(itb->items, it);
2502 itb = (Item_Block *)(wd->blocks->last);
2503 if (itb->count >= wd->max_items_per_block)
2505 itb = calloc(1, sizeof(Item_Block));
2509 eina_inlist_append(wd->blocks,
2510 EINA_INLIST_GET(itb));
2515 itb = calloc(1, sizeof(Item_Block));
2519 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2521 itb->items = eina_list_append(itb->items, it);
2527 itb = it->rel->block;
2528 if (!itb) goto newblock;
2530 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2532 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2535 itb->changed = EINA_TRUE;
2541 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2542 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2545 it->rel->relcount--;
2546 if ((it->rel->delete_me) && (!it->rel->relcount))
2550 if (itb->count > itb->wd->max_items_per_block)
2554 Elm_Genlist_Item *it2;
2556 newc = itb->count / 2;
2557 itb2 = calloc(1, sizeof(Item_Block));
2561 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2562 EINA_INLIST_GET(itb));
2563 itb2->changed = EINA_TRUE;
2564 while ((itb->count > newc) && (itb->items))
2568 l = eina_list_last(itb->items);
2570 itb->items = eina_list_remove_list(itb->items, l);
2573 itb2->items = eina_list_prepend(itb2->items, it2);
2581 _queue_proecess(Widget_Data *wd, int norender)
2586 t0 = ecore_time_get();
2587 for (n = 0; (wd->queue) && (n < 128); n++)
2589 Elm_Genlist_Item *it;
2591 it = wd->queue->data;
2592 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2593 it->queued = EINA_FALSE;
2594 _item_block_add(wd, it);
2595 t = ecore_time_get();
2596 if (it->block->changed)
2598 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2599 it->block->changed = 0;
2601 if (showme) it->block->showme = 1;
2602 if (eina_inlist_count(wd->blocks) > 1)
2604 if ((t - t0) > (ecore_animator_frametime_get())) break;
2611 _item_idler(void *data)
2613 Widget_Data *wd = data;
2616 //static double q_start = 0.0;
2617 //if (q_start == 0.0) q_start = ecore_time_get();
2620 if (_queue_proecess(wd, 1) > 0)
2622 if (wd->calc_job) ecore_job_del(wd->calc_job);
2623 wd->calc_job = ecore_job_add(_calc_job, wd);
2628 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2630 wd->queue_idler = NULL;
2631 if (wd->pinch_zoom_reserve)
2632 _elm_genlist_pinch_zoom_execute(wd->obj, 1);
2633 return ECORE_CALLBACK_CANCEL;
2635 return ECORE_CALLBACK_RENEW;
2639 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2641 if (!wd->queue_exception)
2643 if (it->queued) return;
2644 wd->queue = eina_list_append(wd->queue, it);
2645 it->queued = EINA_TRUE;
2648 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2650 if (wd->queue_idler)
2652 ecore_idler_del(wd->queue_idler);
2653 wd->queue_idler = NULL;
2655 _queue_proecess(wd, 0);
2657 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2658 if (wd->queue_exception)
2660 wd->queue = eina_list_append(wd->queue, it);
2661 it->queued = EINA_TRUE;
2666 * Append item to the end of the genlist
2668 * This appends the given item to the end of the list or the end of the
2669 * children if the parent is given.
2671 * @param obj The genlist object
2672 * @param itc The item class for the item
2673 * @param data The item data
2674 * @param parent The parent item, or NULL if none
2675 * @param flags Item flags
2676 * @param func Convenience function called when item selected
2677 * @param func_data Data passed to @p func above.
2678 * @return A handle to the item added or NULL if not possible
2682 EAPI Elm_Genlist_Item *
2683 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2684 const void *data, Elm_Genlist_Item *parent,
2685 Elm_Genlist_Item_Flags flags,
2686 Evas_Smart_Cb func, const void *func_data)
2688 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2689 Widget_Data *wd = elm_widget_data_get(obj);
2690 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2692 if (!wd) return NULL;
2693 if (!it) return NULL;
2696 if (flags & ELM_GENLIST_ITEM_GROUP)
2697 wd->group_items = eina_list_append(wd->group_items, it);
2698 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2703 Elm_Genlist_Item *it2 = NULL;
2704 Eina_List *ll = eina_list_last(it->parent->items);
2705 if (ll) it2 = ll->data;
2706 it->parent->items = eina_list_append(it->parent->items, it);
2707 if (!it2) it2 = it->parent;
2709 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2710 EINA_INLIST_GET(it2));
2712 it->rel->relcount++;
2714 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2715 it->group_item = parent;
2716 else if (it->parent->group_item)
2717 it->group_item = it->parent->group_item;
2719 it->before = EINA_FALSE;
2720 _item_queue(wd, it);
2725 * Prepend item at start of the genlist
2727 * This adds an item to the beginning of the list or beginning of the children
2728 * of the parent if given.
2730 * @param obj The genlist object
2731 * @param itc The item class for the item
2732 * @param data The item data
2733 * @param parent The parent item, or NULL if none
2734 * @param flags Item flags
2735 * @param func Convenience function called when item selected
2736 * @param func_data Data passed to @p func above.
2737 * @return A handle to the item added or NULL if not possible
2741 EAPI Elm_Genlist_Item *
2742 elm_genlist_item_prepend(Evas_Object *obj,
2743 const Elm_Genlist_Item_Class *itc,
2745 Elm_Genlist_Item *parent,
2746 Elm_Genlist_Item_Flags flags,
2748 const void *func_data)
2750 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2751 Widget_Data *wd = elm_widget_data_get(obj);
2752 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2754 if (!wd) return NULL;
2755 if (!it) return NULL;
2758 if (flags & ELM_GENLIST_ITEM_GROUP)
2759 wd->group_items = eina_list_prepend(wd->group_items, it);
2760 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2765 Elm_Genlist_Item *it2 = NULL;
2766 Eina_List *ll = it->parent->items;
2767 if (ll) it2 = ll->data;
2768 it->parent->items = eina_list_prepend(it->parent->items, it);
2769 if (!it2) it2 = it->parent;
2771 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2772 EINA_INLIST_GET(it2));
2774 it->rel->relcount++;
2776 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2777 it->group_item = parent;
2778 else if (it->parent->group_item)
2779 it->group_item = it->parent->group_item;
2781 it->before = EINA_TRUE;
2782 _item_queue(wd, it);
2787 * Insert item before another in the genlist
2789 * This inserts an item before another in the list. It will be in the same tree
2790 * level as the item it is inseted before.
2792 * @param obj The genlist object
2793 * @param itc The item class for the item
2794 * @param data The item data
2795 * @param parent The parent item
2796 * @param before The item to insert before
2797 * @param flags Item flags
2798 * @param func Convenience function called when item selected
2799 * @param func_data Data passed to @p func above.
2800 * @return A handle to the item added or NULL if not possible
2804 EAPI Elm_Genlist_Item *
2805 elm_genlist_item_insert_before(Evas_Object *obj,
2806 const Elm_Genlist_Item_Class *itc,
2808 Elm_Genlist_Item *parent,
2809 Elm_Genlist_Item *before,
2810 Elm_Genlist_Item_Flags flags,
2812 const void *func_data)
2814 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2815 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
2816 Widget_Data *wd = elm_widget_data_get(obj);
2817 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2819 if (!wd) return NULL;
2820 if (!it) return NULL;
2823 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2824 (before->flags & ELM_GENLIST_ITEM_GROUP))
2825 wd->group_items = eina_list_prepend_relative(wd->group_items, it,
2830 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
2832 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2833 it->group_item = parent;
2834 else if (it->parent->group_item)
2835 it->group_item = it->parent->group_item;
2837 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
2838 EINA_INLIST_GET(before));
2840 it->rel->relcount++;
2841 it->before = EINA_TRUE;
2842 _item_queue(wd, it);
2847 * Insert and item after another in the genlst
2849 * This inserts an item after another in the list. It will be in the same tree
2850 * level as the item it is inseted after.
2852 * @param obj The genlist object
2853 * @param itc The item class for the item
2854 * @param data The item data
2855 * @param parent The parent item
2856 * @param after The item to insert after
2857 * @param flags Item flags
2858 * @param func Convenience function called when item selected
2859 * @param func_data Data passed to @p func above.
2860 * @return A handle to the item added or NULL if not possible
2864 EAPI Elm_Genlist_Item *
2865 elm_genlist_item_insert_after(Evas_Object *obj,
2866 const Elm_Genlist_Item_Class *itc,
2868 Elm_Genlist_Item *parent,
2869 Elm_Genlist_Item *after,
2870 Elm_Genlist_Item_Flags flags,
2872 const void *func_data)
2874 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2875 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
2876 Widget_Data *wd = elm_widget_data_get(obj);
2877 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
2879 if (!wd) return NULL;
2880 if (!it) return NULL;
2883 if ((flags & ELM_GENLIST_ITEM_GROUP) &&
2884 (after->flags & ELM_GENLIST_ITEM_GROUP))
2885 wd->group_items = eina_list_append_relative(wd->group_items, it,
2890 it->parent->items = eina_list_append_relative(it->parent->items, it,
2892 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
2893 it->group_item = parent;
2894 else if (it->parent->group_item)
2895 it->group_item = it->parent->group_item;
2897 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2898 EINA_INLIST_GET(after));
2900 it->rel->relcount++;
2901 it->before = EINA_FALSE;
2902 _item_queue(wd, it);
2909 * This clears all items in the list, leaving it empty.
2911 * @param obj The genlist object
2916 elm_genlist_clear(Evas_Object *obj)
2918 ELM_CHECK_WIDTYPE(obj, widtype);
2919 Widget_Data *wd = elm_widget_data_get(obj);
2922 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
2923 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
2924 elm_smart_scroller_hold_set(wd->scr, 0);
2925 elm_smart_scroller_freeze_set(wd->scr, 0);
2926 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
2927 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2928 wd->max_git_num = 0;
2929 wd->pinch_zoom_reserve = EINA_FALSE;
2931 if (wd->item_moving_effect_timer)
2933 // ecore_timer_del(wd->item_moving_effect_timer);
2934 wd->item_moving_effect_timer = NULL;
2936 if (wd->walking > 0)
2938 Elm_Genlist_Item *it;
2941 EINA_INLIST_FOREACH(wd->items, it)
2950 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
2952 wd->items = eina_inlist_remove(wd->items, wd->items);
2953 if (it->realized) _item_unrealize(it);
2954 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
2955 if (it->long_timer) ecore_timer_del(it->long_timer);
2956 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2957 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
2962 Item_Block *itb = (Item_Block *)(wd->blocks);
2964 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
2965 if (itb->items) eina_list_free(itb->items);
2970 ecore_job_del(wd->calc_job);
2971 wd->calc_job = NULL;
2973 if (wd->queue_idler)
2975 ecore_idler_del(wd->queue_idler);
2976 wd->queue_idler = NULL;
2980 eina_list_free(wd->queue);
2985 eina_list_free(wd->selected);
2986 wd->selected = NULL;
2988 wd->show_item = NULL;
2995 evas_object_del(wd->alpha_bg);
2996 wd->alpha_bg = NULL;
3000 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3001 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3007 * Enable or disable multi-select in the genlist
3009 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3010 * more than 1 item to be selected.
3012 * @param obj The genlist object
3013 * @param multi Multi-select enable/disable
3018 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3020 ELM_CHECK_WIDTYPE(obj, widtype);
3021 Widget_Data *wd = elm_widget_data_get(obj);
3027 * Gets if multi-select in genlist is enable or disable
3029 * @param obj The genlist object
3030 * @return Multi-select enable/disable
3031 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3036 elm_genlist_multi_select_get(const Evas_Object *obj)
3038 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3039 Widget_Data *wd = elm_widget_data_get(obj);
3040 if (!wd) return EINA_FALSE;
3045 * Get the selectd item in the genlist
3047 * This gets the selected item in the list (if multi-select is enabled only
3048 * the first item in the list is selected - which is not very useful, so see
3049 * elm_genlist_selected_items_get()for when multi-select is used).
3051 * If no item is selected, NULL is returned.
3053 * @param obj The genlist object
3054 * @return The selected item, or NULL if none.
3058 EAPI Elm_Genlist_Item *
3059 elm_genlist_selected_item_get(const Evas_Object *obj)
3061 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3062 Widget_Data *wd = elm_widget_data_get(obj);
3063 if (!wd) return NULL;
3064 if (wd->selected) return wd->selected->data;
3069 * Get a list of selected items in the genlist
3071 * This retgurns a list of the selected items. This list pointer is only valid
3072 * so long as no items are selected or unselected (or unselected implicitly
3073 * by deletion). The list contains Elm_Genlist_Item pointers.
3075 * @param obj The genlist object
3076 * @return The list of selected items, nor NULL if none are selected.
3080 EAPI const Eina_List *
3081 elm_genlist_selected_items_get(const Evas_Object *obj)
3083 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3084 Widget_Data *wd = elm_widget_data_get(obj);
3085 if (!wd) return NULL;
3086 return wd->selected;
3090 * Get a list of realized items in genlist
3092 * This returns a list of the realized items in the genlist. The list
3093 * contains Elm_Genlist_Item pointers. The list must be freed by the
3094 * caller when done with eina_list_free(). The item pointers in the list
3095 * are only vallid so long as those items are not deleted or the genlist is
3098 * @param obj The genlist object
3099 * @return The list of realized items, nor NULL if none are realized.
3104 elm_genlist_realized_items_get(const Evas_Object *obj)
3106 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3107 Widget_Data *wd = elm_widget_data_get(obj);
3108 Eina_List *list = NULL;
3110 Eina_Bool done = EINA_FALSE;
3111 if (!wd) return NULL;
3112 EINA_INLIST_FOREACH(wd->blocks, itb)
3117 Elm_Genlist_Item *it;
3120 EINA_LIST_FOREACH(itb->items, l, it)
3122 if (it->realized) list = eina_list_append(list, it);
3134 * Get the item that is at the x, y canvas coords
3136 * This returns the item at the given coordinates (which are canvas relative
3137 * not object-relative). If an item is at that coordinate, that item handle
3138 * is returned, and if @p posret is not NULL, the integer pointed to is set
3139 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3140 * portion of that item (-1), on the middle section (0) or on the lower part
3141 * (1). If NULL is returned as an item (no item found there), then posret
3142 * may indicate -1 or 1 based if the coordinate is above or below all items
3143 * respectively in the genlist.
3145 * @param it The item
3146 * @param x The input x coordinate
3147 * @param y The input y coordinate
3148 * @param posret The position relative to the item returned here
3149 * @return The item at the coordinates or NULL if none
3153 EAPI Elm_Genlist_Item *
3154 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3156 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3157 Widget_Data *wd = elm_widget_data_get(obj);
3158 Evas_Coord ox, oy, ow, oh;
3161 if (!wd) return NULL;
3162 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3164 EINA_INLIST_FOREACH(wd->blocks, itb)
3167 Elm_Genlist_Item *it;
3169 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3170 oy + itb->y - itb->wd->pan_y,
3171 itb->w, itb->h, x, y, 1, 1))
3173 EINA_LIST_FOREACH(itb->items, l, it)
3175 Evas_Coord itx, ity;
3177 itx = ox + itb->x + it->x - itb->wd->pan_x;
3178 ity = oy + itb->y + it->y - itb->wd->pan_y;
3179 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3183 if (y <= (ity + (it->h / 4))) *posret = -1;
3184 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3189 lasty = ity + it->h;
3194 if (y > lasty) *posret = 1;
3201 * Get the first item in the genlist
3203 * This returns the first item in the list.
3205 * @param obj The genlist object
3206 * @return The first item, or NULL if none
3210 EAPI Elm_Genlist_Item *
3211 elm_genlist_first_item_get(const Evas_Object *obj)
3213 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3214 Widget_Data *wd = elm_widget_data_get(obj);
3215 if (!wd) return NULL;
3216 if (!wd->items) return NULL;
3217 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3218 while ((it) && (it->delete_me))
3219 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3224 * Get the last item in the genlist
3226 * This returns the last item in the list.
3228 * @return The last item, or NULL if none
3232 EAPI Elm_Genlist_Item *
3233 elm_genlist_last_item_get(const Evas_Object *obj)
3235 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3236 Widget_Data *wd = elm_widget_data_get(obj);
3237 if (!wd->items) return NULL;
3238 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3239 if (!wd) return NULL;
3240 while ((it) && (it->delete_me))
3241 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3246 * Get the next item in the genlist
3248 * This returns the item after the item @p it.
3250 * @param it The item
3251 * @return The item after @p it, or NULL if none
3255 EAPI Elm_Genlist_Item *
3256 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3260 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3261 if ((it) && (!it->delete_me)) break;
3263 return (Elm_Genlist_Item *)it;
3267 * Get the previous item in the genlist
3269 * This returns the item before the item @p it.
3271 * @param it The item
3272 * @return The item before @p it, or NULL if none
3276 EAPI Elm_Genlist_Item *
3277 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3281 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3282 if ((it) && (!it->delete_me)) break;
3284 return (Elm_Genlist_Item *)it;
3288 * Get the genlist object from an item
3290 * This returns the genlist object itself that an item belongs to.
3292 * @param it The item
3293 * @return The genlist object
3298 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3300 if (!it) return NULL;
3305 * Get the parent item of the given item
3307 * This returns the prent item of the item @p it given.
3309 * @param it The item
3310 * @return The parent of the item or NULL if none
3314 EAPI Elm_Genlist_Item *
3315 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3317 if (!it) return NULL;
3322 * Clear all sub-items (children) of the given item
3324 * This clears all items that are children (or their descendants) of the
3327 * @param it The item
3332 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3335 Eina_List *tl = NULL, *l;
3336 Elm_Genlist_Item *it2;
3338 EINA_LIST_FOREACH(it->items, l, it2)
3339 tl = eina_list_append(tl, it2);
3340 EINA_LIST_FREE(tl, it2)
3341 elm_genlist_item_del(it2);
3345 * Set the selected state of an item
3347 * This sets the selected state (1 selected, 0 not selected) of the given
3350 * @param it The item
3351 * @param selected The slected state
3356 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3359 ELM_CHECK_WIDTYPE(it->wd->obj, widtype);
3360 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3362 if (it->delete_me) return;
3363 selected = !!selected;
3364 if (it->selected == selected) return;
3370 while (wd->selected)
3371 _item_unselect(wd->selected->data);
3381 * Get the selected state of an item
3383 * This gets the selected state of an item (1 selected, 0 not selected).
3385 * @param it The item
3386 * @return The selected state
3391 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3393 if (!it) return EINA_FALSE;
3394 return it->selected;
3398 * Sets the expanded state of an item (if it's a parent)
3400 * This expands or contracts a parent iterm (thus showing or hiding the
3403 * @param it The item
3404 * @param expanded The expanded state (1 expanded, 0 not expanded).
3409 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3412 if (it->expanded == expanded || it->disabled) return;
3413 it->expanded = expanded;
3414 it->wd->expand_item = it;
3415 it->effect_done = EINA_FALSE;
3418 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
3420 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3421 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3426 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
3428 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3429 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3434 * Get the expanded state of an item
3436 * This gets the expanded state of an item
3438 * @param it The item
3439 * @return Thre expanded state
3444 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3446 if (!it) return EINA_FALSE;
3447 return it->expanded;
3451 * Get the depth of expanded item
3453 * @param it The genlist item object
3454 * @return The depth of expanded item
3459 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3462 return it->expanded_depth;
3466 * Sets the disabled state of an item.
3468 * A disabled item cannot be selected or unselected. It will also change
3469 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3472 * @param it The item
3473 * @param disabled The disabled state
3478 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3481 if (it->disabled == disabled) return;
3482 if (it->delete_me) return;
3483 it->disabled = disabled;
3487 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3489 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3494 * Get the disabled state of an item
3496 * This gets the disabld state of the given item.
3498 * @param it The item
3499 * @return The disabled state
3504 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3506 if (!it) return EINA_FALSE;
3507 if (it->delete_me) return EINA_FALSE;
3508 return it->disabled;
3512 * Sets the display only state of an item.
3514 * A display only item cannot be selected or unselected. It is for display
3515 * only and not selecting or otherwise clicking, dragging etc. by the user,
3516 * thus finger size rules will not be applied to this item.
3518 * @param it The item
3519 * @param display_only The display only state
3524 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3527 if (!it->block) return;
3528 if (it->display_only == display_only) return;
3529 if (it->delete_me) return;
3530 it->display_only = display_only;
3531 it->mincalcd = EINA_FALSE;
3532 it->updateme = EINA_TRUE;
3533 it->block->updateme = EINA_TRUE;
3534 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3535 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3539 * Get the display only state of an item
3541 * This gets the display only state of the given item.
3543 * @param it The item
3544 * @return The display only state
3549 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3551 if (!it) return EINA_FALSE;
3552 if (it->delete_me) return EINA_FALSE;
3553 return it->display_only;
3557 * Show the given item
3559 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3560 * if it is not fully visible.
3562 * @param it The item
3567 elm_genlist_item_show(Elm_Genlist_Item *it)
3570 if (it->delete_me) return;
3571 Evas_Coord gith = 0;
3572 if ((it->queued) || (!it->mincalcd))
3574 it->wd->show_item = it;
3575 it->wd->bring_in = 1;
3576 it->showme = EINA_TRUE;
3579 if (it->wd->show_item)
3581 it->wd->show_item->showme = EINA_FALSE;
3582 it->wd->show_item = NULL;
3584 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3585 gith = it->group_item->h;
3586 elm_smart_scroller_child_region_show(it->wd->scr,
3587 it->x + it->block->x,
3588 it->y + it->block->y - gith,
3589 it->block->w, it->h);
3593 * Bring in the given item
3595 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3596 * if it is not fully visible. This may use animation to do so and take a
3599 * @param it The item
3604 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3607 if (it->delete_me) return;
3608 Evas_Coord gith = 0;
3609 if ((it->queued) || (!it->mincalcd))
3611 it->wd->show_item = it;
3612 it->wd->bring_in = 1;
3613 it->showme = EINA_TRUE;
3616 if (it->wd->show_item)
3618 it->wd->show_item->showme = EINA_FALSE;
3619 it->wd->show_item = NULL;
3621 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
3622 gith = it->group_item->h;
3623 elm_smart_scroller_region_bring_in(it->wd->scr,
3624 it->x + it->block->x,
3625 it->y + it->block->y - gith,
3626 it->block->w, it->h);
3630 * Show the given item at the top
3632 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3633 * if it is not fully visible.
3635 * @param it The item
3640 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3644 Evas_Coord gith = 0;
3646 if (it->delete_me) return;
3647 if ((it->queued) || (!it->mincalcd))
3649 it->wd->show_item = it;
3650 it->wd->bring_in = 1;
3651 it->showme = EINA_TRUE;
3654 if (it->wd->show_item)
3656 it->wd->show_item->showme = EINA_FALSE;
3657 it->wd->show_item = NULL;
3659 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3660 if (it->group_item) gith = it->group_item->h;
3661 elm_smart_scroller_child_region_show(it->wd->scr,
3662 it->x + it->block->x,
3663 it->y + it->block->y - gith,
3669 * Bring in the given item at the top
3671 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3672 * if it is not fully visible. This may use animation to do so and take a
3675 * @param it The item
3680 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3684 Evas_Coord gith = 0;
3686 if (it->delete_me) return;
3687 if ((it->queued) || (!it->mincalcd))
3689 it->wd->show_item = it;
3690 it->wd->bring_in = 1;
3691 it->showme = EINA_TRUE;
3694 if (it->wd->show_item)
3696 it->wd->show_item->showme = EINA_FALSE;
3697 it->wd->show_item = NULL;
3699 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3700 if (it->group_item) gith = it->group_item->h;
3701 elm_smart_scroller_region_bring_in(it->wd->scr,
3702 it->x + it->block->x,
3703 it->y + it->block->y - gith,
3709 * Show the given item at the middle
3711 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3712 * if it is not fully visible.
3714 * @param it The item
3719 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3724 if (it->delete_me) return;
3725 if ((it->queued) || (!it->mincalcd))
3727 it->wd->show_item = it;
3728 it->wd->bring_in = 1;
3729 it->showme = EINA_TRUE;
3732 if (it->wd->show_item)
3734 it->wd->show_item->showme = EINA_FALSE;
3735 it->wd->show_item = NULL;
3737 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3738 elm_smart_scroller_child_region_show(it->wd->scr,
3739 it->x + it->block->x,
3740 it->y + it->block->y - oh/2 + it->h/2,
3746 * Bring in the given item at the middle
3748 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3749 * if it is not fully visible. This may use animation to do so and take a
3752 * @param it The item
3757 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3762 if (it->delete_me) return;
3763 if ((it->queued) || (!it->mincalcd))
3765 it->wd->show_item = it;
3766 it->wd->bring_in = 1;
3767 it->showme = EINA_TRUE;
3770 if (it->wd->show_item)
3772 it->wd->show_item->showme = EINA_FALSE;
3773 it->wd->show_item = NULL;
3775 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3776 elm_smart_scroller_region_bring_in(it->wd->scr,
3777 it->x + it->block->x,
3778 it->y + it->block->y - oh/2 + it->h/2,
3783 * Delete a given item
3785 * This deletes the item from genlist and calls the genlist item del class
3786 * callback defined in the item class, if it is set.
3788 * @param it The item
3793 elm_genlist_item_del(Elm_Genlist_Item *it)
3796 if ((it->relcount > 0) || (it->walking > 0))
3798 elm_genlist_item_subitems_clear(it);
3799 it->delete_me = EINA_TRUE;
3800 if (it->wd->show_item == it) it->wd->show_item = NULL;
3801 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3804 if (it->realized) _item_unrealize(it);
3805 it->block->changed = EINA_TRUE;
3806 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3807 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3809 if (it->itc->func.del)
3810 it->itc->func.del((void *)it->data, it->wd->obj);
3817 * Set the data item from the genlist item
3819 * This set the data value passed on the elm_genlist_item_append() and
3820 * related item addition calls. This function will also call
3821 * elm_genlist_item_update() so the item will be updated to reflect the
3824 * @param it The item
3825 * @param data The new data pointer to set
3830 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3834 elm_genlist_item_update(it);
3838 * Get the data item from the genlist item
3840 * This returns the data value passed on the elm_genlist_item_append() and
3841 * related item addition calls.
3843 * @param it The item
3844 * @return The data pointer provided when created
3849 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
3851 if (!it) return NULL;
3856 * Get the real evas object of the genlist item
3858 * This returns the actual evas object used for the specified genlist item.
3859 * This may be NULL as it may not be created, and ma be deleted at any time
3860 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
3861 * genlist is controlling it. This function is for querying, emitting
3862 * custom signals or hooking lower level callbacks for events. Do not
3863 * delete this object under any circumstances.
3865 * @param it The item
3866 * @return The objct pointer
3870 EAPI const Evas_Object *
3871 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
3873 if (!it) return NULL;
3878 * Update the contents of an item
3880 * This updates an item by calling all the item class functions again to get
3881 * the icons, labels and states. Use this when the original item data has
3882 * changed and the changes are desired to be reflected.
3884 * @param it The item
3889 elm_genlist_item_update(Elm_Genlist_Item *it)
3892 if (!it->block) return;
3893 if (it->delete_me) return;
3894 it->mincalcd = EINA_FALSE;
3895 it->updateme = EINA_TRUE;
3896 it->block->updateme = EINA_TRUE;
3897 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3898 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3902 * Update the item class of an item
3904 * @param it The item
3905 * @parem itc The item class for the item
3910 elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc)
3913 if (!it->block) return;
3915 if (it->delete_me) return;
3917 elm_genlist_item_update(it);
3921 * This sets the horizontal stretching mode
3923 * This sets the mode used for sizing items horizontally. Valid modes are
3924 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
3925 * mode means that if items are too wide to fit, the scroller will scroll
3926 * horizontally. Otherwise items are expanded to fill the width of the
3927 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
3928 * to the viewport width and limited to that size.
3930 * @param obj The genlist object
3931 * @param mode The mode to use
3936 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
3938 ELM_CHECK_WIDTYPE(obj, widtype);
3939 Widget_Data *wd = elm_widget_data_get(obj);
3941 if (wd->mode == mode) return;
3947 * Gets the horizontal stretching mode
3949 * @param obj The genlist object
3950 * @return The mode to use
3951 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
3956 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
3958 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
3959 Widget_Data *wd = elm_widget_data_get(obj);
3960 if (!wd) return ELM_LIST_LAST;
3965 * Set the always select mode.
3967 * Items will only call their selection func and callback when first becoming
3968 * selected. Any further clicks will do nothing, unless you enable always
3969 * select with elm_genlist_always_select_mode_set(). This means even if
3970 * selected, every click will make the selected callbacks be called.
3972 * @param obj The genlist object
3973 * @param always_select The always select mode
3974 * (EINA_TRUE = on, EINA_FALSE = off)
3979 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
3981 ELM_CHECK_WIDTYPE(obj, widtype);
3982 Widget_Data *wd = elm_widget_data_get(obj);
3984 wd->always_select = always_select;
3988 * Get the always select mode.
3990 * @param obj The genlist object
3991 * @return The always select mode
3992 * (EINA_TRUE = on, EINA_FALSE = off)
3997 elm_genlist_always_select_mode_get(const Evas_Object *obj)
3999 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4000 Widget_Data *wd = elm_widget_data_get(obj);
4001 if (!wd) return EINA_FALSE;
4002 return wd->always_select;
4006 * Set no select mode
4008 * This will turn off the ability to select items entirely and they will
4009 * neither appear selected nor call selected callback functions.
4011 * @param obj The genlist object
4012 * @param no_select The no select mode
4013 * (EINA_TRUE = on, EINA_FALSE = off)
4018 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4020 ELM_CHECK_WIDTYPE(obj, widtype);
4021 Widget_Data *wd = elm_widget_data_get(obj);
4023 wd->no_select = no_select;
4027 * Gets no select mode
4029 * @param obj The genlist object
4030 * @return The no select mode
4031 * (EINA_TRUE = on, EINA_FALSE = off)
4036 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4038 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4039 Widget_Data *wd = elm_widget_data_get(obj);
4040 if (!wd) return EINA_FALSE;
4041 return wd->no_select;
4047 * This will enable the compress mode where items are "compressed" horizontally
4048 * to fit the genlist scrollable viewport width. This is special for genlist.
4049 * Do not rely on elm_genlist_horizontal_mode_set() being set to
4050 * ELM_LIST_COMPRESS to work as genlist needs to handle it specially.
4052 * @param obj The genlist object
4053 * @param compress The compress mode
4054 * (EINA_TRUE = on, EINA_FALSE = off)
4059 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4061 ELM_CHECK_WIDTYPE(obj, widtype);
4062 Widget_Data *wd = elm_widget_data_get(obj);
4064 wd->compress = compress;
4068 * Get the compress mode
4070 * @param obj The genlist object
4071 * @return The compress mode
4072 * (EINA_TRUE = on, EINA_FALSE = off)
4077 elm_genlist_compress_mode_get(const Evas_Object *obj)
4079 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4080 Widget_Data *wd = elm_widget_data_get(obj);
4081 if (!wd) return EINA_FALSE;
4082 return wd->compress;
4088 * This will enable or disable the scroller bounce mode for the genlist. See
4089 * elm_scroller_bounce_set() for details
4091 * @param obj The genlist object
4092 * @param h_bounce Allow bounce horizontally
4093 * @param v_bounce Allow bounce vertically
4098 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4100 ELM_CHECK_WIDTYPE(obj, widtype);
4101 Widget_Data *wd = elm_widget_data_get(obj);
4103 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4107 * Get the bounce mode
4109 * @param obj The genlist object
4110 * @param h_bounce Allow bounce horizontally
4111 * @param v_bounce Allow bounce vertically
4116 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4118 ELM_CHECK_WIDTYPE(obj, widtype);
4119 Widget_Data *wd = elm_widget_data_get(obj);
4121 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4125 * Set homogenous mode
4127 * This will enable the homogeneous mode where items are of the same height and width
4128 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4130 * @param obj The genlist object
4131 * @param homogeneous Assume the items within the genlist are of the same height and width
4132 * (EINA_TRUE = on, EINA_FALSE = off)
4137 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4139 ELM_CHECK_WIDTYPE(obj, widtype);
4140 Widget_Data *wd = elm_widget_data_get(obj);
4142 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4143 wd->homogeneous = homogeneous;
4147 * Get the homogenous mode
4149 * @param obj The genlist object
4150 * @return Assume the items within the genlist are of the same height and width
4151 * (EINA_TRUE = on, EINA_FALSE = off)
4156 elm_genlist_homogeneous_get(const Evas_Object *obj)
4158 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4159 Widget_Data *wd = elm_widget_data_get(obj);
4160 if (!wd) return EINA_FALSE;
4161 return wd->homogeneous;
4165 * Set the maximum number of items within an item block
4167 * This will configure the block count to tune to the target with particular performance matrix.
4169 * @param obj The genlist object
4170 * @param n Maximum number of items within an item block
4175 elm_genlist_block_count_set(Evas_Object *obj, int n)
4177 ELM_CHECK_WIDTYPE(obj, widtype);
4178 Widget_Data *wd = elm_widget_data_get(obj);
4180 wd->max_items_per_block = n;
4184 * Get the maximum number of items within an item block
4186 * @param obj The genlist object
4187 * @return Maximum number of items within an item block
4192 elm_genlist_block_count_get(const Evas_Object *obj)
4194 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4195 Widget_Data *wd = elm_widget_data_get(obj);
4197 return wd->max_items_per_block;
4201 * Set the timeout in seconds for the longpress event
4203 * @param obj The genlist object
4204 * @param timeout timeout in seconds
4209 elm_genlist_longpress_timeout_set(Evas_Object *obj, double timeout)
4211 ELM_CHECK_WIDTYPE(obj, widtype);
4212 Widget_Data *wd = elm_widget_data_get(obj);
4214 wd->longpress_timeout = timeout;
4218 * Get the timeout in seconds for the longpress event
4220 * @param obj The genlist object
4221 * @return timeout in seconds
4226 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4228 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4229 Widget_Data *wd = elm_widget_data_get(obj);
4231 return wd->longpress_timeout;
4235 * Set the scrollbar policy
4237 * This sets the scrollbar visibility policy for the given genlist scroller.
4238 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
4239 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4240 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4241 * This applies respectively for the horizontal and vertical scrollbars.
4243 * @param obj The genlist object
4244 * @param policy_h Horizontal scrollbar policy
4245 * @param policy_v Vertical scrollbar policy
4250 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4252 ELM_CHECK_WIDTYPE(obj, widtype);
4253 Widget_Data *wd = elm_widget_data_get(obj);
4255 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4256 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4259 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4263 elm_genlist_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
4265 ELM_CHECK_WIDTYPE(obj, widtype);
4266 Widget_Data *wd = elm_widget_data_get(obj);
4267 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4268 if ((!wd) || (!wd->scr)) return;
4269 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4270 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
4271 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
4274 // added for item moving animation.
4276 _group_item_contract_moving_effect_timer_cb(void *data)
4278 Evas_Object *obj = (Evas_Object *)data;
4279 Widget_Data *wd = elm_widget_data_get(obj);
4281 Item_Block *itb = NULL;
4282 Elm_Genlist_Item *git;
4283 Elm_Genlist_Item *it;
4285 int cnt = 0, git_count = 0;
4286 double added_gy = 1;
4288 int hide_git = 0, git_cnt = 0, list_start_y = 0;
4290 int *git_array = NULL;
4291 int base_git = 0, base_git_num = 0;
4292 int tmp_y = 0, devide_size = 1;
4295 Eina_Bool finish = EINA_FALSE;
4297 Evas_Coord ox, oy, ow, oh;
4299 return ECORE_CALLBACK_CANCEL;
4301 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4302 return ECORE_CALLBACK_CANCEL;
4304 git_array = (int*)malloc(sizeof(int) * wd->max_git_num);
4305 t = ecore_loop_time_get();
4307 if (t - wd->effect_start >= 5.0)
4310 if (wd->item_count < 100)
4311 devide_size = 8 * _elm_config->scale;
4312 else if (wd->item_count < 500)
4313 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4315 devide_size = 2 * _elm_config->scale;
4317 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4320 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4321 list_start_y += wd->select_all_item->h;
4323 EINA_INLIST_FOREACH(wd->group_items, git)
4325 git_array[git_cnt++] = git->y;
4326 if (git->y < list_start_y)
4328 edje_object_signal_emit(git->base, "elm,state,alpha,disable", "elm");
4330 base_git_num = hide_git;
4332 EINA_INLIST_FOREACH(wd->group_items, git)
4334 base_git = list_start_y + git->h * (git->num - 1) + git->num;
4335 git->old_y = git->y;
4336 added_gy = abs(base_git - git->y) / devide_size;
4340 if (!git->down && git->old_y < list_start_y)
4342 git->finish_y = base_git;
4344 git->y = list_start_y - (git->h+1) * hide_git--;
4348 else if (!git->down && git->y < base_git)
4351 if (wd->pinch_zoom_reserve)
4358 if (git->y < base_git)
4361 if (git->y > base_git)
4367 if (git->y > base_git)
4370 if (git->y < base_git)
4374 if (git->num - 1 == cnt && git->y == base_git)
4377 evas_object_resize(git->base, wd->minw, git->h);
4378 evas_object_move(git->base, git->x, git->y);
4379 evas_object_raise(git->base);
4380 if (git->y < list_start_y)
4381 evas_object_lower(git->base);
4383 evas_object_raise(git->base);
4384 evas_object_show(git->base);
4386 EINA_INLIST_FOREACH(wd->blocks, itb)
4388 EINA_LIST_FOREACH(itb->items, l, it)
4390 if (it->group_item == git)
4392 if (it->group_item->old_y)
4393 it->old_scrl_y -= (it->group_item->old_y - it->group_item->y);
4395 if (git_array[it->group_item->num+1] <= it->old_scrl_y || added_gy == 1.0)
4397 evas_object_color_set(it->base, 0,0,0,0);
4398 evas_object_color_set(it->edit_obj, 0,0,0,0);
4400 _move_edit_controls(it,it->scrl_x, it->old_scrl_y);
4401 evas_object_resize(it->base, itb->wd->minw-(it->pad_left+it->pad_right), it->h);
4402 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4403 evas_object_raise(it->group_item->base);
4404 evas_object_show(it->base);
4408 if (git_count == git_cnt)
4413 if (wd->select_all_item) evas_object_raise(wd->select_all_item->base);
4418 if (finish) // finish animation
4421 EINA_INLIST_FOREACH(wd->group_items, git)
4425 wd->contract_pan_y = 0;
4426 wd->pinch_zoom_reserve = EINA_FALSE;
4427 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH;
4428 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4429 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4431 // fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT FINISH \n");
4435 EINA_INLIST_FOREACH(wd->blocks, itb)
4437 if (itb->realized) {
4438 EINA_LIST_FOREACH(itb->items, l, it)
4441 it->scrl_y = oy + tmp_y;
4443 // need to handle edit mode
4444 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4445 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
4446 evas_object_color_set(it->base, 0,0,0,0);
4447 evas_object_show(it->base);
4453 evas_object_lower(wd->alpha_bg);
4454 evas_object_hide(wd->alpha_bg);
4456 return ECORE_CALLBACK_CANCEL;
4459 return ECORE_CALLBACK_RENEW;
4462 // added for item moving animation.
4464 _group_item_expand_moving_effect_timer_cb(void *data)
4466 Evas_Object *obj = (Evas_Object *)data;
4467 Widget_Data *wd = elm_widget_data_get(obj);
4468 Elm_Genlist_Item *git, *tmp_git;
4469 Item_Block *itb = NULL;
4470 Elm_Genlist_Item *it;
4472 int cnt = 0, git_count = 0, git_cnt = 0, git_tmp_y = 0, in = 0, start_in = 0;
4473 int tmp = 0, show_git_cnt = 0, scroll_y = 0, top_git = 0 , git_h = 0, scroll_pan_y = 0, down = 0;
4474 int up_cnt = 1, down_cnt = 1, it_h = 0, devide_size = 1;
4475 static int last_git_y = 0;
4479 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4481 static double added_gy = 0; // temp value for animation speed
4482 static double added_gy2 = 0;
4483 Eina_Bool finish = EINA_FALSE;
4485 return ECORE_CALLBACK_CANCEL;
4487 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4488 return ECORE_CALLBACK_CANCEL;
4490 t = ecore_loop_time_get();
4492 top_git = wd->pinch_it;
4496 else if (top_git >= wd->max_git_num)
4497 top_git = wd->max_git_num - 1;
4499 if (wd->item_count < 100)
4500 devide_size = 8 * _elm_config->scale;
4501 else if (wd->item_count < 500)
4502 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4504 devide_size = 2 * _elm_config->scale;
4506 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4507 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4508 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4509 oy += wd->select_all_item->h;
4510 // calculate git count and srcroll move position
4511 EINA_INLIST_FOREACH(wd->group_items, git)
4513 if (git_cnt == top_git - 1)
4518 EINA_INLIST_FOREACH(wd->blocks, itb)
4520 EINA_LIST_FOREACH(itb->items, l, it)
4522 if (it->group_item == git)
4532 scroll_pan_y = scroll_y + git_h * (top_git-1) ;
4534 if (t - wd->effect_start >= 5.0)
4538 EINA_INLIST_FOREACH(wd->blocks, itb)
4540 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4541 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4546 EINA_LIST_FOREACH(itb->items, l, it)
4548 _item_realize(it, start_in, 0);
4549 it->realized = EINA_TRUE;
4552 itb->realized = EINA_TRUE;
4553 itb->want_unrealize = EINA_FALSE;
4559 if (itb->realized) _item_block_unrealize(itb);
4564 // set group item finish y and items y position of group item and items.
4567 EINA_INLIST_FOREACH(wd->group_items, git)
4569 if (git->num >= top_git)
4571 git->finish_y = git_tmp_y;
4572 git_tmp_y += git->h;
4573 tmp = git->y + git->h;
4577 git->finish_y = -1 * oh;
4579 EINA_INLIST_FOREACH(wd->blocks, itb)
4581 EINA_LIST_FOREACH(itb->items, l, it)
4583 if (it->group_item == git)
4585 if (git->finish_y != -1 * oh)
4587 it->old_scrl_y = tmp;
4589 added_gy2 = abs(git->finish_y - git->y) / devide_size;
4590 tmp += it->h - added_gy2;
4593 it->old_scrl_y = -1 * oh;
4598 if (git->finish_y >= oy && git->finish_y < oy+oh)
4602 EINA_INLIST_FOREACH(wd->group_items, git)
4606 evas_object_move(git->base, git->x, git->y);
4609 evas_object_raise(git->base);
4610 evas_object_show(git->base);
4614 evas_object_lower(git->base);
4615 evas_object_hide(git->base);
4618 added_gy = abs(git->finish_y - git->y) / devide_size;
4619 if (added_gy < 1.0) added_gy = 1.0;
4620 if (git->y > git->finish_y)
4624 if (git->num >= top_git)
4628 else if (git->y < git->finish_y)
4635 if ((!down && git->y < git->finish_y) || (down && git->y > git->finish_y))
4636 git->y = git->finish_y;
4638 if (git_cnt-1 == cnt)
4639 last_git_y = git->y;
4641 if (git->num == top_git && git->y == oy)
4643 evas_object_move(git->base, git->x, git->y);
4644 evas_object_show(git->base);
4646 EINA_INLIST_FOREACH(wd->group_items, tmp_git)
4648 if (tmp_git->y == tmp_git->finish_y && tmp_git->y > oy && tmp_git->y < oy+oh)
4655 EINA_INLIST_FOREACH(wd->blocks, itb)
4657 EINA_LIST_FOREACH(itb->items, l, it)
4659 if (it->group_item == git)
4662 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4663 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4665 evas_object_resize(it->base, wd->minw-(it->pad_left+it->pad_right), it->h);
4666 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4667 _move_edit_controls(it, it->scrl_x, it->old_scrl_y);
4668 evas_object_color_set(it->edit_obj, 255,255,255,255);
4669 evas_object_color_set(it->base, 255,255,255,255);
4670 evas_object_raise(it->base);
4671 evas_object_raise(it->group_item->base);
4679 if (git_count + 1 == show_git_cnt)
4688 wd->pan_y = scroll_y + (git_h) * (top_git-1) ;
4690 EINA_INLIST_FOREACH(wd->group_items, git)
4692 edje_object_signal_emit(git->base, "elm,state,alpha,enable", "elm");
4694 EINA_INLIST_FOREACH(wd->blocks, itb)
4696 EINA_LIST_FOREACH(itb->items, l, it)
4701 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
4702 fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND FINISH \n");
4703 elm_smart_scroller_hold_set(wd->scr, 0);
4704 elm_smart_scroller_freeze_set(wd->scr, 0);
4705 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_FALSE);
4706 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4707 // printf("_group_item_expand_moving_effect_timer_cb FINISH \n");
4708 evas_object_lower(wd->alpha_bg);
4709 evas_object_hide(wd->alpha_bg);
4710 // evas_object_smart_changed(wd->pan_smart);
4711 if (wd->calc_job) ecore_job_del(wd->calc_job);
4712 wd->calc_job = ecore_job_add(_calc_job, wd);
4714 return ECORE_CALLBACK_CANCEL;
4717 return ECORE_CALLBACK_RENEW;
4721 _item_pinch_recalc(Evas_Object *obj, int emode)
4723 Item_Block *itb = NULL;
4725 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4726 Widget_Data *wd = elm_widget_data_get(obj);
4728 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND)
4731 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4732 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4736 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4738 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT;
4740 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4741 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE);
4742 evas_object_raise(wd->alpha_bg);
4743 evas_object_show(wd->alpha_bg);
4745 wd->effect_start = ecore_loop_time_get();
4746 wd->item_moving_effect_timer = ecore_animator_add(_group_item_contract_moving_effect_timer_cb, obj);
4749 else if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4751 elm_smart_scroller_momentum_animator_disabled_set(wd->scr, EINA_TRUE);
4753 evas_object_raise(wd->alpha_bg);
4754 evas_object_show(wd->alpha_bg);
4756 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND;
4757 EINA_INLIST_FOREACH(wd->blocks, itb)
4759 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4760 itb->y - wd->pan_y + oy,
4762 cvx, cvy, cvw, cvh))
4764 if (itb->realized) _item_block_unrealize(itb);
4765 itb->realized = EINA_FALSE;
4769 wd->effect_start = ecore_loop_time_get();
4770 wd->item_moving_effect_timer = ecore_animator_add(_group_item_expand_moving_effect_timer_cb, obj);
4777 create_tray_alpha_bg(const Evas_Object *obj)
4779 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4780 Widget_Data *wd = elm_widget_data_get(obj);
4781 if (!wd) return NULL;
4783 Evas_Object *bg = NULL;
4784 Evas_Coord ox, oy, ow, oh;
4786 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4787 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
4788 evas_object_color_set(bg , 0,0,0,0);
4789 evas_object_resize(bg , ow, oh);
4790 evas_object_move(bg , ox, oy);
4791 evas_object_show(bg);
4792 evas_object_hide(bg);
4797 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
4799 ELM_CHECK_WIDTYPE(obj, widtype);
4800 Widget_Data *wd = elm_widget_data_get(obj);
4801 if (!wd || !wd->pinch_zoom) return;
4802 if (!wd->queue_idler)
4805 wd->alpha_bg = create_tray_alpha_bg(obj);
4806 _item_pinch_recalc(obj, emode);
4811 * Set pinch zoom mode
4813 * @param obj The genlist object
4815 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4820 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
4822 ELM_CHECK_WIDTYPE(obj, widtype);
4823 Widget_Data *wd = elm_widget_data_get(obj);
4824 if (!wd || !wd->pinch_zoom) return;
4825 wd->pinch_zoom_reserve = emode;
4829 * Get pinch zoom mode
4831 * @param obj The genlist object
4832 * @return The pinch mode
4833 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4838 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
4840 Widget_Data *wd = elm_widget_data_get(obj);
4841 if (!wd) return EINA_FALSE;
4842 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4844 else return EINA_FALSE;
4848 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
4850 Widget_Data *wd = elm_widget_data_get(obj);
4852 wd->pinch_zoom = emode;
4855 // added for item moving animation.
4857 _item_moving_effect_timer_cb(void *data)
4859 Widget_Data *wd = data;
4861 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4862 Elm_Genlist_Item *it;
4864 int expanded_cnt = 0;
4866 static double added_gy =25;
4867 static int count = 0;
4868 if (!wd) return EINA_FALSE;
4869 if (added_gy < 1) added_gy = 1;
4872 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4873 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4875 EINA_INLIST_FOREACH(wd->blocks, itb)
4878 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4879 itb->y - wd->pan_y + oy,
4881 cvx, cvy, cvw, cvh))
4883 EINA_LIST_FOREACH(itb->items, l, it)
4885 if (!it->old_scrl_y)
4886 it->old_scrl_y = it->scrl_y;
4887 if (it->parent && it->parent->expanded && !it->showme)
4889 evas_object_hide(it->base);
4891 else evas_object_show(it->base);
4893 evas_object_show(it->base);
4895 if (itb && itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
4897 if (it->old_scrl_y && it->old_scrl_y < it->scrl_y) {
4898 it->old_scrl_y += added_gy;
4900 if (it->old_scrl_y >= it->scrl_y) {
4901 it->list_expanded = 1;
4902 it->old_scrl_y = it->scrl_y;
4905 else if (itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
4907 if (it->old_scrl_y && it->old_scrl_y > it->scrl_y)
4910 it->old_scrl_y -= added_gy;
4913 if (it->old_scrl_y <= it->scrl_y) {
4914 it->list_expanded = 1;
4915 it->old_scrl_y = it->scrl_y;
4918 expanded_cnt += it->list_expanded;
4921 _move_edit_controls(it,it->scrl_x, it->scrl_y);
4922 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
4923 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4924 evas_object_raise(it->base);
4928 if (expanded_cnt == cnt)
4930 if (wd->item_moving_effect_timer)
4934 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
4935 EINA_INLIST_FOREACH(wd->blocks, itb)
4937 EINA_LIST_FOREACH(itb->items, l, it)
4939 it->list_expanded = 0;
4944 return ECORE_CALLBACK_CANCEL;
4946 return ECORE_CALLBACK_RENEW;
4949 // added for edit mode item moving animation.
4951 _edit_mode_item_moving_effect_cb(void *data)
4953 Widget_Data *wd = data;
4955 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4956 Elm_Genlist_Item *it, *select_all_item;
4958 int expanded_cnt = 0;
4959 static double added_gy = 9;
4960 static float count = 0;
4962 static float select_all_y = 0;
4964 if (!wd) return EINA_FALSE;
4967 if (!wd->select_all_item)
4968 return ECORE_CALLBACK_CANCEL;
4970 static float dy = 9;
4975 select_all_y += (dy);
4977 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4978 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4980 EINA_INLIST_FOREACH(wd->blocks, itb)
4983 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4984 itb->y - wd->pan_y + oy,
4986 cvx, cvy, cvw, cvh))
4989 EINA_LIST_FOREACH(itb->items, l, it)
4992 evas_object_show(it->base);
4993 if (it->old_pad_left < it->pad_left)
4995 it->old_pad_left += dy;
4996 if (it->old_pad_left >= it->pad_left)
4998 it->list_expanded = 1;
4999 it->old_pad_left = it->pad_left;
5002 if (it->old_pad_left > it->pad_left)
5004 it->old_pad_left -= dy;
5005 if (it->old_pad_left <= it->pad_left)
5007 it->list_expanded = 1;
5008 it->old_pad_left = it->pad_left;
5012 if (it->old_scrl_y < it->scrl_y)
5014 it->old_scrl_y += (dy) ;
5015 if (it->old_scrl_y >= it->scrl_y)
5017 it->list_expanded = 1;
5018 it->old_scrl_y = it->scrl_y;
5022 if (it->old_scrl_y > it->scrl_y)
5024 it->old_scrl_y -= (dy);
5025 if (it->old_scrl_y <= it->scrl_y)
5027 it->list_expanded = 1;
5028 it->old_scrl_y = it->scrl_y;
5033 select_all_item = itb->wd->select_all_item;
5034 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
5035 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5036 evas_object_move(select_all_item->base, ox, oy - select_all_y);
5037 else if (select_all_y <= select_all_item->h)
5038 evas_object_move(select_all_item->base, ox, oy - select_all_item->h + select_all_y);
5039 evas_object_raise(select_all_item->base);
5040 evas_object_show(select_all_item->base);
5042 expanded_cnt += it->list_expanded;
5044 evas_object_move(it->base, it->scrl_x+it->old_pad_left, it->old_scrl_y);
5045 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
5046 evas_object_raise(it->edit_obj);
5047 evas_object_raise(it->base);
5049 evas_object_show(it->edit_obj);
5050 evas_object_show(it->base);
5052 if (select_all_y >= wd->select_all_item->h && it->list_expanded == 1)
5055 evas_object_raise(it->edit_obj);
5064 if (wd->item_moving_effect_timer)
5070 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5071 EINA_INLIST_FOREACH(wd->blocks, itb)
5073 EINA_LIST_FOREACH(itb->items, l, it)
5075 it->list_expanded = 0;
5078 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5080 if (wd->select_all_item)
5082 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5083 free(wd->select_all_item);
5085 wd->select_all_item = NULL;
5088 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5089 wd->effect_mode = 0;
5091 if (wd->calc_job) ecore_job_del(wd->calc_job);
5092 wd->calc_job = ecore_job_add(_calc_job, wd);
5093 return ECORE_CALLBACK_CANCEL;
5095 return ECORE_CALLBACK_RENEW;
5099 // added for item moving animation.
5101 _item_flip_effect_show(void *data)
5103 Widget_Data *wd = data;
5105 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5107 if (!wd) return EINA_FALSE;
5109 Elm_Genlist_Item *it;
5112 int start = 0, end = 0;
5114 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5115 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5117 EINA_INLIST_FOREACH(wd->blocks, itb)
5120 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5121 itb->y - wd->pan_y + oy,
5123 cvx, cvy, cvw, cvh))
5125 EINA_LIST_FOREACH(itb->items, l, it)
5127 if (it->parent && it->wd->expand_item == it->parent && !it->effect_done)
5129 if (!start) start = it->scrl_y;
5130 base = (Evas_Object *) it->base;
5131 edje_object_signal_emit(it->base, "flip_item", "");
5132 end = it->scrl_y + it->h;
5133 it->effect_done = EINA_TRUE;
5138 wd->expand_item_cnt = end - start;
5139 return ECORE_CALLBACK_CANCEL;
5143 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5145 ELM_CHECK_WIDTYPE(obj, widtype);
5146 Widget_Data *wd = elm_widget_data_get(obj);
5148 wd->effect_mode = emode;
5149 wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5150 evas_object_resize(wd->point_rect, 10, 25);
5151 evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5152 evas_object_show(wd->point_rect);
5153 evas_object_hide(wd->point_rect);
5157 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
5159 Widget_Data *wd = data;
5160 evas_object_hide(wd->ed->del_confirm);
5161 if (wd->ed->ec && wd->ed->ec->remove)
5162 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
5163 wd->ed->del_item = NULL;
5167 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
5169 const char *del_icon_part;
5170 Elm_Genlist_Item *it = data;
5171 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5173 edje_object_part_unswallow(it->edit_obj, it->wd->ed->del_confirm);
5174 evas_object_hide(it->wd->ed->del_confirm);
5178 _edit_item_check_set(Elm_Genlist_Item *it, Eina_Bool del_confirm_state)
5180 if (del_confirm_state)
5182 it->del_confirm_state = 0;
5183 it->delete_check = 0;
5184 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5185 it->wd->selct_all = 0;
5186 if (elm_genlist_item_parent_get(it))
5187 edje_object_signal_emit(elm_genlist_item_parent_get(it)->edit_obj, "elm,state,del,animated,enable", "elm");
5188 if (it->wd->select_all_item)
5189 edje_object_signal_emit(it->wd->select_all_item->base, "elm,state,del,animated,enable", "elm");
5190 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5191 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5195 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5196 it->del_confirm_state = 1;
5197 it->delete_check = 1;
5202 _edit_subitems_check(Elm_Genlist_Item *it)
5205 Eina_List *tl = NULL, *l;
5206 Elm_Genlist_Item *it2;
5208 EINA_LIST_FOREACH(it->items, l, it2)
5209 tl = eina_list_append(tl, it2);
5210 EINA_LIST_FREE(tl, it2)
5211 _edit_item_check_set(it2, !elm_genlist_item_parent_get(it2)->del_confirm_state);
5215 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5217 const char *del_conf_style;
5218 Elm_Genlist_Item *it = data;
5219 if (_edit_mode_reset(it->wd))
5222 if (it->edit_long_timer)
5224 ecore_timer_del(it->edit_long_timer);
5225 it->edit_long_timer = NULL;
5227 _edit_item_check_set(it, it->del_confirm_state);
5228 _edit_subitems_check(it);
5229 it->wd->ed->del_item = it;
5231 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5232 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5233 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
5235 elm_object_style_set(it->wd->ed->del_confirm, del_conf_style);
5238 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5240 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
5241 evas_object_show(it->wd->ed->del_confirm);
5246 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5248 Elm_Genlist_Item *it = data;
5250 if (_edit_mode_reset(it->wd))
5253 if (it->wd->ed->ec && it->wd->ed->ec->insert_new)
5254 it->wd->ed->ec->insert_new(it->wd->obj, it);
5258 _edit_mode_reset(Widget_Data *wd)
5261 if (wd->ed->del_confirm_state)
5263 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
5264 //wd->ed->del_confirm_state = 0;
5265 //wd->ed->del_item = NULL;
5273 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5275 Elm_Genlist_Item *it = data;
5276 Evas_Event_Mouse_Down *ev = event_info;
5279 if (it->wd->edit_field && !it->renamed)
5280 elm_genlist_item_rename_mode_set(it, 0);
5282 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
5285 if (_edit_mode_reset(it->wd))
5290 it->reoder_cavas_x = ev->canvas.x;
5291 it->reoder_cavas_y = ev->canvas.y;
5293 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5294 it->dx = ev->canvas.x - x;
5295 it->dy = ev->canvas.y - y;
5297 if (it->edit_long_timer)
5299 ecore_timer_del(it->edit_long_timer);
5300 it->edit_long_timer = NULL;
5305 it->edit_long_timer = ecore_timer_add(0.3,_edit_long_press, it);
5307 it->edit_long_timer = NULL;
5309 fprintf(stderr, "genlist : reordering is temporary disabled.\n");
5313 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5315 Elm_Genlist_Item *it = data;
5318 EINA_INLIST_FOREACH(it->wd->blocks, itb)
5322 if (it->edit_long_timer)
5324 ecore_timer_del(it->edit_long_timer);
5325 it->edit_long_timer = NULL;
5329 it->wd->reoder_moved = EINA_FALSE;
5331 if (it->wd->ed->ec->selected)
5332 it->wd->ed->ec->selected(NULL, it, 1);
5334 if (it->reordering && it->wd->ed->reorder_item)
5336 it->wd->ed->reorder_item->reordering = 0;
5337 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
5338 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
5340 if ((!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
5341 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE)))
5343 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);
5344 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y);
5346 it->wd->ed->reorder_item = NULL;
5347 it->wd->ed->reorder_rel = NULL;
5353 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5355 Elm_Genlist_Item *it = data;
5356 Evas_Event_Mouse_Move *ev = event_info;
5358 if ((it->dragging) && (it->down))
5360 if (it->edit_long_timer)
5362 ecore_timer_del(it->edit_long_timer);
5363 it->edit_long_timer = NULL;
5366 evas_object_smart_callback_call(it->wd->obj, "drag", it);
5370 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
5372 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
5373 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5374 x = ev->cur.canvas.x - x;
5375 y = ev->cur.canvas.y - y;
5378 if (adx < 0) adx = -dx;
5381 if (ady < 0) ady = -dy;
5384 if ((adx > minw) || (ady > minh))
5387 if (it->edit_long_timer)
5389 ecore_timer_del(it->edit_long_timer);
5390 it->edit_long_timer = NULL;
5394 if (it->reordering && it->wd->ed->reorder_item)
5396 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
5397 evas_object_raise(it->wd->ed->reorder_item->base);
5398 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
5399 evas_object_show(it->wd->ed->reorder_item->base);
5400 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, y);
5402 it->block->updateme = EINA_TRUE;
5404 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5405 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5412 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5415 Elm_Genlist_Item *select_all_it = data, *it;
5417 Widget_Data *wd = select_all_it->wd;
5421 edje_object_signal_emit(select_all_it->base, "elm,state,del_confirm", "elm");
5423 edje_object_signal_emit(select_all_it->base, "elm,state,del,animated,enable", "elm");
5425 EINA_INLIST_FOREACH(wd->blocks, itb)
5427 EINA_LIST_FOREACH(itb->items, l, it)
5431 it->delete_check = 1;
5432 it->del_confirm_state = 1;
5433 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5437 it->delete_check = 0;
5438 it->del_confirm_state = 0;
5439 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5443 wd->selct_all ^= 0xFF;
5445 if (wd->ed->ec->item_selected)
5446 wd->ed->ec->item_selected(select_all_it->data, select_all_it, wd->selct_all);
5447 if (wd->calc_job) ecore_job_del(wd->calc_job);
5448 wd->calc_job = ecore_job_add(_calc_job, wd);
5452 _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity)
5454 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5456 evas_object_resize(it->edit_obj,it->w, it->h);
5457 evas_object_move(it->edit_obj, itx, ity);
5458 evas_object_raise(it->edit_obj);
5462 _edit_controls_eval(Elm_Genlist_Item *it)
5465 const char *pad_str;
5472 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj)
5475 if (it->itc->func.editmode_get)
5476 itmode = it->itc->func.editmode_get(it->data, it->wd->obj, it->wd->edit_mode);
5477 itmode &= it->wd->edit_mode;
5479 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5480 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5484 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
5485 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
5486 _elm_config->scale);
5487 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5488 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
5489 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5490 else strncpy(buf, "item", sizeof(buf));
5491 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5492 // if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
5493 strncat(buf, "/", sizeof(buf) - strlen(buf));
5495 if (it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5497 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5498 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
5502 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
5505 // edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
5506 // "elm", _edit_mode_reset, it);
5509 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
5510 if (pad_str) pad = atoi(pad_str);
5512 if ((itmode & ELM_GENLIST_EDIT_MODE_INSERT))
5514 if (it->wd->animate_edit_controls)
5515 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
5517 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
5519 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
5520 "elm", _insert_new_item_cb, it);
5521 it->pad_left += pad * _elm_config->scale;
5525 if (it->wd->animate_edit_controls)
5526 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
5528 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
5530 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
5531 "elm", _insert_new_item_cb);
5534 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
5536 if (it->wd->animate_edit_controls)
5537 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5539 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5541 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5542 "elm", _remove_item_cb);
5543 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5544 "elm", _hide_delete_confirm_object);
5546 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
5547 "elm", _remove_item_cb, it);
5549 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
5550 "elm", _hide_delete_confirm_object, it);
5551 it->pad_left += pad * _elm_config->scale;
5552 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5553 _reorder_mouse_down, it);
5557 if (it->wd->animate_edit_controls)
5558 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
5560 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
5562 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5563 "elm", _remove_item_cb);
5564 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5565 "elm", _hide_delete_confirm_object);
5566 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5567 _reorder_mouse_down);
5570 if ((itmode & ELM_GENLIST_EDIT_MODE_REORDER))
5572 const char* reorder_part;
5574 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5575 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5577 edje_object_part_object_get(it->edit_obj, reorder_part);
5579 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5580 _reorder_mouse_down);
5581 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5583 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5584 _reorder_mouse_move);
5586 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5587 _reorder_mouse_down, it);
5588 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5589 _reorder_mouse_up, it);
5590 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5591 _reorder_mouse_move, it);
5593 // it->pad_right += pad * _elm_config->scale;
5597 const char* reorder_part;
5599 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5600 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5603 if (itmode == ELM_GENLIST_EDIT_MODE_NONE)
5605 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5606 _reorder_mouse_down);
5607 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5609 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5610 _reorder_mouse_move);
5615 if (it->wd->edit_mode != 0xF0) {
5616 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
5618 if (it->itc->func.icon_get)
5620 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
5625 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
5626 EINA_LIST_FOREACH(it->icons, l, key)
5628 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
5632 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5633 edje_object_part_swallow(it->edit_obj, key, ic);
5634 evas_object_show(ic);
5635 // elm_widget_sub_object_add(it->wd->obj, ic);
5642 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5643 EINA_LIST_FREE(it->edit_icon_objs, icon)
5644 evas_object_del(icon);
5646 Evas_Object *editfield;
5647 EINA_LIST_FREE(it->wd->edit_field, editfield)
5648 evas_object_del(editfield);
5652 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)//Unrealize
5654 evas_object_del(it->edit_obj);
5655 it->edit_obj = NULL;
5658 _move_edit_controls(it,it->scrl_x, it->scrl_y);
5659 evas_object_show(it->edit_obj);
5663 _notify_item_position(Elm_Genlist_Item *it)
5668 l = eina_list_last(it->parent->items);
5670 //Check if the Item is First Node or Last node of its Parent & raise signal.
5671 if (it->parent->items->data != it && l->data != it)
5673 edje_object_signal_emit(it->base, "normal_item", "elm");
5677 if (it->parent->items->data == it)
5678 edje_object_signal_emit(it->base, "first_item", "elm");
5681 edje_object_signal_emit(it->base, "last_item", "elm");
5687 _get_space_for_reorder_item(Elm_Genlist_Item *it)
5690 Evas_Coord rox, roy, row, roh;
5691 if (!it->wd->ed) return 0;
5692 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) || !it->wd->ed->reorder_item)
5694 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
5695 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
5696 rox, roy+roh/2, row, 1));
5699 it->wd->ed->reorder_rel = it;
5700 it->scrl_y+=it->wd->ed->reorder_item->h;
5701 it->reorder_check = 1;
5702 return it->wd->ed->reorder_item->h;
5708 * Moves the Genlist Item
5711 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5716 Elm_Genlist_Item *next_item = elm_genlist_item_next_get(after);
5718 if (it->y == after->y && after->reorder_check && it->reorder_check)
5720 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5721 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5725 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5726 _item_block_del(it);
5728 if ((!next_item && after->reorder_check) || (next_item && !after->reorder_check))
5731 if (next_item && !after->reorder_check && it == after)
5733 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5734 EINA_INLIST_GET(next_item));
5735 it->rel = next_item;
5739 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
5740 EINA_INLIST_GET(after));
5744 it->rel->relcount++;
5751 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
5752 EINA_INLIST_GET(after));
5754 it->rel->relcount++;
5758 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
5762 after->reorder_check = 0;
5763 _item_queue(it->wd, it);
5767 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5769 fprintf(stderr, "=================> Caution!!! <========================\n");
5770 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
5771 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
5772 fprintf(stderr, "=======================================================\n");
5774 elm_genlist_edit_mode_set(obj, emode, edit_class);
5778 * Set Genlist edit mode
5780 * This sets Genlist edit mode.
5782 * @param obj The Genlist object
5783 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5784 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5789 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5791 Elm_Genlist_Item *it;
5795 static Elm_Genlist_Item_Class itc;
5797 ELM_CHECK_WIDTYPE(obj, widtype);
5798 Widget_Data *wd = elm_widget_data_get(obj);
5800 if (wd->edit_mode == emode) return;
5802 wd->edit_mode = emode;
5803 wd->animate_edit_controls = 1;
5805 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5806 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
5808 if (wd->edit_mode_effect_mode)
5810 wd->effect_mode = EINA_TRUE;
5811 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE;
5814 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5816 if (wd->ed) free (wd->ed);
5822 wd->ed = calloc(1, sizeof(Edit_Data));
5824 wd->ed->ec = edit_class;
5826 if (((wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)) && !wd->ed->del_confirm)
5828 wd->ed->del_confirm = elm_button_add(wd->obj);
5829 elm_button_label_set(wd->ed->del_confirm, "Delete");
5830 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
5831 edje_object_scale_set(wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
5832 _elm_config->scale);
5833 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd);
5836 EINA_INLIST_FOREACH(wd->blocks, itb)
5838 EINA_LIST_FOREACH(itb->items, l, it)
5840 if (it->flags != ELM_GENLIST_ITEM_GROUP)
5842 it->delete_check = 0;
5843 it->del_confirm_state = 0;
5845 _edit_controls_eval(it);
5849 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5851 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
5852 itc.item_style = edit_class->select_all_item_style;
5854 itc.item_style = "select_all";
5855 itc.func.label_get = NULL;
5856 itc.func.icon_get = NULL;
5857 itc.func.del = NULL;
5858 itc.func.editmode_get = NULL;
5860 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
5863 if (!wd->select_all_item) return;
5865 _item_realize(wd->select_all_item, 0, 0);
5866 edje_object_signal_callback_add(wd->select_all_item->base, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
5868 wd->select_all_item->rel = NULL;
5869 wd->select_all_item->selected = 0;
5870 wd->select_all_item->before = 1;
5871 wd->select_all_item->block = NULL;
5872 wd->select_all_minh = wd->minh + wd->select_all_item->h;
5874 else if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
5876 if (wd->select_all_item)
5878 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5879 free(wd->select_all_item);
5881 wd->select_all_item = NULL;
5883 edje_object_signal_emit(wd->scr, "elm,state,edit,animated,enable", "elm");
5885 if (wd->calc_job) ecore_job_del(wd->calc_job);
5886 wd->calc_job = ecore_job_add(_calc_job, wd);
5890 * Delete selected items in genlist edit mode.
5892 * @param obj The genlist object
5897 elm_genlist_edit_selected_items_del(Evas_Object *obj)
5899 Elm_Genlist_Item *it;
5901 Item_Block *itb = NULL;
5903 ELM_CHECK_WIDTYPE(obj, widtype);
5904 Widget_Data *wd = elm_widget_data_get(obj);
5906 if (!wd->blocks) return;
5908 EINA_INLIST_FOREACH(wd->blocks, itb)
5910 if (!wd->blocks) break;
5914 EINA_LIST_FOREACH(itb->items, l, it)
5916 if (it->delete_check)
5918 it->wd->effect_mode = EINA_TRUE;
5922 itb->wd->minh -= it->h;
5923 itb->wd->select_all_minh -= it->h;
5926 if ((it->relcount > 0) || (it->walking > 0))
5928 elm_genlist_item_subitems_clear(it);
5929 it->delete_me = EINA_TRUE;
5930 if (it->wd->show_item == it) it->wd->show_item = NULL;
5931 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5934 if (it->realized) _item_unrealize(it);
5935 it->block->changed = EINA_TRUE;
5937 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
5941 it->wd->walking -= it->walking;
5942 if (it->wd->show_item == it) it->wd->show_item = NULL;
5943 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
5944 if (it->realized) _item_unrealize(it);
5946 EINA_LIST_FREE(it->edit_icon_objs, icon)
5947 evas_object_del(icon);
5949 Evas_Object *editfield;
5950 EINA_LIST_FREE(it->wd->edit_field, editfield)
5951 evas_object_del(editfield);
5953 evas_object_del(it->edit_obj);
5954 it->edit_obj = NULL;
5956 itb->items = eina_list_remove(itb->items, it);
5958 itb->changed = EINA_TRUE;
5959 if ((!it->delete_me) && (it->itc->func.del))
5960 it->itc->func.del(it->data, it->wd->obj);
5961 it->delete_me = EINA_TRUE;
5963 it->wd->queue = eina_list_remove(it->wd->queue, it);
5964 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5966 it->parent->items = eina_list_remove(it->parent->items, it);
5967 if (it->long_timer) ecore_timer_del(it->long_timer);
5969 it->group_item->items = eina_list_remove(it->group_item->items,it);
5976 evas_render(evas_object_evas_get(wd->obj));
5977 if (wd->calc_job) ecore_job_del(wd->calc_job);
5978 wd->calc_job = ecore_job_add(_calc_job, wd);
5982 elm_genlist_selected_items_del(Evas_Object *obj)
5984 fprintf(stderr, "=================> Caution!!! <========================\n");
5985 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
5986 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
5987 fprintf(stderr, "=======================================================\n");
5988 elm_genlist_edit_selected_items_del(obj);
5992 * Get a list of selected items in genlist
5994 * This returns a list of the selected items in the genlist. The list
5995 * contains Elm_Genlist_Item pointers. The list must be freed by the
5996 * caller when done with eina_list_free(). The item pointers in the list
5997 * are only vallid so long as those items are not deleted or the genlist is
6000 * @param obj The genlist object
6001 * @return The list of selected items, nor NULL if none are selected.
6006 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6008 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6009 Widget_Data *wd = elm_widget_data_get(obj);
6010 Eina_List *list = NULL;
6012 if (!wd) return NULL;
6014 EINA_INLIST_FOREACH(wd->blocks, itb)
6017 Elm_Genlist_Item *it;
6019 EINA_LIST_FOREACH(itb->items, l, it)
6021 if (it->delete_check) list = eina_list_append(list, it);
6029 * Set a given item's rename mode
6031 * This renames the item's label from genlist
6033 * @param it The item
6034 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6039 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6043 const Eina_List *l, *list, *l2;
6044 const char *label, *rename_swallow_part;
6046 Eina_Bool done = EINA_FALSE;
6047 int label_cnt = 0 , swallow_part_cnt = 0;
6050 Evas_Object *editfield;
6051 Evas_Object *entry = NULL;
6052 int edit_field_cnt = 0;
6055 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6057 it->wd->edit_mode = 0xF0;
6058 _edit_controls_eval(it);
6061 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6066 Elm_Genlist_Item *it;
6069 EINA_LIST_FOREACH(itb->items, l, it)
6073 it->renamed = EINA_FALSE;
6075 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6077 entry = elm_editfield_entry_get(editfield);
6078 const char *text = elm_entry_entry_get(entry);
6080 if (it->itc->func.label_changed)
6081 it->itc->func.label_changed(it->data, it, text, edit_field_cnt++);
6083 Ecore_IMF_Context *imf = elm_entry_imf_context_get(entry);
6084 ecore_imf_context_input_panel_hide(imf);
6086 Evas_Object *editfield;
6087 EINA_LIST_FREE(it->wd->edit_field, editfield)
6088 evas_object_del(editfield);
6090 if (it->wd->edit_mode)
6092 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_INSERT))
6093 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
6095 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT))
6096 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6098 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
6099 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6103 evas_object_del(it->edit_obj);
6104 it->edit_obj = NULL;
6106 EINA_LIST_FREE(it->edit_icon_objs, icon)
6107 evas_object_del(icon);
6117 // if (emode != ELM_GENLIST_RENAME_MODE_NONE)
6120 it->renamed = EINA_TRUE;
6122 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base, "labels"));
6123 EINA_LIST_FOREACH(it->labels, list, label)
6125 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6126 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6127 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6128 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6130 if (it->itc->func.label_get)
6132 it->renamed = EINA_TRUE;
6133 swallow_part_cnt = 0;
6135 EINA_LIST_FREE(it->edit_icon_objs, icon)
6136 evas_object_del(icon);
6137 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6138 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6140 if (label_cnt == swallow_part_cnt)
6142 editfield = elm_editfield_add(it->wd->obj);
6143 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6145 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6146 elm_editfield_eraser_set(editfield, EINA_TRUE);
6147 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6148 elm_widget_sub_object_add(it->edit_obj, editfield);
6150 evas_object_show(editfield);
6152 s = it->itc->func.label_get(it->data, it->wd->obj, list->data);
6156 Evas_Object *entry = elm_editfield_entry_get(editfield);
6157 elm_entry_entry_set(entry,s);
6162 elm_editfield_guide_text_set(editfield, "Text Input");
6171 if (it->wd->edit_mode == 0xF0)
6173 it->wd->edit_mode = 0;
6178 EAPI Elm_Genlist_Item *
6179 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6182 _print_deprecated("elm_genlist_groupitem_add", "elm_genlist_item_append");
6183 return elm_genlist_item_append(obj, itc, data, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
6186 EAPI Elm_Genlist_Item *
6187 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6188 const void *data, Elm_Genlist_Item *parent,
6189 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6190 Evas_Smart_Cb func, const void *func_data)
6192 _print_deprecated("elm_genlist_item_append_with_group", "elm_genlist_item_append");
6193 return elm_genlist_item_append(obj, itc, data, git, flags, func, func_data);
6196 EAPI Elm_Genlist_Item *
6197 elm_genlist_item_prepend_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6198 const void *data, Elm_Genlist_Item *parent,
6199 Elm_Genlist_Item_Flags flags, Elm_Genlist_Item *git,
6200 Evas_Smart_Cb func, const void *func_data)
6202 _print_deprecated("elm_genlist_item_prepend_with_group", "elm_genlist_item_prepend");
6203 return elm_genlist_item_prepend(obj, itc, data, git, flags, func, func_data);
6207 elm_genlist_groupitem_del(Elm_Genlist_Item *git)
6209 _print_deprecated("elm_genlist_groupitem_del", "elm_genlist_item_del");
6210 return elm_genlist_item_del(git);
6214 _print_deprecated(const char *deprecated, const char *new)
6216 fprintf(stderr, "=================> Caution!!! <========================\n");
6217 fprintf(stderr, "==> %s () is deprecated.\n", deprecated);
6218 fprintf(stderr, "==> Use %s() instead.\n", new);
6219 fprintf(stderr, "=======================================================\n");
6224 elm_genlist_queue_exception_set(const Evas_Object *obj, Eina_Bool emode)
6226 ELM_CHECK_WIDTYPE(obj, widtype);
6227 Widget_Data *wd = elm_widget_data_get(obj);
6229 wd->queue_exception = emode;
6231 fprintf(stderr, "=================> Caution!!! <========================\n");
6232 fprintf(stderr, "==> elm_genlist_queue_exception_set() is for demo. <===\n");
6233 fprintf(stderr, "==> Do not use this API <==\n");
6234 fprintf(stderr, "=======================================================\n");