1 #include <Elementary.h>
3 #include "els_scroller.h"
6 #define MAX_ITEMS_PER_BLOCK 32
7 #define LONGPRESS_TIMEOUT 1.0
10 * @defgroup Genlist Genlist
13 * The Aim was to have more expansive list that the simple list in
14 * Elementary that could have more flexible items and allow many more entries
15 * while still being fast and low on memory usage. At the same time it was
16 * also made to be able to do tree structures. But the price to pay is more
17 * complexity when it comes to usage. If all you want is a simple list with
18 * icons and a single label, use the normal List object.
20 * Signals that you can add callbacks for are:
22 * clicked - This is called when a user has double-clicked an item. The
23 * event_info parameter is the genlist item that was double-clicked.
25 * selected - This is called when a user has made an item selected. The
26 * event_info parameter is the genlist item that was selected.
28 * unselected - This is called when a user has made an item unselected. The
29 * event_info parameter is the genlist item that was unselected.
31 * expanded - This is called when elm_genlist_item_expanded_set() is called
32 * and the item is now meant to be expanded. The event_info parameter is the
33 * genlist item that was indicated to expand. It is the job of this callback
34 * to then fill in the child items.
36 * contracted - This is called when elm_genlist_item_expanded_set() is called
37 * and the item is now meant to be contracted. The event_info parameter is
38 * the genlist item that was indicated to contract. It is the job of this
39 * callback to then delete the child items
41 * expand,request - This is called when a user has indicated they want to
42 * expand a tree branch item. The callback should decide if the item can
43 * expand (has any children) and then call elm_genlist_item_expanded_set()
44 * appropriately to set the state. The event_info parameter is the genlist
45 * item that was indicated to expand.
47 * contract,request - This is called when a user has indicated they want to
48 * contract a tree branch item. The callback should decide if the item can
49 * contract (has any children) and then call elm_genlist_item_expanded_set()
50 * appropriately to set the state. The event_info parameter is the genlist
51 * item that was indicated to contract.
53 * realized - This is called when the item in the list is created as a real
54 * evas object. event_info parameter is the genlist item that was created.
55 * The object may be deleted at any time, so it is up to the caller to
56 * not use the object pointer from elm_genlist_item_object_get() in a way
57 * where it may point to freed objects.
59 * unrealized - This is called just before an item is unrealized. After
60 * this call icon objects provideed will be deleted and the item object
61 * itself delete or be put into a floating cache.
63 * drag,start,up - This is called when the item in the list has been dragged
66 * drag,start,down - This is called when the item in the list has been dragged
67 * (not scrolled) down.
69 * drag,start,left - This is called when the item in the list has been dragged
70 * (not scrolled) left.
72 * drag,start,right - This is called when the item in the list has been dragged
73 * (not scrolled) right.
75 * drag,stop - This is called when the item in the list has stopped being
78 * drag - This is called when the item in the list is being dragged.
80 * longpressed - This is called when the item is pressed for a certain amount
81 * of time. By default it's 1 second.
83 * scroll,edge,top - This is called when the genlist is scrolled until the top
86 * scroll,edge,bottom - This is called when the genlist is scrolled until the
89 * scroll,edge,left - This is called when the genlist is scrolled until the
92 * scroll,edge,right - This is called when the genlist is scrolled until the
95 * Genlist has a fairly large API, mostly because it's relatively complex,
96 * trying to be both expansive, powerful and efficient. First we will begin
97 * an overview o the theory behind genlist.
99 * Evas tracks every object you create. Every time it processes an event
100 * (mouse move, down, up etc.) it needs to walk through objects and find out
101 * what event that affects. Even worse every time it renders display updates,
102 * in order to just calculate what to re-draw, it needs to walk through many
103 * many many objects. Thus, the more objects you keep active, the more
104 * overhead Evas has in just doing its work. It is advisable to keep your
105 * active objects to the minimum working set you need. Also remember that
106 * object creation and deletion carries an overhead, so there is a
107 * middle-ground, which is not easily determined. But don't keep massive lists
108 * of objects you can't see or use. Genlist does this with list objects. It
109 * creates and destroys them dynamically as you scroll around. It groups them
110 * into blocks so it can determine the visibility etc. of a whole block at
111 * once as opposed to having to walk the whole list. This 2-level list allows
112 * for very large numbers of items to be in the list (tests have used up to
113 * 2,000,000 items). Also genlist employs a queue for adding items. As items
114 * may be different sizes, every item added needs to be calculated as to its
115 * size and thus this presents a lot of overhead on populating the list, this
116 * genlist employs a queue. Any item added is queued and spooled off over
117 * time, actually appearing some time later, so if your list has many members
118 * you may find it takes a while for them to all appear, with your process
119 * consuming a lot of CPU while it is busy spooling.
121 * Genlist also implements a tree structure, but it does so with callbacks to
122 * the application, with the application filling in tree structures when
123 * requested (allowing for efficient building of a very deep tree that could
124 * even be used for file-management). See the above smart signal callbacks for
127 * An item in the genlist world can have 0 or more text labels (they can be
128 * regular text or textblock ??that's up to the style to determine), 0 or
129 * more icons (which are simply objects swallowed into the genlist item) and
130 * 0 or more boolean states that can be used for check, radio or other
131 * indicators by the edje theme style. An item may be one of several styles
132 * (Elementary provides 2 by default - ?
\9cdefault??and ?
\9cdouble_label?? but this
133 * can be extended by system or application custom themes/overlays/extensions).
135 * In order to implement the ability to add and delete items on the fly,
136 * Genlist implements a class/callback system where the application provides
137 * a structure with information about that type of item (genlist may contain
138 * multiple different items with different classes, states and styles).
139 * Genlist will call the functions in this struct (methods) when an item is
140 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
141 * simply be deleted when no longer needed with evas_object_del(). The
142 * Elm_Genlist_Item_Class structure contains the following members:
144 * item_style - This is a constant string and simply defines the name of the
145 * item style. It must be specified and the default should be ?
\9cdefault??
147 * func.label_get - This function is called when an actual item object is
148 * created. The data parameter is the data parameter passed to
149 * elm_genlist_item_append() and related item creation functions. The obj
150 * parameter is the genlist object and the part parameter is the string name
151 * of the text part in the edje design that is listed as one of the possible
152 * labels that can be set. This function must return a strudup()'ed string as
153 * the caller will free() it when done.
155 * func.icon_get - This function is called when an actual item object is
156 * created. The data parameter is the data parameter passed to
157 * elm_genlist_item_append() and related item creation functions. The obj
158 * parameter is the genlist object and the part parameter is the string name
159 * of the icon part in the edje design that is listed as one of the possible
160 * icons that can be set. This must return NULL for no object or a valid
161 * object. The object will be deleted by genlist on shutdown or when the item
164 * func.state_get - This function is called when an actual item object is
165 * created. The data parameter is the data parameter passed to
166 * elm_genlist_item_append() and related item creation functions. The obj
167 * parameter is the genlist object and the part parameter is the string name
168 * of the state part in the edje design that is listed as one of the possible
169 * states that can be set. Return 0 for false or 1 for true. Genlist will
170 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
171 * true (the default is false), where XXX is the name of the part.
173 * func.del - This is called when elm_genlist_item_del() is called on an
174 * item, elm_genlist_clear() is called on the genlist, or
175 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
176 * intended for use when actual genlist items are deleted, so any backing
177 * data attached to the item (e.g. its data parameter on creation) can be
180 * Items can be added by several calls. All of them return a Elm_Genlist_Item
181 * handle that is an internal member inside the genlist. They all take a data
182 * parameter that is meant to be used for a handle to the applications
183 * internal data (eg the struct with the original item data). The parent
184 * parameter is the parent genlist item this belongs to if it is a tree, and
185 * NULL if there is no parent. The flags can be a bitmask of
186 * ELM_GENLIST_ITEM_NONE and ELM_GENLIST_ITEM_SUBITEMS. If
187 * ELM_GENLIST_ITEM_SUBITEMS is set then this item is displayed as a item
188 * that is able to expand and have child items. The func parameter is a
189 * convenience callback that is called when the item is selected and the data
190 * parameter will be the func_data parameter, obj be the genlist object and
191 * vent_info will be the genlist item.
193 * elm_genlist_item_append() appends an item to the end of the list, or if
194 * there is a parent, to the end of all the child items of the parent.
195 * elm_genlist_item_prepend() is the same but prepends to the beginning of
196 * the list or children list. elm_genlist_item_insert_before() inserts at
197 * item before another item and elm_genlist_item_insert_after() inserts after
198 * the indicated item.
200 * The application can clear the list with elm_genlist_clear() which deletes
201 * all the items in the list and elm_genlist_item_del() will delete a specific
202 * item. elm_genlist_item_subitems_clear() will clear all items that are
203 * children of the indicated parent item.
205 * If the application wants multiple items to be able to be selected,
206 * elm_genlist_multi_select_set() can enable this. If the list is
207 * single-selection only (the default), then elm_genlist_selected_item_get()
208 * will return the selected item, if any, or NULL I none is selected. If the
209 * list is multi-select then elm_genlist_selected_items_get() will return a
210 * list (that is only valid as long as no items are modified (added, deleted,
211 * selected or unselected).
213 * To help inspect list items you can jump to the item at the top of the list
214 * with elm_genlist_first_item_get() which will return the item pointer, and
215 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
216 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
217 * and previous items respectively relative to the indicated item. Using
218 * these calls you can walk the entire item list/tree. Note that as a tree
219 * the items are flattened in the list, so elm_genlist_item_parent_get() will
220 * let you know which item is the parent (and thus know how to skip them if
223 * There are also convenience functions. elm_genlist_item_genlist_get() will
224 * return the genlist object the item belongs to. elm_genlist_item_show()
225 * will make the scroller scroll to show that specific item so its visible.
226 * elm_genlist_item_data_get() returns the data pointer set by the item
227 * creation functions.
229 * If an item changes (state of boolean changes, label or icons change),
230 * then use elm_genlist_item_update() to have genlist update the item with
231 * the new state. Genlist will re-realize the item thus call the functions
232 * in the _Elm_Genlist_Item_Class for that item.
234 * To programmatically (un)select an item use elm_genlist_item_selected_set().
235 * To get its selected state use elm_genlist_item_selected_get(). Similarly
236 * to expand/contract and item and get its expanded state, use
237 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
238 * again to make an item disabled (unable to be selected and appear
239 * differently) use elm_genlist_item_disabled_set() to set this and
240 * elm_genlist_item_disabled_get() to get the disabled state.
242 * In general to indicate how the genlist should expand items horizontally to
243 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
244 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
245 * mode means that if items are too wide to fit, the scroller will scroll
246 * horizontally. Otherwise items are expanded to fill the width of the
247 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
248 * to the viewport width and limited to that size. This can be combined with
249 * a different style that uses edjes' ellipsis feature (cutting text off like
250 * this: ?
\9ctex...??.
252 * Items will only call their selection func and callback when first becoming
253 * selected. Any further clicks will do nothing, unless you enable always
254 * select with elm_genlist_always_select_mode_set(). This means even if
255 * selected, every click will make the selected callbacks be called.
256 * elm_genlist_no_select_mode_set() will turn off the ability to select
257 * items entirely and they will neither appear selected nor call selected
258 * callback functions.
260 * Remember that you can create new styles and add you own theme augmentation
261 * per application with elm_theme_extension_add(). If you absolutely must
262 * have a specific style that overrides any theme the user or system sets up
263 * you can use elm_theme_overlay_add() to add such a file.
266 typedef struct _Widget_Data Widget_Data;
267 typedef struct _Item_Block Item_Block;
268 typedef struct _Pan Pan;
269 typedef struct _Edit_Data Edit_Data;
271 typedef enum _Elm_Genlist_Item_Move_effect_Mode
273 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
274 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
275 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
276 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
277 } Elm_Genlist_Item_Move_effect_Mode;
279 typedef enum _Elm_Genlist_Item_Pinchzoom_effect_Mode
281 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE = 0,
282 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND = (1 << 0),
283 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT = (1 << 1),
284 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH = (1 << 2),
285 ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND_FINISH = (1 << 3),
286 } Elm_Genlist_Item_Pinchzoom_effect_Mode;
288 #define GROUP_ALIGN_NORTH 1
289 #define GROUP_ALIGN_WEST 2
293 Evas_Object *obj, *scr, *pan_smart;
294 Eina_Inlist *items, *blocks;
296 Evas_Coord pan_x, pan_y, minw, minh;
297 Ecore_Job *calc_job, *update_job;
298 Ecore_Idler *queue_idler;
299 Eina_List *queue, *selected;
300 Elm_Genlist_Item *show_item;
302 Eina_Bool on_hold : 1;
304 Eina_Bool always_select : 1;
305 Eina_Bool longpressed : 1;
306 Eina_Bool wasselected : 1;
307 Eina_Bool no_select : 1;
308 Eina_Bool bring_in : 1;
309 Eina_Bool compress : 1;
310 Eina_Bool homogeneous : 1;
311 Eina_Bool clear_me : 1;
315 int max_items_per_block;
316 double longpress_timeout;
317 Eina_Inlist *group_items;
318 Eina_List *menuopened;
321 Eina_Bool animate_edit_controls :1;
324 Evas_Coord td1_x, td1_y, tu1_x, tu1_y;
325 Evas_Coord td2_x, td2_y, tu2_x, tu2_y;
326 Evas_Coord d1_x, d1_y, d2_x, d2_y;
327 Evas_Coord acc_x1, acc_y1, acc_x2, acc_y2;
328 Evas_Coord prev_multi_x, prev_multi_y;
329 Eina_Bool multi_down : 1;
330 Eina_Bool multi_touch : 1;
331 Eina_List *edit_field;
332 Eina_Bool selct_all : 1;
333 Elm_Genlist_Item *select_all_item;
335 Eina_Bool effect_mode : 1;
336 Eina_Bool edit_mode_effect_mode : 1;
337 Eina_Bool pinch_zoom : 1;
338 Eina_Bool pinch_zoom_reserve : 1;
339 int move_effect_mode;
340 int pinchzoom_effect_mode;
343 Ecore_Animator *item_moving_effect_timer;
344 Evas_Object *alpha_bg;
345 Evas_Object *point_rect;
346 Elm_Genlist_Item *expand_item;
349 Evas_Coord start_y_pos;
351 Eina_Bool queue_exception : 1;
353 Eina_Bool reoder_moved : 1;
355 Eina_Bool group_items_moved : 1;
360 Elm_Genlist_Edit_Class *ec;
361 Elm_Genlist_Item *del_item;
362 Elm_Genlist_Item *reorder_item;
363 Elm_Genlist_Item *reorder_rel;
364 Evas_Object *del_confirm;
374 Evas_Coord x, y, w, h, minw, minh;
375 Eina_Bool want_unrealize : 1;
376 Eina_Bool realized : 1;
377 Eina_Bool changed : 1;
378 Eina_Bool updateme : 1;
379 Eina_Bool showme : 1;
383 struct _Elm_Genlist_Item
389 Evas_Coord x, y, w, h, minw, minh;
390 const Elm_Genlist_Item_Class *itc;
392 Elm_Genlist_Item *parent;
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 reoder_cavas_x, reoder_cavas_y;
405 Elm_Genlist_Item *rel;
410 Eina_Bool before : 1;
412 Eina_Bool want_unrealize : 1;
413 Eina_Bool realized : 1;
414 Eina_Bool selected : 1;
415 Eina_Bool hilighted : 1;
416 Eina_Bool expanded : 1;
417 Eina_Bool disabled : 1;
418 Eina_Bool display_only : 1;
419 Eina_Bool mincalcd : 1;
420 Eina_Bool queued : 1;
421 Eina_Bool showme : 1;
422 Eina_Bool delete_me : 1;
424 Eina_Bool dragging : 1;
425 Eina_Bool updateme : 1;
426 Eina_Bool delete_check : 1;
427 Eina_Bool del_confirm_state : 1;
428 Eina_Bool reordering : 1;
429 Eina_Bool menuopened : 1;
430 Eina_Bool select_all_item : 1;
431 Eina_Bool reorder_check: 1;
432 Eina_Bool renamed : 1;
434 int pad_left, pad_right;
436 Evas_Coord old_scrl_y;
437 Evas_Coord old_pad_left;
439 Eina_Bool effect_done : 1;
440 Elm_Genlist_GroupItem *group_item;
441 Evas_Object *edit_obj;
442 Eina_List *edit_icon_objs;
443 Ecore_Timer *edit_long_timer;
446 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
447 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
451 Evas_Object_Smart_Clipped_Data __clipped_data;
455 struct _Elm_Genlist_GroupItem
460 Evas_Coord x, y, w, h, minw, minh;
461 const Elm_Genlist_Item_Class *itc;
469 Eina_List *labels, *icons, *states, *icon_objs;
471 Eina_Bool realized : 1;
472 Eina_Bool delete_me : 1;
473 Eina_Bool visible : 1;
474 Eina_Bool mincalcd : 1;
476 Evas_Coord old_y, finish_y;
479 Eina_Bool update_finish_y : 1;
482 static const char *widtype = NULL;
483 static void _del_hook(Evas_Object *obj);
484 static void _theme_hook(Evas_Object *obj);
485 static void _show_region_hook(void *data, Evas_Object *obj);
486 static void _sizing_eval(Evas_Object *obj);
487 static void _item_unrealize(Elm_Genlist_Item *it);
488 static void _item_block_unrealize(Item_Block *itb);
489 static void _calc_job(void *data);
490 static void _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items);
491 static void _groupitem_unrealize(Elm_Genlist_GroupItem *git);
492 static Eina_Bool _edit_mode_reset(Widget_Data *wd);
493 static void _edit_controls_eval(Elm_Genlist_Item *it);
494 static void _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity);
495 static Eina_Bool _item_moving_effect_timer_cb(void *data);
496 static Eina_Bool _edit_mode_item_moving_effect_cb(void *data);
497 static int _item_flip_effect_show(void *data);
498 static void _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode);
499 static void _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info);
500 static void _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__);
501 static void _notify_item_position(Elm_Genlist_Item *it);
502 static void _notify_item_position(Elm_Genlist_Item *it);
503 static int _get_space_for_reorder_item(Elm_Genlist_Item *it);
505 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
508 _del_hook(Evas_Object *obj)
510 Widget_Data *wd = elm_widget_data_get(obj);
512 if (wd->calc_job) ecore_job_del(wd->calc_job);
513 if (wd->update_job) ecore_job_del(wd->update_job);
518 _del_pre_hook(Evas_Object *obj)
520 Widget_Data *wd = elm_widget_data_get(obj);
522 evas_object_del(wd->pan_smart);
523 wd->pan_smart = NULL;
524 elm_genlist_clear(obj);
528 _theme_hook(Evas_Object *obj)
530 Widget_Data *wd = elm_widget_data_get(obj);
532 Elm_Genlist_GroupItem *git;
534 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
535 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
536 EINA_INLIST_FOREACH(wd->group_items, git)
538 _groupitem_unrealize(git);
540 EINA_INLIST_FOREACH(wd->blocks, itb)
543 Elm_Genlist_Item *it;
545 if (itb->realized) _item_block_unrealize(itb);
546 EINA_LIST_FOREACH(itb->items, l, it)
547 it->mincalcd = EINA_FALSE;
549 itb->changed = EINA_TRUE;
551 if (wd->calc_job) ecore_job_del(wd->calc_job);
552 wd->calc_job = ecore_job_add(_calc_job, wd);
557 _show_region_hook(void *data, Evas_Object *obj)
559 Widget_Data *wd = elm_widget_data_get(data);
560 Evas_Coord x, y, w, h;
562 elm_widget_show_region_get(obj, &x, &y, &w, &h);
563 //x & y are screen coordinates, Add with pan coordinates
566 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
570 _sizing_eval(Evas_Object *obj)
572 Widget_Data *wd = elm_widget_data_get(obj);
573 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
575 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
576 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
578 if (wd->mode != ELM_LIST_LIMIT) minw = -1;
581 Evas_Coord vmw, vmh, vw, vh;
585 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
586 if ((minw > 0) && (vw < minw)) vw = minw;
587 else if ((maxw > 0) && (vw > maxw)) vw = maxw;
589 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
592 evas_object_size_hint_min_set(obj, minw, minh);
593 evas_object_size_hint_max_set(obj, maxw, maxh);
597 _item_hilight(Elm_Genlist_Item *it)
599 const char *selectraise;
601 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) || (it->disabled) ||
602 (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
604 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
605 selectraise = edje_object_data_get(it->base, "selectraise");
606 if ((selectraise) && (!strcmp(selectraise, "on")))
608 evas_object_raise(it->base);
609 if (it->group_item && it->group_item->realized)
610 evas_object_raise(it->group_item->base);
612 it->hilighted = EINA_TRUE;
616 _item_block_del(Elm_Genlist_Item *it)
619 Item_Block *itb = it->block;
621 itb->items = eina_list_remove(itb->items, it);
623 itb->changed = EINA_TRUE;
624 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
625 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
628 il = EINA_INLIST_GET(itb);
629 Item_Block *itbn = (Item_Block *)(il->next);
631 it->parent->items = eina_list_remove(it->parent->items, it);
633 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
635 if (itbn) itbn->changed = EINA_TRUE;
639 if (itb->count < itb->wd->max_items_per_block/2)
641 il = EINA_INLIST_GET(itb);
642 Item_Block *itbp = (Item_Block *)(il->prev);
643 Item_Block *itbn = (Item_Block *)(il->next);
644 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
646 Elm_Genlist_Item *it2;
648 EINA_LIST_FREE(itb->items, it2)
651 itbp->items = eina_list_append(itbp->items, it2);
653 itbp->changed = EINA_TRUE;
655 it->wd->blocks = eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
658 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
662 Eina_List *last = eina_list_last(itb->items);
663 Elm_Genlist_Item *it2 = last->data;
666 itb->items = eina_list_remove_list(itb->items, last);
667 itbn->items = eina_list_prepend(itbn->items, it2);
669 itbn->changed = EINA_TRUE;
672 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
680 _item_del(Elm_Genlist_Item *it)
682 elm_genlist_item_subitems_clear(it);
683 it->wd->walking -= it->walking;
684 if (it->wd->show_item == it) it->wd->show_item = NULL;
685 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
686 if (it->realized) _item_unrealize(it);
687 if (it->block) _item_block_del(it);
688 if ((!it->delete_me) && (it->itc->func.del))
689 it->itc->func.del(it->data, it->wd->obj);
690 it->delete_me = EINA_TRUE;
692 it->wd->queue = eina_list_remove(it->wd->queue, it);
693 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
695 it->parent->items = eina_list_remove(it->parent->items, it);
696 if (it->long_timer) ecore_timer_del(it->long_timer);
699 it->group_item->items = eina_list_remove(it->group_item->items,it);
705 _item_select(Elm_Genlist_Item *it)
707 if ((it->wd->no_select) || (it->delete_me) || (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)) return;
710 if (it->wd->always_select) goto call;
713 it->selected = EINA_TRUE;
714 it->wd->selected = eina_list_append(it->wd->selected, it);
718 if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
720 evas_object_smart_callback_call(it->wd->obj, "selected", it);
723 if ((it->wd->clear_me) && (!it->wd->walking))
724 elm_genlist_clear(it->wd->obj);
727 if ((!it->walking) && (it->delete_me))
729 if (!it->relcount) _item_del(it);
735 _item_unselect(Elm_Genlist_Item *it)
737 const char *stacking, *selectraise;
739 if ((it->delete_me) || (!it->hilighted)) return;
741 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
742 stacking = edje_object_data_get(it->base, "stacking");
743 selectraise = edje_object_data_get(it->base, "selectraise");
744 if ((selectraise) && (!strcmp(selectraise, "on")))
746 if ((stacking) && (!strcmp(stacking, "below")))
747 evas_object_lower(it->base);
749 it->hilighted = EINA_FALSE;
752 it->selected = EINA_FALSE;
753 it->wd->selected = eina_list_remove(it->wd->selected, it);
754 evas_object_smart_callback_call(it->wd->obj, "unselected", it);
759 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
762 Elm_Genlist_Item *it2;
763 const char *allow_slide;
765 allow_slide = edje_object_data_get(it->base, "allow_slide");
769 if (atoi(allow_slide) != 1)
775 edje_object_signal_emit(it->base, "elm,state,slide,right", "elm");
776 it->wd->menuopened = eina_list_append(it->wd->menuopened, it);
778 EINA_LIST_FOREACH(it->wd->menuopened, l, it2)
782 it2->menuopened = EINA_FALSE;
783 edje_object_signal_emit(it2->base, "elm,state,slide,left", "elm");
784 it2->wd->menuopened = eina_list_remove(it2->wd->menuopened, it2);
791 edje_object_signal_emit(it->base, "elm,state,slide,left", "elm");
792 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
795 it->menuopened = slide_to_right;
799 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
801 Elm_Genlist_Item *it = data;
802 Evas_Event_Mouse_Move *ev = event_info;
803 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
804 Evas_Coord acc_x, acc_y;
806 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
808 if (!it->wd->on_hold)
810 it->wd->on_hold = EINA_TRUE;
811 if (!it->wd->wasselected)
815 if ((it->dragging) && (it->down))
819 ecore_timer_del(it->long_timer);
820 it->long_timer = NULL;
822 evas_object_smart_callback_call(it->wd->obj, "drag", it);
825 if ((!it->down)/* || (it->wd->on_hold)*/ || (it->wd->longpressed))
829 ecore_timer_del(it->long_timer);
830 it->long_timer = NULL;
835 if (it->wd->multi_down)
837 acc_x = ev->prev.canvas.x - ev->cur.canvas.x;
839 it->wd->acc_x1 = it->wd->acc_x1 - acc_x;
841 it->wd->acc_x1 = it->wd->acc_x1 + acc_x;
843 acc_y = ev->prev.canvas.y - ev->cur.canvas.y;
845 it->wd->acc_y1 = it->wd->acc_y1 - acc_y;
847 it->wd->acc_y1 = it->wd->acc_y1 + acc_y;
852 if (!it->display_only)
853 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
854 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
855 x = ev->cur.canvas.x - x;
856 y = ev->cur.canvas.y - y;
859 if (adx < 0) adx = -dx;
862 if (ady < 0) ady = -dy;
865 if ((adx > minw) || (ady > minh))
870 ecore_timer_del(it->long_timer);
871 it->long_timer = NULL;
873 if (!it->wd->wasselected)
878 evas_object_smart_callback_call(it->wd->obj, "drag,start,up", it);
883 evas_object_smart_callback_call(it->wd->obj,
884 "drag,start,left", it);
889 evas_object_smart_callback_call(it->wd->obj,
890 "drag,start,right", it);
898 evas_object_smart_callback_call(it->wd->obj,
899 "drag,start,down", it);
904 evas_object_smart_callback_call(it->wd->obj,
905 "drag,start,left", it);
910 evas_object_smart_callback_call(it->wd->obj,
911 "drag,start,right", it);
920 _long_press(void *data)
922 Elm_Genlist_Item *it = data;
924 it->long_timer = NULL;
925 if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
926 it->wd->longpressed = EINA_TRUE;
927 evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
928 return ECORE_CALLBACK_CANCEL;
932 _edit_long_press(void *data)
934 Elm_Genlist_Item *it = data, *it_tmp;
936 static Eina_Bool contracted = EINA_FALSE;
940 it->edit_long_timer = NULL;
941 if ((it->disabled) || (it->dragging)) return 0;
943 EINA_INLIST_FOREACH(it->wd->blocks, itb)
945 EINA_LIST_FOREACH(itb->items, l, it_tmp)
947 if(!it_tmp->parent && elm_genlist_item_expanded_get(it_tmp))
949 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
950 contracted = EINA_TRUE;
957 contracted = EINA_FALSE;
961 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
963 evas_object_geometry_get(it->base, &x, &y, NULL, NULL);
965 it->dx = it->reoder_cavas_x - x;
966 it->dy = it->reoder_cavas_y - y;
968 evas_object_raise(it->base);
969 evas_object_raise(it->edit_obj);
971 it->wd->ed->reorder_item = it;
972 it->wd->ed->reorder_item->reordering = 1;
973 it->wd->ed->reorder_rel = NULL;
974 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
975 it->wd->reoder_pan_y = it->wd->pan_y;
976 it->wd->reoder_moved = EINA_TRUE;
982 _multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
984 Elm_Genlist_Item *it = data;
985 Evas_Event_Multi_Down *ev = event_info;
986 Evas_Coord dx, dy, adx, ady;
990 ecore_timer_del(it->long_timer);
991 it->long_timer = NULL;
994 dx = it->wd->td1_x - ev->canvas.x;
996 if (adx < 0) adx = -dx;
997 dy = it->wd->td1_y - ev->canvas.y;
999 if (ady < 0) ady = -dy;
1001 if (adx < 60 && ady < 60)
1004 it->wd->multi_down = 1;
1005 it->wd->td2_x = ev->canvas.x;
1006 it->wd->td2_y = ev->canvas.y;
1008 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
1010 evas_object_move(it->wd->point_rect, 2, (it->wd->td1_y + it->wd->td2_y) / 2);
1011 evas_object_raise(it->wd->point_rect);
1012 evas_object_show(it->wd->point_rect);
1014 fprintf(stderr, "\n MULTI_DOWN - BUTTON ID = %d, x= %d, y= %d\n", ev->device, it->wd->td2_x, it->wd->td2_y);
1019 _multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1021 Elm_Genlist_Item *it = data;
1022 Evas_Event_Multi_Up *ev = event_info;
1023 Evas_Coord dy, uy, ady, auy;
1024 int multi_y_avg = 0;
1026 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);
1028 if (!it->wd->multi_down)
1031 it->wd->multi_down = 0;
1032 it->wd->tu2_x = ev->canvas.x;
1033 it->wd->tu2_y = ev->canvas.y;
1034 it->wd->d2_x = ev->canvas.x - it->wd->td2_x;
1035 it->wd->d2_y = ev->canvas.y - it->wd->td2_y;
1037 evas_object_lower(it->wd->point_rect);
1038 evas_object_hide(it->wd->point_rect);
1042 it->wd->multi_touch = EINA_TRUE;
1046 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);
1048 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1050 // Two finger : Left -> Right
1051 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1052 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1053 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1055 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1057 // Two finger : Top -> Bottom
1058 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1059 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1060 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1064 dy = it->wd->td1_y - it->wd->td2_y;
1070 uy = it->wd->tu1_y - it->wd->tu2_y;
1080 // Two finger : Pinch Out
1081 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1083 if (it->wd->effect_mode == EINA_TRUE)
1084 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1091 // Two finger : Pinch In
1092 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1094 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1096 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1098 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1099 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);
1100 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1110 it->wd->prev_multi_x = 0;
1111 it->wd->prev_multi_y = 0;
1116 _multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1118 Elm_Genlist_Item *it = data;
1119 Evas_Event_Multi_Move *ev = event_info;
1120 Evas_Coord acc_x, acc_y;
1122 if (!it->wd->prev_multi_x)
1124 it->wd->prev_multi_x = ev->cur.canvas.x;
1125 it->wd->prev_multi_y = ev->cur.canvas.y;
1129 acc_x = it->wd->prev_multi_x - ev->cur.canvas.x;
1131 it->wd->acc_x2 = it->wd->acc_x2 - acc_x;
1133 it->wd->acc_x2 = it->wd->acc_x2 + acc_x;
1135 acc_y = it->wd->prev_multi_y - ev->cur.canvas.y;
1137 it->wd->acc_y2 = it->wd->acc_y2 - acc_y;
1139 it->wd->acc_y2 = it->wd->acc_y2 + acc_y;
1141 it->wd->prev_multi_x = ev->cur.canvas.x;
1142 it->wd->prev_multi_y = ev->cur.canvas.y;
1146 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1148 Elm_Genlist_Item *it = data;
1149 Evas_Event_Mouse_Down *ev = event_info;
1152 it->wd->group_items_moved = EINA_FALSE;
1153 it->wd->td1_x = ev->canvas.x;
1154 it->wd->td1_y = ev->canvas.y;
1155 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
1157 elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
1161 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
1162 (void)_edit_mode_reset(it->wd);
1163 if (ev->button != 1) return;
1164 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1166 it->wd->on_hold = EINA_TRUE;
1169 if (it->wd->edit_field && !it->renamed)
1170 elm_genlist_item_rename_mode_set(it, 0);
1174 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1175 it->dx = ev->canvas.x - x;
1176 it->dy = ev->canvas.y - y;
1177 it->wd->longpressed = EINA_FALSE;
1178 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1179 else it->wd->on_hold = EINA_FALSE;
1180 if (it->wd->on_hold) return;
1181 it->wd->wasselected = it->selected;
1183 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1184 evas_object_smart_callback_call(it->wd->obj, "clicked", it);
1185 if (it->long_timer) ecore_timer_del(it->long_timer);
1187 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it);
1189 it->long_timer = NULL;
1193 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1195 Elm_Genlist_Item *it = data;
1196 Evas_Event_Mouse_Up *ev = event_info;
1197 Eina_Bool dragged = EINA_FALSE;
1198 Evas_Coord dy, uy, ady, auy;
1201 if (ev->button != 1) return;
1206 it->wd->tu1_x = ev->canvas.x;
1207 it->wd->tu1_y = ev->canvas.y;
1208 it->wd->d1_x = ev->canvas.x - it->wd->td1_x;
1209 it->wd->d1_y = ev->canvas.y - it->wd->td1_y;
1211 // evas_object_lower(it->wd->point_rect);
1212 // evas_object_hide(it->wd->point_rect);
1213 if (it->wd->effect_mode && it->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
1215 if (!it->wd->multi_down && it->wd->multi_touch == EINA_TRUE)
1217 if ((it->wd->d1_x > 180) && (it->wd->d2_x > 180))
1219 // Two finger : Left -> Right
1220 fprintf(stderr, "L->R acc_y1= %d, acc_y2= %d\n", it->wd->acc_y1, it->wd->acc_y2);
1221 if (it->wd->acc_y1 < 200 && it->wd->acc_y2 < 200)
1222 evas_object_smart_callback_call(it->wd->obj, "multi_touch,left,right", it);
1224 else if ((it->wd->d1_y > 180) && (it->wd->d2_y > 180))
1226 // Two finger : Top -> Bottom
1227 fprintf(stderr, "T->B acc_x1= %d, acc_x2= %d\n", it->wd->acc_x1, it->wd->acc_x2);
1228 if (it->wd->acc_x1 < 200 && it->wd->acc_x2 < 200)
1229 evas_object_smart_callback_call(it->wd->obj, "multi_touch,top,bottom", it);
1233 dy = it->wd->td1_y - it->wd->td2_y;
1234 if (dy < 0) ady = -dy;
1237 uy = it->wd->tu1_y - it->wd->tu2_y;
1238 if (uy < 0) auy = -uy;
1245 // Two finger : Pinch Out
1246 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,out", it);
1247 if (it->wd->effect_mode == EINA_TRUE)
1248 _elm_genlist_pinch_zoom_execute(it->wd->obj, 1);
1255 // Two finger : Pinch In
1256 evas_object_smart_callback_call(it->wd->obj, "multi_touch,pinch,in", it);
1257 if (it->wd->effect_mode == EINA_TRUE && it->wd->pinch_zoom == EINA_TRUE)
1259 multi_y_avg= (it->wd->td1_y + it->wd->td2_y) / 2;
1261 it->wd->pinch_it = (multi_y_avg / it->group_item->h + it->wd->contract_pan_y / it->group_item->h) - 2;
1262 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);
1263 _elm_genlist_pinch_zoom_execute(it->wd->obj, 0);
1274 it->wd->prev_multi_x = 0;
1275 it->wd->prev_multi_y = 0;
1276 it->wd->multi_down = 0;
1279 it->wd->multi_touch = EINA_FALSE;
1281 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1282 else it->wd->on_hold = EINA_FALSE;
1285 ecore_timer_del(it->long_timer);
1286 it->long_timer = NULL;
1291 evas_object_smart_callback_call(it->wd->obj, "drag,stop", it);
1294 if (it->wd->on_hold)
1296 it->wd->longpressed = EINA_FALSE;
1297 it->wd->on_hold = EINA_FALSE;
1300 if (it->wd->longpressed)
1302 it->wd->longpressed = EINA_FALSE;
1303 if (!it->wd->wasselected)
1305 it->wd->wasselected = 0;
1310 if (it->want_unrealize)
1312 _item_unrealize(it);
1313 if (it->block->want_unrealize)
1314 _item_block_unrealize(it->block);
1317 if ((it->disabled) || (dragged)) return;
1318 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1321 if (!it->selected && !it->menuopened)
1326 else _item_unselect(it);
1332 Widget_Data *wd = it->wd;
1335 while (wd->selected) _item_unselect(wd->selected->data);
1340 const Eina_List *l, *l_next;
1341 Elm_Genlist_Item *it2;
1343 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1344 if (it2 != it) _item_unselect(it2);
1345 //_item_hilight(it);
1348 if (!it->menuopened)
1357 _signal_expand_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1359 Elm_Genlist_Item *it = data;
1362 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1364 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1368 _signal_expand(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1370 Elm_Genlist_Item *it = data;
1373 evas_object_smart_callback_call(it->wd->obj, "expand,request", it);
1377 _signal_contract(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1379 Elm_Genlist_Item *it = data;
1382 evas_object_smart_callback_call(it->wd->obj, "contract,request", it);
1386 _group_item_click_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1388 Elm_Genlist_GroupItem *git = data;
1389 elm_smart_scroller_bounce_allow_set(git->wd->scr, EINA_FALSE, EINA_TRUE);
1390 if (git->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
1392 if(!git->wd->group_items_moved)
1394 git->wd->pinch_it = git->num;
1395 _elm_genlist_pinch_zoom_execute(git->wd->obj, 0);
1397 git->wd->group_items_moved = EINA_FALSE;
1403 _groupitem_realize(Elm_Genlist_Item *it, int calc)
1407 Elm_Genlist_GroupItem *git = it->group_item;
1408 Evas_Coord ox, oy, ow, oh;
1410 if (calc && git->realized)
1412 git->wd->start_y_pos += it->h;
1415 if ((git->realized) || (git->delete_me)) return;
1416 git->base = edje_object_add(evas_object_evas_get(git->wd->obj));
1417 edje_object_scale_set(git->base, elm_widget_scale_get(git->wd->obj) *
1418 _elm_config->scale);
1419 evas_object_smart_member_add(git->base, git->wd->pan_smart);
1420 elm_widget_sub_object_add(git->wd->obj, git->base);
1422 strncpy(buf, "item/", sizeof(buf));
1423 strncat(buf, git->itc->item_style, sizeof(buf) - strlen(buf));
1424 _elm_theme_object_set(git->wd->obj, git->base, "genlist", buf, elm_widget_style_get(git->wd->obj));
1426 align = edje_object_data_get(git->base, "orientation");
1427 git->align = GROUP_ALIGN_NORTH;
1430 if (!strcmp(align, "top"))
1431 git->align = GROUP_ALIGN_NORTH;
1432 else if (!strcmp(align, "left"))
1433 git->align = GROUP_ALIGN_WEST;
1434 else git->align = GROUP_ALIGN_NORTH;
1437 if (git->itc->func.label_get)
1442 git->labels = _elm_stringlist_get(edje_object_data_get(git->base, "labels"));
1443 EINA_LIST_FOREACH(git->labels, l, key)
1445 char *s = git->itc->func.label_get(git->data, git->wd->obj, l->data);
1449 edje_object_part_text_set(git->base, l->data, s);
1455 if (git->itc->func.icon_get)
1460 git->icons = _elm_stringlist_get(edje_object_data_get(git->base, "icons"));
1461 EINA_LIST_FOREACH(git->icons, l, key)
1463 Evas_Object *ic = git->itc->func.icon_get(git->data, git->wd->obj, l->data);
1467 git->icon_objs = eina_list_append(git->icon_objs, ic);
1468 edje_object_part_swallow(git->base, key, ic);
1469 evas_object_show(ic);
1470 elm_widget_sub_object_add(git->wd->obj, ic);
1475 if (git->itc->func.state_get)
1480 git->states = _elm_stringlist_get(edje_object_data_get(git->base, "states"));
1481 EINA_LIST_FOREACH(git->states, l, key)
1483 Eina_Bool on = git->itc->func.state_get(git->data, git->wd->obj, l->data);
1487 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1488 edje_object_signal_emit(git->base, buf, "elm");
1494 Evas_Coord mw = -1, mh = -1;
1496 edje_object_size_min_restricted_calc(git->base, &mw, &mh, mw, mh);
1498 git->w = git->minw = mw;
1499 git->h = git->minh = mh;
1500 git->mincalcd = EINA_TRUE;
1502 evas_object_geometry_get(git->wd->pan_smart, &ox, &oy, &ow, &oh);
1505 git->update_finish_y = EINA_TRUE;
1507 git->y = git->finish_y = oy + git->wd->start_y_pos;
1508 git->wd->start_y_pos += it->h + git->h;
1510 git->num = ++git->wd->max_git_num;
1512 edje_object_signal_callback_add(git->base, "elm,title_action,item,click",
1513 "elm", _group_item_click_cb, git);
1514 evas_object_show(git->base);
1516 git->realized = EINA_TRUE;
1520 _groupitem_unrealize(Elm_Genlist_GroupItem *git)
1524 if (!git->realized) return;
1525 evas_object_del(git->base);
1527 _elm_stringlist_free(git->labels);
1529 _elm_stringlist_free(git->icons);
1531 _elm_stringlist_free(git->states);
1533 EINA_LIST_FREE(git->icon_objs, icon)
1534 evas_object_del(icon);
1536 if (git->wd->max_git_num)
1537 git->wd->max_git_num--;
1539 git->realized = EINA_FALSE;
1543 _groupitem_remove(Elm_Genlist_GroupItem *git, Eina_Bool update_items)
1545 Elm_Genlist_Item *it;
1551 _groupitem_unrealize(git);
1553 git->wd->group_items = eina_inlist_remove(git->wd->group_items,EINA_INLIST_GET(git));
1557 EINA_LIST_FOREACH(git->items,l, it)
1559 it->group_item = NULL;
1560 elm_genlist_item_update(it);
1564 if (git->itc->func.del) git->itc->func.del(git->data, git->wd->obj);
1569 _item_realize(Elm_Genlist_Item *it, int in, int calc)
1571 Elm_Genlist_Item *it2;
1572 const char *stacking;
1573 const char *treesize;
1575 int depth, tsize = 20;
1577 if ((it->realized) || (it->delete_me)) return;
1578 it->base = edje_object_add(evas_object_evas_get(it->wd->obj));
1579 edje_object_scale_set(it->base, elm_widget_scale_get(it->wd->obj) *
1580 _elm_config->scale);
1581 evas_object_smart_member_add(it->base, it->wd->pan_smart);
1582 elm_widget_sub_object_add(it->wd->obj, it->base);
1584 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
1585 else strncpy(buf, "item", sizeof(buf));
1586 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1588 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1589 strncat(buf, "/", sizeof(buf) - strlen(buf));
1590 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1592 _elm_theme_object_set(it->wd->obj, it->base, "genlist", buf, elm_widget_style_get(it->wd->obj));
1593 it->spacer = evas_object_rectangle_add(evas_object_evas_get(it->wd->obj));
1594 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1595 elm_widget_sub_object_add(it->wd->obj, it->spacer);
1596 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
1597 it->expanded_depth = depth;
1598 treesize = edje_object_data_get(it->base, "treesize");
1599 if (treesize) tsize = atoi(treesize);
1600 evas_object_size_hint_min_set(it->spacer,
1601 (depth * tsize) * _elm_config->scale, 1);
1602 edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
1605 edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
1606 "elm", _signal_expand_toggle, it);
1607 edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
1608 _signal_expand, it);
1609 edje_object_signal_callback_add(it->base, "elm,action,contract",
1610 "elm", _signal_contract, it);
1611 stacking = edje_object_data_get(it->base, "stacking");
1614 if (!strcmp(stacking, "below")) evas_object_lower(it->base);
1615 else if (!strcmp(stacking, "above")) evas_object_raise(it->base);
1617 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1619 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
1621 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE,
1623 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_DOWN,
1625 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_UP,
1627 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MULTI_MOVE,
1629 if (it->selected && !it->menuopened)
1630 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
1632 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
1634 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
1637 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1639 /* homogenous genlist shortcut */
1642 it->w = it->minw = it->wd->item_width;
1643 it->h = it->minh = it->wd->item_height;
1644 it->mincalcd = EINA_TRUE;
1649 if (!strcmp(it->itc->item_style, "select_all"))
1654 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1655 EINA_LIST_FOREACH(it->labels, l, key) {
1656 edje_object_part_text_set(it->base, l->data, "Select all");
1660 if (it->itc->func.label_get)
1665 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
1666 EINA_LIST_FOREACH(it->labels, l, key)
1668 char *s = it->itc->func.label_get
1669 ((void *)it->data, it->wd->obj, l->data);
1673 edje_object_part_text_set(it->base, l->data, s);
1677 edje_object_part_text_set(it->base, l->data, "");*/
1680 if (it->itc->func.icon_get)
1685 it->icons = _elm_stringlist_get(edje_object_data_get(it->base, "icons"));
1686 EINA_LIST_FOREACH(it->icons, l, key)
1688 Evas_Object *ic = it->itc->func.icon_get
1689 ((void *)it->data, it->wd->obj, l->data);
1693 it->icon_objs = eina_list_append(it->icon_objs, ic);
1694 edje_object_part_swallow(it->base, key, ic);
1695 evas_object_show(ic);
1696 elm_widget_sub_object_add(it->wd->obj, ic);
1700 if (it->itc->func.state_get)
1705 it->states = _elm_stringlist_get(edje_object_data_get(it->base, "states"));
1706 EINA_LIST_FOREACH(it->states, l, key)
1708 Eina_Bool on = it->itc->func.state_get
1709 (it->data, it->wd->obj, l->data);
1713 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1714 edje_object_signal_emit(it->base, buf, "elm");
1718 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1719 edje_object_signal_emit(it->base, buf, "elm");
1725 Evas_Coord mw = -1, mh = -1;
1727 if (!it->display_only)
1728 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1729 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
1730 if (!it->display_only)
1731 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1732 it->w = it->minw = mw;
1733 it->h = it->minh = mh;
1734 it->mincalcd = EINA_TRUE;
1736 if ((!in) && (it->wd->homogeneous))
1738 it->wd->item_width = mw;
1739 it->wd->item_height = mh;
1742 if (!calc) evas_object_show(it->base);
1745 it->realized = EINA_TRUE;
1746 it->want_unrealize = EINA_FALSE;
1748 _groupitem_realize(it, calc);
1749 if (ELM_GENLIST_EDIT_MODE_NONE != it->wd->edit_mode)
1752 EINA_LIST_FREE(it->edit_icon_objs, icon)
1753 evas_object_del(icon);
1754 _edit_controls_eval(it);
1759 _item_unrealize(Elm_Genlist_Item *it)
1763 if (!it->realized) return;
1764 it->menuopened = EINA_FALSE;
1765 it->wd->menuopened = eina_list_remove(it->wd->menuopened, it);
1768 ecore_timer_del(it->long_timer);
1769 it->long_timer = NULL;
1771 evas_object_del(it->base);
1773 evas_object_del(it->spacer);
1776 evas_object_del(it->edit_obj);
1777 it->edit_obj = NULL;
1778 _elm_stringlist_free(it->labels);
1780 _elm_stringlist_free(it->icons);
1782 _elm_stringlist_free(it->states);
1784 EINA_LIST_FREE(it->icon_objs, icon)
1785 evas_object_del(icon);
1787 EINA_LIST_FREE(it->edit_icon_objs, icon)
1788 evas_object_del(icon);
1791 it->realized = EINA_FALSE;
1792 it->want_unrealize = EINA_FALSE;
1796 _item_block_recalc(Item_Block *itb, int in, int qadd, int norender)
1799 Elm_Genlist_Item *it;
1800 Evas_Coord minw = 0, minh = 0;
1801 int showme = 0, changed = 0;
1803 Elm_Genlist_GroupItem *git = NULL;
1806 EINA_LIST_FOREACH(itb->items, l, it)
1808 if (it->delete_me) continue;
1809 showme |= it->showme;
1814 if (!it->mincalcd) changed = 1;
1817 _item_realize(it, in, 1);
1818 _item_unrealize(it);
1823 _item_realize(it, in, 1);
1824 _item_unrealize(it);
1829 Eina_Bool was_realized = it->realized;
1831 _item_realize(it, in, 0);
1833 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1836 if (minw < it->minw) minw = it->minw;
1841 if (git != it->group_item)
1843 git = it->group_item;
1845 if (git && git->align == GROUP_ALIGN_NORTH && git->items->data == it) //Add Place holder for Group title
1855 itb->changed = EINA_FALSE;
1856 /* force an evas norender to garbage collect deleted objects */
1857 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
1862 _item_block_realize(Item_Block *itb, int in, int full)
1865 Elm_Genlist_Item *it;
1867 if (itb->realized) return;
1868 EINA_LIST_FOREACH(itb->items, l, it)
1870 if (it->delete_me) continue;
1873 Eina_Bool was_realized = it->realized;
1875 _item_realize(it, in, 0);
1877 evas_object_smart_callback_call(it->wd->obj, "realized", it);
1881 itb->realized = EINA_TRUE;
1882 itb->want_unrealize = EINA_FALSE;
1886 _item_block_unrealize(Item_Block *itb)
1889 Elm_Genlist_Item *it;
1892 if (!itb->realized) return;
1893 EINA_LIST_FOREACH(itb->items, l, it)
1895 if (it->dragging || it->reordering)
1898 it->want_unrealize = EINA_TRUE;
1901 _item_unrealize(it);
1905 itb->realized = EINA_FALSE;
1906 itb->want_unrealize = EINA_TRUE;
1909 itb->want_unrealize = EINA_FALSE;
1913 _item_block_position(Item_Block *itb, int in)
1916 Elm_Genlist_Item *it;
1917 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
1920 Elm_Genlist_GroupItem *git = NULL;
1921 Elm_Genlist_Item *select_all_item = NULL;
1923 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
1924 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh);
1926 if (itb->wd->select_all_item &&
1927 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
1930 select_all_item = itb->wd->select_all_item;
1932 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
1933 evas_object_move(select_all_item->base, ox, oy);
1934 evas_object_raise(select_all_item->base);
1936 if (itb->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
1937 evas_object_show(select_all_item->base);
1939 evas_object_hide(select_all_item->base);
1940 y = select_all_item->h;
1943 EINA_LIST_FOREACH(itb->items, l, it)
1945 if (it->delete_me) continue;
1949 vis = (ELM_RECTS_INTERSECT(itb->x - it->wd->pan_x + ox,
1950 itb->y - it->wd->pan_y + oy,
1952 cvx, cvy, cvw, cvh));
1953 if ((itb->realized) && (!it->realized))
1957 Eina_Bool was_realized = it->realized;
1959 _item_realize(it, in, 0);
1961 evas_object_smart_callback_call(it->wd->obj,
1967 _notify_item_position(it);
1970 it->scrl_x = ox + itb->x + it->x - itb->wd->pan_x;
1971 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y + itb->reoder_y;;
1972 if (git != it->group_item)
1974 git = it->group_item;
1977 git->visible = EINA_TRUE; //Mark Group Item to make it visible
1978 if (git->items->data == it)
1979 git->y = it->scrl_y;
1980 if (GROUP_ALIGN_NORTH == git->align)
1983 if (git->items->data == it)
1985 it->scrl_y += git->minh;
1993 git->x = ox + itb->x - itb->wd->pan_x;
1998 if (git->align == GROUP_ALIGN_WEST)
2001 it->scrl_x += git->x + git->w;
2002 git->h = (it->scrl_y + it->h) - git->y ;
2005 git->y = it->scrl_y;
2009 if (git->align == GROUP_ALIGN_NORTH)
2012 if ((git->y + git->h) > (it->scrl_y + it->h))
2013 git->y = (it->scrl_y + it->h) - git->minh;
2015 if (git->update_finish_y)
2017 git->finish_y += oy;
2018 git->update_finish_y = EINA_FALSE;
2023 is_reorder = _get_space_for_reorder_item(it);
2027 if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && !itb->reoder_y)
2029 itb->reoder_y -= it->h;
2030 it->scrl_y = oy + itb->y + it->y - itb->wd->pan_y + itb->reoder_y;
2032 else if (it != it->wd->ed->reorder_item && is_reorder && in > 0 && !(in % it->wd->max_items_per_block) && itb->reoder_y)
2039 if (!it->reordering)
2041 if ((!it->wd->effect_mode ||
2042 (it->wd->effect_mode && it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE)) && !it->wd->pinch_zoom_reserve)
2044 _move_edit_controls(it,it->scrl_x, it->scrl_y);
2045 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
2047 evas_object_move(it->base, it->scrl_x+it->pad_left, it->scrl_y);
2049 if (it->delete_check)
2051 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
2052 edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
2054 evas_object_show(it->base);
2055 it->old_pad_left = it->pad_left;
2056 it->old_scrl_y = it->scrl_y;
2064 _item_unrealize(it);
2067 if (!it->reordering)
2073 if (itb->wd->select_all_item &&
2074 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2075 evas_object_raise(select_all_item->base);
2079 itb->wd->animate_edit_controls = 0;
2081 git->visible = EINA_TRUE;
2086 _calc_job(void *data)
2088 Widget_Data *wd = data;
2090 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2091 Item_Block *chb = NULL;
2092 int in = 0, minw_change = 0;
2096 EINA_INLIST_FOREACH(wd->blocks, itb)
2101 showme = itb->showme;
2105 if (itb->realized) _item_block_unrealize(itb);
2109 if (itb->realized) _item_block_unrealize(itb);
2110 showme = _item_block_recalc(itb, in, 0, 1);
2116 if (minw == -1) minw = itb->minw;
2117 else if (minw < itb->minw)
2126 if ((showme) && (wd->show_item) && (wd->show_item->mincalcd))
2128 wd->show_item->showme = 0;
2130 elm_smart_scroller_region_bring_in(wd->scr,
2131 wd->show_item->x + wd->show_item->block->x,
2132 wd->show_item->y + wd->show_item->block->y,
2133 wd->show_item->block->w,
2136 elm_smart_scroller_child_region_show(wd->scr,
2137 wd->show_item->x + wd->show_item->block->x,
2138 wd->show_item->y + wd->show_item->block->y,
2139 wd->show_item->block->w,
2141 wd->show_item = NULL;
2146 EINA_INLIST_FOREACH(wd->blocks, itb)
2152 if ((chb) && (EINA_INLIST_GET(chb)->next))
2154 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2156 if (itb->realized) _item_block_unrealize(itb);
2159 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
2160 if (minw < ow) minw = ow;
2161 if ((minw != wd->minw) || (minh != wd->minh) || wd->select_all_item)
2165 if (wd->select_all_item)
2166 wd->minh += wd->select_all_item->h;
2167 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2168 _sizing_eval(wd->obj);
2170 wd->calc_job = NULL;
2171 evas_object_smart_changed(wd->pan_smart);
2175 _update_job(void *data)
2177 Widget_Data *wd = data;
2180 int num, num0, position = 0, recalc = 0;
2182 wd->update_job = NULL;
2184 EINA_INLIST_FOREACH(wd->blocks, itb)
2186 Evas_Coord itminw, itminh;
2187 Elm_Genlist_Item *it;
2193 _item_block_position(itb, num);
2198 EINA_LIST_FOREACH(itb->items, l2, it)
2208 _item_unrealize(it);
2209 _item_realize(it, num, 0);
2210 evas_object_smart_callback_call(it->wd->obj,
2215 _item_realize(it, num, 1);
2216 _item_unrealize(it);
2218 if ((it->minw != itminw) || (it->minh != itminh))
2227 itb->changed = EINA_TRUE;
2228 _item_block_recalc(itb, num0, 0, 1);
2229 _item_block_position(itb, num0);
2234 if (wd->calc_job) ecore_job_del(wd->calc_job);
2235 wd->calc_job = ecore_job_add(_calc_job, wd);
2240 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2242 Pan *sd = evas_object_smart_data_get(obj);
2243 // Evas_Coord ow, oh;
2244 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2245 // ow = sd->wd->minw - ow;
2246 // if (ow < 0) ow = 0;
2247 // oh = sd->wd->minh - oh;
2248 // if (oh < 0) oh = 0;
2249 // if (x < 0) x = 0;
2250 // if (y < 0) y = 0;
2251 // if (x > ow) x = ow;
2252 // if (y > oh) y = oh;
2253 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2255 if(sd->wd->reoder_moved)
2258 if(sd->wd->pan_y >= sd->wd->minh)
2259 sd->wd->pan_y = sd->wd->minh;
2262 if(sd->wd->pan_y < y )
2263 sd->wd->pan_y = y + 5 + abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2265 sd->wd->pan_y = y - 5 - abs(sd->wd->reoder_pan_y - sd->wd->pan_y) / 100;
2273 evas_object_smart_changed(obj);
2277 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2279 Pan *sd = evas_object_smart_data_get(obj);
2281 if (x) *x = sd->wd->pan_x;
2282 if (y) *y = sd->wd->pan_y;
2284 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2286 int git_cnt = 0, git_h = 0;
2287 Elm_Genlist_GroupItem *git;
2289 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2295 if (sd->wd->minh != (git_h+1) * git_cnt)
2297 sd->wd->minh = (git_h+1) * git_cnt;
2304 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2306 Pan *sd = evas_object_smart_data_get(obj);
2309 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2310 ow = sd->wd->minw - ow;
2312 oh = sd->wd->minh - oh;
2319 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2321 Pan *sd = evas_object_smart_data_get(obj);
2323 if (w) *w = sd->wd->minw;
2324 if (h) *h = sd->wd->minh;
2328 _pan_add(Evas_Object *obj)
2331 Evas_Object_Smart_Clipped_Data *cd;
2334 cd = evas_object_smart_data_get(obj);
2337 sd->__clipped_data = *cd;
2339 evas_object_smart_data_set(obj, sd);
2343 _pan_del(Evas_Object *obj)
2345 Pan *sd = evas_object_smart_data_get(obj);
2352 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2354 Pan *sd = evas_object_smart_data_get(obj);
2357 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2358 if ((ow == w) && (oh == h)) return;
2359 /* don't do this... use wd->compress mode
2360 if (sd->wd->mode == ELM_LIST_COMPRESS)
2363 // this is nasty - but no choice. have to mark all as not mincalced.
2364 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2367 Elm_Genlist_Item *it;
2369 EINA_LIST_FOREACH(itb->items, l, it)
2370 it->mincalcd = EINA_FALSE;
2372 itb->changed = EINA_TRUE;
2376 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2377 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2381 _pan_calculate(Evas_Object *obj)
2383 Pan *sd = evas_object_smart_data_get(obj);
2385 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2387 Elm_Genlist_GroupItem *git;
2389 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2390 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND) return;
2393 if (sd->wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
2395 sd->wd->group_items_moved = EINA_TRUE;
2396 sd->wd->contract_pan_y = sd->wd->pan_y;
2397 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2399 git->visible = EINA_TRUE;
2400 evas_object_raise(git->base);
2401 evas_object_resize(git->base, sd->wd->minw, git->h);
2402 evas_object_move(git->base, git->x, git->y + sd->wd->pan_y * -1);
2403 evas_object_show(git->base);
2407 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2409 if (sd->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2410 (void)_edit_mode_reset(sd->wd);
2411 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2413 git->visible = EINA_FALSE;
2416 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2417 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2419 itb->w = sd->wd->minw;
2420 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2421 itb->y - sd->wd->pan_y + oy,
2423 cvx, cvy, cvw, cvh))
2425 if ((!itb->realized) || (itb->changed))
2426 _item_block_realize(itb, in, 0);
2427 _item_block_position(itb, in);
2431 if (itb->realized) _item_block_unrealize(itb);
2436 if (sd->wd->effect_mode &&
2437 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2439 _item_flip_effect_show(sd->wd);
2440 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2443 if (sd->wd->effect_mode && sd->wd->edit_mode_effect_mode)
2444 sd->wd->item_moving_effect_timer = ecore_animator_add(_edit_mode_item_moving_effect_cb, sd->wd);
2446 EINA_INLIST_FOREACH(sd->wd->group_items, git)
2450 evas_object_raise(git->base);
2451 evas_object_resize(git->base, git->w, git->h - 1);
2452 evas_object_move(git->base, git->x, git->y);
2453 if (!sd->wd->pinch_zoom_reserve)
2454 evas_object_show(git->base);
2456 evas_object_hide(git->base);
2459 evas_object_hide(git->base);
2461 if ((sd->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) && (sd->wd->ed->reorder_item))
2463 evas_object_raise(sd->wd->ed->reorder_item->base);
2464 evas_object_raise(sd->wd->ed->reorder_item->edit_obj);
2466 if (sd->wd->select_all_item)
2467 evas_object_raise(sd->wd->select_all_item->base);
2471 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2473 Pan *sd = evas_object_smart_data_get(obj);
2475 if (sd->wd->effect_mode && sd->wd->multi_down) return;
2476 if (sd->wd->effect_mode && sd->wd->pinchzoom_effect_mode != ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE) return;
2478 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2479 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2483 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2485 Widget_Data *wd = elm_widget_data_get(obj);
2487 elm_smart_scroller_hold_set(wd->scr, 1);
2491 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2493 Widget_Data *wd = elm_widget_data_get(obj);
2495 elm_smart_scroller_hold_set(wd->scr, 0);
2499 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2501 Widget_Data *wd = elm_widget_data_get(obj);
2503 elm_smart_scroller_freeze_set(wd->scr, 1);
2507 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2509 Widget_Data *wd = elm_widget_data_get(obj);
2511 elm_smart_scroller_freeze_set(wd->scr, 0);
2515 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2517 Evas_Object *obj = data;
2518 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2522 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2524 Evas_Object *obj = data;
2525 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2529 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2531 Evas_Object *obj = data;
2532 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2536 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
2538 Evas_Object *obj = data;
2539 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2543 * Add a new Genlist object
2545 * @param parent The parent object
2546 * @return The new object or NULL if it cannot be created
2551 elm_genlist_add(Evas_Object *parent)
2556 Evas_Coord minw, minh;
2557 static Evas_Smart *smart = NULL;
2559 if (!parent) return NULL;
2562 static Evas_Smart_Class sc;
2564 evas_object_smart_clipped_smart_set(&_pan_sc);
2566 sc.name = "elm_genlist_pan";
2567 sc.version = EVAS_SMART_CLASS_VERSION;
2570 sc.resize = _pan_resize;
2571 sc.move = _pan_move;
2572 sc.calculate = _pan_calculate;
2573 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2575 wd = ELM_NEW(Widget_Data);
2576 e = evas_object_evas_get(parent);
2577 obj = elm_widget_add(e);
2578 ELM_SET_WIDTYPE(widtype, "genlist");
2579 elm_widget_type_set(obj, "genlist");
2580 elm_widget_sub_object_add(parent, obj);
2581 elm_widget_data_set(obj, wd);
2582 elm_widget_del_hook_set(obj, _del_hook);
2583 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2584 elm_widget_theme_hook_set(obj, _theme_hook);
2585 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2587 wd->scr = elm_smart_scroller_add(e);
2588 elm_smart_scroller_widget_set(wd->scr, obj);
2589 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base", elm_widget_style_get(obj));
2590 elm_widget_resize_object_set(obj, wd->scr);
2592 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
2594 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2595 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
2596 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2597 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
2600 wd->mode = ELM_LIST_SCROLL;
2601 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2602 wd->max_items_per_block = 32;
2603 wd->longpress_timeout = _elm_config->longpress_timeout;
2604 wd->max_git_num = 0;
2606 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2607 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2608 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2609 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2611 wd->pan_smart = evas_object_smart_add(e, smart);
2612 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2615 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2617 _pan_max_get, _pan_child_size_get);
2619 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2621 evas_object_size_hint_min_set(obj, minw, minh);
2627 static Elm_Genlist_Item *
2628 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
2629 const void *data, Elm_Genlist_Item *parent,
2630 Elm_Genlist_Item_Flags flags,
2632 const void *func_data)
2634 Elm_Genlist_Item *it;
2636 it = calloc(1, sizeof(Elm_Genlist_Item));
2637 if (!it) return NULL;
2641 it->parent = parent;
2643 it->func.func = func;
2644 it->func.data = func_data;
2645 it->expanded_depth = 0;
2650 _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
2652 Item_Block *itb = NULL;
2659 itb = calloc(1, sizeof(Item_Block));
2662 if (!it->rel->block)
2664 it->rel->block = itb;
2666 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2667 itb->items = eina_list_append(itb->items, it);
2674 eina_inlist_prepend_relative(wd->blocks,
2675 EINA_INLIST_GET(itb),
2676 EINA_INLIST_GET(it->rel->block));
2678 eina_list_prepend_relative(itb->items, it, it->rel);
2683 eina_inlist_append_relative(wd->blocks,
2684 EINA_INLIST_GET(itb),
2685 EINA_INLIST_GET(it->rel->block));
2687 eina_list_append_relative(itb->items, it, it->rel);
2697 itb = (Item_Block *)(wd->blocks);
2698 if (itb->count >= wd->max_items_per_block)
2700 itb = calloc(1, sizeof(Item_Block));
2704 eina_inlist_prepend(wd->blocks,
2705 EINA_INLIST_GET(itb));
2710 itb = calloc(1, sizeof(Item_Block));
2714 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2716 itb->items = eina_list_prepend(itb->items, it);
2722 itb = (Item_Block *)(wd->blocks->last);
2723 if (itb->count >= wd->max_items_per_block)
2725 itb = calloc(1, sizeof(Item_Block));
2729 eina_inlist_append(wd->blocks,
2730 EINA_INLIST_GET(itb));
2735 itb = calloc(1, sizeof(Item_Block));
2739 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2741 itb->items = eina_list_append(itb->items, it);
2747 itb = it->rel->block;
2748 if (!itb) goto newblock;
2750 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
2752 itb->items = eina_list_append_relative(itb->items, it, it->rel);
2755 itb->changed = EINA_TRUE;
2761 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
2762 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
2765 it->rel->relcount--;
2766 if ((it->rel->delete_me) && (!it->rel->relcount))
2770 if (itb->count > itb->wd->max_items_per_block)
2774 Elm_Genlist_Item *it2;
2776 newc = itb->count / 2;
2777 itb2 = calloc(1, sizeof(Item_Block));
2781 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
2782 EINA_INLIST_GET(itb));
2783 itb2->changed = EINA_TRUE;
2784 while ((itb->count > newc) && (itb->items))
2788 l = eina_list_last(itb->items);
2790 itb->items = eina_list_remove_list(itb->items, l);
2793 itb2->items = eina_list_prepend(itb2->items, it2);
2801 _queue_proecess(Widget_Data *wd, int norender)
2806 t0 = ecore_time_get();
2807 for (n = 0; (wd->queue) && (n < 128); n++)
2809 Elm_Genlist_Item *it;
2811 it = wd->queue->data;
2812 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
2813 it->queued = EINA_FALSE;
2814 _item_block_add(wd, it);
2815 t = ecore_time_get();
2816 if (it->block->changed)
2818 showme = _item_block_recalc(it->block, it->block->num, 1, norender);
2819 it->block->changed = 0;
2821 if (showme) it->block->showme = 1;
2822 if (eina_inlist_count(wd->blocks) > 1)
2824 if ((t - t0) > (ecore_animator_frametime_get())) break;
2831 _item_idler(void *data)
2833 Widget_Data *wd = data;
2836 //static double q_start = 0.0;
2837 //if (q_start == 0.0) q_start = ecore_time_get();
2840 if (_queue_proecess(wd, 1) > 0)
2842 if (wd->calc_job) ecore_job_del(wd->calc_job);
2843 wd->calc_job = ecore_job_add(_calc_job, wd);
2848 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
2850 wd->queue_idler = NULL;
2851 if (wd->pinch_zoom_reserve)
2852 _elm_genlist_pinch_zoom_execute(wd->obj, 1);
2853 return ECORE_CALLBACK_CANCEL;
2855 return ECORE_CALLBACK_RENEW;
2859 _item_queue(Widget_Data *wd, Elm_Genlist_Item *it)
2861 if (!wd->queue_exception)
2863 if (it->queued) return;
2864 wd->queue = eina_list_append(wd->queue, it);
2865 it->queued = EINA_TRUE;
2868 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
2870 if (wd->queue_idler)
2872 ecore_idler_del(wd->queue_idler);
2873 wd->queue_idler = NULL;
2875 _queue_proecess(wd, 0);
2877 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
2878 if (wd->queue_exception)
2880 wd->queue = eina_list_append(wd->queue, it);
2881 it->queued = EINA_TRUE;
2886 * Append item to the end of the genlist
2888 * This appends the given item to the end of the list or the end of the
2889 * children if the parent is given.
2891 * @param obj The genlist object
2892 * @param itc The item class for the item
2893 * @param data The item data
2894 * @param parent The parent item, or NULL if none
2895 * @param flags Item flags
2896 * @param func Convenience function called when item selected
2897 * @param func_data Data passed to @p func above.
2898 * @return A handle to the item added or NULL if not possible
2902 EAPI Elm_Genlist_Item *
2903 elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2904 const void *data, Elm_Genlist_Item *parent,
2905 Elm_Genlist_Item_Flags flags,
2906 Evas_Smart_Cb func, const void *func_data)
2908 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2909 Widget_Data *wd = elm_widget_data_get(obj);
2910 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2911 if (!wd) return NULL;
2912 if (!it) return NULL;
2915 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2921 Elm_Genlist_Item *it2 = NULL;
2922 Eina_List *ll = eina_list_last(it->parent->items);
2923 if (ll) it2 = ll->data;
2924 it->parent->items = eina_list_append(it->parent->items, it);
2925 if (!it2) it2 = it->parent;
2927 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
2928 EINA_INLIST_GET(it2));
2930 it->rel->relcount++;
2933 _item_queue(wd, it);
2938 * Prepend item at start of the genlist
2940 * This adds an item to the beginning of the list or beginning of the children
2941 * of the parent if given.
2943 * @param obj The genlist object
2944 * @param itc The item class for the item
2945 * @param data The item data
2946 * @param parent The parent item, or NULL if none
2947 * @param flags Item flags
2948 * @param func Convenience function called when item selected
2949 * @param func_data Data passed to @p func above.
2950 * @return A handle to the item added or NULL if not possible
2954 EAPI Elm_Genlist_Item *
2955 elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2956 const void *data, Elm_Genlist_Item *parent,
2957 Elm_Genlist_Item_Flags flags,
2958 Evas_Smart_Cb func, const void *func_data)
2960 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2961 Widget_Data *wd = elm_widget_data_get(obj);
2962 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
2963 if (!wd) return NULL;
2964 if (!it) return NULL;
2966 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2969 printf("FIXME: 12 tree not handled yet\n");
2973 _item_queue(wd, it);
2978 * Insert item before another in the genlist
2980 * This inserts an item before another in the list. It will be in the same tree
2981 * level as the item it is inseted before.
2983 * @param obj The genlist object
2984 * @param itc The item class for the item
2985 * @param data The item data
2986 * @param before The item to insert before
2987 * @param flags Item flags
2988 * @param func Convenience function called when item selected
2989 * @param func_data Data passed to @p func above.
2990 * @return A handle to the item added or NULL if not possible
2994 EAPI Elm_Genlist_Item *
2995 elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
2996 const void *data, Elm_Genlist_Item *before,
2997 Elm_Genlist_Item_Flags flags,
2998 Evas_Smart_Cb func, const void *func_data)
3000 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3001 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3002 Widget_Data *wd = elm_widget_data_get(obj);
3003 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3004 if (!wd) return NULL;
3005 if (!it) return NULL;
3007 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3008 EINA_INLIST_GET(before));
3011 printf("FIXME: 13 tree not handled yet\n");
3014 it->rel->relcount++;
3016 _item_queue(wd, it);
3021 * Insert and item after another in the genlst
3023 * This inserts an item after another in the list. It will be in the same tree
3024 * level as the item it is inseted after.
3026 * @param obj The genlist object
3027 * @param itc The item class for the item
3028 * @param data The item data
3029 * @param after The item to insert after
3030 * @param flags Item flags
3031 * @param func Convenience function called when item selected
3032 * @param func_data Data passed to @p func above.
3033 * @return A handle to the item added or NULL if not possible
3037 EAPI Elm_Genlist_Item *
3038 elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
3039 const void *data, Elm_Genlist_Item *after,
3040 Elm_Genlist_Item_Flags flags,
3041 Evas_Smart_Cb func, const void *func_data)
3043 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3044 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3045 Widget_Data *wd = elm_widget_data_get(obj);
3046 Elm_Genlist_Item *it = _item_new(wd, itc, data, NULL, flags, func, func_data);
3047 if (!wd) return NULL;
3048 if (!it) return NULL;
3050 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3051 EINA_INLIST_GET(after));
3054 printf("FIXME: 14 tree not handled yet\n");
3057 it->rel->relcount++;
3059 _item_queue(wd, it);
3066 * This clears all items in the list, leaving it empty.
3068 * @param obj The genlist object
3073 elm_genlist_clear(Evas_Object *obj)
3075 ELM_CHECK_WIDTYPE(obj, widtype);
3076 Widget_Data *wd = elm_widget_data_get(obj);
3079 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
3080 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
3081 elm_smart_scroller_hold_set(wd->scr, 0);
3082 elm_smart_scroller_freeze_set(wd->scr, 0);
3083 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
3084 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
3085 wd->max_git_num = 0;
3086 wd->pinch_zoom_reserve = EINA_FALSE;
3088 if (wd->item_moving_effect_timer)
3090 // ecore_timer_del(wd->item_moving_effect_timer);
3091 wd->item_moving_effect_timer = NULL;
3094 while (wd->group_items)
3096 _groupitem_remove((Elm_Genlist_GroupItem *)wd->group_items, EINA_FALSE);
3099 if (wd->walking > 0)
3101 Elm_Genlist_Item *it;
3104 EINA_INLIST_FOREACH(wd->items, it)
3113 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3115 wd->items = eina_inlist_remove(wd->items, wd->items);
3116 if (it->realized) _item_unrealize(it);
3117 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
3118 if (it->long_timer) ecore_timer_del(it->long_timer);
3123 Item_Block *itb = (Item_Block *)(wd->blocks);
3125 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3126 if (itb->items) eina_list_free(itb->items);
3131 ecore_job_del(wd->calc_job);
3132 wd->calc_job = NULL;
3134 if (wd->queue_idler)
3136 ecore_idler_del(wd->queue_idler);
3137 wd->queue_idler = NULL;
3141 eina_list_free(wd->queue);
3146 eina_list_free(wd->selected);
3147 wd->selected = NULL;
3149 wd->show_item = NULL;
3156 evas_object_del(wd->alpha_bg);
3157 wd->alpha_bg = NULL;
3161 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3162 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3168 * Enable or disable multi-select in the genlist
3170 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in the list. This allows
3171 * more than 1 item to be selected.
3173 * @param obj The genlist object
3174 * @param multi Multi-select enable/disable
3179 elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
3181 ELM_CHECK_WIDTYPE(obj, widtype);
3182 Widget_Data *wd = elm_widget_data_get(obj);
3188 * Gets if multi-select in genlist is enable or disable
3190 * @param obj The genlist object
3191 * @return Multi-select enable/disable
3192 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3197 elm_genlist_multi_select_get(const Evas_Object *obj)
3199 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3200 Widget_Data *wd = elm_widget_data_get(obj);
3201 if (!wd) return EINA_FALSE;
3206 * Get the selectd item in the genlist
3208 * This gets the selected item in the list (if multi-select is enabled only
3209 * the first item in the list is selected - which is not very useful, so see
3210 * elm_genlist_selected_items_get()for when multi-select is used).
3212 * If no item is selected, NULL is returned.
3214 * @param obj The genlist object
3215 * @return The selected item, or NULL if none.
3219 EAPI Elm_Genlist_Item *
3220 elm_genlist_selected_item_get(const Evas_Object *obj)
3222 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3223 Widget_Data *wd = elm_widget_data_get(obj);
3224 if (!wd) return NULL;
3225 if (wd->selected) return wd->selected->data;
3230 * Get a list of selected items in the genlist
3232 * This retgurns a list of the selected items. This list pointer is only valid
3233 * so long as no items are selected or unselected (or unselected implicitly
3234 * by deletion). The list contains Elm_Genlist_Item pointers.
3236 * @param obj The genlist object
3237 * @return The list of selected items, nor NULL if none are selected.
3241 EAPI const Eina_List *
3242 elm_genlist_selected_items_get(const Evas_Object *obj)
3244 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3245 Widget_Data *wd = elm_widget_data_get(obj);
3246 if (!wd) return NULL;
3247 return wd->selected;
3251 * Get a list of realized items in genlist
3253 * This returns a list of the realized items in the genlist. The list
3254 * contains Elm_Genlist_Item pointers. The list must be freed by the
3255 * caller when done with eina_list_free(). The item pointers in the list
3256 * are only vallid so long as those items are not deleted or the genlist is
3259 * @param obj The genlist object
3260 * @return The list of realized items, nor NULL if none are realized.
3265 elm_genlist_realized_items_get(const Evas_Object *obj)
3267 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3268 Widget_Data *wd = elm_widget_data_get(obj);
3269 Eina_List *list = NULL;
3271 Eina_Bool done = EINA_FALSE;
3272 if (!wd) return NULL;
3273 EINA_INLIST_FOREACH(wd->blocks, itb)
3278 Elm_Genlist_Item *it;
3281 EINA_LIST_FOREACH(itb->items, l, it)
3283 if (it->realized) list = eina_list_append(list, it);
3295 * Get the item that is at the x, y canvas coords
3297 * This returns the item at the given coordinates (which are canvas relative
3298 * not object-relative). If an item is at that coordinate, that item handle
3299 * is returned, and if @p posret is not NULL, the integer pointed to is set
3300 * to a value of -1, 0 or 1, depending if the coordinate is on the upper
3301 * portion of that item (-1), on the middle section (0) or on the lower part
3302 * (1). If NULL is returned as an item (no item found there), then posret
3303 * may indicate -1 or 1 based if the coordinate is above or below all items
3304 * respectively in the genlist.
3306 * @param it The item
3307 * @param x The input x coordinate
3308 * @param y The input y coordinate
3309 * @param posret The position relative to the item returned here
3310 * @return The item at the coordinates or NULL if none
3314 EAPI Elm_Genlist_Item *
3315 elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret)
3317 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3318 Widget_Data *wd = elm_widget_data_get(obj);
3319 Evas_Coord ox, oy, ow, oh;
3322 if (!wd) return NULL;
3323 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3325 EINA_INLIST_FOREACH(wd->blocks, itb)
3328 Elm_Genlist_Item *it;
3330 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3331 oy + itb->y - itb->wd->pan_y,
3332 itb->w, itb->h, x, y, 1, 1))
3334 EINA_LIST_FOREACH(itb->items, l, it)
3336 Evas_Coord itx, ity;
3338 itx = ox + itb->x + it->x - itb->wd->pan_x;
3339 ity = oy + itb->y + it->y - itb->wd->pan_y;
3340 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3344 if (y <= (ity + (it->h / 4))) *posret = -1;
3345 else if (y >= (ity + it->h - (it->h / 4))) *posret = 1;
3350 lasty = ity + it->h;
3355 if (y > lasty) *posret = 1;
3362 * Get the first item in the genlist
3364 * This returns the first item in the list.
3366 * @param obj The genlist object
3367 * @return The first item, or NULL if none
3371 EAPI Elm_Genlist_Item *
3372 elm_genlist_first_item_get(const Evas_Object *obj)
3374 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3375 Widget_Data *wd = elm_widget_data_get(obj);
3376 if (!wd) return NULL;
3377 if (!wd->items) return NULL;
3378 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
3379 while ((it) && (it->delete_me))
3380 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3385 * Get the last item in the genlist
3387 * This returns the last item in the list.
3389 * @return The last item, or NULL if none
3393 EAPI Elm_Genlist_Item *
3394 elm_genlist_last_item_get(const Evas_Object *obj)
3396 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3397 Widget_Data *wd = elm_widget_data_get(obj);
3398 if (!wd->items) return NULL;
3399 Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items->last);
3400 if (!wd) return NULL;
3401 while ((it) && (it->delete_me))
3402 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3407 * Get the next item in the genlist
3409 * This returns the item after the item @p it.
3411 * @param it The item
3412 * @return The item after @p it, or NULL if none
3416 EAPI Elm_Genlist_Item *
3417 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3421 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3422 if ((it) && (!it->delete_me)) break;
3424 return (Elm_Genlist_Item *)it;
3428 * Get the previous item in the genlist
3430 * This returns the item before the item @p it.
3432 * @param it The item
3433 * @return The item before @p it, or NULL if none
3437 EAPI Elm_Genlist_Item *
3438 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3442 it = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3443 if ((it) && (!it->delete_me)) break;
3445 return (Elm_Genlist_Item *)it;
3449 * Get the genlist object from an item
3451 * This returns the genlist object itself that an item belongs to.
3453 * @param it The item
3454 * @return The genlist object
3459 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3461 if (!it) return NULL;
3466 * Get the parent item of the given item
3468 * This returns the prent item of the item @p it given.
3470 * @param it The item
3471 * @return The parent of the item or NULL if none
3475 EAPI Elm_Genlist_Item *
3476 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3478 if (!it) return NULL;
3483 * Clear all sub-items (children) of the given item
3485 * This clears all items that are children (or their descendants) of the
3488 * @param it The item
3493 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3496 Eina_List *tl = NULL, *l;
3497 Elm_Genlist_Item *it2;
3499 EINA_LIST_FOREACH(it->items, l, it2)
3500 tl = eina_list_append(tl, it2);
3501 EINA_LIST_FREE(tl, it2)
3502 elm_genlist_item_del(it2);
3506 * Set the selected state of an item
3508 * This sets the selected state (1 selected, 0 not selected) of the given
3511 * @param it The item
3512 * @param selected The slected state
3517 elm_genlist_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected)
3520 ELM_CHECK_WIDTYPE(it->wd->obj, widtype);
3521 Widget_Data *wd = elm_widget_data_get(it->wd->obj);
3523 if (it->delete_me) return;
3524 selected = !!selected;
3525 if (it->selected == selected) return;
3531 while (wd->selected)
3532 _item_unselect(wd->selected->data);
3542 * Get the selected state of an item
3544 * This gets the selected state of an item (1 selected, 0 not selected).
3546 * @param it The item
3547 * @return The selected state
3552 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3554 if (!it) return EINA_FALSE;
3555 return it->selected;
3559 * Sets the expanded state of an item (if it's a parent)
3561 * This expands or contracts a parent iterm (thus showing or hiding the
3564 * @param it The item
3565 * @param expanded The expanded state (1 expanded, 0 not expanded).
3570 elm_genlist_item_expanded_set(Elm_Genlist_Item *it, Eina_Bool expanded)
3573 if (it->expanded == expanded || it->disabled) return;
3574 it->expanded = expanded;
3575 it->wd->expand_item = it;
3576 it->effect_done = EINA_FALSE;
3579 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
3581 edje_object_signal_emit(it->base, "elm,state,expanded", "elm");
3582 evas_object_smart_callback_call(it->wd->obj, "expanded", it);
3587 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
3589 edje_object_signal_emit(it->base, "elm,state,contracted", "elm");
3590 evas_object_smart_callback_call(it->wd->obj, "contracted", it);
3595 * Get the expanded state of an item
3597 * This gets the expanded state of an item
3599 * @param it The item
3600 * @return Thre expanded state
3605 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3607 if (!it) return EINA_FALSE;
3608 return it->expanded;
3612 * Get the depth of expanded item
3614 * @param it The genlist item object
3615 * @return The depth of expanded item
3620 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3623 return it->expanded_depth;
3627 * Sets the disabled state of an item.
3629 * A disabled item cannot be selected or unselected. It will also change
3630 * appearance to appear disabled. This sets the disabled state (1 disabled, 0
3633 * @param it The item
3634 * @param disabled The disabled state
3639 elm_genlist_item_disabled_set(Elm_Genlist_Item *it, Eina_Bool disabled)
3642 if (it->disabled == disabled) return;
3643 if (it->delete_me) return;
3644 it->disabled = disabled;
3648 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
3650 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
3655 * Get the disabled state of an item
3657 * This gets the disabld state of the given item.
3659 * @param it The item
3660 * @return The disabled state
3665 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3667 if (!it) return EINA_FALSE;
3668 if (it->delete_me) return EINA_FALSE;
3669 return it->disabled;
3673 * Sets the display only state of an item.
3675 * A display only item cannot be selected or unselected. It is for display
3676 * only and not selecting or otherwise clicking, dragging etc. by the user,
3677 * thus finger size rules will not be applied to this item.
3679 * @param it The item
3680 * @param display_only The display only state
3685 elm_genlist_item_display_only_set(Elm_Genlist_Item *it, Eina_Bool display_only)
3688 if (!it->block) return;
3689 if (it->display_only == display_only) return;
3690 if (it->delete_me) return;
3691 it->display_only = display_only;
3692 it->mincalcd = EINA_FALSE;
3693 it->updateme = EINA_TRUE;
3694 it->block->updateme = EINA_TRUE;
3695 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
3696 it->wd->update_job = ecore_job_add(_update_job, it->wd);
3700 * Get the display only state of an item
3702 * This gets the display only state of the given item.
3704 * @param it The item
3705 * @return The display only state
3710 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
3712 if (!it) return EINA_FALSE;
3713 if (it->delete_me) return EINA_FALSE;
3714 return it->display_only;
3718 * Show the given item
3720 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3721 * if it is not fully visible.
3723 * @param it The item
3728 elm_genlist_item_show(Elm_Genlist_Item *it)
3731 if (it->delete_me) return;
3732 if ((it->queued) || (!it->mincalcd))
3734 it->wd->show_item = it;
3735 it->wd->bring_in = 1;
3736 it->showme = EINA_TRUE;
3739 if (it->wd->show_item)
3741 it->wd->show_item->showme = EINA_FALSE;
3742 it->wd->show_item = NULL;
3744 elm_smart_scroller_child_region_show(it->wd->scr,
3745 it->x + it->block->x,
3746 it->y + it->block->y,
3747 it->block->w, it->h);
3751 * Bring in the given item
3753 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3754 * if it is not fully visible. This may use animation to do so and take a
3757 * @param it The item
3762 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
3765 if (it->delete_me) return;
3766 if ((it->queued) || (!it->mincalcd))
3768 it->wd->show_item = it;
3769 it->wd->bring_in = 1;
3770 it->showme = EINA_TRUE;
3773 if (it->wd->show_item)
3775 it->wd->show_item->showme = EINA_FALSE;
3776 it->wd->show_item = NULL;
3778 elm_smart_scroller_region_bring_in(it->wd->scr,
3779 it->x + it->block->x,
3780 it->y + it->block->y,
3781 it->block->w, it->h);
3785 * Show the given item at the top
3787 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3788 * if it is not fully visible.
3790 * @param it The item
3795 elm_genlist_item_top_show(Elm_Genlist_Item *it)
3800 if (it->delete_me) return;
3801 if ((it->queued) || (!it->mincalcd))
3803 it->wd->show_item = it;
3804 it->wd->bring_in = 1;
3805 it->showme = EINA_TRUE;
3808 if (it->wd->show_item)
3810 it->wd->show_item->showme = EINA_FALSE;
3811 it->wd->show_item = NULL;
3813 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3814 elm_smart_scroller_child_region_show(it->wd->scr,
3815 it->x + it->block->x,
3816 it->y + it->block->y,
3821 * Bring in the given item at the top
3823 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3824 * if it is not fully visible. This may use animation to do so and take a
3827 * @param it The item
3832 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
3837 if (it->delete_me) return;
3838 if ((it->queued) || (!it->mincalcd))
3840 it->wd->show_item = it;
3841 it->wd->bring_in = 1;
3842 it->showme = EINA_TRUE;
3845 if (it->wd->show_item)
3847 it->wd->show_item->showme = EINA_FALSE;
3848 it->wd->show_item = NULL;
3850 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3851 elm_smart_scroller_region_bring_in(it->wd->scr,
3852 it->x + it->block->x,
3853 it->y + it->block->y,
3858 * Show the given item at the middle
3860 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3861 * if it is not fully visible.
3863 * @param it The item
3868 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
3873 if (it->delete_me) return;
3874 if ((it->queued) || (!it->mincalcd))
3876 it->wd->show_item = it;
3877 it->wd->bring_in = 1;
3878 it->showme = EINA_TRUE;
3881 if (it->wd->show_item)
3883 it->wd->show_item->showme = EINA_FALSE;
3884 it->wd->show_item = NULL;
3886 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3887 elm_smart_scroller_child_region_show(it->wd->scr,
3888 it->x + it->block->x,
3889 it->y + it->block->y - oh/2 + it->h/2,
3895 * Bring in the given item at the middle
3897 * This causes genlist to jump to the given item @p it and show it (by scrolling),
3898 * if it is not fully visible. This may use animation to do so and take a
3901 * @param it The item
3906 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
3911 if (it->delete_me) return;
3912 if ((it->queued) || (!it->mincalcd))
3914 it->wd->show_item = it;
3915 it->wd->bring_in = 1;
3916 it->showme = EINA_TRUE;
3919 if (it->wd->show_item)
3921 it->wd->show_item->showme = EINA_FALSE;
3922 it->wd->show_item = NULL;
3924 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
3925 elm_smart_scroller_region_bring_in(it->wd->scr,
3926 it->x + it->block->x,
3927 it->y + it->block->y - oh/2 + it->h/2,
3932 * Delete a given item
3934 * This deletes the item from genlist and calls the genlist item del class
3935 * callback defined in the item class, if it is set.
3937 * @param it The item
3942 elm_genlist_item_del(Elm_Genlist_Item *it)
3945 if ((it->relcount > 0) || (it->walking > 0))
3947 elm_genlist_item_subitems_clear(it);
3948 it->delete_me = EINA_TRUE;
3949 if (it->wd->show_item == it) it->wd->show_item = NULL;
3950 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
3953 if (it->realized) _item_unrealize(it);
3954 it->block->changed = EINA_TRUE;
3955 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
3956 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
3958 if (it->itc->func.del)
3959 it->itc->func.del((void *)it->data, it->wd->obj);
3966 * Set the data item from the genlist item
3968 * This set the data value passed on the elm_genlist_item_append() and
3969 * related item addition calls. This function will also call
3970 * elm_genlist_item_update() so the item will be updated to reflect the
3973 * @param it The item
3974 * @param data The new data pointer to set
3979 elm_genlist_item_data_set(Elm_Genlist_Item *it, const void *data)
3983 elm_genlist_item_update(it);
3987 * Get the data item from the genlist item
3989 * This returns the data value passed on the elm_genlist_item_append() and
3990 * related item addition calls.
3992 * @param it The item
3993 * @return The data pointer provided when created
3998 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4000 if (!it) return NULL;
4005 * Get the real evas object of the genlist item
4007 * This returns the actual evas object used for the specified genlist item.
4008 * This may be NULL as it may not be created, and ma be deleted at any time
4009 * by genlist. Do not modify this object (move, resize, show, hide etc.) as
4010 * genlist is controlling it. This function is for querying, emitting
4011 * custom signals or hooking lower level callbacks for events. Do not
4012 * delete this object under any circumstances.
4014 * @param it The item
4015 * @return The objct pointer
4019 EAPI const Evas_Object *
4020 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4022 if (!it) return NULL;
4027 * Update the contents of an item
4029 * This updates an item by calling all the item class functions again to get
4030 * the icons, labels and states. Use this when the original item data has
4031 * changed and the changes are desired to be reflected.
4033 * @param it The item
4038 elm_genlist_item_update(Elm_Genlist_Item *it)
4041 if (!it->block) return;
4042 if (it->delete_me) return;
4043 it->mincalcd = EINA_FALSE;
4044 it->updateme = EINA_TRUE;
4045 it->block->updateme = EINA_TRUE;
4046 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4047 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4051 * Update the item class of an item
4053 * @param it The item
4054 * @parem itc The item class for the item
4059 elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc)
4062 if (!it->block) return;
4064 if (it->delete_me) return;
4066 elm_genlist_item_update(it);
4070 * This sets the horizontal stretching mode
4072 * This sets the mode used for sizing items horizontally. Valid modes are
4073 * ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This
4074 * mode means that if items are too wide to fit, the scroller will scroll
4075 * horizontally. Otherwise items are expanded to fill the width of the
4076 * viewport of the scroller. If it is ELM_LIST_LIMIT, Items will be expanded
4077 * to the viewport width and limited to that size.
4079 * @param obj The genlist object
4080 * @param mode The mode to use
4085 elm_genlist_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode)
4087 ELM_CHECK_WIDTYPE(obj, widtype);
4088 Widget_Data *wd = elm_widget_data_get(obj);
4090 if (wd->mode == mode) return;
4096 * Gets the horizontal stretching mode
4098 * @param obj The genlist object
4099 * @return The mode to use
4100 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL, ELM_LIST_LIMIT)
4105 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4107 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4108 Widget_Data *wd = elm_widget_data_get(obj);
4109 if (!wd) return ELM_LIST_LAST;
4114 * Set the always select mode.
4116 * Items will only call their selection func and callback when first becoming
4117 * selected. Any further clicks will do nothing, unless you enable always
4118 * select with elm_genlist_always_select_mode_set(). This means even if
4119 * selected, every click will make the selected callbacks be called.
4121 * @param obj The genlist object
4122 * @param always_select The always select mode
4123 * (EINA_TRUE = on, EINA_FALSE = off)
4128 elm_genlist_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
4130 ELM_CHECK_WIDTYPE(obj, widtype);
4131 Widget_Data *wd = elm_widget_data_get(obj);
4133 wd->always_select = always_select;
4137 * Get the always select mode.
4139 * @param obj The genlist object
4140 * @return The always select mode
4141 * (EINA_TRUE = on, EINA_FALSE = off)
4146 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4148 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4149 Widget_Data *wd = elm_widget_data_get(obj);
4150 if (!wd) return EINA_FALSE;
4151 return wd->always_select;
4155 * Set no select mode
4157 * This will turn off the ability to select items entirely and they will
4158 * neither appear selected nor call selected callback functions.
4160 * @param obj The genlist object
4161 * @param no_select The no select mode
4162 * (EINA_TRUE = on, EINA_FALSE = off)
4167 elm_genlist_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
4169 ELM_CHECK_WIDTYPE(obj, widtype);
4170 Widget_Data *wd = elm_widget_data_get(obj);
4172 wd->no_select = no_select;
4176 * Gets no select mode
4178 * @param obj The genlist object
4179 * @return The no select mode
4180 * (EINA_TRUE = on, EINA_FALSE = off)
4185 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4187 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4188 Widget_Data *wd = elm_widget_data_get(obj);
4189 if (!wd) return EINA_FALSE;
4190 return wd->no_select;
4196 * This will enable the compress mode where items are "compressed" horizontally
4197 * to fit the genlist scrollable viewport width. This is special for genlist.
4198 * Do not rely on elm_genlist_horizontal_mode_set() being set to
4199 * ELM_LIST_COMPRESS to work as genlist needs to handle it specially.
4201 * @param obj The genlist object
4202 * @param compress The compress mode
4203 * (EINA_TRUE = on, EINA_FALSE = off)
4208 elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress)
4210 ELM_CHECK_WIDTYPE(obj, widtype);
4211 Widget_Data *wd = elm_widget_data_get(obj);
4213 wd->compress = compress;
4217 * Get the compress mode
4219 * @param obj The genlist object
4220 * @return The compress mode
4221 * (EINA_TRUE = on, EINA_FALSE = off)
4226 elm_genlist_compress_mode_get(const Evas_Object *obj)
4228 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4229 Widget_Data *wd = elm_widget_data_get(obj);
4230 if (!wd) return EINA_FALSE;
4231 return wd->compress;
4237 * This will enable or disable the scroller bounce mode for the genlist. See
4238 * elm_scroller_bounce_set() for details
4240 * @param obj The genlist object
4241 * @param h_bounce Allow bounce horizontally
4242 * @param v_bounce Allow bounce vertically
4247 elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
4249 ELM_CHECK_WIDTYPE(obj, widtype);
4250 Widget_Data *wd = elm_widget_data_get(obj);
4252 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4256 * Get the bounce mode
4258 * @param obj The genlist object
4259 * @param h_bounce Allow bounce horizontally
4260 * @param v_bounce Allow bounce vertically
4265 elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
4267 ELM_CHECK_WIDTYPE(obj, widtype);
4268 Widget_Data *wd = elm_widget_data_get(obj);
4270 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4274 * Set homogenous mode
4276 * This will enable the homogeneous mode where items are of the same height and width
4277 * so that genlist may do the lazy-loading at its maximum. This implies 'compressed' mode
4279 * @param obj The genlist object
4280 * @param homogeneous Assume the items within the genlist are of the same height and width
4281 * (EINA_TRUE = on, EINA_FALSE = off)
4286 elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
4288 ELM_CHECK_WIDTYPE(obj, widtype);
4289 Widget_Data *wd = elm_widget_data_get(obj);
4291 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4292 wd->homogeneous = homogeneous;
4296 * Get the homogenous mode
4298 * @param obj The genlist object
4299 * @return Assume the items within the genlist are of the same height and width
4300 * (EINA_TRUE = on, EINA_FALSE = off)
4305 elm_genlist_homogeneous_get(const Evas_Object *obj)
4307 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4308 Widget_Data *wd = elm_widget_data_get(obj);
4309 if (!wd) return EINA_FALSE;
4310 return wd->homogeneous;
4314 * Set the maximum number of items within an item block
4316 * This will configure the block count to tune to the target with particular performance matrix.
4318 * @param obj The genlist object
4319 * @param n Maximum number of items within an item block
4324 elm_genlist_block_count_set(Evas_Object *obj, int n)
4326 ELM_CHECK_WIDTYPE(obj, widtype);
4327 Widget_Data *wd = elm_widget_data_get(obj);
4329 wd->max_items_per_block = n;
4333 * Get the maximum number of items within an item block
4335 * @param obj The genlist object
4336 * @return Maximum number of items within an item block
4341 elm_genlist_block_count_get(const Evas_Object *obj)
4343 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4344 Widget_Data *wd = elm_widget_data_get(obj);
4346 return wd->max_items_per_block;
4350 * Set the timeout in seconds for the longpress event
4352 * @param obj The genlist object
4353 * @param timeout timeout in seconds
4358 elm_genlist_longpress_timeout_set(Evas_Object *obj, double timeout)
4360 ELM_CHECK_WIDTYPE(obj, widtype);
4361 Widget_Data *wd = elm_widget_data_get(obj);
4363 wd->longpress_timeout = timeout;
4367 * Get the timeout in seconds for the longpress event
4369 * @param obj The genlist object
4370 * @return timeout in seconds
4375 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
4377 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4378 Widget_Data *wd = elm_widget_data_get(obj);
4380 return wd->longpress_timeout;
4384 * Set the scrollbar policy
4386 * This sets the scrollbar visibility policy for the given genlist scroller.
4387 * ELM_SMART_SCROLLER_POLICY_AUTO means the scrollber is made visible if it
4388 * is needed, and otherwise kept hidden. ELM_SMART_SCROLLER_POLICY_ON turns
4389 * it on all the time, and ELM_SMART_SCROLLER_POLICY_OFF always keeps it off.
4390 * This applies respectively for the horizontal and vertical scrollbars.
4392 * @param obj The genlist object
4393 * @param policy_h Horizontal scrollbar policy
4394 * @param policy_v Vertical scrollbar policy
4399 elm_genlist_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
4401 ELM_CHECK_WIDTYPE(obj, widtype);
4402 Widget_Data *wd = elm_widget_data_get(obj);
4404 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
4405 (policy_v >= ELM_SCROLLER_POLICY_LAST))
4408 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
4412 elm_genlist_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
4414 ELM_CHECK_WIDTYPE(obj, widtype);
4415 Widget_Data *wd = elm_widget_data_get(obj);
4416 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
4417 if ((!wd) || (!wd->scr)) return;
4418 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
4419 if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
4420 if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
4423 // added for item moving animation.
4425 _group_item_contract_moving_effect_timer_cb(void *data)
4427 Evas_Object *obj = (Evas_Object *)data;
4428 Widget_Data *wd = elm_widget_data_get(obj);
4430 Item_Block *itb = NULL;
4431 Elm_Genlist_GroupItem *git;
4432 Elm_Genlist_Item *it;
4434 int cnt = 0, git_count = 0;
4435 double added_gy = 1;
4437 int hide_git = 0, git_cnt = 0, list_start_y = 0;
4439 int *git_array = NULL;
4440 int base_git = 0, base_git_num = 0;
4441 int tmp_y = 0, devide_size = 1;
4444 Eina_Bool finish = EINA_FALSE;
4446 Evas_Coord ox, oy, ow, oh;
4448 return ECORE_CALLBACK_CANCEL;
4450 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4451 return ECORE_CALLBACK_CANCEL;
4453 git_array = (int*)malloc(sizeof(int) * wd->max_git_num);
4454 t = ecore_loop_time_get();
4456 if (t - wd->effect_start >= 5.0)
4459 if (wd->item_count < 100)
4460 devide_size = 8 * _elm_config->scale;
4461 else if (wd->item_count < 500)
4462 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4464 devide_size = 2 * _elm_config->scale;
4466 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4469 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4470 list_start_y += wd->select_all_item->h;
4472 EINA_INLIST_FOREACH(wd->group_items, git)
4474 git_array[git_cnt++] = git->y;
4475 if (git->y < list_start_y)
4477 edje_object_signal_emit(git->base, "elm,state,alpha,disable", "elm");
4479 base_git_num = hide_git;
4481 EINA_INLIST_FOREACH(wd->group_items, git)
4483 base_git = list_start_y + git->h * (git->num-1) + git->num;
4484 git->old_y = git->y;
4485 added_gy = abs(base_git - git->y) / devide_size;
4489 if (!git->down && git->old_y < list_start_y)
4491 git->finish_y = base_git;
4493 git->y = list_start_y - (git->h+1) * hide_git--;
4497 else if (!git->down && git->y < base_git)
4500 if (wd->pinch_zoom_reserve)
4507 if (git->y < base_git)
4510 if (git->y > base_git)
4516 if (git->y > base_git)
4519 if (git->y < base_git)
4523 if (git->num - 1 == cnt && git->y == base_git)
4526 evas_object_resize(git->base, wd->minw, git->h);
4527 evas_object_move(git->base, git->x, git->y);
4528 evas_object_raise(git->base);
4529 if (git->y < list_start_y)
4530 evas_object_lower(git->base);
4532 evas_object_raise(git->base);
4533 evas_object_show(git->base);
4535 EINA_INLIST_FOREACH(wd->blocks, itb)
4537 EINA_LIST_FOREACH(itb->items, l, it)
4539 if (it->group_item == git)
4541 if (it->group_item->old_y)
4542 it->old_scrl_y -= (it->group_item->old_y - it->group_item->y);
4544 if (git_array[it->group_item->num+1] <= it->old_scrl_y || added_gy == 1.0)
4546 evas_object_color_set(it->base, 0,0,0,0);
4547 evas_object_color_set(it->edit_obj, 0,0,0,0);
4549 _move_edit_controls(it,it->scrl_x, it->old_scrl_y);
4550 evas_object_resize(it->base, itb->wd->minw-(it->pad_left+it->pad_right), it->h);
4551 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4552 evas_object_raise(it->group_item->base);
4553 evas_object_show(it->base);
4557 if (git_count == git_cnt)
4562 if (wd->select_all_item) evas_object_raise(wd->select_all_item->base);
4567 if (finish) // finish animation
4570 EINA_INLIST_FOREACH(wd->group_items, git)
4574 wd->contract_pan_y = 0;
4575 wd->pinch_zoom_reserve = EINA_FALSE;
4576 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH;
4577 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
4578 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4580 // fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT FINISH \n");
4584 EINA_INLIST_FOREACH(wd->blocks, itb)
4586 if (itb->realized) {
4587 EINA_LIST_FOREACH(itb->items, l, it)
4590 it->scrl_y = oy + tmp_y;
4592 // need to handle edit mode
4593 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4594 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
4595 evas_object_color_set(it->base, 0,0,0,0);
4596 evas_object_show(it->base);
4602 evas_object_lower(wd->alpha_bg);
4603 evas_object_hide(wd->alpha_bg);
4605 return ECORE_CALLBACK_CANCEL;
4608 return ECORE_CALLBACK_RENEW;
4611 // added for item moving animation.
4613 _group_item_expand_moving_effect_timer_cb(void *data)
4615 Evas_Object *obj = (Evas_Object *)data;
4616 Widget_Data *wd = elm_widget_data_get(obj);
4617 Elm_Genlist_GroupItem *git, *tmp_git;
4618 Item_Block *itb = NULL;
4619 Elm_Genlist_Item *it;
4621 int cnt = 0, git_count = 0, git_cnt = 0, git_tmp_y = 0, in = 0, start_in = 0;
4622 int tmp = 0, show_git_cnt = 0, scroll_y = 0, top_git = 0 , git_h = 0, scroll_pan_y = 0, down = 0;
4623 int up_cnt = 1, down_cnt = 1, it_h = 0, devide_size = 1;
4624 static int last_git_y = 0;
4628 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4630 static double added_gy = 0; // temp value for animation speed
4631 static double added_gy2 = 0;
4632 Eina_Bool finish = EINA_FALSE;
4634 return ECORE_CALLBACK_CANCEL;
4636 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4637 return ECORE_CALLBACK_CANCEL;
4639 t = ecore_loop_time_get();
4641 top_git = wd->pinch_it;
4645 else if (top_git >= wd->max_git_num)
4646 top_git = wd->max_git_num - 1;
4648 if (wd->item_count < 100)
4649 devide_size = 8 * _elm_config->scale;
4650 else if (wd->item_count < 500)
4651 devide_size = (8 - (devide_size / 100)) * _elm_config->scale;
4653 devide_size = 2 * _elm_config->scale;
4655 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4656 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4657 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
4658 oy += wd->select_all_item->h;
4659 // calculate git count and srcroll move position
4660 EINA_INLIST_FOREACH(wd->group_items, git)
4662 if (git_cnt == top_git - 1)
4667 EINA_INLIST_FOREACH(wd->blocks, itb)
4669 EINA_LIST_FOREACH(itb->items, l, it)
4671 if (it->group_item == git)
4681 scroll_pan_y = scroll_y + git_h * (top_git-1) ;
4683 if (t - wd->effect_start >= 5.0)
4687 EINA_INLIST_FOREACH(wd->blocks, itb)
4689 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4690 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4695 EINA_LIST_FOREACH(itb->items, l, it)
4697 _item_realize(it, start_in, 0);
4698 it->realized = EINA_TRUE;
4701 itb->realized = EINA_TRUE;
4702 itb->want_unrealize = EINA_FALSE;
4708 if (itb->realized) _item_block_unrealize(itb);
4713 // set group item finish y and items y position of group item and items.
4716 EINA_INLIST_FOREACH(wd->group_items, git)
4718 if (git->num >= top_git)
4720 git->finish_y = git_tmp_y;
4721 git_tmp_y += git->h;
4722 tmp = git->y + git->h;
4726 git->finish_y = -1 * oh;
4728 EINA_INLIST_FOREACH(wd->blocks, itb)
4730 EINA_LIST_FOREACH(itb->items, l, it)
4732 if (it->group_item == git)
4734 if (git->finish_y != -1 * oh)
4736 it->old_scrl_y = tmp;
4738 added_gy2 = abs(git->finish_y - git->y) / devide_size;
4739 tmp += it->h - added_gy2;
4742 it->old_scrl_y = -1 * oh;
4747 if (git->finish_y >= oy && git->finish_y < oy+oh)
4751 EINA_INLIST_FOREACH(wd->group_items, git)
4755 evas_object_move(git->base, git->x, git->y);
4758 evas_object_raise(git->base);
4759 evas_object_show(git->base);
4763 evas_object_lower(git->base);
4764 evas_object_hide(git->base);
4767 added_gy = abs(git->finish_y - git->y) / devide_size;
4768 if (added_gy < 1.0) added_gy = 1.0;
4769 if (git->y > git->finish_y)
4773 if (git->num >= top_git)
4777 else if (git->y < git->finish_y)
4784 if ((!down && git->y < git->finish_y) || (down && git->y > git->finish_y))
4785 git->y = git->finish_y;
4787 if (git_cnt-1 == cnt)
4788 last_git_y = git->y;
4790 if (git->num == top_git && git->y == oy)
4792 evas_object_move(git->base, git->x, git->y);
4793 evas_object_show(git->base);
4795 EINA_INLIST_FOREACH(wd->group_items, tmp_git)
4797 if (tmp_git->y == tmp_git->finish_y && tmp_git->y > oy && tmp_git->y < oy+oh)
4804 EINA_INLIST_FOREACH(wd->blocks, itb)
4806 EINA_LIST_FOREACH(itb->items, l, it)
4808 if (it->group_item == git)
4811 if ((itb->y + itb->h >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh)
4812 || (itb->y >= scroll_pan_y - oh && itb->y <= scroll_pan_y + oh))
4814 evas_object_resize(it->base, wd->minw-(it->pad_left+it->pad_right), it->h);
4815 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
4816 _move_edit_controls(it, it->scrl_x, it->old_scrl_y);
4817 evas_object_color_set(it->edit_obj, 255,255,255,255);
4818 evas_object_color_set(it->base, 255,255,255,255);
4819 evas_object_raise(it->base);
4820 evas_object_raise(it->group_item->base);
4828 if (git_count + 1 == show_git_cnt)
4837 wd->pan_y = scroll_y + (git_h) * (top_git-1) ;
4839 EINA_INLIST_FOREACH(wd->group_items, git)
4841 edje_object_signal_emit(git->base, "elm,state,alpha,enable", "elm");
4843 EINA_INLIST_FOREACH(wd->blocks, itb)
4845 EINA_LIST_FOREACH(itb->items, l, it)
4850 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE;
4851 fprintf(stderr,"ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND FINISH \n");
4852 elm_smart_scroller_hold_set(wd->scr, 0);
4853 elm_smart_scroller_freeze_set(wd->scr, 0);
4854 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
4855 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_TRUE);
4856 // printf("_group_item_expand_moving_effect_timer_cb FINISH \n");
4857 evas_object_lower(wd->alpha_bg);
4858 evas_object_hide(wd->alpha_bg);
4859 // evas_object_smart_changed(wd->pan_smart);
4860 if (wd->calc_job) ecore_job_del(wd->calc_job);
4861 wd->calc_job = ecore_job_add(_calc_job, wd);
4863 return ECORE_CALLBACK_CANCEL;
4866 return ECORE_CALLBACK_RENEW;
4870 _item_pinch_recalc(Evas_Object *obj, int emode)
4872 Item_Block *itb = NULL;
4874 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
4875 Widget_Data *wd = elm_widget_data_get(obj);
4877 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND)
4880 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4881 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
4885 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_NONE)
4887 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT;
4889 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 1);
4890 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, EINA_FALSE);
4891 evas_object_raise(wd->alpha_bg);
4892 evas_object_show(wd->alpha_bg);
4894 wd->effect_start = ecore_loop_time_get();
4895 wd->item_moving_effect_timer = ecore_animator_add(_group_item_contract_moving_effect_timer_cb, obj);
4898 else if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4900 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 1);
4902 evas_object_raise(wd->alpha_bg);
4903 evas_object_show(wd->alpha_bg);
4905 wd->pinchzoom_effect_mode = ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_EXPAND;
4906 EINA_INLIST_FOREACH(wd->blocks, itb)
4908 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
4909 itb->y - wd->pan_y + oy,
4911 cvx, cvy, cvw, cvh))
4913 if (itb->realized) _item_block_unrealize(itb);
4914 itb->realized = EINA_FALSE;
4918 wd->effect_start = ecore_loop_time_get();
4919 wd->item_moving_effect_timer = ecore_animator_add(_group_item_expand_moving_effect_timer_cb, obj);
4926 create_tray_alpha_bg(const Evas_Object *obj)
4928 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4929 Widget_Data *wd = elm_widget_data_get(obj);
4930 if (!wd) return NULL;
4932 Evas_Object *bg = NULL;
4933 Evas_Coord ox, oy, ow, oh;
4935 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4936 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
4937 evas_object_color_set(bg , 0,0,0,0);
4938 evas_object_resize(bg , ow, oh);
4939 evas_object_move(bg , ox, oy);
4940 evas_object_show(bg);
4941 evas_object_hide(bg);
4946 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
4948 ELM_CHECK_WIDTYPE(obj, widtype);
4949 Widget_Data *wd = elm_widget_data_get(obj);
4950 if (!wd || !wd->pinch_zoom) return;
4951 if (!wd->queue_idler)
4954 wd->alpha_bg = create_tray_alpha_bg(obj);
4955 _item_pinch_recalc(obj, emode);
4960 * Set pinch zoom mode
4962 * @param obj The genlist object
4964 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4969 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
4971 ELM_CHECK_WIDTYPE(obj, widtype);
4972 Widget_Data *wd = elm_widget_data_get(obj);
4973 if (!wd || !wd->pinch_zoom) return;
4974 wd->pinch_zoom_reserve = emode;
4978 * Get pinch zoom mode
4980 * @param obj The genlist object
4981 * @return The pinch mode
4982 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
4987 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
4989 Widget_Data *wd = elm_widget_data_get(obj);
4990 if (!wd) return EINA_FALSE;
4991 if (wd->pinchzoom_effect_mode == ELM_GENLIST_ITEM_PINCHZOOM_EFFECT_CONTRACT_FINISH)
4993 else return EINA_FALSE;
4997 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
4999 Widget_Data *wd = elm_widget_data_get(obj);
5001 wd->pinch_zoom = emode;
5004 // added for item moving animation.
5006 _item_moving_effect_timer_cb(void *data)
5008 Widget_Data *wd = data;
5010 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5011 Elm_Genlist_Item *it;
5013 int expanded_cnt = 0;
5015 static double added_gy =25;
5016 static int count = 0;
5017 if (!wd) return EINA_FALSE;
5018 if (added_gy < 1) added_gy = 1;
5021 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5022 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5024 EINA_INLIST_FOREACH(wd->blocks, itb)
5027 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5028 itb->y - wd->pan_y + oy,
5030 cvx, cvy, cvw, cvh))
5032 EINA_LIST_FOREACH(itb->items, l, it)
5034 if (!it->old_scrl_y)
5035 it->old_scrl_y = it->scrl_y;
5036 if (it->parent && it->parent->expanded && !it->showme)
5038 evas_object_hide(it->base);
5040 else evas_object_show(it->base);
5042 evas_object_show(it->base);
5044 if (itb && itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5046 if (it->old_scrl_y && it->old_scrl_y < it->scrl_y) {
5047 it->old_scrl_y += added_gy;
5049 if (it->old_scrl_y >= it->scrl_y) {
5050 it->list_expanded = 1;
5051 it->old_scrl_y = it->scrl_y;
5054 else if (itb->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5056 if (it->old_scrl_y && it->old_scrl_y > it->scrl_y)
5059 it->old_scrl_y -= added_gy;
5062 if (it->old_scrl_y <= it->scrl_y) {
5063 it->list_expanded = 1;
5064 it->old_scrl_y = it->scrl_y;
5067 expanded_cnt += it->list_expanded;
5070 _move_edit_controls(it,it->scrl_x, it->scrl_y);
5071 evas_object_resize(it->base, it->w-(it->pad_left+it->pad_right), it->h);
5072 evas_object_move(it->base, it->scrl_x+it->pad_left, it->old_scrl_y);
5073 evas_object_raise(it->base);
5077 if (expanded_cnt == cnt)
5079 if (wd->item_moving_effect_timer)
5083 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5084 EINA_INLIST_FOREACH(wd->blocks, itb)
5086 EINA_LIST_FOREACH(itb->items, l, it)
5088 it->list_expanded = 0;
5093 return ECORE_CALLBACK_CANCEL;
5095 return ECORE_CALLBACK_RENEW;
5098 // added for edit mode item moving animation.
5100 _edit_mode_item_moving_effect_cb(void *data)
5102 Widget_Data *wd = data;
5104 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5105 Elm_Genlist_Item *it, *select_all_item;
5107 int expanded_cnt = 0;
5108 static double added_gy = 9;
5109 static float count = 0;
5111 static float select_all_y = 0;
5113 if (!wd) return EINA_FALSE;
5116 if (!wd->select_all_item)
5117 return ECORE_CALLBACK_CANCEL;
5119 static float dy = 9;
5124 select_all_y += (dy);
5126 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5127 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5129 EINA_INLIST_FOREACH(wd->blocks, itb)
5132 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5133 itb->y - wd->pan_y + oy,
5135 cvx, cvy, cvw, cvh))
5138 EINA_LIST_FOREACH(itb->items, l, it)
5141 evas_object_show(it->base);
5142 if (it->old_pad_left < it->pad_left)
5144 it->old_pad_left += dy;
5145 if (it->old_pad_left >= it->pad_left)
5147 it->list_expanded = 1;
5148 it->old_pad_left = it->pad_left;
5151 if (it->old_pad_left > it->pad_left)
5153 it->old_pad_left -= dy;
5154 if (it->old_pad_left <= it->pad_left)
5156 it->list_expanded = 1;
5157 it->old_pad_left = it->pad_left;
5161 if (it->old_scrl_y < it->scrl_y)
5163 it->old_scrl_y += (dy) ;
5164 if (it->old_scrl_y >= it->scrl_y)
5166 it->list_expanded = 1;
5167 it->old_scrl_y = it->scrl_y;
5171 if (it->old_scrl_y > it->scrl_y)
5173 it->old_scrl_y -= (dy);
5174 if (it->old_scrl_y <= it->scrl_y)
5176 it->list_expanded = 1;
5177 it->old_scrl_y = it->scrl_y;
5182 select_all_item = itb->wd->select_all_item;
5183 evas_object_resize(select_all_item->base, itb->w, select_all_item->h);
5184 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5185 evas_object_move(select_all_item->base, ox, oy - select_all_y);
5186 else if (select_all_y <= select_all_item->h)
5187 evas_object_move(select_all_item->base, ox, oy - select_all_item->h + select_all_y);
5188 evas_object_raise(select_all_item->base);
5189 evas_object_show(select_all_item->base);
5191 expanded_cnt += it->list_expanded;
5193 evas_object_move(it->base, it->scrl_x+it->old_pad_left, it->old_scrl_y);
5194 evas_object_move(it->edit_obj, it->scrl_x, it->old_scrl_y);
5195 evas_object_raise(it->edit_obj);
5196 evas_object_raise(it->base);
5198 evas_object_show(it->edit_obj);
5199 evas_object_show(it->base);
5201 if (select_all_y >= wd->select_all_item->h && it->list_expanded == 1)
5204 evas_object_raise(it->edit_obj);
5213 if (wd->item_moving_effect_timer)
5219 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5220 EINA_INLIST_FOREACH(wd->blocks, itb)
5222 EINA_LIST_FOREACH(itb->items, l, it)
5224 it->list_expanded = 0;
5227 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5229 if (wd->select_all_item)
5231 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
5232 free(wd->select_all_item);
5234 wd->select_all_item = NULL;
5237 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5238 wd->effect_mode = 0;
5240 if (wd->calc_job) ecore_job_del(wd->calc_job);
5241 wd->calc_job = ecore_job_add(_calc_job, wd);
5242 return ECORE_CALLBACK_CANCEL;
5244 return ECORE_CALLBACK_RENEW;
5248 // added for item moving animation.
5250 _item_flip_effect_show(void *data)
5252 Widget_Data *wd = data;
5254 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5256 if (!wd) return EINA_FALSE;
5258 Elm_Genlist_Item *it;
5261 int start = 0, end = 0;
5263 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5264 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5266 EINA_INLIST_FOREACH(wd->blocks, itb)
5269 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5270 itb->y - wd->pan_y + oy,
5272 cvx, cvy, cvw, cvh))
5274 EINA_LIST_FOREACH(itb->items, l, it)
5276 if (it->parent && it->wd->expand_item == it->parent && !it->effect_done)
5278 if (!start) start = it->scrl_y;
5279 base = (Evas_Object *) it->base;
5280 edje_object_signal_emit(it->base, "flip_item", "");
5281 end = it->scrl_y + it->h;
5282 it->effect_done = EINA_TRUE;
5287 wd->expand_item_cnt = end - start;
5288 return ECORE_CALLBACK_CANCEL;
5292 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5294 ELM_CHECK_WIDTYPE(obj, widtype);
5295 Widget_Data *wd = elm_widget_data_get(obj);
5297 wd->effect_mode = emode;
5298 wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5299 evas_object_resize(wd->point_rect, 10, 25);
5300 evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5301 evas_object_show(wd->point_rect);
5302 evas_object_hide(wd->point_rect);
5307 elm_genlist_edit_mode_effect_set(const Evas_Object *obj, Eina_Bool emode)
5309 ELM_CHECK_WIDTYPE(obj, widtype);
5310 Widget_Data *wd = elm_widget_data_get(obj);
5312 wd->edit_mode_effect_mode = emode;
5317 elm_genlist_queue_exception_set(const Evas_Object *obj, Eina_Bool emode)
5319 ELM_CHECK_WIDTYPE(obj, widtype);
5320 Widget_Data *wd = elm_widget_data_get(obj);
5322 wd->queue_exception = emode;
5324 fprintf(stderr, "=================> Caution!!! <========================\n");
5325 fprintf(stderr, "==> elm_genlist_queue_exception_set() is for demo. <===\n");
5326 fprintf(stderr, "==> Do not use this API <==\n");
5327 fprintf(stderr, "=======================================================\n");
5331 _delete_confirm_cb(void *data, Evas_Object *obj, void *event_info)
5333 Widget_Data *wd = data;
5334 evas_object_hide(wd->ed->del_confirm);
5335 if (wd->ed->ec && wd->ed->ec->remove)
5336 wd->ed->ec->remove(wd->obj, wd->ed->del_item);
5337 wd->ed->del_item = NULL;
5341 _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission, const char *source)
5343 const char *del_icon_part;
5344 Elm_Genlist_Item *it = data;
5345 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5347 edje_object_part_unswallow(it->edit_obj, it->wd->ed->del_confirm);
5348 evas_object_hide(it->wd->ed->del_confirm);
5352 _edit_item_check_set(Elm_Genlist_Item *it, Eina_Bool del_confirm_state)
5354 if (del_confirm_state)
5356 it->del_confirm_state = 0;
5357 it->delete_check = 0;
5358 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5359 it->wd->selct_all = 0;
5360 if (elm_genlist_item_parent_get(it))
5361 edje_object_signal_emit(elm_genlist_item_parent_get(it)->edit_obj, "elm,state,del,animated,enable", "elm");
5362 if (it->wd->select_all_item)
5363 edje_object_signal_emit(it->wd->select_all_item->base, "elm,state,del,animated,enable", "elm");
5364 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5365 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5369 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5370 it->del_confirm_state = 1;
5371 it->delete_check = 1;
5376 _edit_subitems_check(Elm_Genlist_Item *it)
5379 Eina_List *tl = NULL, *l;
5380 Elm_Genlist_Item *it2;
5382 EINA_LIST_FOREACH(it->items, l, it2)
5383 tl = eina_list_append(tl, it2);
5384 EINA_LIST_FREE(tl, it2)
5385 _edit_item_check_set(it2, !elm_genlist_item_parent_get(it2)->del_confirm_state);
5389 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5391 const char *del_conf_style;
5392 Elm_Genlist_Item *it = data;
5393 if (_edit_mode_reset(it->wd))
5396 if (it->edit_long_timer)
5398 ecore_timer_del(it->edit_long_timer);
5399 it->edit_long_timer = NULL;
5401 _edit_item_check_set(it, it->del_confirm_state);
5402 _edit_subitems_check(it);
5403 it->wd->ed->del_item = it;
5405 if (!it->wd->selct_all && it->wd->ed->ec->item_selected)
5406 it->wd->ed->ec->item_selected(it->data, it, it->delete_check);
5407 del_conf_style = edje_object_data_get(it->edit_obj, "del_button_style");
5409 elm_object_style_set(it->wd->ed->del_confirm, del_conf_style);
5412 del_icon_part = edje_object_data_get(it->edit_obj, "del_confirm");
5414 edje_object_part_swallow(it->edit_obj, del_icon_part, it->wd->ed->del_confirm);
5415 evas_object_show(it->wd->ed->del_confirm);
5420 _insert_new_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5422 Elm_Genlist_Item *it = data;
5424 if (_edit_mode_reset(it->wd))
5427 if (it->wd->ed->ec && it->wd->ed->ec->insert_new)
5428 it->wd->ed->ec->insert_new(it->wd->obj, it);
5432 _edit_mode_reset(Widget_Data *wd)
5435 if (wd->ed->del_confirm_state)
5437 //edje_object_signal_emit(wd->ed->del_item->edit_obj, "elm,state,delete", "elm");
5438 //wd->ed->del_confirm_state = 0;
5439 //wd->ed->del_item = NULL;
5447 _reorder_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5449 Elm_Genlist_Item *it = data;
5450 Evas_Event_Mouse_Down *ev = event_info;
5453 if (it->wd->edit_field && !it->renamed)
5454 elm_genlist_item_rename_mode_set(it, 0);
5456 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
5459 if (_edit_mode_reset(it->wd))
5464 it->reoder_cavas_x = ev->canvas.x;
5465 it->reoder_cavas_y = ev->canvas.y;
5467 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5468 it->dx = ev->canvas.x - x;
5469 it->dy = ev->canvas.y - y;
5471 if (it->edit_long_timer)
5473 ecore_timer_del(it->edit_long_timer);
5474 it->edit_long_timer = NULL;
5477 it->edit_long_timer = ecore_timer_add(0.3,_edit_long_press, it);
5479 it->edit_long_timer = NULL;
5483 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5485 Elm_Genlist_Item *it = data;
5488 EINA_INLIST_FOREACH(it->wd->blocks, itb)
5492 if (it->edit_long_timer)
5494 ecore_timer_del(it->edit_long_timer);
5495 it->edit_long_timer = NULL;
5499 it->wd->reoder_moved = EINA_FALSE;
5501 if (it->wd->ed->ec->selected)
5502 it->wd->ed->ec->selected(NULL, it, 1);
5504 if (it->reordering && it->wd->ed->reorder_item)
5506 it->wd->ed->reorder_item->reordering = 0;
5507 edje_object_signal_emit(it->wd->ed->reorder_item->edit_obj, "elm,action,item,reorder_end", "elm");
5508 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
5510 if ((!it->wd->ed->reorder_rel) || (!it->wd->ed->ec->move) ||
5511 (!it->wd->ed->ec->move(it->wd->obj, it->wd->ed->reorder_item, it->wd->ed->reorder_rel, EINA_TRUE)))
5513 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);
5514 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, it->wd->ed->reorder_item->scrl_y);
5516 it->wd->ed->reorder_item = NULL;
5517 it->wd->ed->reorder_rel = NULL;
5523 _reorder_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
5525 Elm_Genlist_Item *it = data;
5526 Evas_Event_Mouse_Move *ev = event_info;
5528 if ((it->dragging) && (it->down))
5530 if (it->edit_long_timer)
5532 ecore_timer_del(it->edit_long_timer);
5533 it->edit_long_timer = NULL;
5536 evas_object_smart_callback_call(it->wd->obj, "drag", it);
5540 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
5542 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
5543 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
5544 x = ev->cur.canvas.x - x;
5545 y = ev->cur.canvas.y - y;
5548 if (adx < 0) adx = -dx;
5551 if (ady < 0) ady = -dy;
5554 if ((adx > minw) || (ady > minh))
5557 if (it->edit_long_timer)
5559 ecore_timer_del(it->edit_long_timer);
5560 it->edit_long_timer = NULL;
5564 if (it->reordering && it->wd->ed->reorder_item)
5566 int y = ev->cur.canvas.y - it->wd->ed->reorder_item->dy;
5567 evas_object_raise(it->wd->ed->reorder_item->base);
5568 evas_object_move(it->wd->ed->reorder_item->base, it->wd->ed->reorder_item->scrl_x+it->pad_left, y);
5569 evas_object_show(it->wd->ed->reorder_item->base);
5570 _move_edit_controls(it,it->wd->ed->reorder_item->scrl_x, y);
5572 it->block->updateme = EINA_TRUE;
5574 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
5575 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
5582 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5585 Elm_Genlist_Item *select_all_it = data, *it;
5587 Widget_Data *wd = select_all_it->wd;
5591 edje_object_signal_emit(select_all_it->base, "elm,state,del_confirm", "elm");
5593 edje_object_signal_emit(select_all_it->base, "elm,state,del,animated,enable", "elm");
5595 EINA_INLIST_FOREACH(wd->blocks, itb)
5597 EINA_LIST_FOREACH(itb->items, l, it)
5601 it->delete_check = 1;
5602 it->del_confirm_state = 1;
5603 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5607 it->delete_check = 0;
5608 it->del_confirm_state = 0;
5609 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5613 wd->selct_all ^= 0xFF;
5615 if (wd->ed->ec->item_selected)
5616 wd->ed->ec->item_selected(select_all_it->data, select_all_it, wd->selct_all);
5617 if (wd->calc_job) ecore_job_del(wd->calc_job);
5618 wd->calc_job = ecore_job_add(_calc_job, wd);
5622 _move_edit_controls(Elm_Genlist_Item *it, int itx, int ity)
5624 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5626 evas_object_resize(it->edit_obj,it->w, it->h);
5627 evas_object_move(it->edit_obj, itx, ity);
5628 evas_object_raise(it->edit_obj);
5632 _edit_controls_eval(Elm_Genlist_Item *it)
5635 const char *pad_str;
5642 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj)
5645 if (it->itc->func.editmode_get)
5646 itmode = it->itc->func.editmode_get(it->data, it->wd->obj, it->wd->edit_mode);
5647 itmode &= it->wd->edit_mode;
5649 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5650 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5654 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
5655 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
5656 _elm_config->scale);
5657 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5658 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
5659 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5660 else strncpy(buf, "item", sizeof(buf));
5661 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5662 // if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
5663 strncat(buf, "/", sizeof(buf) - strlen(buf));
5665 if (it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5667 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5668 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
5672 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
5675 // edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
5676 // "elm", _edit_mode_reset, it);
5679 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
5680 if (pad_str) pad = atoi(pad_str);
5682 if ((itmode & ELM_GENLIST_EDIT_MODE_INSERT))
5684 if (it->wd->animate_edit_controls)
5685 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,enable", "elm");
5687 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
5689 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,insert",
5690 "elm", _insert_new_item_cb, it);
5691 it->pad_left += pad * _elm_config->scale;
5695 if (it->wd->animate_edit_controls)
5696 edje_object_signal_emit(it->edit_obj, "elm,state,ins,animated,disable", "elm");
5698 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
5700 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,insert",
5701 "elm", _insert_new_item_cb);
5704 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
5706 if (it->wd->animate_edit_controls)
5707 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5709 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5711 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5712 "elm", _remove_item_cb);
5713 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5714 "elm", _hide_delete_confirm_object);
5716 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
5717 "elm", _remove_item_cb, it);
5719 edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
5720 "elm", _hide_delete_confirm_object, it);
5721 it->pad_left += pad * _elm_config->scale;
5722 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5723 _reorder_mouse_down, it);
5727 if (it->wd->animate_edit_controls)
5728 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,disable", "elm");
5730 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
5732 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5733 "elm", _remove_item_cb);
5734 edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
5735 "elm", _hide_delete_confirm_object);
5736 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5737 _reorder_mouse_down);
5740 if ((itmode & ELM_GENLIST_EDIT_MODE_REORDER))
5742 const char* reorder_part;
5744 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5745 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5747 edje_object_part_object_get(it->edit_obj, reorder_part);
5749 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5750 _reorder_mouse_down);
5751 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5753 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5754 _reorder_mouse_move);
5756 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5757 _reorder_mouse_down, it);
5758 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5759 _reorder_mouse_up, it);
5760 evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5761 _reorder_mouse_move, it);
5763 // it->pad_right += pad * _elm_config->scale;
5767 const char* reorder_part;
5769 reorder_part = edje_object_data_get(it->edit_obj, "reorder");
5770 if (reorder_part && edje_object_part_exists(it->edit_obj, reorder_part))
5773 if (itmode == ELM_GENLIST_EDIT_MODE_NONE)
5775 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
5776 _reorder_mouse_down);
5777 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
5779 evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
5780 _reorder_mouse_move);
5785 if (it->wd->edit_mode != 0xF0) {
5786 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
5788 if (it->itc->func.icon_get)
5790 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
5795 it->icons = _elm_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
5796 EINA_LIST_FOREACH(it->icons, l, key)
5798 Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
5802 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5803 edje_object_part_swallow(it->edit_obj, key, ic);
5804 evas_object_show(ic);
5805 // elm_widget_sub_object_add(it->wd->obj, ic);
5812 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5813 EINA_LIST_FREE(it->edit_icon_objs, icon)
5814 evas_object_del(icon);
5816 Evas_Object *editfield;
5817 EINA_LIST_FREE(it->wd->edit_field, editfield)
5818 evas_object_del(editfield);
5822 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)//Unrealize
5824 evas_object_del(it->edit_obj);
5825 it->edit_obj = NULL;
5828 _move_edit_controls(it,it->scrl_x, it->scrl_y);
5829 evas_object_show(it->edit_obj);
5833 _notify_item_position(Elm_Genlist_Item *it)
5838 l = eina_list_last(it->parent->items);
5840 //Check if the Item is First Node or Last node of its Parent & raise signal.
5841 if (it->parent->items->data != it && l->data != it)
5843 edje_object_signal_emit(it->base, "normal_item", "elm");
5847 if (it->parent->items->data == it)
5848 edje_object_signal_emit(it->base, "first_item", "elm");
5851 edje_object_signal_emit(it->base, "last_item", "elm");
5857 _get_space_for_reorder_item(Elm_Genlist_Item *it)
5860 Evas_Coord rox, roy, row, roh;
5861 if (!it->wd->ed) return 0;
5862 if (!(it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) || !it->wd->ed->reorder_item)
5864 evas_object_geometry_get(it->wd->ed->reorder_item->base, &rox, &roy, &row, &roh);
5865 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
5866 rox, roy+roh/2, row, 1));
5869 it->wd->ed->reorder_rel = it;
5870 it->scrl_y+=it->wd->ed->reorder_item->h;
5871 it->reorder_check = 1;
5872 return it->wd->ed->reorder_item->h;
5878 * Add Group Item to the genlist
5880 * @param obj The genlist object
5881 * @param itc The item class for the item
5882 * @param data The group item data
5884 EAPI Elm_Genlist_GroupItem *
5885 elm_genlist_groupitem_add(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
5888 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5889 Elm_Genlist_GroupItem *git;
5890 Widget_Data *wd = elm_widget_data_get(obj);
5892 git = calloc(1, sizeof(Elm_Genlist_GroupItem));
5893 if (!git) return NULL;
5898 wd->group_items = eina_inlist_append(wd->group_items, EINA_INLIST_GET(git));
5903 * Delete a given groupitem
5905 * This deletes the group item from genlist and calls the genlist group item del class
5906 * callback defined in the item class, if it is set.
5908 * @param git The group item
5913 elm_genlist_groupitem_del(Elm_Genlist_GroupItem *git)
5915 _groupitem_remove(git, EINA_TRUE);
5919 * Append item to the end of the genlist with Group Item
5921 * This appends the given item to the end of the list or the end of the
5922 * children if the parent is given.
5924 * @param obj The genlist object
5925 * @param itc The item class for the item
5926 * @param data The item data
5927 * @param parent The parent item, or NULL if none
5928 * @param flags Item flags
5929 * @param git Group Item
5930 * @param func Convenience function called when item selected
5931 * @param func_data Data passed to @p func above.
5932 * @return A handle to the item added or NULL if not possible
5936 EAPI Elm_Genlist_Item *
5937 elm_genlist_item_append_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
5938 const void *data, Elm_Genlist_Item *parent,
5939 Elm_Genlist_Item_Flags flags, Elm_Genlist_GroupItem *git,
5940 Evas_Smart_Cb func, const void *func_data)
5942 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5943 Widget_Data *wd = elm_widget_data_get(obj);
5945 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
5946 Elm_Genlist_GroupItem *pgit = NULL;
5947 Elm_Genlist_Item *it2 = NULL;
5948 Eina_List *ll = NULL;
5949 if (!wd) return NULL;
5950 if (!it) return NULL;
5951 if (!git) return NULL;
5956 ll = eina_list_last(pgit->items);
5962 if (!(EINA_INLIST_GET(pgit)->prev)) break;
5963 pgit = (Elm_Genlist_GroupItem *)(EINA_INLIST_GET(pgit)->prev);
5968 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
5969 EINA_INLIST_GET(it2));
5971 it->rel->relcount++;
5975 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
5978 git->items = eina_list_append(git->items, it);
5980 it->group_item = git;
5981 _item_queue(wd, it);
5986 * Prepend item at start of the genlist with Group Item
5988 * This adds the given item to the beginning of the list or beginning of the
5989 * children if the parent is given.
5991 * @param obj The genlist object
5992 * @param itc The item class for the item
5993 * @param data The item data
5994 * @param parent The parent item, or NULL if none
5995 * @param flags Item flags
5996 * @param git Group Item
5997 * @param func Convenience function called when item selected
5998 * @param func_data Data passed to @p func above.
5999 * @return A handle to the item added or NULL if not possible
6003 EAPI Elm_Genlist_Item *
6004 elm_genlist_item_prepend_with_group(Evas_Object *obj, const Elm_Genlist_Item_Class *itc,
6005 const void *data, Elm_Genlist_Item *parent,
6006 Elm_Genlist_Item_Flags flags, Elm_Genlist_GroupItem *git,
6007 Evas_Smart_Cb func, const void *func_data)
6009 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6010 Widget_Data *wd = elm_widget_data_get(obj);
6012 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, func_data);
6013 Elm_Genlist_GroupItem *pgit = NULL;
6014 Elm_Genlist_Item *it2 = NULL;
6015 Eina_List *ll = NULL;
6016 Eina_Bool new_group = EINA_FALSE;
6017 if (!wd) return NULL;
6018 if (!it) return NULL;
6019 if (!git) return NULL;
6025 ll = eina_list_last(pgit->items);
6034 if (!(EINA_INLIST_GET(pgit)->prev)) break;
6035 pgit = (Elm_Genlist_GroupItem *)(EINA_INLIST_GET(pgit)->prev);
6036 new_group = EINA_TRUE;
6042 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
6043 EINA_INLIST_GET(it2));
6046 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
6047 EINA_INLIST_GET(it2));
6049 it->rel->relcount++;
6053 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
6056 git->items = eina_list_prepend(git->items, it);
6062 it->group_item = git;
6063 _item_queue(wd, it);
6068 * Moves the Genlist Item
6071 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
6075 Elm_Genlist_Item *next_item = elm_genlist_item_next_get(after);
6077 if (it->y == after->y && after->reorder_check && it->reorder_check)
6079 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
6080 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
6084 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
6085 _item_block_del(it);
6087 if ((!next_item && after->reorder_check) || (next_item && !after->reorder_check))
6090 if (next_item && !after->reorder_check && it == after)
6092 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
6093 EINA_INLIST_GET(next_item));
6094 it->rel = next_item;
6098 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it),
6099 EINA_INLIST_GET(after));
6103 it->rel->relcount++;
6110 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it),
6111 EINA_INLIST_GET(after));
6113 it->rel->relcount++;
6117 it->wd->items = eina_inlist_prepend(it->wd->items, EINA_INLIST_GET(it));
6121 after->reorder_check = 0;
6122 _item_queue(it->wd, it);
6126 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6128 fprintf(stderr, "=================> Caution!!! <========================\n");
6129 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6130 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6131 fprintf(stderr, "=======================================================\n");
6133 elm_genlist_edit_mode_set(obj, emode, edit_class);
6137 * Set Genlist edit mode
6139 * This sets Genlist edit mode.
6141 * @param obj The Genlist object
6142 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6143 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6148 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6150 Elm_Genlist_Item *it;
6154 static Elm_Genlist_Item_Class itc;
6156 ELM_CHECK_WIDTYPE(obj, widtype);
6157 Widget_Data *wd = elm_widget_data_get(obj);
6159 if (wd->edit_mode == emode) return;
6161 wd->edit_mode = emode;
6162 wd->animate_edit_controls = 1;
6164 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6165 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6167 if (wd->edit_mode_effect_mode)
6169 wd->effect_mode = EINA_TRUE;
6170 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE;
6173 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6175 if (wd->ed) free (wd->ed);
6181 wd->ed = calloc(1, sizeof(Edit_Data));
6183 wd->ed->ec = edit_class;
6185 if (((wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)) && !wd->ed->del_confirm)
6187 wd->ed->del_confirm = elm_button_add(wd->obj);
6188 elm_button_label_set(wd->ed->del_confirm, "Delete");
6189 evas_object_smart_member_add(wd->ed->del_confirm, wd->pan_smart);
6190 edje_object_scale_set(wd->ed->del_confirm, elm_widget_scale_get(wd->ed->del_confirm) *
6191 _elm_config->scale);
6192 evas_object_smart_callback_add(wd->ed->del_confirm, "clicked", _delete_confirm_cb, wd);
6195 EINA_INLIST_FOREACH(wd->blocks, itb)
6197 EINA_LIST_FOREACH(itb->items, l, it)
6199 it->delete_check = 0;
6200 it->del_confirm_state = 0;
6202 _edit_controls_eval(it);
6205 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6207 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6208 itc.item_style = edit_class->select_all_item_style;
6210 itc.item_style = "select_all";
6211 itc.func.label_get = NULL;
6212 itc.func.icon_get = NULL;
6213 itc.func.del = NULL;
6214 itc.func.editmode_get = NULL;
6216 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6219 if (!wd->select_all_item) return;
6221 _item_realize(wd->select_all_item, 0, 0);
6222 edje_object_signal_callback_add(wd->select_all_item->base, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
6224 wd->select_all_item->rel = NULL;
6225 wd->select_all_item->selected = 0;
6226 wd->select_all_item->before = 1;
6227 wd->select_all_item->block = NULL;
6228 wd->select_all_minh = wd->minh + wd->select_all_item->h;
6230 else if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
6232 if (wd->select_all_item)
6234 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
6235 free(wd->select_all_item);
6237 wd->select_all_item = NULL;
6239 edje_object_signal_emit(wd->scr, "elm,state,edit,animated,enable", "elm");
6241 if (wd->calc_job) ecore_job_del(wd->calc_job);
6242 wd->calc_job = ecore_job_add(_calc_job, wd);
6246 * Delete selected items in genlist edit mode.
6248 * @param obj The genlist object
6253 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6255 Elm_Genlist_Item *it;
6257 Item_Block *itb = NULL;
6259 ELM_CHECK_WIDTYPE(obj, widtype);
6260 Widget_Data *wd = elm_widget_data_get(obj);
6262 if (!wd->blocks) return;
6264 EINA_INLIST_FOREACH(wd->blocks, itb)
6266 if (!wd->blocks) break;
6270 EINA_LIST_FOREACH(itb->items, l, it)
6272 if (it->delete_check)
6274 it->wd->effect_mode = EINA_TRUE;
6278 itb->wd->minh -= it->h;
6279 itb->wd->select_all_minh -= it->h;
6282 if ((it->relcount > 0) || (it->walking > 0))
6284 elm_genlist_item_subitems_clear(it);
6285 it->delete_me = EINA_TRUE;
6286 if (it->wd->show_item == it) it->wd->show_item = NULL;
6287 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
6290 if (it->realized) _item_unrealize(it);
6291 it->block->changed = EINA_TRUE;
6293 if (it->itc->func.del) it->itc->func.del(it->data, it->wd->obj);
6297 it->wd->walking -= it->walking;
6298 if (it->wd->show_item == it) it->wd->show_item = NULL;
6299 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
6300 if (it->realized) _item_unrealize(it);
6302 EINA_LIST_FREE(it->edit_icon_objs, icon)
6303 evas_object_del(icon);
6305 Evas_Object *editfield;
6306 EINA_LIST_FREE(it->wd->edit_field, editfield)
6307 evas_object_del(editfield);
6309 evas_object_del(it->edit_obj);
6310 it->edit_obj = NULL;
6312 itb->items = eina_list_remove(itb->items, it);
6314 itb->changed = EINA_TRUE;
6315 if ((!it->delete_me) && (it->itc->func.del))
6316 it->itc->func.del(it->data, it->wd->obj);
6317 it->delete_me = EINA_TRUE;
6319 it->wd->queue = eina_list_remove(it->wd->queue, it);
6320 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
6322 it->parent->items = eina_list_remove(it->parent->items, it);
6323 if (it->long_timer) ecore_timer_del(it->long_timer);
6325 it->group_item->items = eina_list_remove(it->group_item->items,it);
6332 evas_render(evas_object_evas_get(wd->obj));
6333 if (wd->calc_job) ecore_job_del(wd->calc_job);
6334 wd->calc_job = ecore_job_add(_calc_job, wd);
6338 elm_genlist_selected_items_del(Evas_Object *obj)
6340 fprintf(stderr, "=================> Caution!!! <========================\n");
6341 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6342 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6343 fprintf(stderr, "=======================================================\n");
6344 elm_genlist_edit_selected_items_del(obj);
6348 * Get a list of selected items in genlist
6350 * This returns a list of the selected items in the genlist. The list
6351 * contains Elm_Genlist_Item pointers. The list must be freed by the
6352 * caller when done with eina_list_free(). The item pointers in the list
6353 * are only vallid so long as those items are not deleted or the genlist is
6356 * @param obj The genlist object
6357 * @return The list of selected items, nor NULL if none are selected.
6362 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6364 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6365 Widget_Data *wd = elm_widget_data_get(obj);
6366 Eina_List *list = NULL;
6368 if (!wd) return NULL;
6370 EINA_INLIST_FOREACH(wd->blocks, itb)
6373 Elm_Genlist_Item *it;
6375 EINA_LIST_FOREACH(itb->items, l, it)
6377 if (it->delete_check) list = eina_list_append(list, it);
6385 * Set a given item's rename mode
6387 * This renames the item's label from genlist
6389 * @param it The item
6390 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6395 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6399 const Eina_List *l, *list, *l2;
6400 const char *label, *rename_swallow_part;
6402 Eina_Bool done = EINA_FALSE;
6403 int label_cnt = 0 , swallow_part_cnt = 0;
6406 Evas_Object *editfield;
6407 Evas_Object *entry = NULL;
6408 int edit_field_cnt = 0;
6411 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6413 it->wd->edit_mode = 0xF0;
6414 _edit_controls_eval(it);
6417 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6422 Elm_Genlist_Item *it;
6425 EINA_LIST_FOREACH(itb->items, l, it)
6429 it->renamed = EINA_FALSE;
6431 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6433 entry = elm_editfield_entry_get(editfield);
6434 const char *text = elm_entry_entry_get(entry);
6436 if (it->itc->func.label_changed)
6437 it->itc->func.label_changed(it->data, it, text, edit_field_cnt++);
6439 Ecore_IMF_Context *imf = elm_entry_imf_context_get(entry);
6440 ecore_imf_context_input_panel_hide(imf);
6442 Evas_Object *editfield;
6443 EINA_LIST_FREE(it->wd->edit_field, editfield)
6444 evas_object_del(editfield);
6446 if (it->wd->edit_mode)
6448 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_INSERT))
6449 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
6451 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT))
6452 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6454 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
6455 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6459 evas_object_del(it->edit_obj);
6460 it->edit_obj = NULL;
6462 EINA_LIST_FREE(it->edit_icon_objs, icon)
6463 evas_object_del(icon);
6473 // if (emode != ELM_GENLIST_RENAME_MODE_NONE)
6476 it->renamed = EINA_TRUE;
6478 it->labels = _elm_stringlist_get(edje_object_data_get(it->base, "labels"));
6479 EINA_LIST_FOREACH(it->labels, list, label)
6481 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6482 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6483 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6484 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6486 if (it->itc->func.label_get)
6488 it->renamed = EINA_TRUE;
6489 swallow_part_cnt = 0;
6491 EINA_LIST_FREE(it->edit_icon_objs, icon)
6492 evas_object_del(icon);
6493 Eina_List *rename = _elm_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6494 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6496 if (label_cnt == swallow_part_cnt)
6498 editfield = elm_editfield_add(it->wd->obj);
6499 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6501 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6502 elm_editfield_eraser_set(editfield, EINA_TRUE);
6503 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6504 elm_widget_sub_object_add(it->edit_obj, editfield);
6506 evas_object_show(editfield);
6508 s = it->itc->func.label_get(it->data, it->wd->obj, list->data);
6512 Evas_Object *entry = elm_editfield_entry_get(editfield);
6513 elm_entry_entry_set(entry,s);
6518 elm_editfield_guide_text_set(editfield, "Text Input");
6527 if (it->wd->edit_mode == 0xF0)
6529 it->wd->edit_mode = 0;