1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items.
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * unrealized - This is called just before an item is unrealized. After
58 * this call icon objects provided will be deleted and the item object
59 * itself delete or be put into a floating cache.
61 * drag,start,up - This is called when the item in the list has been dragged
64 * drag,start,down - This is called when the item in the list has been dragged
65 * (not scrolled) down.
67 * drag,start,left - This is called when the item in the list has been dragged
68 * (not scrolled) left.
70 * drag,start,right - This is called when the item in the list has been dragged
71 * (not scrolled) right.
73 * drag,stop - This is called when the item in the list has stopped being
76 * drag - This is called when the item in the list is being dragged.
78 * longpressed - This is called when the item is pressed for a certain amount
79 * of time. By default it's 1 second.
81 * scroll,edge,top - This is called when the genlist is scrolled until the top
84 * scroll,edge,bottom - This is called when the genlist is scrolled until the
87 * scroll,edge,left - This is called when the genlist is scrolled until the
90 * scroll,edge,right - This is called when the genlist is scrolled until the
93 * multi,swipe,left - This is called when the genlist is multi-touch swiped
96 * multi,swipe,right - This is called when the genlist is multi-touch swiped
99 * multi,swipe,up - This is called when the genlist is multi-touch swiped
102 * multi,swipe,down - This is called when the genlist is multi-touch swiped
105 * multi,pinch,out - This is called when the genlist is multi-touch pinched
108 * multi,pinch,in - This is called when the genlist is multi-touch pinched
111 * Genlist has a fairly large API, mostly because it's relatively complex,
112 * trying to be both expansive, powerful and efficient. First we will begin
113 * an overview on the theory behind genlist.
115 * Evas tracks every object you create. Every time it processes an event
116 * (mouse move, down, up etc.) it needs to walk through objects and find out
117 * what event that affects. Even worse every time it renders display updates,
118 * in order to just calculate what to re-draw, it needs to walk through many
119 * many many objects. Thus, the more objects you keep active, the more
120 * overhead Evas has in just doing its work. It is advisable to keep your
121 * active objects to the minimum working set you need. Also remember that
122 * object creation and deletion carries an overhead, so there is a
123 * middle-ground, which is not easily determined. But don't keep massive lists
124 * of objects you can't see or use. Genlist does this with list objects. It
125 * creates and destroys them dynamically as you scroll around. It groups them
126 * into blocks so it can determine the visibility etc. of a whole block at
127 * once as opposed to having to walk the whole list. This 2-level list allows
128 * for very large numbers of items to be in the list (tests have used up to
129 * 2,000,000 items). Also genlist employs a queue for adding items. As items
130 * may be different sizes, every item added needs to be calculated as to its
131 * size and thus this presents a lot of overhead on populating the list, this
132 * genlist employs a queue. Any item added is queued and spooled off over
133 * time, actually appearing some time later, so if your list has many members
134 * you may find it takes a while for them to all appear, with your process
135 * consuming a lot of CPU while it is busy spooling.
137 * Genlist also implements a tree structure, but it does so with callbacks to
138 * the application, with the application filling in tree structures when
139 * requested (allowing for efficient building of a very deep tree that could
140 * even be used for file-management). See the above smart signal callbacks for
143 * An item in the genlist world can have 0 or more text labels (they can be
144 * regular text or textblock ??that's up to the style to determine), 0 or
145 * more icons (which are simply objects swallowed into the genlist item) and
146 * 0 or more boolean states that can be used for check, radio or other
147 * indicators by the edje theme style. An item may be one of several styles
148 * (Elementary provides 4 by default - ?
\9cdefault?? ?
\9cdouble_label?? "group_index"
149 * and "icon_top_text_bottom", but this can be extended by system or
150 * application custom themes/overlays/extensions).
152 * In order to implement the ability to add and delete items on the fly,
153 * Genlist implements a class/callback system where the application provides
154 * a structure with information about that type of item (genlist may contain
155 * multiple different items with different classes, states and styles).
156 * Genlist will call the functions in this struct (methods) when an item is
157 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
158 * simply be deleted when no longer needed with evas_object_del(). The
159 * Elm_Genlist_Item_Class structure contains the following members:
161 * item_style - This is a constant string and simply defines the name of the
162 * item style. It must be specified and the default should be ?
\9cdefault??
164 * func.label_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 text part in the edje design that is listed as one of the possible
169 * labels that can be set. This function must return a strudup()'ed string as
170 * the caller will free() it when done.
172 * func.icon_get - This function is called when an actual item object is
173 * created. The data parameter is the data parameter passed to
174 * elm_genlist_item_append() and related item creation functions. The obj
175 * parameter is the genlist object and the part parameter is the string name
176 * of the icon part in the edje design that is listed as one of the possible
177 * icons that can be set. This must return NULL for no object or a valid
178 * object. The object will be deleted by genlist on shutdown or when the item
181 * func.state_get - This function is called when an actual item object is
182 * created. The data parameter is the data parameter passed to
183 * elm_genlist_item_append() and related item creation functions. The obj
184 * parameter is the genlist object and the part parameter is the string name
185 * of the state part in the edje design that is listed as one of the possible
186 * states that can be set. Return 0 for false or 1 for true. Genlist will
187 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
188 * true (the default is false), where XXX is the name of the part.
190 * func.del - This is called when elm_genlist_item_del() is called on an
191 * item, elm_genlist_clear() is called on the genlist, or
192 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
193 * intended for use when actual genlist items are deleted, so any backing
194 * data attached to the item (e.g. its data parameter on creation) can be
197 * Items can be added by several calls. All of them return a Elm_Genlist_Item
198 * handle that is an internal member inside the genlist. They all take a data
199 * parameter that is meant to be used for a handle to the applications
200 * internal data (eg the struct with the original item data). The parent
201 * parameter is the parent genlist item this belongs to if it is a tree or
202 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
203 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
204 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
205 * is displayed as an item that is able to expand and have child items.
206 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
207 * displayed at the top until the next group comes. The func parameter is a
208 * convenience callback that is called when the item is selected and the data
209 * parameter will be the func_data parameter, obj be the genlist object and
210 * event_info will be the genlist item.
212 * elm_genlist_item_append() appends an item to the end of the list, or if
213 * there is a parent, to the end of all the child items of the parent.
214 * elm_genlist_item_prepend() is the same but prepends to the beginning of
215 * the list or children list. elm_genlist_item_insert_before() inserts at
216 * item before another item and elm_genlist_item_insert_after() inserts after
217 * the indicated item.
219 * The application can clear the list with elm_genlist_clear() which deletes
220 * all the items in the list and elm_genlist_item_del() will delete a specific
221 * item. elm_genlist_item_subitems_clear() will clear all items that are
222 * children of the indicated parent item.
224 * If the application wants multiple items to be able to be selected,
225 * elm_genlist_multi_select_set() can enable this. If the list is
226 * single-selection only (the default), then elm_genlist_selected_item_get()
227 * will return the selected item, if any, or NULL I none is selected. If the
228 * list is multi-select then elm_genlist_selected_items_get() will return a
229 * list (that is only valid as long as no items are modified (added, deleted,
230 * selected or unselected)).
232 * To help inspect list items you can jump to the item at the top of the list
233 * with elm_genlist_first_item_get() which will return the item pointer, and
234 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
235 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
236 * and previous items respectively relative to the indicated item. Using
237 * these calls you can walk the entire item list/tree. Note that as a tree
238 * the items are flattened in the list, so elm_genlist_item_parent_get() will
239 * let you know which item is the parent (and thus know how to skip them if
242 * There are also convenience functions. elm_genlist_item_genlist_get() will
243 * return the genlist object the item belongs to. elm_genlist_item_show()
244 * will make the scroller scroll to show that specific item so its visible.
245 * elm_genlist_item_data_get() returns the data pointer set by the item
246 * creation functions.
248 * If an item changes (state of boolean changes, label or icons change),
249 * then use elm_genlist_item_update() to have genlist update the item with
250 * the new state. Genlist will re-realize the item thus call the functions
251 * in the _Elm_Genlist_Item_Class for that item.
253 * To programmatically (un)select an item use elm_genlist_item_selected_set().
254 * To get its selected state use elm_genlist_item_selected_get(). Similarly
255 * to expand/contract an item and get its expanded state, use
256 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
257 * again to make an item disabled (unable to be selected and appear
258 * differently) use elm_genlist_item_disabled_set() to set this and
259 * elm_genlist_item_disabled_get() to get the disabled state.
261 * In general to indicate how the genlist should expand items horizontally to
262 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
263 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
264 * mode means that if items are too wide to fit, the scroller will scroll
265 * horizontally. Otherwise items are expanded to fill the width of the
266 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
267 * to the viewport width and limited to that size. This can be combined with
268 * a different style that uses edjes' ellipsis feature (cutting text off like
269 * this: ?
\9ctex...??.
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
289 typedef struct _Edit_Data Edit_Data;
291 typedef enum _Elm_Genlist_Item_Move_effect_Mode
293 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
294 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
297 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 3),
298 } Elm_Genlist_Item_Move_effect_Mode;
302 Evas_Object *obj, *scr, *pan_smart;
303 Eina_Inlist *items, *blocks;
304 Eina_List *group_items;
306 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
307 Ecore_Job *calc_job, *update_job;
308 Ecore_Idler *queue_idler;
309 Ecore_Idler *must_recalc_idler;
310 Eina_List *queue, *selected;
311 Elm_Genlist_Item *show_item;
312 Elm_Genlist_Item *last_selected_item;
313 Eina_Inlist *item_cache;
314 Elm_Genlist_Item *anchor_item;
317 Ecore_Timer *multi_timer;
318 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
319 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
320 Eina_Bool mouse_down : 1;
321 Eina_Bool multi_down : 1;
322 Eina_Bool multi_timeout : 1;
323 Eina_Bool multitouched : 1;
324 Eina_Bool on_hold : 1;
326 Eina_Bool always_select : 1;
327 Eina_Bool longpressed : 1;
328 Eina_Bool wasselected : 1;
329 Eina_Bool no_select : 1;
330 Eina_Bool bring_in : 1;
331 Eina_Bool compress : 1;
332 Eina_Bool height_for_width : 1;
333 Eina_Bool homogeneous : 1;
334 Eina_Bool clear_me : 1;
339 } history[SWIPE_MOVES];
341 int item_cache_count;
347 int max_items_per_block;
348 double longpress_timeout;
350 // TODO : refactoring
351 Eina_Bool reorder_mode : 1;
352 Eina_Bool reorder_pan_move : 1;
353 Eina_Bool reorder_deleted : 1;
354 Eina_Bool effect_mode : 1;
355 Eina_Bool select_all_check : 1;
356 Eina_Bool auto_scrolled : 1;
359 Eina_List *edit_field;
360 Elm_Genlist_Item *select_all_item;
361 Eina_List *sweeped_items;
362 Ecore_Timer *scr_hold_timer;
364 int group_item_width;
365 int group_item_height;
366 Elm_Genlist_Item *reorder_it, *reorder_rel;
367 Evas_Coord reorder_start_y;
368 Ecore_Animator *item_moving_effect_timer;
369 Evas_Object *alpha_bg;
370 Elm_Genlist_Item *expand_item;
371 Evas_Coord expand_item_end;
372 Evas_Coord expand_item_gap;
373 int move_effect_mode;
374 unsigned int start_time;
384 Evas_Coord x, y, w, h, minw, minh;
385 Eina_Bool want_unrealize : 1;
386 Eina_Bool realized : 1;
387 Eina_Bool changed : 1;
388 Eina_Bool updateme : 1;
389 Eina_Bool showme : 1;
390 Eina_Bool must_recalc : 1;
394 struct _Elm_Genlist_Item
396 Elm_Widget_Item base;
401 Evas_Coord x, y, w, h, minw, minh;
402 const Elm_Genlist_Item_Class *itc;
403 Elm_Genlist_Item *parent;
404 Elm_Genlist_Item *group_item;
405 Elm_Genlist_Item_Flags flags;
413 Eina_List *labels, *icons, *states, *icon_objs;
414 Ecore_Timer *long_timer;
415 Ecore_Timer *swipe_timer;
417 Evas_Coord scrl_x, scrl_y;
419 Elm_Genlist_Item *rel;
424 Elm_Tooltip_Item_Content_Cb content_cb;
425 Evas_Smart_Cb del_cb;
429 const char *mouse_cursor;
436 Eina_Bool before : 1;
438 Eina_Bool want_unrealize : 1;
439 Eina_Bool want_realize : 1;
440 Eina_Bool realized : 1;
441 Eina_Bool selected : 1;
442 Eina_Bool hilighted : 1;
443 Eina_Bool expanded : 1;
444 Eina_Bool disabled : 1;
445 Eina_Bool display_only : 1;
446 Eina_Bool mincalcd : 1;
447 Eina_Bool queued : 1;
448 Eina_Bool showme : 1;
449 Eina_Bool delete_me : 1;
451 Eina_Bool dragging : 1;
452 Eina_Bool updateme : 1;
453 Eina_Bool nocache : 1;
456 Eina_Bool move_effect_me : 1;
457 Eina_Bool effect_done : 1;
458 Eina_Bool reordering : 1;
459 Eina_Bool edit_select_check: 1;
460 Eina_Bool renamed : 1;
461 Eina_Bool effect_item_realized : 1;
462 Eina_Bool sweeped : 1;
463 Eina_Bool wassweeped : 1;
464 Eina_List *edit_icon_objs;
465 Evas_Object *edit_obj;
466 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
468 Ecore_Animator *item_moving_effect_timer;
469 Evas_Coord old_scrl_x, old_scrl_y;
470 Evas_Coord pad_left, pad_right;
478 Evas_Object *base_view, *spacer;
480 const char *item_style; // it->itc->item_style
481 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
482 Eina_Bool compress : 1; // it->wd->compress
483 Eina_Bool odd : 1; // in & 0x1
485 Eina_Bool selected : 1; // it->selected
486 Eina_Bool disabled : 1; // it->disabled
487 Eina_Bool expanded : 1; // it->expanded
492 Elm_Genlist_Edit_Class *ec;
493 Elm_Genlist_Item *del_item;
494 Elm_Genlist_Item *reorder_item;
495 Elm_Genlist_Item *reorder_rel;
496 Evas_Object *del_confirm;
499 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
500 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
504 Evas_Object_Smart_Clipped_Data __clipped_data;
506 Ecore_Job *resize_job;
509 static const char *widtype = NULL;
510 static void _item_cache_zero(Widget_Data *wd);
511 static void _del_hook(Evas_Object *obj);
512 static void _theme_hook(Evas_Object *obj);
513 static void _show_region_hook(void *data, Evas_Object *obj);
514 static void _sizing_eval(Evas_Object *obj);
515 static void _item_unrealize(Elm_Genlist_Item *it);
516 static void _item_block_unrealize(Item_Block *itb);
517 static void _calc_job(void *data);
518 static void _on_focus_hook(void *data,
520 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
521 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
522 static Eina_Bool _item_single_select_up(Widget_Data *wd);
523 static Eina_Bool _item_single_select_down(Widget_Data *wd);
524 static Eina_Bool _event_hook(Evas_Object *obj,
526 Evas_Callback_Type type,
528 static Eina_Bool _deselect_all_items(Widget_Data *wd);
529 static void _pan_calculate(Evas_Object *obj);
530 // TODO : refactoring
531 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
532 static unsigned int current_time_get();
533 static Eina_Bool _item_moving_effect_timer_cb(void *data);
534 static int _item_flip_effect_show(Elm_Genlist_Item *it);
535 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
536 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
537 static void _effect_item_unrealize(Elm_Genlist_Item *it);
538 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
539 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
540 static void _create_sweep_objs(Elm_Genlist_Item *it);
541 static void _delete_sweep_objs(Elm_Genlist_Item *it);
542 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
543 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
544 static void _group_items_recalc(void *data);
545 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items);
546 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
547 static void _item_auto_scroll(void *data);
549 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
552 _event_hook(Evas_Object *obj,
553 Evas_Object *src __UNUSED__,
554 Evas_Callback_Type type,
557 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
558 Evas_Event_Key_Down *ev = event_info;
559 Widget_Data *wd = elm_widget_data_get(obj);
560 if (!wd) return EINA_FALSE;
561 if (!wd->items) return EINA_FALSE;
562 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
563 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
565 Elm_Genlist_Item *it = NULL;
568 Evas_Coord step_x = 0;
569 Evas_Coord step_y = 0;
572 Evas_Coord page_x = 0;
573 Evas_Coord page_y = 0;
575 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
576 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
577 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
578 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
580 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
584 else if ((!strcmp(ev->keyname, "Right")) ||
585 (!strcmp(ev->keyname, "KP_Right")))
589 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
591 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
592 (_item_multi_select_up(wd)))
593 || (_item_single_select_up(wd)))
595 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
601 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
603 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
604 (_item_multi_select_down(wd)))
605 || (_item_single_select_down(wd)))
607 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
613 else if ((!strcmp(ev->keyname, "Home")) ||
614 (!strcmp(ev->keyname, "KP_Home")))
616 it = elm_genlist_first_item_get(obj);
617 elm_genlist_item_bring_in(it);
618 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
621 else if ((!strcmp(ev->keyname, "End")) ||
622 (!strcmp(ev->keyname, "KP_End")))
624 it = elm_genlist_last_item_get(obj);
625 elm_genlist_item_bring_in(it);
626 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
629 else if ((!strcmp(ev->keyname, "Prior")) ||
630 (!strcmp(ev->keyname, "KP_Prior")))
633 y -= -(page_y * v_h) / 100;
637 else if ((!strcmp(ev->keyname, "Next")) ||
638 (!strcmp(ev->keyname, "KP_Next")))
641 y += -(page_y * v_h) / 100;
645 else if(((!strcmp(ev->keyname, "Return")) ||
646 (!strcmp(ev->keyname, "KP_Enter")) ||
647 (!strcmp(ev->keyname, "space")))
648 && (!wd->multi) && (wd->selected))
650 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
651 elm_genlist_item_expanded_set(it,
652 !elm_genlist_item_expanded_get(it));
654 else if (!strcmp(ev->keyname, "Escape"))
656 if (!_deselect_all_items(wd)) return EINA_FALSE;
657 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
660 else return EINA_FALSE;
662 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
663 elm_smart_scroller_child_pos_set(wd->scr, x, y);
668 _deselect_all_items(Widget_Data *wd)
670 if (!wd->selected) return EINA_FALSE;
672 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
678 _item_multi_select_up(Widget_Data *wd)
680 if (!wd->selected) return EINA_FALSE;
681 if (!wd->multi) return EINA_FALSE;
683 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
684 if (!prev) return EINA_TRUE;
686 if (elm_genlist_item_selected_get(prev))
688 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
689 wd->last_selected_item = prev;
690 elm_genlist_item_show(wd->last_selected_item);
694 elm_genlist_item_selected_set(prev, EINA_TRUE);
695 elm_genlist_item_show(prev);
701 _item_multi_select_down(Widget_Data *wd)
703 if (!wd->selected) return EINA_FALSE;
704 if (!wd->multi) return EINA_FALSE;
706 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
707 if (!next) return EINA_TRUE;
709 if (elm_genlist_item_selected_get(next))
711 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
712 wd->last_selected_item = next;
713 elm_genlist_item_show(wd->last_selected_item);
717 elm_genlist_item_selected_set(next, EINA_TRUE);
718 elm_genlist_item_show(next);
724 _item_single_select_up(Widget_Data *wd)
726 Elm_Genlist_Item *prev;
729 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
730 while ((prev) && (prev->delete_me))
731 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
733 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
735 if (!prev) return EINA_FALSE;
737 _deselect_all_items(wd);
739 elm_genlist_item_selected_set(prev, EINA_TRUE);
740 elm_genlist_item_show(prev);
745 _item_single_select_down(Widget_Data *wd)
747 Elm_Genlist_Item *next;
750 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
751 while ((next) && (next->delete_me))
752 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
754 else next = elm_genlist_item_next_get(wd->last_selected_item);
756 if (!next) return EINA_FALSE;
758 _deselect_all_items(wd);
760 elm_genlist_item_selected_set(next, EINA_TRUE);
761 elm_genlist_item_show(next);
766 _on_focus_hook(void *data __UNUSED__,
769 Widget_Data *wd = elm_widget_data_get(obj);
771 if (elm_widget_focus_get(obj))
773 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
774 evas_object_focus_set(wd->obj, EINA_TRUE);
775 if ((wd->selected) && (!wd->last_selected_item))
776 wd->last_selected_item = eina_list_data_get(wd->selected);
780 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
781 evas_object_focus_set(wd->obj, EINA_FALSE);
786 _del_hook(Evas_Object *obj)
788 Widget_Data *wd = elm_widget_data_get(obj);
790 _item_cache_zero(wd);
791 if (wd->calc_job) ecore_job_del(wd->calc_job);
792 if (wd->update_job) ecore_job_del(wd->update_job);
793 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
794 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
795 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
796 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, ELM_GENLIST_EDIT_MODE_NONE, NULL);
801 _del_pre_hook(Evas_Object *obj)
803 Widget_Data *wd = elm_widget_data_get(obj);
805 evas_object_del(wd->pan_smart);
806 wd->pan_smart = NULL;
807 elm_genlist_clear(obj);
811 _theme_hook(Evas_Object *obj)
813 Widget_Data *wd = elm_widget_data_get(obj);
816 _item_cache_zero(wd);
817 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
818 elm_widget_style_get(obj));
819 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
820 wd->item_width = wd->item_height = 0;
821 wd->minw = wd->minh = wd->realminw = 0;
822 EINA_INLIST_FOREACH(wd->blocks, itb)
825 Elm_Genlist_Item *it;
827 if (itb->realized) _item_block_unrealize(itb);
828 EINA_LIST_FOREACH(itb->items, l, it)
829 it->mincalcd = EINA_FALSE;
831 itb->changed = EINA_TRUE;
833 if (wd->calc_job) ecore_job_del(wd->calc_job);
834 wd->calc_job = ecore_job_add(_calc_job, wd);
839 _show_region_hook(void *data, Evas_Object *obj)
841 Widget_Data *wd = elm_widget_data_get(data);
842 Evas_Coord x, y, w, h;
844 elm_widget_show_region_get(obj, &x, &y, &w, &h);
847 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
851 _sizing_eval(Evas_Object *obj)
853 Widget_Data *wd = elm_widget_data_get(obj);
854 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
856 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
857 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
859 if (wd->height_for_width)
863 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
864 if ((vw != 0) && (vw != wd->prev_viewport_w))
868 wd->prev_viewport_w = vw;
869 EINA_INLIST_FOREACH(wd->blocks, itb)
871 itb->must_recalc = EINA_TRUE;
873 if (wd->calc_job) ecore_job_del(wd->calc_job);
874 wd->calc_job = ecore_job_add(_calc_job, wd);
877 if (wd->mode == ELM_LIST_LIMIT)
879 Evas_Coord vmw, vmh, vw, vh;
883 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
884 if ((minw > 0) && (vw < minw)) vw = minw;
885 else if ((maxw > 0) && (vw > maxw))
887 edje_object_size_min_calc
888 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
895 edje_object_size_min_calc
896 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
900 evas_object_size_hint_min_set(obj, minw, minh);
901 evas_object_size_hint_max_set(obj, maxw, maxh);
905 _item_hilight(Elm_Genlist_Item *it)
907 const char *selectraise;
908 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
909 (it->disabled)) return;
910 if ((!it->sweeped) && (!it->wd->edit_mode))
911 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
912 selectraise = edje_object_data_get(it->base.view, "selectraise");
913 if ((selectraise) && (!strcmp(selectraise, "on")))
915 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
916 if ((it->group_item) && (it->group_item->realized))
917 evas_object_raise(it->group_item->base.view);
919 it->hilighted = EINA_TRUE;
920 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
924 _item_block_del(Elm_Genlist_Item *it)
927 Item_Block *itb = it->block;
929 itb->items = eina_list_remove(itb->items, it);
931 itb->changed = EINA_TRUE;
932 if (!it->wd->reorder_deleted)
934 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
935 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
939 il = EINA_INLIST_GET(itb);
940 Item_Block *itbn = (Item_Block *)(il->next);
942 it->parent->items = eina_list_remove(it->parent->items, it);
944 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
946 if (itbn) itbn->changed = EINA_TRUE;
950 if (itb->count < itb->wd->max_items_per_block/2)
952 il = EINA_INLIST_GET(itb);
953 Item_Block *itbp = (Item_Block *)(il->prev);
954 Item_Block *itbn = (Item_Block *)(il->next);
955 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
957 Elm_Genlist_Item *it2;
959 EINA_LIST_FREE(itb->items, it2)
962 itbp->items = eina_list_append(itbp->items, it2);
964 itbp->changed = EINA_TRUE;
966 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
967 EINA_INLIST_GET(itb));
970 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
974 Eina_List *last = eina_list_last(itb->items);
975 Elm_Genlist_Item *it2 = last->data;
978 itb->items = eina_list_remove_list(itb->items, last);
979 itbn->items = eina_list_prepend(itbn->items, it2);
981 itbn->changed = EINA_TRUE;
984 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
992 _item_subitems_clear(Elm_Genlist_Item *it)
995 Eina_List *tl = NULL, *l;
996 Elm_Genlist_Item *it2;
998 EINA_LIST_FOREACH(it->items, l, it2)
999 tl = eina_list_append(tl, it2);
1001 EINA_LIST_FREE(tl, it2)
1002 elm_genlist_item_del(it2);
1006 _item_del(Elm_Genlist_Item *it)
1008 elm_widget_item_pre_notify_del(it);
1009 elm_genlist_item_subitems_clear(it);
1010 it->wd->walking -= it->walking;
1011 if (it->wd->show_item == it) it->wd->show_item = NULL;
1012 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1013 if (it->realized) _item_unrealize(it);
1014 if (it->effect_item_realized) _effect_item_unrealize(it);
1015 if (it->block) _item_block_del(it);
1016 if ((!it->delete_me) && (it->itc->func.del))
1017 it->itc->func.del((void *)it->base.data, it->base.widget);
1018 it->delete_me = EINA_TRUE;
1020 it->wd->queue = eina_list_remove(it->wd->queue, it);
1022 if (it->wd->anchor_item == it)
1024 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1025 if (!it->wd->anchor_item)
1026 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1029 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1031 it->parent->items = eina_list_remove(it->parent->items, it);
1032 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1033 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1034 if (it->long_timer) ecore_timer_del(it->long_timer);
1035 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1037 if (it->tooltip.del_cb)
1038 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1040 elm_widget_item_del(it);
1041 it->wd->total_num--; // todo : remove
1045 _item_select(Elm_Genlist_Item *it)
1047 if ((it->wd->no_select) || (it->delete_me)) return;
1048 if (it == it->wd->select_all_item)
1050 if(it->wd->select_all_check)
1051 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE);
1053 _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE);
1058 if (it->wd->always_select) goto call;
1061 it->selected = EINA_TRUE;
1062 it->wd->selected = eina_list_append(it->wd->selected, it);
1066 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1068 evas_object_smart_callback_call(it->base.widget, "selected", it);
1071 if ((it->wd->clear_me) && (!it->wd->walking))
1073 elm_genlist_clear(it->base.widget);
1078 if ((!it->walking) && (it->delete_me))
1080 if (!it->relcount) _item_del(it);
1083 if (it && it->wd) it->wd->last_selected_item = it;
1087 _item_unselect(Elm_Genlist_Item *it)
1089 const char *stacking, *selectraise;
1091 if (it == it->wd->select_all_item) return;
1092 if ((it->delete_me) || (!it->hilighted)) return;
1094 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1095 stacking = edje_object_data_get(it->base.view, "stacking");
1096 selectraise = edje_object_data_get(it->base.view, "selectraise");
1097 if ((selectraise) && (!strcmp(selectraise, "on")))
1099 if ((stacking) && (!strcmp(stacking, "below")))
1100 evas_object_lower(it->base.view);
1102 it->hilighted = EINA_FALSE;
1105 it->selected = EINA_FALSE;
1106 it->wd->selected = eina_list_remove(it->wd->selected, it);
1107 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1112 _mouse_move(void *data,
1113 Evas *evas __UNUSED__,
1117 Elm_Genlist_Item *it = data;
1118 Evas_Event_Mouse_Move *ev = event_info;
1119 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1121 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1123 if (!it->wd->on_hold)
1125 it->wd->on_hold = EINA_TRUE;
1126 if (!it->wd->wasselected)
1130 if (it->wd->multitouched)
1132 it->wd->cur_x = ev->cur.canvas.x;
1133 it->wd->cur_y = ev->cur.canvas.y;
1136 if ((it->dragging) && (it->down))
1138 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1141 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1142 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1143 if (abs((it->wd->history[it->wd->movements].x -
1144 it->wd->history[0].x)) > 40)
1145 it->wd->swipe = EINA_TRUE;
1147 it->wd->movements++;
1151 ecore_timer_del(it->long_timer);
1152 it->long_timer = NULL;
1154 evas_object_smart_callback_call(it->base.widget, "drag", it);
1157 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1161 ecore_timer_del(it->long_timer);
1162 it->long_timer = NULL;
1164 if (it->wd->reorder_mode && it->wd->reorder_it)
1166 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1167 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1168 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1169 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1171 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1172 if (it->wd->select_all_item)
1173 sel_all_h = it->wd->select_all_item->h;
1174 if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1175 else if (it_y + it->wd->reorder_it->h > oy+oh) _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1176 else _effect_item_controls(it, it->scrl_x, it_y);
1178 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1179 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1183 if (!it->display_only)
1184 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1185 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1186 x = ev->cur.canvas.x - x;
1187 y = ev->cur.canvas.y - y;
1190 if (adx < 0) adx = -dx;
1193 if (ady < 0) ady = -dy;
1196 if ((adx > minw) || (ady > minh))
1198 it->dragging = EINA_TRUE;
1201 ecore_timer_del(it->long_timer);
1202 it->long_timer = NULL;
1204 if (!it->wd->wasselected)
1209 evas_object_smart_callback_call(it->base.widget,
1210 "drag,start,up", it);
1215 evas_object_smart_callback_call(it->base.widget,
1216 "drag,start,left", it);
1217 _item_slide(it, EINA_FALSE);
1221 evas_object_smart_callback_call(it->base.widget,
1222 "drag,start,right", it);
1223 _item_slide(it, EINA_TRUE);
1230 evas_object_smart_callback_call(it->base.widget,
1231 "drag,start,down", it);
1236 evas_object_smart_callback_call(it->base.widget,
1237 "drag,start,left", it);
1238 _item_slide(it, EINA_FALSE);
1242 evas_object_smart_callback_call(it->base.widget,
1243 "drag,start,right", it);
1244 _item_slide(it, EINA_TRUE);
1252 _long_press(void *data)
1254 Elm_Genlist_Item *it = data;
1255 Elm_Genlist_Item *it_tmp;
1256 static Eina_Bool done = EINA_FALSE;
1257 //static Eina_Bool contracted = EINA_FALSE;
1261 it->long_timer = NULL;
1262 if ((it->disabled) || (it->dragging) || (it->display_only))
1263 return ECORE_CALLBACK_CANCEL;
1264 it->wd->longpressed = EINA_TRUE;
1265 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1266 if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1268 it->wd->reorder_it = it;
1269 it->wd->reorder_start_y = 0;
1270 evas_object_raise(it->edit_obj);
1271 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1272 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1274 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1279 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1281 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1283 _item_unselect(it_tmp);
1295 EINA_LIST_FOREACH(it->items, l, it_tmp)
1297 if (elm_genlist_item_expanded_get(it_tmp))
1299 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1300 return ECORE_CALLBACK_RENEW;
1304 if (elm_genlist_item_expanded_get(it)) {
1305 elm_genlist_item_expanded_set(it, EINA_FALSE);
1306 return ECORE_CALLBACK_RENEW;
1308 if (it->wd->edit_field && it->renamed)
1309 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1312 return ECORE_CALLBACK_CANCEL;
1316 _swipe(Elm_Genlist_Item *it)
1321 it->wd->swipe = EINA_FALSE;
1322 for (i = 0; i < it->wd->movements; i++)
1324 sum += it->wd->history[i].x;
1325 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1328 sum /= it->wd->movements;
1329 if (abs(sum - it->wd->history[0].x) <= 10) return;
1330 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1334 _swipe_cancel(void *data)
1336 Elm_Genlist_Item *it = data;
1338 if (!it) return ECORE_CALLBACK_CANCEL;
1339 it->wd->swipe = EINA_FALSE;
1340 it->wd->movements = 0;
1341 return ECORE_CALLBACK_RENEW;
1345 _multi_cancel(void *data)
1347 Widget_Data *wd = data;
1349 if (!wd) return ECORE_CALLBACK_CANCEL;
1350 wd->multi_timeout = EINA_TRUE;
1351 return ECORE_CALLBACK_RENEW;
1355 _multi_touch_gesture_eval(void *data)
1357 Elm_Genlist_Item *it = data;
1359 it->wd->multitouched = EINA_FALSE;
1360 if (it->wd->multi_timer)
1362 ecore_timer_del(it->wd->multi_timer);
1363 it->wd->multi_timer = NULL;
1365 if (it->wd->multi_timeout)
1367 it->wd->multi_timeout = EINA_FALSE;
1371 Evas_Coord minw = 0, minh = 0;
1372 Evas_Coord off_x, off_y, off_mx, off_my;
1374 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1375 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1376 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1377 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1378 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1380 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1382 if ((off_x + off_mx) > (off_y + off_my))
1384 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1385 evas_object_smart_callback_call(it->base.widget,
1386 "multi,swipe,right", it);
1387 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1388 evas_object_smart_callback_call(it->base.widget,
1389 "multi,swipe,left", it);
1390 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1391 evas_object_smart_callback_call(it->base.widget,
1392 "multi,pinch,out", it);
1394 evas_object_smart_callback_call(it->base.widget,
1395 "multi,pinch,in", it);
1399 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1400 evas_object_smart_callback_call(it->base.widget,
1401 "multi,swipe,down", it);
1402 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1403 evas_object_smart_callback_call(it->base.widget,
1404 "multi,swipe,up", it);
1405 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1406 evas_object_smart_callback_call(it->base.widget,
1407 "multi,pinch,out", it);
1409 evas_object_smart_callback_call(it->base.widget,
1410 "multi,pinch,in", it);
1413 it->wd->multi_timeout = EINA_FALSE;
1417 _multi_down(void *data,
1418 Evas *evas __UNUSED__,
1419 Evas_Object *obj __UNUSED__,
1422 Elm_Genlist_Item *it = data;
1423 Evas_Event_Multi_Down *ev = event_info;
1425 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1426 it->wd->multi_device = ev->device;
1427 it->wd->multi_down = EINA_TRUE;
1428 it->wd->multitouched = EINA_TRUE;
1429 it->wd->prev_mx = ev->canvas.x;
1430 it->wd->prev_my = ev->canvas.y;
1431 if (!it->wd->wasselected) _item_unselect(it);
1432 it->wd->wasselected = EINA_FALSE;
1433 it->wd->longpressed = EINA_FALSE;
1436 ecore_timer_del(it->long_timer);
1437 it->long_timer = NULL;
1441 it->dragging = EINA_FALSE;
1442 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1444 if (it->swipe_timer)
1446 ecore_timer_del(it->swipe_timer);
1447 it->swipe_timer = NULL;
1449 if (it->wd->on_hold)
1451 it->wd->swipe = EINA_FALSE;
1452 it->wd->movements = 0;
1453 it->wd->on_hold = EINA_FALSE;
1458 _multi_up(void *data,
1459 Evas *evas __UNUSED__,
1460 Evas_Object *obj __UNUSED__,
1463 Elm_Genlist_Item *it = data;
1464 Evas_Event_Multi_Up *ev = event_info;
1466 if (it->wd->multi_device != ev->device) return;
1467 it->wd->multi_device = 0;
1468 it->wd->multi_down = EINA_FALSE;
1469 if (it->wd->mouse_down) return;
1470 _multi_touch_gesture_eval(data);
1474 _multi_move(void *data,
1475 Evas *evas __UNUSED__,
1476 Evas_Object *obj __UNUSED__,
1479 Elm_Genlist_Item *it = data;
1480 Evas_Event_Multi_Move *ev = event_info;
1482 if (it->wd->multi_device != ev->device) return;
1483 it->wd->cur_mx = ev->cur.canvas.x;
1484 it->wd->cur_my = ev->cur.canvas.y;
1488 _mouse_down(void *data,
1489 Evas *evas __UNUSED__,
1493 Elm_Genlist_Item *it = data;
1494 Evas_Event_Mouse_Down *ev = event_info;
1497 if (ev->button != 1) return;
1498 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1500 it->wd->on_hold = EINA_TRUE;
1503 if (it->wd->edit_field && !it->renamed)
1504 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1505 it->down = EINA_TRUE;
1506 it->dragging = EINA_FALSE;
1507 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1508 it->dx = ev->canvas.x - x;
1509 it->dy = ev->canvas.y - y;
1510 it->wd->mouse_down = EINA_TRUE;
1511 if (!it->wd->multitouched)
1513 it->wd->prev_x = ev->canvas.x;
1514 it->wd->prev_y = ev->canvas.y;
1515 it->wd->multi_timeout = EINA_FALSE;
1516 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1517 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1519 it->wd->longpressed = EINA_FALSE;
1520 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1521 else it->wd->on_hold = EINA_FALSE;
1522 if (it->wd->on_hold) return;
1523 it->wd->wasselected = it->selected;
1525 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1526 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1527 if (it->long_timer) ecore_timer_del(it->long_timer);
1528 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1529 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1531 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1534 it->long_timer = NULL;
1535 it->wd->swipe = EINA_FALSE;
1536 it->wd->movements = 0;
1540 _mouse_up(void *data,
1541 Evas *evas __UNUSED__,
1542 Evas_Object *obj __UNUSED__,
1545 Elm_Genlist_Item *it = data;
1546 Evas_Event_Mouse_Up *ev = event_info;
1547 Eina_Bool dragged = EINA_FALSE;
1549 if (ev->button != 1) return;
1550 it->down = EINA_FALSE;
1551 it->wd->mouse_down = EINA_FALSE;
1552 if (it->wd->multitouched)
1554 if (it->wd->multi_down) return;
1555 _multi_touch_gesture_eval(data);
1558 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1559 else it->wd->on_hold = EINA_FALSE;
1562 ecore_timer_del(it->long_timer);
1563 it->long_timer = NULL;
1567 it->dragging = EINA_FALSE;
1568 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1571 if (it->swipe_timer)
1573 ecore_timer_del(it->swipe_timer);
1574 it->swipe_timer = NULL;
1576 if (it->wd->multi_timer)
1578 ecore_timer_del(it->wd->multi_timer);
1579 it->wd->multi_timer = NULL;
1580 it->wd->multi_timeout = EINA_FALSE;
1582 if (it->wd->on_hold)
1584 if (it->wd->swipe) _swipe(data);
1585 it->wd->longpressed = EINA_FALSE;
1586 it->wd->on_hold = EINA_FALSE;
1589 if (it->wd->reorder_mode)
1591 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1592 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1595 Evas_Coord ox,oy,oh,ow;
1596 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1597 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1598 if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h;
1599 if (it->wd->reorder_rel)
1601 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1603 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1604 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1606 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1609 it->wd->reorder_deleted = EINA_FALSE;
1610 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1611 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1612 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1615 if (it->wd->longpressed)
1617 it->wd->longpressed = EINA_FALSE;
1618 if (!it->wd->wasselected)
1620 it->wd->wasselected = EINA_FALSE;
1625 if (it->want_unrealize)
1627 _item_unrealize(it);
1628 if (it->block->want_unrealize)
1629 _item_block_unrealize(it->block);
1632 if ((it->disabled) || (dragged) || (it->display_only)) return;
1633 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1636 if ((!it->selected) && (!it->sweeped))
1641 else _item_unselect(it);
1647 Widget_Data *wd = it->wd;
1650 while (wd->selected) _item_unselect(wd->selected->data);
1655 const Eina_List *l, *l_next;
1656 Elm_Genlist_Item *it2;
1658 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1659 if (it2 != it) _item_unselect(it2);
1660 //_item_hilight(it);
1672 _signal_expand_toggle(void *data,
1673 Evas_Object *obj __UNUSED__,
1674 const char *emission __UNUSED__,
1675 const char *source __UNUSED__)
1677 Elm_Genlist_Item *it = data;
1680 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1682 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1686 _signal_expand(void *data,
1687 Evas_Object *obj __UNUSED__,
1688 const char *emission __UNUSED__,
1689 const char *source __UNUSED__)
1691 Elm_Genlist_Item *it = data;
1694 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1698 _signal_contract(void *data,
1699 Evas_Object *obj __UNUSED__,
1700 const char *emission __UNUSED__,
1701 const char *source __UNUSED__)
1703 Elm_Genlist_Item *it = data;
1706 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1710 _item_cache_clean(Widget_Data *wd)
1712 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1716 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1717 wd->item_cache = eina_inlist_remove(wd->item_cache,
1718 wd->item_cache->last);
1719 wd->item_cache_count--;
1720 if (itc->spacer) evas_object_del(itc->spacer);
1721 if (itc->base_view) evas_object_del(itc->base_view);
1722 if (itc->item_style) eina_stringshare_del(itc->item_style);
1728 _item_cache_zero(Widget_Data *wd)
1730 int pmax = wd->item_cache_max;
1731 wd->item_cache_max = 0;
1732 _item_cache_clean(wd);
1733 wd->item_cache_max = pmax;
1737 _item_cache_add(Elm_Genlist_Item *it)
1741 if (it->wd->item_cache_max <= 0)
1743 evas_object_del(it->base.view);
1744 it->base.view = NULL;
1745 evas_object_del(it->spacer);
1750 it->wd->item_cache_count++;
1751 itc = calloc(1, sizeof(Item_Cache));
1753 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1754 EINA_INLIST_GET(itc));
1755 itc->spacer = it->spacer;
1757 itc->base_view = it->base.view;
1758 it->base.view = NULL;
1759 evas_object_hide(itc->base_view);
1760 evas_object_move(itc->base_view, -9999, -9999);
1761 itc->item_style = eina_stringshare_add(it->itc->item_style);
1762 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1763 itc->compress = (it->wd->compress);
1764 itc->odd = (it->order_num_in & 0x1);
1765 itc->selected = it->selected;
1766 itc->disabled = it->disabled;
1767 itc->expanded = it->expanded;
1770 ecore_timer_del(it->long_timer);
1771 it->long_timer = NULL;
1773 if (it->swipe_timer)
1775 ecore_timer_del(it->swipe_timer);
1776 it->swipe_timer = NULL;
1778 // FIXME: other callbacks?
1779 edje_object_signal_callback_del_full(itc->base_view,
1780 "elm,action,expand,toggle",
1781 "elm", _signal_expand_toggle, it);
1782 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1784 _signal_expand, it);
1785 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1786 "elm", _signal_contract, it);
1787 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1789 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1791 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1793 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1795 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1797 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1799 _item_cache_clean(it->wd);
1803 _item_cache_find(Elm_Genlist_Item *it)
1806 Eina_Bool tree = 0, odd;
1808 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1809 odd = (it->order_num_in & 0x1);
1810 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1812 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1814 if ((itc->tree == tree) &&
1815 (itc->odd == odd) &&
1816 (itc->compress == it->wd->compress) &&
1817 (!strcmp(it->itc->item_style, itc->item_style)))
1819 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1820 EINA_INLIST_GET(itc));
1821 it->wd->item_cache_count--;
1829 _item_cache_free(Item_Cache *itc)
1831 if (itc->spacer) evas_object_del(itc->spacer);
1832 if (itc->base_view) evas_object_del(itc->base_view);
1833 if (itc->item_style) eina_stringshare_del(itc->item_style);
1838 _item_realize(Elm_Genlist_Item *it,
1842 Elm_Genlist_Item *it2;
1843 const char *stacking;
1844 const char *treesize;
1846 int depth, tsize = 20;
1847 Item_Cache *itc = NULL;
1849 if ((it->realized) || (it->delete_me)) return;
1850 it->order_num_in = in;
1851 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1853 it->nocache = EINA_FALSE;
1855 itc = _item_cache_find(it);
1856 if ((!it->wd->effect_mode) && (itc))
1858 it->base.view = itc->base_view;
1859 itc->base_view = NULL;
1860 it->spacer = itc->spacer;
1865 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1866 edje_object_scale_set(it->base.view,
1867 elm_widget_scale_get(it->base.widget) *
1868 _elm_config->scale);
1869 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1870 elm_widget_sub_object_add(it->base.widget, it->base.view);
1872 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1873 strncpy(buf, "tree", sizeof(buf));
1874 else strncpy(buf, "item", sizeof(buf));
1875 if (it->wd->compress)
1876 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1878 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1879 strncat(buf, "/", sizeof(buf) - strlen(buf));
1880 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1882 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1883 elm_widget_style_get(it->base.widget));
1885 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1886 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1887 elm_widget_sub_object_add(it->base.widget, it->spacer);
1889 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1891 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1893 it->expanded_depth = depth;
1894 treesize = edje_object_data_get(it->base.view, "treesize");
1895 if (treesize) tsize = atoi(treesize);
1896 evas_object_size_hint_min_set(it->spacer,
1897 (depth * tsize) * _elm_config->scale, 1);
1898 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1901 edje_object_signal_callback_add(it->base.view,
1902 "elm,action,expand,toggle",
1903 "elm", _signal_expand_toggle, it);
1904 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1905 "elm", _signal_expand, it);
1906 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1907 "elm", _signal_contract, it);
1908 stacking = edje_object_data_get(it->base.view, "stacking");
1911 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1912 else if (!strcmp(stacking, "above"))
1913 evas_object_raise(it->base.view);
1915 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1917 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1919 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1921 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1923 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1925 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1929 if (it->selected != itc->selected)
1931 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1932 edje_object_signal_emit(it->base.view,
1933 "elm,state,selected", "elm");
1935 if (it->disabled != itc->disabled)
1938 edje_object_signal_emit(it->base.view,
1939 "elm,state,disabled", "elm");
1941 if (it->expanded != itc->expanded)
1944 edje_object_signal_emit(it->base.view,
1945 "elm,state,expanded", "elm");
1950 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1951 edje_object_signal_emit(it->base.view,
1952 "elm,state,selected", "elm");
1954 edje_object_signal_emit(it->base.view,
1955 "elm,state,disabled", "elm");
1957 edje_object_signal_emit(it->base.view,
1958 "elm,state,expanded", "elm");
1962 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1964 /* homogenous genlist shortcut */
1965 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1967 it->w = it->minw = it->wd->group_item_width;
1968 it->h = it->minh = it->wd->group_item_height;
1969 it->mincalcd = EINA_TRUE;
1971 else if (!it->mincalcd)
1973 it->w = it->minw = it->wd->item_width;
1974 it->h = it->minh = it->wd->item_height;
1975 it->mincalcd = EINA_TRUE;
1980 if (it->itc->func.label_get)
1986 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1988 EINA_LIST_FOREACH(it->labels, l, key)
1990 char *s = it->itc->func.label_get
1991 ((void *)it->base.data, it->base.widget, l->data);
1995 edje_object_part_text_set(it->base.view, l->data, s);
1999 edje_object_part_text_set(it->base.view, l->data, "");
2002 if (it->itc->func.icon_get)
2008 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2010 EINA_LIST_FOREACH(it->icons, l, key)
2012 Evas_Object *ic = it->itc->func.icon_get
2013 ((void *)it->base.data, it->base.widget, l->data);
2017 it->icon_objs = eina_list_append(it->icon_objs, ic);
2018 edje_object_part_swallow(it->base.view, key, ic);
2019 evas_object_show(ic);
2020 elm_widget_sub_object_add(it->base.widget, ic);
2024 if (it->itc->func.state_get)
2030 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2032 EINA_LIST_FOREACH(it->states, l, key)
2034 Eina_Bool on = it->itc->func.state_get
2035 ((void *)it->base.data, it->base.widget, l->data);
2039 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2040 edje_object_signal_emit(it->base.view, buf, "elm");
2044 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2045 edje_object_signal_emit(it->base.view, buf, "elm");
2050 _create_sweep_objs(it);
2053 Evas_Coord mw = -1, mh = -1;
2055 if (it->wd->height_for_width) mw = it->wd->w;
2057 if (!it->display_only)
2058 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2059 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2060 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2062 if (!it->display_only)
2063 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2064 it->w = it->minw = mw;
2065 it->h = it->minh = mh;
2066 it->mincalcd = EINA_TRUE;
2068 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2070 it->wd->group_item_width = mw;
2071 it->wd->group_item_height = mh;
2073 else if ((it->wd->homogeneous))
2074 // if ((!in) && (it->wd->homogeneous))
2076 it->wd->item_width = mw;
2077 it->wd->item_height = mh;
2079 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2081 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2083 it->wd->group_item_width = mw;
2084 it->wd->group_item_height = mh;
2088 if (!calc) evas_object_show(it->base.view);
2091 if (it->tooltip.content_cb)
2093 elm_widget_item_tooltip_content_cb_set(it,
2094 it->tooltip.content_cb,
2095 it->tooltip.data, NULL);
2096 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2099 if (it->mouse_cursor)
2100 elm_widget_item_cursor_set(it, it->mouse_cursor);
2102 it->realized = EINA_TRUE;
2103 it->want_unrealize = EINA_FALSE;
2105 if (itc) _item_cache_free(itc);
2106 evas_object_smart_callback_call(it->base.widget, "realized", it);
2107 if ((it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && ((!it->wd->select_all_item) || ((it->wd->select_all_item) && (it != it->wd->select_all_item))))
2109 _effect_item_realize(it, EINA_FALSE);
2110 edje_object_message_signal_process(it->edit_obj);
2115 _item_unrealize(Elm_Genlist_Item *it)
2119 if (!it->realized) return;
2120 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2121 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2124 ecore_timer_del(it->long_timer);
2125 it->long_timer = NULL;
2127 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2129 it->sweeped = EINA_FALSE;
2130 it->wassweeped = EINA_FALSE;
2131 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2132 _delete_sweep_objs(it);
2133 evas_object_del(it->base.view);
2134 it->base.view = NULL;
2135 evas_object_del(it->spacer);
2139 _item_cache_add(it);
2140 elm_widget_stringlist_free(it->labels);
2142 elm_widget_stringlist_free(it->icons);
2144 elm_widget_stringlist_free(it->states);
2146 EINA_LIST_FREE(it->icon_objs, icon)
2147 evas_object_del(icon);
2150 it->realized = EINA_FALSE;
2151 it->want_unrealize = EINA_FALSE;
2152 if (it->wd->edit_field && it->renamed)
2153 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
2154 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2158 _item_block_recalc(Item_Block *itb,
2164 Elm_Genlist_Item *it;
2165 Evas_Coord minw = 0, minh = 0;
2166 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2170 EINA_LIST_FOREACH(itb->items, l, it)
2172 if (it->delete_me) continue;
2173 showme |= it->showme;
2178 if (!it->mincalcd) changed = EINA_TRUE;
2181 _item_realize(it, in, 1);
2182 _item_unrealize(it);
2187 _item_realize(it, in, 1);
2188 _item_unrealize(it);
2192 _item_realize(it, in, 0);
2194 if (minw < it->minw) minw = it->minw;
2202 itb->changed = EINA_FALSE;
2203 /* force an evas norender to garbage collect deleted objects */
2204 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2209 _item_block_realize(Item_Block *itb,
2214 Elm_Genlist_Item *it;
2216 if (itb->realized) return;
2217 EINA_LIST_FOREACH(itb->items, l, it)
2219 if (it->delete_me) continue;
2220 if (full) _item_realize(it, in, 0);
2223 itb->realized = EINA_TRUE;
2224 itb->want_unrealize = EINA_FALSE;
2228 _item_block_unrealize(Item_Block *itb)
2231 Elm_Genlist_Item *it;
2232 Eina_Bool dragging = EINA_FALSE;
2234 if (!itb->realized) return;
2235 EINA_LIST_FOREACH(itb->items, l, it)
2237 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2241 dragging = EINA_TRUE;
2242 it->want_unrealize = EINA_TRUE;
2245 _item_unrealize(it);
2250 itb->realized = EINA_FALSE;
2251 itb->want_unrealize = EINA_TRUE;
2254 itb->want_unrealize = EINA_FALSE;
2258 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2260 Evas_Coord rox, roy, row, roh;
2261 Eina_Bool top = EINA_FALSE;
2262 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2263 if (!reorder_it) return 0;
2265 Evas_Coord ox,oy,oh,ow;
2266 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2267 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2269 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2271 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2272 if (it->block->count == 1)
2273 it->wd->reorder_rel = it;
2275 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2277 it->block->reorder_offset = it->wd->reorder_it->h;
2280 it->block->reorder_offset = 0;
2282 it->scrl_y += it->block->reorder_offset;
2284 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2285 rox, roy+roh/2, row, 1));
2288 it->wd->reorder_rel = it;
2289 it->scrl_y+=it->wd->reorder_it->h;
2290 return it->wd->reorder_it->h;
2297 _reorder_item_moving_effect_timer_cb(void *data)
2299 Elm_Genlist_Item *it = data;
2300 Eina_Bool down = EINA_FALSE;
2301 double time = 0.4, t;
2303 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2306 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2310 if (it->old_scrl_y < it->scrl_y)
2312 it->old_scrl_y += y;
2315 else if (it->old_scrl_y > it->scrl_y)
2317 it->old_scrl_y -= y;
2321 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2323 _group_items_recalc(it->wd);
2324 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2326 it->old_scrl_y = it->scrl_y;
2327 it->move_effect_me = EINA_FALSE;
2328 it->wd->item_moving_effect_timer = NULL;
2329 return ECORE_CALLBACK_CANCEL;
2331 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2333 it->old_scrl_y = it->scrl_y;
2334 it->move_effect_me = EINA_FALSE;
2335 it->wd->item_moving_effect_timer = NULL;
2336 return ECORE_CALLBACK_CANCEL;
2338 return ECORE_CALLBACK_RENEW;
2342 _item_block_position(Item_Block *itb,
2346 Elm_Genlist_Item *it;
2347 Elm_Genlist_Item *git;
2348 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2351 Elm_Genlist_Item *select_all_item = NULL;
2353 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2354 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2357 if (itb->wd->select_all_item &&
2358 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2360 if (itb->wd->select_all_check)
2361 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
2363 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
2365 select_all_item = itb->wd->select_all_item;
2367 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2368 evas_object_move(select_all_item->base.view, ox, oy);
2369 evas_object_raise(select_all_item->base.view);
2371 y = select_all_item->h;
2372 sel_all_h = select_all_item->h;
2375 EINA_LIST_FOREACH(itb->items, l, it)
2377 if (it->delete_me) continue;
2378 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2383 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2384 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2386 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2387 cvx, cvy, cvw, cvh));
2388 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2390 if ((itb->realized) && (!it->realized))
2392 if (vis) _item_realize(it, in, 0);
2398 if(it->wd->reorder_mode)
2399 y += _get_space_for_reorder_item(it);
2400 git = it->group_item;
2403 git->scrl_x = it->scrl_x;
2404 if (git->scrl_y < oy + sel_all_h)
2405 git->scrl_y = oy + sel_all_h;
2406 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2407 git->scrl_y = (it->scrl_y + it->h) - git->h;
2408 git->want_realize = EINA_TRUE;
2410 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2412 if (!it->move_effect_me)
2414 it->move_effect_me = EINA_TRUE;
2415 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2419 if (!it->move_effect_me )
2420 if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item))
2422 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2424 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2428 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2429 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2430 if((!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) && (it->old_scrl_y == it->scrl_y)))
2431 evas_object_show(it->base.view);
2433 evas_object_hide(it->base.view);
2435 it->old_scrl_x = it->scrl_x;
2436 it->old_scrl_y = it->scrl_y;
2441 if (!it->dragging) _item_unrealize(it);
2448 if (vis) it->want_realize = EINA_TRUE;
2455 _group_items_recalc(void *data)
2457 Widget_Data *wd = data;
2459 Elm_Genlist_Item *git;
2461 EINA_LIST_FOREACH(wd->group_items, l, git)
2463 if (git->want_realize)
2466 _item_realize(git, 0, 0);
2467 evas_object_resize(git->base.view, wd->minw, git->h);
2468 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2469 evas_object_show(git->base.view);
2470 evas_object_raise(git->base.view);
2472 else if (!git->want_realize && git->realized)
2475 _item_unrealize(git);
2481 _must_recalc_idler(void *data)
2483 Widget_Data *wd = data;
2484 if (wd->calc_job) ecore_job_del(wd->calc_job);
2485 wd->calc_job = ecore_job_add(_calc_job, wd);
2486 wd->must_recalc_idler = NULL;
2487 return ECORE_CALLBACK_CANCEL;
2491 _calc_job(void *data)
2493 Widget_Data *wd = data;
2495 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2496 Item_Block *chb = NULL;
2497 int in = 0, minw_change = 0;
2498 Eina_Bool changed = EINA_FALSE;
2500 Eina_Bool did_must_recalc = EINA_FALSE;
2503 t0 = ecore_time_get();
2504 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2508 // if (wd->height_for_width) changed = EINA_TRUE;
2511 EINA_INLIST_FOREACH(wd->blocks, itb)
2513 Eina_Bool showme = EINA_FALSE;
2516 showme = itb->showme;
2517 itb->showme = EINA_FALSE;
2520 if (itb->realized) _item_block_unrealize(itb);
2522 if ((itb->changed) || (changed) ||
2523 ((itb->must_recalc) && (!did_must_recalc)))
2525 if ((changed) || (itb->must_recalc))
2528 Elm_Genlist_Item *it;
2529 EINA_LIST_FOREACH(itb->items, l, it)
2530 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2531 itb->changed = EINA_TRUE;
2532 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2533 itb->must_recalc = EINA_FALSE;
2535 if (itb->realized) _item_block_unrealize(itb);
2536 showme = _item_block_recalc(itb, in, 0, 1);
2542 if (minw == -1) minw = itb->minw;
2543 else if ((!itb->must_recalc) && (minw < itb->minw))
2552 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2554 wd->show_item->showme = EINA_FALSE;
2556 elm_smart_scroller_region_bring_in(wd->scr,
2558 wd->show_item->block->x,
2560 wd->show_item->block->y,
2561 wd->show_item->block->w,
2564 elm_smart_scroller_child_region_show(wd->scr,
2566 wd->show_item->block->x,
2568 wd->show_item->block->y,
2569 wd->show_item->block->w,
2571 wd->show_item = NULL;
2576 EINA_INLIST_FOREACH(wd->blocks, itb)
2582 if ((chb) && (EINA_INLIST_GET(chb)->next))
2584 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2586 if (itb->realized) _item_block_unrealize(itb);
2589 wd->realminw = minw;
2590 if (minw < wd->w) minw = wd->w;
2591 if ((minw != wd->minw) || (minh != wd->minh) || (wd->select_all_item))
2595 if (wd->select_all_item)
2596 wd->minh += wd->select_all_item->h;
2597 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2598 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2599 _sizing_eval(wd->obj);
2601 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2603 Elm_Genlist_Item *it;
2606 it = wd->anchor_item;
2607 it_y = wd->anchor_y;
2608 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2609 it->block->y + it->y + it_y);
2610 wd->anchor_item = it;
2611 wd->anchor_y = it_y;
2615 t = ecore_time_get();
2616 if (did_must_recalc)
2618 if (!wd->must_recalc_idler)
2619 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2621 wd->calc_job = NULL;
2622 evas_object_smart_changed(wd->pan_smart);
2626 _update_job(void *data)
2628 Widget_Data *wd = data;
2631 int num, num0, position = 0, recalc = 0;
2633 wd->update_job = NULL;
2635 EINA_INLIST_FOREACH(wd->blocks, itb)
2637 Evas_Coord itminw, itminh;
2638 Elm_Genlist_Item *it;
2644 _item_block_position(itb, num);
2649 EINA_LIST_FOREACH(itb->items, l2, it)
2656 it->updateme = EINA_FALSE;
2659 _item_unrealize(it);
2660 _item_realize(it, num, 0);
2665 _item_realize(it, num, 1);
2666 _item_unrealize(it);
2668 if ((it->minw != itminw) || (it->minh != itminh))
2673 itb->updateme = EINA_FALSE;
2677 itb->changed = EINA_TRUE;
2678 _item_block_recalc(itb, num0, 0, 1);
2679 _item_block_position(itb, num0);
2684 if (wd->calc_job) ecore_job_del(wd->calc_job);
2685 wd->calc_job = ecore_job_add(_calc_job, wd);
2690 _pan_set(Evas_Object *obj,
2694 Pan *sd = evas_object_smart_data_get(obj);
2697 // Evas_Coord ow, oh;
2698 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2699 // ow = sd->wd->minw - ow;
2700 // if (ow < 0) ow = 0;
2701 // oh = sd->wd->minh - oh;
2702 // if (oh < 0) oh = 0;
2703 // if (x < 0) x = 0;
2704 // if (y < 0) y = 0;
2705 // if (x > ow) x = ow;
2706 // if (y > oh) y = oh;
2707 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2712 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2714 if ((itb->y + itb->h) > y)
2716 Elm_Genlist_Item *it;
2719 EINA_LIST_FOREACH(itb->items, l2, it)
2721 if ((itb->y + it->y) >= y)
2723 sd->wd->anchor_item = it;
2724 sd->wd->anchor_y = -(itb->y + it->y - y);
2732 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2736 _pan_get(Evas_Object *obj,
2740 Pan *sd = evas_object_smart_data_get(obj);
2742 if (x) *x = sd->wd->pan_x;
2743 if (y) *y = sd->wd->pan_y;
2747 _pan_max_get(Evas_Object *obj,
2751 Pan *sd = evas_object_smart_data_get(obj);
2754 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2755 ow = sd->wd->minw - ow;
2757 oh = sd->wd->minh - oh;
2764 _pan_min_get(Evas_Object *obj __UNUSED__,
2773 _pan_child_size_get(Evas_Object *obj,
2777 Pan *sd = evas_object_smart_data_get(obj);
2779 if (w) *w = sd->wd->minw;
2780 if (h) *h = sd->wd->minh;
2784 _pan_add(Evas_Object *obj)
2787 Evas_Object_Smart_Clipped_Data *cd;
2790 cd = evas_object_smart_data_get(obj);
2793 sd->__clipped_data = *cd;
2795 evas_object_smart_data_set(obj, sd);
2799 _pan_del(Evas_Object *obj)
2801 Pan *sd = evas_object_smart_data_get(obj);
2806 ecore_job_del(sd->resize_job);
2807 sd->resize_job = NULL;
2813 _pan_resize_job(void *data)
2816 _sizing_eval(sd->wd->obj);
2817 sd->resize_job = NULL;
2821 _pan_resize(Evas_Object *obj,
2825 Pan *sd = evas_object_smart_data_get(obj);
2828 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2829 if ((ow == w) && (oh == h)) return;
2830 if ((sd->wd->height_for_width) && (ow != w))
2832 if (sd->resize_job) ecore_job_del(sd->resize_job);
2833 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2835 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2836 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2840 _pan_calculate(Evas_Object *obj)
2842 Pan *sd = evas_object_smart_data_get(obj);
2844 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2845 static Evas_Coord old_pan_y = 0;
2847 Elm_Genlist_Item *git;
2850 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2851 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2852 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2854 git->want_realize = EINA_FALSE;
2856 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2858 itb->w = sd->wd->minw;
2859 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2860 itb->y - sd->wd->pan_y + oy,
2862 cvx, cvy, cvw, cvh))
2864 if ((!itb->realized) || (itb->changed))
2865 _item_block_realize(itb, in, 0);
2866 _item_block_position(itb, in);
2870 if (itb->realized) _item_block_unrealize(itb);
2874 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2875 _group_items_recalc(sd->wd);
2877 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2879 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2880 else sd->wd->reorder_pan_move = EINA_FALSE;
2881 evas_object_raise(sd->wd->reorder_it->edit_obj);
2882 old_pan_y = sd->wd->pan_y;
2885 if (sd->wd->effect_mode &&
2886 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2887 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2888 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2890 if (!sd->wd->item_moving_effect_timer)
2892 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2893 _item_flip_effect_show(sd->wd->expand_item);
2895 evas_object_raise(sd->wd->alpha_bg);
2896 evas_object_show(sd->wd->alpha_bg);
2897 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2898 sd->wd->start_time = current_time_get();
2899 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2902 else _item_auto_scroll(sd->wd);
2903 if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view);
2907 _pan_move(Evas_Object *obj,
2908 Evas_Coord x __UNUSED__,
2909 Evas_Coord y __UNUSED__)
2911 Pan *sd = evas_object_smart_data_get(obj);
2913 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2914 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2918 _hold_on(void *data __UNUSED__,
2920 void *event_info __UNUSED__)
2922 Widget_Data *wd = elm_widget_data_get(obj);
2924 elm_smart_scroller_hold_set(wd->scr, 1);
2928 _hold_off(void *data __UNUSED__,
2930 void *event_info __UNUSED__)
2932 Widget_Data *wd = elm_widget_data_get(obj);
2934 elm_smart_scroller_hold_set(wd->scr, 0);
2938 _freeze_on(void *data __UNUSED__,
2940 void *event_info __UNUSED__)
2942 Widget_Data *wd = elm_widget_data_get(obj);
2944 elm_smart_scroller_freeze_set(wd->scr, 1);
2948 _freeze_off(void *data __UNUSED__,
2950 void *event_info __UNUSED__)
2952 Widget_Data *wd = elm_widget_data_get(obj);
2954 elm_smart_scroller_freeze_set(wd->scr, 0);
2958 _scroll_edge_left(void *data,
2959 Evas_Object *scr __UNUSED__,
2960 void *event_info __UNUSED__)
2962 Evas_Object *obj = data;
2963 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2967 _scroll_edge_right(void *data,
2968 Evas_Object *scr __UNUSED__,
2969 void *event_info __UNUSED__)
2971 Evas_Object *obj = data;
2972 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2976 _scroll_edge_top(void *data,
2977 Evas_Object *scr __UNUSED__,
2978 void *event_info __UNUSED__)
2980 Evas_Object *obj = data;
2981 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2985 _scroll_edge_bottom(void *data,
2986 Evas_Object *scr __UNUSED__,
2987 void *event_info __UNUSED__)
2989 Evas_Object *obj = data;
2990 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2994 * Add a new Genlist object
2996 * @param parent The parent object
2997 * @return The new object or NULL if it cannot be created
3002 elm_genlist_add(Evas_Object *parent)
3007 Evas_Coord minw, minh;
3008 static Evas_Smart *smart = NULL;
3010 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3014 static Evas_Smart_Class sc;
3016 evas_object_smart_clipped_smart_set(&_pan_sc);
3018 sc.name = "elm_genlist_pan";
3019 sc.version = EVAS_SMART_CLASS_VERSION;
3022 sc.resize = _pan_resize;
3023 sc.move = _pan_move;
3024 sc.calculate = _pan_calculate;
3025 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3027 wd = ELM_NEW(Widget_Data);
3028 e = evas_object_evas_get(parent);
3029 if (!e) return NULL;
3030 obj = elm_widget_add(e);
3031 ELM_SET_WIDTYPE(widtype, "genlist");
3032 elm_widget_type_set(obj, "genlist");
3033 elm_widget_sub_object_add(parent, obj);
3034 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3035 elm_widget_data_set(obj, wd);
3036 elm_widget_del_hook_set(obj, _del_hook);
3037 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3038 elm_widget_theme_hook_set(obj, _theme_hook);
3039 elm_widget_can_focus_set(obj, EINA_TRUE);
3040 elm_widget_event_hook_set(obj, _event_hook);
3041 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3043 wd->scr = elm_smart_scroller_add(e);
3044 elm_smart_scroller_widget_set(wd->scr, obj);
3045 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3046 elm_widget_style_get(obj));
3047 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3048 _elm_config->thumbscroll_bounce_enable);
3049 elm_widget_resize_object_set(obj, wd->scr);
3051 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3052 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3054 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3055 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3059 wd->mode = ELM_LIST_SCROLL;
3060 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3061 wd->item_cache_max = wd->max_items_per_block * 2;
3062 wd->longpress_timeout = _elm_config->longpress_timeout;
3063 //wd->effect_mode = _elm_config->effect_enable;
3064 // wd->effect_mode = EINA_TRUE;
3066 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3067 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3068 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3069 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3071 wd->pan_smart = evas_object_smart_add(e, smart);
3072 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3075 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3076 _pan_set, _pan_get, _pan_max_get,
3077 _pan_min_get, _pan_child_size_get);
3079 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3081 evas_object_size_hint_min_set(obj, minw, minh);
3087 static Elm_Genlist_Item *
3088 _item_new(Widget_Data *wd,
3089 const Elm_Genlist_Item_Class *itc,
3091 Elm_Genlist_Item *parent,
3092 Elm_Genlist_Item_Flags flags,
3094 const void *func_data)
3096 Elm_Genlist_Item *it;
3098 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3099 if (!it) return NULL;
3102 it->base.data = data;
3103 it->parent = parent;
3105 it->func.func = func;
3106 it->func.data = func_data;
3107 it->mouse_cursor = NULL;
3108 it->expanded_depth = 0;
3109 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3110 if ((!it->parent) && (it->wd->select_all_item))
3111 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE);
3112 it->num = ++wd->total_num; // todo : remov
3117 _item_block_add(Widget_Data *wd,
3118 Elm_Genlist_Item *it)
3120 Item_Block *itb = NULL;
3127 itb = calloc(1, sizeof(Item_Block));
3130 if (!it->rel->block)
3133 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3134 itb->items = eina_list_append(itb->items, it);
3140 wd->blocks = eina_inlist_prepend_relative
3141 (wd->blocks, EINA_INLIST_GET(itb),
3142 EINA_INLIST_GET(it->rel->block));
3144 eina_list_prepend_relative(itb->items, it, it->rel);
3148 wd->blocks = eina_inlist_append_relative
3149 (wd->blocks, EINA_INLIST_GET(itb),
3150 EINA_INLIST_GET(it->rel->block));
3152 eina_list_append_relative(itb->items, it, it->rel);
3162 itb = (Item_Block *)(wd->blocks);
3163 if (itb->count >= wd->max_items_per_block)
3165 itb = calloc(1, sizeof(Item_Block));
3169 eina_inlist_prepend(wd->blocks,
3170 EINA_INLIST_GET(itb));
3175 itb = calloc(1, sizeof(Item_Block));
3179 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3181 itb->items = eina_list_prepend(itb->items, it);
3187 itb = (Item_Block *)(wd->blocks->last);
3188 if (itb->count >= wd->max_items_per_block)
3190 itb = calloc(1, sizeof(Item_Block));
3194 eina_inlist_append(wd->blocks,
3195 EINA_INLIST_GET(itb));
3200 itb = calloc(1, sizeof(Item_Block));
3204 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3206 itb->items = eina_list_append(itb->items, it);
3212 itb = it->rel->block;
3213 if (!itb) goto newblock;
3215 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3217 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3220 itb->changed = EINA_TRUE;
3222 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3223 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3226 it->rel->relcount--;
3227 if ((it->rel->delete_me) && (!it->rel->relcount))
3231 if (itb->count > itb->wd->max_items_per_block)
3235 Elm_Genlist_Item *it2;
3237 newc = itb->count / 2;
3238 itb2 = calloc(1, sizeof(Item_Block));
3242 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3243 EINA_INLIST_GET(itb));
3244 itb2->changed = EINA_TRUE;
3245 while ((itb->count > newc) && (itb->items))
3249 l = eina_list_last(itb->items);
3251 itb->items = eina_list_remove_list(itb->items, l);
3254 itb2->items = eina_list_prepend(itb2->items, it2);
3262 _queue_proecess(Widget_Data *wd,
3266 Eina_Bool showme = EINA_FALSE;
3269 t0 = ecore_time_get();
3270 for (n = 0; (wd->queue) && (n < 128); n++)
3272 Elm_Genlist_Item *it;
3274 it = wd->queue->data;
3275 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3276 it->queued = EINA_FALSE;
3277 _item_block_add(wd, it);
3278 t = ecore_time_get();
3279 if (it->block->changed)
3281 showme = _item_block_recalc(it->block, it->block->num, 1,
3283 it->block->changed = 0;
3285 if (showme) it->block->showme = EINA_TRUE;
3286 if (eina_inlist_count(wd->blocks) > 1)
3288 if ((t - t0) > (ecore_animator_frametime_get())) break;
3295 _item_idler(void *data)
3297 Widget_Data *wd = data;
3300 //static double q_start = 0.0;
3301 //if (q_start == 0.0) q_start = ecore_time_get();
3304 if (_queue_proecess(wd, 1) > 0)
3306 if (wd->calc_job) ecore_job_del(wd->calc_job);
3307 wd->calc_job = ecore_job_add(_calc_job, wd);
3312 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3314 wd->queue_idler = NULL;
3315 return ECORE_CALLBACK_CANCEL;
3317 return ECORE_CALLBACK_RENEW;
3321 _item_queue(Widget_Data *wd,
3322 Elm_Genlist_Item *it)
3324 if (it->queued) return;
3325 it->queued = EINA_TRUE;
3326 wd->queue = eina_list_append(wd->queue, it);
3327 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3329 if (wd->queue_idler)
3331 ecore_idler_del(wd->queue_idler);
3332 wd->queue_idler = NULL;
3334 _queue_proecess(wd, 0);
3336 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3340 * Append item to the end of the genlist
3342 * This appends the given item to the end of the list or the end of
3343 * the children if the parent is given.
3345 * @param obj The genlist object
3346 * @param itc The item class for the item
3347 * @param data The item data
3348 * @param parent The parent item, or NULL if none
3349 * @param flags Item flags
3350 * @param func Convenience function called when item selected
3351 * @param func_data Data passed to @p func above.
3352 * @return A handle to the item added or NULL if not possible
3356 EAPI Elm_Genlist_Item *
3357 elm_genlist_item_append(Evas_Object *obj,
3358 const Elm_Genlist_Item_Class *itc,
3360 Elm_Genlist_Item *parent,
3361 Elm_Genlist_Item_Flags flags,
3363 const void *func_data)
3365 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3366 Widget_Data *wd = elm_widget_data_get(obj);
3367 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3369 if (!wd) return NULL;
3370 if (!it) return NULL;
3373 if (flags & ELM_GENLIST_ITEM_GROUP)
3374 wd->group_items = eina_list_append(wd->group_items, it);
3375 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3380 Elm_Genlist_Item *it2 = NULL;
3381 Eina_List *ll = eina_list_last(it->parent->items);
3382 if (ll) it2 = ll->data;
3383 it->parent->items = eina_list_append(it->parent->items, it);
3384 if (!it2) it2 = it->parent;
3386 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3387 EINA_INLIST_GET(it2));
3389 it->rel->relcount++;
3391 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3392 it->group_item = parent;
3393 else if (it->parent->group_item)
3394 it->group_item = it->parent->group_item;
3396 it->before = EINA_FALSE;
3397 _item_queue(wd, it);
3402 * Prepend item at start of the genlist
3404 * This adds an item to the beginning of the list or beginning of the
3405 * children of the parent if given.
3407 * @param obj The genlist object
3408 * @param itc The item class for the item
3409 * @param data The item data
3410 * @param parent The parent item, or NULL if none
3411 * @param flags Item flags
3412 * @param func Convenience function called when item selected
3413 * @param func_data Data passed to @p func above.
3414 * @return A handle to the item added or NULL if not possible
3418 EAPI Elm_Genlist_Item *
3419 elm_genlist_item_prepend(Evas_Object *obj,
3420 const Elm_Genlist_Item_Class *itc,
3422 Elm_Genlist_Item *parent,
3423 Elm_Genlist_Item_Flags flags,
3425 const void *func_data)
3427 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3428 Widget_Data *wd = elm_widget_data_get(obj);
3429 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3431 if (!wd) return NULL;
3432 if (!it) return NULL;
3435 if (flags & ELM_GENLIST_ITEM_GROUP)
3436 wd->group_items = eina_list_prepend(wd->group_items, it);
3437 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3442 Elm_Genlist_Item *it2 = NULL;
3443 Eina_List *ll = it->parent->items;
3444 if (ll) it2 = ll->data;
3445 it->parent->items = eina_list_prepend(it->parent->items, it);
3446 if (!it2) it2 = it->parent;
3448 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3449 EINA_INLIST_GET(it2));
3451 it->rel->relcount++;
3453 it->before = EINA_TRUE;
3454 _item_queue(wd, it);
3459 * Insert item before another in the genlist
3461 * This inserts an item before another in the list. It will be in the
3462 * same tree level or group as the item it is inseted before.
3464 * @param obj The genlist object
3465 * @param itc The item class for the item
3466 * @param data The item data
3467 * @param before The item to insert before
3468 * @param flags Item flags
3469 * @param func Convenience function called when item selected
3470 * @param func_data Data passed to @p func above.
3471 * @return A handle to the item added or NULL if not possible
3475 EAPI Elm_Genlist_Item *
3476 elm_genlist_item_insert_before(Evas_Object *obj,
3477 const Elm_Genlist_Item_Class *itc,
3479 Elm_Genlist_Item *parent,
3480 Elm_Genlist_Item *before,
3481 Elm_Genlist_Item_Flags flags,
3483 const void *func_data)
3485 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3486 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3487 Widget_Data *wd = elm_widget_data_get(obj);
3488 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3490 if (!wd) return NULL;
3491 if (!it) return NULL;
3494 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3497 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3498 EINA_INLIST_GET(before));
3500 it->rel->relcount++;
3501 it->before = EINA_TRUE;
3502 _item_queue(wd, it);
3507 * Insert an item after another in the genlst
3509 * This inserts an item after another in the list. It will be in the
3510 * same tree level or group as the item it is inseted after.
3512 * @param obj The genlist object
3513 * @param itc The item class for the item
3514 * @param data The item data
3515 * @param after The item to insert after
3516 * @param flags Item flags
3517 * @param func Convenience function called when item selected
3518 * @param func_data Data passed to @p func above.
3519 * @return A handle to the item added or NULL if not possible
3523 EAPI Elm_Genlist_Item *
3524 elm_genlist_item_insert_after(Evas_Object *obj,
3525 const Elm_Genlist_Item_Class *itc,
3527 Elm_Genlist_Item *parent,
3528 Elm_Genlist_Item *after,
3529 Elm_Genlist_Item_Flags flags,
3531 const void *func_data)
3533 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3534 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3535 Widget_Data *wd = elm_widget_data_get(obj);
3536 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3538 if (!wd) return NULL;
3539 if (!it) return NULL;
3540 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3541 EINA_INLIST_GET(after));
3544 it->parent->items = eina_list_append_relative(it->parent->items, it,
3548 it->rel->relcount++;
3549 it->before = EINA_FALSE;
3550 _item_queue(wd, it);
3557 * This clears all items in the list, leaving it empty.
3559 * @param obj The genlist object
3564 elm_genlist_clear(Evas_Object *obj)
3566 ELM_CHECK_WIDTYPE(obj, widtype);
3567 Widget_Data *wd = elm_widget_data_get(obj);
3569 if (wd->walking > 0)
3571 Elm_Genlist_Item *it;
3573 wd->clear_me = EINA_TRUE;
3574 EINA_INLIST_FOREACH(wd->items, it)
3576 it->delete_me = EINA_TRUE;
3580 wd->clear_me = EINA_FALSE;
3583 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3584 it->nocache = EINA_TRUE;
3585 it->hilighted = EINA_FALSE;
3587 if (wd->anchor_item == it)
3589 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3590 if (!wd->anchor_item)
3592 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3595 wd->items = eina_inlist_remove(wd->items, wd->items);
3596 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3597 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3598 elm_widget_item_pre_notify_del(it);
3599 if (it->effect_item_realized) _effect_item_unrealize(it);
3600 if (it->realized) _item_unrealize(it);
3601 if (it->itc->func.del)
3602 it->itc->func.del((void *)it->base.data, it->base.widget);
3603 if (it->long_timer) ecore_timer_del(it->long_timer);
3604 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3605 elm_widget_item_del(it);
3607 wd->anchor_item = NULL;
3610 Item_Block *itb = (Item_Block *)(wd->blocks);
3612 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3613 if (itb->items) eina_list_free(itb->items);
3618 ecore_job_del(wd->calc_job);
3619 wd->calc_job = NULL;
3621 if (wd->queue_idler)
3623 ecore_idler_del(wd->queue_idler);
3624 wd->queue_idler = NULL;
3626 if (wd->must_recalc_idler)
3628 ecore_idler_del(wd->must_recalc_idler);
3629 wd->must_recalc_idler = NULL;
3633 eina_list_free(wd->queue);
3638 eina_list_free(wd->selected);
3639 wd->selected = NULL;
3643 Evas_Object *editfield;
3644 EINA_LIST_FREE(wd->edit_field, editfield)
3645 evas_object_del(editfield);
3646 wd->edit_field = NULL;
3648 if (wd->item_moving_effect_timer)
3650 ecore_animator_del(wd->item_moving_effect_timer);
3651 wd->item_moving_effect_timer = NULL;
3653 wd->show_item = NULL;
3660 evas_object_del(wd->alpha_bg);
3661 wd->alpha_bg = NULL;
3665 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3666 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3672 * Enable or disable multi-select in the genlist
3674 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3675 * the list. This allows more than 1 item to be selected.
3677 * @param obj The genlist object
3678 * @param multi Multi-select enable/disable
3683 elm_genlist_multi_select_set(Evas_Object *obj,
3686 ELM_CHECK_WIDTYPE(obj, widtype);
3687 Widget_Data *wd = elm_widget_data_get(obj);
3693 * Gets if multi-select in genlist is enable or disable
3695 * @param obj The genlist object
3696 * @return Multi-select enable/disable
3697 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3702 elm_genlist_multi_select_get(const Evas_Object *obj)
3704 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3705 Widget_Data *wd = elm_widget_data_get(obj);
3706 if (!wd) return EINA_FALSE;
3711 * Get the selectd item in the genlist
3713 * This gets the selected item in the list (if multi-select is enabled
3714 * only the first item in the list is selected - which is not very
3715 * useful, so see elm_genlist_selected_items_get() for when
3716 * multi-select is used).
3718 * If no item is selected, NULL is returned.
3720 * @param obj The genlist object
3721 * @return The selected item, or NULL if none.
3725 EAPI Elm_Genlist_Item *
3726 elm_genlist_selected_item_get(const Evas_Object *obj)
3728 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3729 Widget_Data *wd = elm_widget_data_get(obj);
3730 if (!wd) return NULL;
3731 if (wd->selected) return wd->selected->data;
3736 * Get a list of selected items in the genlist
3738 * This returns a list of the selected items. This list pointer is
3739 * only valid so long as no items are selected or unselected (or
3740 * unselected implicitly by deletion). The list contains
3741 * Elm_Genlist_Item pointers.
3743 * @param obj The genlist object
3744 * @return The list of selected items, nor NULL if none are selected.
3748 EAPI const Eina_List *
3749 elm_genlist_selected_items_get(const Evas_Object *obj)
3751 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3752 Widget_Data *wd = elm_widget_data_get(obj);
3753 if (!wd) return NULL;
3754 return wd->selected;
3758 * Get a list of realized items in genlist
3760 * This returns a list of the realized items in the genlist. The list
3761 * contains Elm_Genlist_Item pointers. The list must be freed by the
3762 * caller when done with eina_list_free(). The item pointers in the
3763 * list are only valid so long as those items are not deleted or the
3764 * genlist is not deleted.
3766 * @param obj The genlist object
3767 * @return The list of realized items, nor NULL if none are realized.
3772 elm_genlist_realized_items_get(const Evas_Object *obj)
3774 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3775 Widget_Data *wd = elm_widget_data_get(obj);
3776 Eina_List *list = NULL;
3778 Eina_Bool done = EINA_FALSE;
3779 if (!wd) return NULL;
3780 EINA_INLIST_FOREACH(wd->blocks, itb)
3785 Elm_Genlist_Item *it;
3788 EINA_LIST_FOREACH(itb->items, l, it)
3790 if (it->realized) list = eina_list_append(list, it);
3802 * Get the item that is at the x, y canvas coords
3804 * This returns the item at the given coordinates (which are canvas
3805 * relative not object-relative). If an item is at that coordinate,
3806 * that item handle is returned, and if @p posret is not NULL, the
3807 * integer pointed to is set to a value of -1, 0 or 1, depending if
3808 * the coordinate is on the upper portion of that item (-1), on the
3809 * middle section (0) or on the lower part (1). If NULL is returned as
3810 * an item (no item found there), then posret may indicate -1 or 1
3811 * based if the coordinate is above or below all items respectively in
3814 * @param it The item
3815 * @param x The input x coordinate
3816 * @param y The input y coordinate
3817 * @param posret The position relative to the item returned here
3818 * @return The item at the coordinates or NULL if none
3822 EAPI Elm_Genlist_Item *
3823 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3828 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3829 Widget_Data *wd = elm_widget_data_get(obj);
3830 Evas_Coord ox, oy, ow, oh;
3833 if (!wd) return NULL;
3834 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3836 EINA_INLIST_FOREACH(wd->blocks, itb)
3839 Elm_Genlist_Item *it;
3841 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3842 oy + itb->y - itb->wd->pan_y,
3843 itb->w, itb->h, x, y, 1, 1))
3845 EINA_LIST_FOREACH(itb->items, l, it)
3847 Evas_Coord itx, ity;
3849 itx = ox + itb->x + it->x - itb->wd->pan_x;
3850 ity = oy + itb->y + it->y - itb->wd->pan_y;
3851 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3855 if (y <= (ity + (it->h / 4))) *posret = -1;
3856 else if (y >= (ity + it->h - (it->h / 4)))
3862 lasty = ity + it->h;
3867 if (y > lasty) *posret = 1;
3874 * Get the first item in the genlist
3876 * This returns the first item in the list.
3878 * @param obj The genlist object
3879 * @return The first item, or NULL if none
3883 EAPI Elm_Genlist_Item *
3884 elm_genlist_first_item_get(const Evas_Object *obj)
3886 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3887 Widget_Data *wd = elm_widget_data_get(obj);
3888 if (!wd) return NULL;
3889 if (!wd->items) return NULL;
3890 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3891 while ((it) && (it->delete_me))
3892 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3897 * Get the last item in the genlist
3899 * This returns the last item in the list.
3901 * @return The last item, or NULL if none
3905 EAPI Elm_Genlist_Item *
3906 elm_genlist_last_item_get(const Evas_Object *obj)
3908 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3909 Widget_Data *wd = elm_widget_data_get(obj);
3910 if (!wd) return NULL;
3911 if (!wd->items) return NULL;
3912 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3913 while ((it) && (it->delete_me))
3914 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3919 * Get the next item in the genlist
3921 * This returns the item after the item @p it.
3923 * @param it The item
3924 * @return The item after @p it, or NULL if none
3928 EAPI Elm_Genlist_Item *
3929 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3931 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3934 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3935 if ((it) && (!it->delete_me)) break;
3937 return (Elm_Genlist_Item *)it;
3941 * Get the previous item in the genlist
3943 * This returns the item before the item @p it.
3945 * @param it The item
3946 * @return The item before @p it, or NULL if none
3950 EAPI Elm_Genlist_Item *
3951 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3953 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3956 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3957 if ((it) && (!it->delete_me)) break;
3959 return (Elm_Genlist_Item *)it;
3963 * Get the genlist object from an item
3965 * This returns the genlist object itself that an item belongs to.
3967 * @param it The item
3968 * @return The genlist object
3973 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3975 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3976 return it->base.widget;
3980 * Get the parent item of the given item
3982 * This returns the parent item of the item @p it given.
3984 * @param it The item
3985 * @return The parent of the item or NULL if none
3989 EAPI Elm_Genlist_Item *
3990 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3992 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3997 * Clear all sub-items (children) of the given item
3999 * This clears all items that are children (or their descendants) of the
4002 * @param it The item
4007 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4009 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4010 Elm_Genlist_Item *it2;
4013 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4014 _item_subitems_clear(it);
4017 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4018 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4020 it->wd->expand_item = it;
4021 _item_flip_effect_show(it);
4022 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4023 it->wd->expand_item_end = y + h;
4027 it2 = elm_genlist_item_next_get(it2);
4029 } while (it2->expanded_depth > it->expanded_depth);
4031 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4033 it->wd->expand_item_gap = 0;
4035 evas_object_raise(it->wd->alpha_bg);
4036 evas_object_show(it->wd->alpha_bg);
4038 it->wd->start_time = current_time_get();
4039 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4042 _item_subitems_clear(it);
4047 * Set the selected state of an item
4049 * This sets the selected state (1 selected, 0 not selected) of the given
4052 * @param it The item
4053 * @param selected The selected state
4058 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4061 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4062 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4064 if (it->delete_me) return;
4065 selected = !!selected;
4066 if (it->selected == selected) return;
4072 while (wd->selected)
4073 _item_unselect(wd->selected->data);
4083 * Get the selected state of an item
4085 * This gets the selected state of an item (1 selected, 0 not selected).
4087 * @param it The item
4088 * @return The selected state
4093 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4095 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4096 return it->selected;
4100 * Sets the expanded state of an item (if it's a parent)
4102 * This expands or contracts a parent item (thus showing or hiding the
4105 * @param it The item
4106 * @param expanded The expanded state (1 expanded, 0 not expanded).
4111 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4114 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4115 if (it->expanded == expanded) return;
4116 it->expanded = expanded;
4117 it->wd->expand_item = it;
4119 if(it->wd->effect_mode && !it->wd->alpha_bg)
4120 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4124 it->wd->auto_scrolled = EINA_FALSE;
4125 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4127 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4128 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4132 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4134 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4135 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4140 * Get the expanded state of an item
4142 * This gets the expanded state of an item
4144 * @param it The item
4145 * @return Thre expanded state
4150 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4152 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4153 return it->expanded;
4157 * Get the depth of expanded item
4159 * @param it The genlist item object
4160 * @return The depth of expanded item
4165 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4167 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4168 return it->expanded_depth;
4172 * Sets the disabled state of an item.
4174 * A disabled item cannot be selected or unselected. It will also
4175 * change appearance to appear disabled. This sets the disabled state
4176 * (1 disabled, 0 not disabled).
4178 * @param it The item
4179 * @param disabled The disabled state
4184 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4187 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4188 if (it->disabled == disabled) return;
4189 if (it->delete_me) return;
4190 it->disabled = disabled;
4194 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4196 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4201 * Get the disabled state of an item
4203 * This gets the disabled state of the given item.
4205 * @param it The item
4206 * @return The disabled state
4211 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4213 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4214 if (it->delete_me) return EINA_FALSE;
4215 return it->disabled;
4219 * Sets the display only state of an item.
4221 * A display only item cannot be selected or unselected. It is for
4222 * display only and not selecting or otherwise clicking, dragging
4223 * etc. by the user, thus finger size rules will not be applied to
4226 * @param it The item
4227 * @param display_only The display only state
4232 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4233 Eina_Bool display_only)
4235 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4236 if (!it->block) return;
4237 if (it->display_only == display_only) return;
4238 if (it->delete_me) return;
4239 it->display_only = display_only;
4240 it->mincalcd = EINA_FALSE;
4241 it->updateme = EINA_TRUE;
4242 it->block->updateme = EINA_TRUE;
4243 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4244 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4248 * Get the display only state of an item
4250 * This gets the display only state of the given item.
4252 * @param it The item
4253 * @return The display only state
4258 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4260 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4261 if (it->delete_me) return EINA_FALSE;
4262 return it->display_only;
4266 * Show the given item
4268 * This causes genlist to jump to the given item @p it and show it (by
4269 * scrolling), if it is not fully visible.
4271 * @param it The item
4276 elm_genlist_item_show(Elm_Genlist_Item *it)
4278 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4279 Evas_Coord gith = 0;
4280 if (it->delete_me) return;
4281 if ((it->queued) || (!it->mincalcd))
4283 it->wd->show_item = it;
4284 it->wd->bring_in = EINA_TRUE;
4285 it->showme = EINA_TRUE;
4288 if (it->wd->show_item)
4290 it->wd->show_item->showme = EINA_FALSE;
4291 it->wd->show_item = NULL;
4293 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4294 gith = it->group_item->h;
4295 elm_smart_scroller_child_region_show(it->wd->scr,
4296 it->x + it->block->x,
4297 it->y + it->block->y - gith,
4298 it->block->w, it->h);
4302 * Bring in the given item
4304 * This causes genlist to jump to the given item @p it and show it (by
4305 * scrolling), if it is not fully visible. This may use animation to
4306 * do so and take a period of time
4308 * @param it The item
4313 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4315 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4316 Evas_Coord gith = 0;
4317 if (it->delete_me) return;
4318 if ((it->queued) || (!it->mincalcd))
4320 it->wd->show_item = it;
4321 it->wd->bring_in = EINA_TRUE;
4322 it->showme = EINA_TRUE;
4325 if (it->wd->show_item)
4327 it->wd->show_item->showme = EINA_FALSE;
4328 it->wd->show_item = NULL;
4330 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4331 gith = it->group_item->h;
4332 elm_smart_scroller_region_bring_in(it->wd->scr,
4333 it->x + it->block->x,
4334 it->y + it->block->y - gith,
4335 it->block->w, it->h);
4339 * Show the given item at the top
4341 * This causes genlist to jump to the given item @p it and show it (by
4342 * scrolling), if it is not fully visible.
4344 * @param it The item
4349 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4351 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4353 Evas_Coord gith = 0;
4355 if (it->delete_me) return;
4356 if ((it->queued) || (!it->mincalcd))
4358 it->wd->show_item = it;
4359 it->wd->bring_in = EINA_TRUE;
4360 it->showme = EINA_TRUE;
4363 if (it->wd->show_item)
4365 it->wd->show_item->showme = EINA_FALSE;
4366 it->wd->show_item = NULL;
4368 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4369 if (it->group_item) gith = it->group_item->h;
4370 elm_smart_scroller_child_region_show(it->wd->scr,
4371 it->x + it->block->x,
4372 it->y + it->block->y - gith,
4377 * Bring in the given item at the top
4379 * This causes genlist to jump to the given item @p it and show it (by
4380 * scrolling), if it is not fully visible. This may use animation to
4381 * do so and take a period of time
4383 * @param it The item
4388 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4390 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4392 Evas_Coord gith = 0;
4394 if (it->delete_me) return;
4395 if ((it->queued) || (!it->mincalcd))
4397 it->wd->show_item = it;
4398 it->wd->bring_in = EINA_TRUE;
4399 it->showme = EINA_TRUE;
4402 if (it->wd->show_item)
4404 it->wd->show_item->showme = EINA_FALSE;
4405 it->wd->show_item = NULL;
4407 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4408 if (it->group_item) gith = it->group_item->h;
4409 elm_smart_scroller_region_bring_in(it->wd->scr,
4410 it->x + it->block->x,
4411 it->y + it->block->y - gith,
4416 * Show the given item at the middle
4418 * This causes genlist to jump to the given item @p it and show it (by
4419 * scrolling), if it is not fully visible.
4421 * @param it The item
4426 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4428 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4431 if (it->delete_me) return;
4432 if ((it->queued) || (!it->mincalcd))
4434 it->wd->show_item = it;
4435 it->wd->bring_in = EINA_TRUE;
4436 it->showme = EINA_TRUE;
4439 if (it->wd->show_item)
4441 it->wd->show_item->showme = EINA_FALSE;
4442 it->wd->show_item = NULL;
4444 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4445 elm_smart_scroller_child_region_show(it->wd->scr,
4446 it->x + it->block->x,
4447 it->y + it->block->y - oh / 2 +
4448 it->h / 2, it->block->w, oh);
4452 * Bring in the given item at the middle
4454 * This causes genlist to jump to the given item @p it and show it (by
4455 * scrolling), if it is not fully visible. This may use animation to
4456 * do so and take a period of time
4458 * @param it The item
4463 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4465 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4468 if (it->delete_me) return;
4469 if ((it->queued) || (!it->mincalcd))
4471 it->wd->show_item = it;
4472 it->wd->bring_in = EINA_TRUE;
4473 it->showme = EINA_TRUE;
4476 if (it->wd->show_item)
4478 it->wd->show_item->showme = EINA_FALSE;
4479 it->wd->show_item = NULL;
4481 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4482 elm_smart_scroller_region_bring_in(it->wd->scr,
4483 it->x + it->block->x,
4484 it->y + it->block->y - oh / 2 + it->h / 2,
4489 * Delete a given item
4491 * This deletes the item from genlist and calls the genlist item del
4492 * class callback defined in the item class, if it is set. This clears all
4493 * subitems if it is a tree.
4495 * @param it The item
4500 elm_genlist_item_del(Elm_Genlist_Item *it)
4502 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4503 if ((it->relcount > 0) || (it->walking > 0))
4505 elm_widget_item_pre_notify_del(it);
4506 elm_genlist_item_subitems_clear(it);
4507 it->delete_me = EINA_TRUE;
4508 if (it->wd->show_item == it) it->wd->show_item = NULL;
4510 it->wd->selected = eina_list_remove(it->wd->selected,
4514 if (it->realized) _item_unrealize(it);
4515 if (it->effect_item_realized) _effect_item_unrealize(it);
4516 it->block->changed = EINA_TRUE;
4517 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4518 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4520 // if (it->itc->func.del)
4521 // it->itc->func.del((void *)it->base.data, it->base.widget);
4528 * Set the data item from the genlist item
4530 * This set the data value passed on the elm_genlist_item_append() and
4531 * related item addition calls. This function will also call
4532 * elm_genlist_item_update() so the item will be updated to reflect the
4535 * @param it The item
4536 * @param data The new data pointer to set
4541 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4545 elm_widget_item_data_set(it, data);
4546 elm_genlist_item_update(it);
4550 * Get the data item from the genlist item
4552 * This returns the data value passed on the elm_genlist_item_append()
4553 * and related item addition calls and elm_genlist_item_data_set().
4555 * @param it The item
4556 * @return The data pointer provided when created
4561 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4563 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4564 return elm_widget_item_data_get(it);
4568 * Tells genlist to "orphan" icons fetchs by the item class
4570 * This instructs genlist to release references to icons in the item,
4571 * meaning that they will no longer be managed by genlist and are
4572 * floating "orphans" that can be re-used elsewhere if the user wants
4575 * @param it The item
4580 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4583 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4584 EINA_LIST_FREE(it->icon_objs, icon)
4586 elm_widget_sub_object_del(it->base.widget, icon);
4587 evas_object_smart_member_del(icon);
4588 evas_object_hide(icon);
4593 * Get the real evas object of the genlist item
4595 * This returns the actual evas object used for the specified genlist
4596 * item. This may be NULL as it may not be created, and may be deleted
4597 * at any time by genlist. Do not modify this object (move, resize,
4598 * show, hide etc.) as genlist is controlling it. This function is for
4599 * querying, emitting custom signals or hooking lower level callbacks
4600 * for events. Do not delete this object under any circumstances.
4602 * @param it The item
4603 * @return The object pointer
4607 EAPI const Evas_Object *
4608 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4610 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4611 return it->base.view;
4615 * Update the contents of an item
4617 * This updates an item by calling all the item class functions again
4618 * to get the icons, labels and states. Use this when the original
4619 * item data has changed and the changes are desired to be reflected.
4621 * @param it The item
4626 elm_genlist_item_update(Elm_Genlist_Item *it)
4628 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4629 if (!it->block) return;
4630 if (it->delete_me) return;
4631 it->mincalcd = EINA_FALSE;
4632 it->updateme = EINA_TRUE;
4633 it->block->updateme = EINA_TRUE;
4634 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4635 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4639 * Update the item class of an item
4641 * @param it The item
4642 * @parem itc The item class for the item
4647 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4648 const Elm_Genlist_Item_Class *itc)
4650 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4651 if (!it->block) return;
4652 EINA_SAFETY_ON_NULL_RETURN(itc);
4653 if (it->delete_me) return;
4655 it->nocache = EINA_TRUE;
4656 elm_genlist_item_update(it);
4659 static Evas_Object *
4660 _elm_genlist_item_label_create(void *data,
4662 void *item __UNUSED__)
4664 Evas_Object *label = elm_label_add(obj);
4667 elm_object_style_set(label, "tooltip");
4668 elm_label_label_set(label, data);
4673 _elm_genlist_item_label_del_cb(void *data,
4674 Evas_Object *obj __UNUSED__,
4675 void *event_info __UNUSED__)
4677 eina_stringshare_del(data);
4681 * Set the text to be shown in the genlist item.
4683 * @param item Target item
4684 * @param text The text to set in the content
4686 * Setup the text as tooltip to object. The item can have only one
4687 * tooltip, so any previous tooltip data is removed.
4692 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4695 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4696 text = eina_stringshare_add(text);
4697 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4699 _elm_genlist_item_label_del_cb);
4703 * Set the content to be shown in the tooltip item
4705 * Setup the tooltip to item. The item can have only one tooltip, so
4706 * any previous tooltip data is removed. @p func(with @p data) will be
4707 * called every time that need to show the tooltip and it should return a
4708 * valid Evas_Object. This object is then managed fully by tooltip
4709 * system and is deleted when the tooltip is gone.
4711 * @param item the genlist item being attached by a tooltip.
4712 * @param func the function used to create the tooltip contents.
4713 * @param data what to provide to @a func as callback data/context.
4714 * @param del_cb called when data is not needed anymore, either when
4715 * another callback replaces @func, the tooltip is unset with
4716 * elm_genlist_item_tooltip_unset() or the owner @a item
4717 * dies. This callback receives as the first parameter the
4718 * given @a data, and @c event_info is the item.
4723 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4724 Elm_Tooltip_Item_Content_Cb func,
4726 Evas_Smart_Cb del_cb)
4728 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4730 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4733 if (item->tooltip.del_cb)
4734 item->tooltip.del_cb((void *)item->tooltip.data,
4735 item->base.widget, item);
4737 item->tooltip.content_cb = func;
4738 item->tooltip.data = data;
4739 item->tooltip.del_cb = del_cb;
4741 if (item->base.view)
4743 elm_widget_item_tooltip_content_cb_set(item,
4744 item->tooltip.content_cb,
4745 item->tooltip.data, NULL);
4746 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4752 if (del_cb) del_cb((void *)data, NULL, NULL);
4756 * Unset tooltip from item
4758 * @param item genlist item to remove previously set tooltip.
4760 * Remove tooltip from item. The callback provided as del_cb to
4761 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4762 * it is not used anymore.
4764 * @see elm_genlist_item_tooltip_content_cb_set()
4769 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4771 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4772 if ((item->base.view) && (item->tooltip.content_cb))
4773 elm_widget_item_tooltip_unset(item);
4775 if (item->tooltip.del_cb)
4776 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4777 item->tooltip.del_cb = NULL;
4778 item->tooltip.content_cb = NULL;
4779 item->tooltip.data = NULL;
4780 if (item->tooltip.style)
4781 elm_genlist_item_tooltip_style_set(item, NULL);
4785 * Sets a different style for this item tooltip.
4787 * @note before you set a style you should define a tooltip with
4788 * elm_genlist_item_tooltip_content_cb_set() or
4789 * elm_genlist_item_tooltip_text_set()
4791 * @param item genlist item with tooltip already set.
4792 * @param style the theme style to use (default, transparent, ...)
4797 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4800 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4801 eina_stringshare_replace(&item->tooltip.style, style);
4802 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4806 * Get the style for this item tooltip.
4808 * @param item genlist item with tooltip already set.
4809 * @return style the theme style in use, defaults to "default". If the
4810 * object does not have a tooltip set, then NULL is returned.
4815 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4818 return item->tooltip.style;
4822 * Set the cursor to be shown when mouse is over the genlist item
4824 * @param item Target item
4825 * @param cursor the cursor name to be used.
4827 * @see elm_object_cursor_set()
4831 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4834 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4835 eina_stringshare_replace(&item->mouse_cursor, cursor);
4836 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4840 * Get the cursor to be shown when mouse is over the genlist item
4842 * @param item genlist item with cursor already set.
4843 * @return the cursor name.
4848 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4850 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4851 return elm_widget_item_cursor_get(item);
4855 * Unset the cursor to be shown when mouse is over the genlist item
4857 * @param item Target item
4859 * @see elm_object_cursor_unset()
4863 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4865 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4866 if (!item->mouse_cursor)
4869 if (item->base.view)
4870 elm_widget_item_cursor_unset(item);
4872 eina_stringshare_del(item->mouse_cursor);
4873 item->mouse_cursor = NULL;
4877 * Sets a different style for this item cursor.
4879 * @note before you set a style you should define a cursor with
4880 * elm_genlist_item_cursor_set()
4882 * @param item genlist item with cursor already set.
4883 * @param style the theme style to use (default, transparent, ...)
4888 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4891 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4892 elm_widget_item_cursor_style_set(item, style);
4896 * Get the style for this item cursor.
4898 * @param item genlist item with cursor already set.
4899 * @return style the theme style in use, defaults to "default". If the
4900 * object does not have a cursor set, then NULL is returned.
4905 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4907 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4908 return elm_widget_item_cursor_style_get(item);
4912 * Set if the cursor set should be searched on the theme or should use
4913 * the provided by the engine, only.
4915 * @note before you set if should look on theme you should define a
4916 * cursor with elm_object_cursor_set(). By default it will only look
4917 * for cursors provided by the engine.
4919 * @param item widget item with cursor already set.
4920 * @param engine_only boolean to define it cursors should be looked
4921 * only between the provided by the engine or searched on widget's
4927 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4928 Eina_Bool engine_only)
4930 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4931 elm_widget_item_cursor_engine_only_set(item, engine_only);
4935 * Get the cursor engine only usage for this item cursor.
4937 * @param item widget item with cursor already set.
4938 * @return engine_only boolean to define it cursors should be looked
4939 * only between the provided by the engine or searched on widget's
4940 * theme as well. If the object does not have a cursor set, then
4941 * EINA_FALSE is returned.
4946 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4948 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4949 return elm_widget_item_cursor_engine_only_get(item);
4953 * This sets the horizontal stretching mode
4955 * This sets the mode used for sizing items horizontally. Valid modes
4956 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4957 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4958 * the scroller will scroll horizontally. Otherwise items are expanded
4959 * to fill the width of the viewport of the scroller. If it is
4960 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4961 * limited to that size.
4963 * @param obj The genlist object
4964 * @param mode The mode to use
4969 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4972 ELM_CHECK_WIDTYPE(obj, widtype);
4973 Widget_Data *wd = elm_widget_data_get(obj);
4975 if (wd->mode == mode) return;
4981 * Gets the horizontal stretching mode
4983 * @param obj The genlist object
4984 * @return The mode to use
4985 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4990 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4992 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4993 Widget_Data *wd = elm_widget_data_get(obj);
4994 if (!wd) return ELM_LIST_LAST;
4999 * Set the always select mode.
5001 * Items will only call their selection func and callback when first
5002 * becoming selected. Any further clicks will do nothing, unless you
5003 * enable always select with elm_genlist_always_select_mode_set().
5004 * This means even if selected, every click will make the selected
5005 * callbacks be called.
5007 * @param obj The genlist object
5008 * @param always_select The always select mode
5009 * (EINA_TRUE = on, EINA_FALSE = off)
5014 elm_genlist_always_select_mode_set(Evas_Object *obj,
5015 Eina_Bool always_select)
5017 ELM_CHECK_WIDTYPE(obj, widtype);
5018 Widget_Data *wd = elm_widget_data_get(obj);
5020 wd->always_select = always_select;
5024 * Get the always select mode.
5026 * @param obj The genlist object
5027 * @return The always select mode
5028 * (EINA_TRUE = on, EINA_FALSE = off)
5033 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5035 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5036 Widget_Data *wd = elm_widget_data_get(obj);
5037 if (!wd) return EINA_FALSE;
5038 return wd->always_select;
5042 * Set no select mode
5044 * This will turn off the ability to select items entirely and they
5045 * will neither appear selected nor call selected callback functions.
5047 * @param obj The genlist object
5048 * @param no_select The no select mode
5049 * (EINA_TRUE = on, EINA_FALSE = off)
5054 elm_genlist_no_select_mode_set(Evas_Object *obj,
5055 Eina_Bool no_select)
5057 ELM_CHECK_WIDTYPE(obj, widtype);
5058 Widget_Data *wd = elm_widget_data_get(obj);
5060 wd->no_select = no_select;
5064 * Gets no select mode
5066 * @param obj The genlist object
5067 * @return The no select mode
5068 * (EINA_TRUE = on, EINA_FALSE = off)
5073 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5075 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5076 Widget_Data *wd = elm_widget_data_get(obj);
5077 if (!wd) return EINA_FALSE;
5078 return wd->no_select;
5084 * This will enable the compress mode where items are "compressed"
5085 * horizontally to fit the genlist scrollable viewport width. This is
5086 * special for genlist. Do not rely on
5087 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5088 * work as genlist needs to handle it specially.
5090 * @param obj The genlist object
5091 * @param compress The compress mode
5092 * (EINA_TRUE = on, EINA_FALSE = off)
5097 elm_genlist_compress_mode_set(Evas_Object *obj,
5100 ELM_CHECK_WIDTYPE(obj, widtype);
5101 Widget_Data *wd = elm_widget_data_get(obj);
5103 wd->compress = compress;
5107 * Get the compress mode
5109 * @param obj The genlist object
5110 * @return The compress mode
5111 * (EINA_TRUE = on, EINA_FALSE = off)
5116 elm_genlist_compress_mode_get(const Evas_Object *obj)
5118 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5119 Widget_Data *wd = elm_widget_data_get(obj);
5120 if (!wd) return EINA_FALSE;
5121 return wd->compress;
5125 * Set height-for-width mode
5127 * With height-for-width mode the item width will be fixed (restricted
5128 * to a minimum of) to the list width when calculating its size in
5129 * order to allow the height to be calculated based on it. This allows,
5130 * for instance, text block to wrap lines if the Edje part is
5131 * configured with "text.min: 0 1".
5133 * @note This mode will make list resize slower as it will have to
5134 * recalculate every item height again whenever the list width
5137 * @note When height-for-width mode is enabled, it also enables
5138 * compress mode (see elm_genlist_compress_mode_set()) and
5139 * disables homogeneous (see elm_genlist_homogeneous_set()).
5141 * @param obj The genlist object
5142 * @param setting The height-for-width mode (EINA_TRUE = on,
5148 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5149 Eina_Bool height_for_width)
5151 ELM_CHECK_WIDTYPE(obj, widtype);
5152 Widget_Data *wd = elm_widget_data_get(obj);
5154 wd->height_for_width = !!height_for_width;
5155 if (wd->height_for_width)
5157 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5158 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5163 * Get the height-for-width mode
5165 * @param obj The genlist object
5166 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5172 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5174 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5175 Widget_Data *wd = elm_widget_data_get(obj);
5176 if (!wd) return EINA_FALSE;
5177 return wd->height_for_width;
5183 * This will enable or disable the scroller bounce mode for the
5184 * genlist. See elm_scroller_bounce_set() for details
5186 * @param obj The genlist object
5187 * @param h_bounce Allow bounce horizontally
5188 * @param v_bounce Allow bounce vertically
5193 elm_genlist_bounce_set(Evas_Object *obj,
5197 ELM_CHECK_WIDTYPE(obj, widtype);
5198 Widget_Data *wd = elm_widget_data_get(obj);
5200 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5204 * Get the bounce mode
5206 * @param obj The genlist object
5207 * @param h_bounce Allow bounce horizontally
5208 * @param v_bounce Allow bounce vertically
5213 elm_genlist_bounce_get(const Evas_Object *obj,
5214 Eina_Bool *h_bounce,
5215 Eina_Bool *v_bounce)
5217 ELM_CHECK_WIDTYPE(obj, widtype);
5218 Widget_Data *wd = elm_widget_data_get(obj);
5220 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5224 * Set homogenous mode
5226 * This will enable the homogeneous mode where items are of the same
5227 * height and width so that genlist may do the lazy-loading at its
5228 * maximum. This implies 'compressed' mode.
5230 * @param obj The genlist object
5231 * @param homogeneous Assume the items within the genlist are of the
5232 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5237 elm_genlist_homogeneous_set(Evas_Object *obj,
5238 Eina_Bool homogeneous)
5240 ELM_CHECK_WIDTYPE(obj, widtype);
5241 Widget_Data *wd = elm_widget_data_get(obj);
5243 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5244 wd->homogeneous = homogeneous;
5248 * Get the homogenous mode
5250 * @param obj The genlist object
5251 * @return Assume the items within the genlist are of the same height
5252 * and width (EINA_TRUE = on, EINA_FALSE = off)
5257 elm_genlist_homogeneous_get(const Evas_Object *obj)
5259 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5260 Widget_Data *wd = elm_widget_data_get(obj);
5261 if (!wd) return EINA_FALSE;
5262 return wd->homogeneous;
5266 * Set the maximum number of items within an item block
5268 * This will configure the block count to tune to the target with
5269 * particular performance matrix.
5271 * @param obj The genlist object
5272 * @param n Maximum number of items within an item block
5277 elm_genlist_block_count_set(Evas_Object *obj,
5280 ELM_CHECK_WIDTYPE(obj, widtype);
5281 Widget_Data *wd = elm_widget_data_get(obj);
5283 wd->max_items_per_block = n;
5284 wd->item_cache_max = wd->max_items_per_block * 2;
5285 _item_cache_clean(wd);
5289 * Get the maximum number of items within an item block
5291 * @param obj The genlist object
5292 * @return Maximum number of items within an item block
5297 elm_genlist_block_count_get(const Evas_Object *obj)
5299 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5300 Widget_Data *wd = elm_widget_data_get(obj);
5302 return wd->max_items_per_block;
5306 * Set the timeout in seconds for the longpress event
5308 * @param obj The genlist object
5309 * @param timeout timeout in seconds
5314 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5317 ELM_CHECK_WIDTYPE(obj, widtype);
5318 Widget_Data *wd = elm_widget_data_get(obj);
5320 wd->longpress_timeout = timeout;
5324 * Get the timeout in seconds for the longpress event
5326 * @param obj The genlist object
5327 * @return timeout in seconds
5332 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5334 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5335 Widget_Data *wd = elm_widget_data_get(obj);
5337 return wd->longpress_timeout;
5341 * Set the scrollbar policy
5343 * This sets the scrollbar visibility policy for the given genlist
5344 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5345 * made visible if it is needed, and otherwise kept hidden.
5346 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5347 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5348 * respectively for the horizontal and vertical scrollbars.
5350 * @param obj The genlist object
5351 * @param policy_h Horizontal scrollbar policy
5352 * @param policy_v Vertical scrollbar policy
5357 elm_genlist_scroller_policy_set(Evas_Object *obj,
5358 Elm_Scroller_Policy policy_h,
5359 Elm_Scroller_Policy policy_v)
5361 ELM_CHECK_WIDTYPE(obj, widtype);
5362 Widget_Data *wd = elm_widget_data_get(obj);
5364 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5365 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5368 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5372 * Get the scrollbar policy
5374 * @param obj The genlist object
5375 * @param policy_h Horizontal scrollbar policy
5376 * @param policy_v Vertical scrollbar policy
5381 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5382 Elm_Scroller_Policy *policy_h,
5383 Elm_Scroller_Policy *policy_v)
5385 ELM_CHECK_WIDTYPE(obj, widtype);
5386 Widget_Data *wd = elm_widget_data_get(obj);
5387 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5388 if ((!wd) || (!wd->scr)) return;
5389 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5390 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5391 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5394 /****************************************************************************/
5399 * @param obj The genlist object
5400 * @param reorder_mode The reorder mode
5401 * (EINA_TRUE = on, EINA_FALSE = off)
5406 elm_genlist_reorder_mode_set(Evas_Object *obj,
5407 Eina_Bool reorder_mode)
5409 ELM_CHECK_WIDTYPE(obj, widtype);
5410 Widget_Data *wd = elm_widget_data_get(obj);
5412 wd->reorder_mode = reorder_mode;
5416 * Get the reorder mode
5418 * @param obj The genlist object
5419 * @return The reorder mode
5420 * (EINA_TRUE = on, EINA_FALSE = off)
5425 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5427 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5428 Widget_Data *wd = elm_widget_data_get(obj);
5429 if (!wd) return EINA_FALSE;
5430 return wd->reorder_mode;
5434 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5440 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5446 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5451 if (it->wd->ed->ec->move)
5452 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5454 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5455 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5456 it->wd->reorder_deleted = EINA_TRUE;
5457 _item_block_del(it);
5459 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5461 it->rel->relcount++;
5462 it->before = EINA_FALSE;
5463 _item_queue(it->wd, it);
5467 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5470 if (!before) return;
5472 if (it->wd->ed->ec->move)
5473 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5475 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5476 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5477 it->wd->reorder_deleted = EINA_TRUE;
5478 _item_block_del(it);
5479 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5481 it->rel->relcount++;
5482 it->before = EINA_TRUE;
5483 _item_queue(it->wd, it);
5487 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5489 ELM_CHECK_WIDTYPE(obj, widtype);
5490 Widget_Data *wd = elm_widget_data_get(obj);
5492 wd->effect_mode = emode;
5493 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5494 // evas_object_resize(wd->point_rect, 10, 25);
5495 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5496 // evas_object_show(wd->point_rect);
5497 // evas_object_hide(wd->point_rect);
5501 _create_tray_alpha_bg(const Evas_Object *obj)
5503 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5504 Widget_Data *wd = elm_widget_data_get(obj);
5505 if (!wd) return NULL;
5507 Evas_Object *bg = NULL;
5508 Evas_Coord ox, oy, ow, oh;
5510 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5511 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5512 evas_object_color_set(bg,0,0,0,0);
5513 evas_object_resize(bg , ow, oh);
5514 evas_object_move(bg , ox, oy);
5515 evas_object_show(bg);
5516 evas_object_hide(bg);
5523 struct timeval timev;
5525 gettimeofday(&timev, NULL);
5526 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5529 // added for item moving animation.
5531 _item_moving_effect_timer_cb(void *data)
5533 Widget_Data *wd = data;
5534 if (!wd) return EINA_FALSE;
5536 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5537 Elm_Genlist_Item *it, *it2;
5539 double time = 0.4, t;
5541 Eina_Bool check, end = EINA_FALSE;
5542 // static Eina_Bool first = EINA_TRUE;
5545 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5547 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5548 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5549 if (t > time) end = EINA_TRUE;
5550 EINA_INLIST_FOREACH(wd->blocks, itb)
5553 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5554 itb->y - wd->pan_y + oy,
5556 cvx, cvy, cvw, cvh))
5558 EINA_LIST_FOREACH(itb->items, l, it)
5560 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5565 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5571 //printf(" s: %d %d ", oy, oh);
5572 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5573 dy = it->scrl_y - it->old_scrl_y;
5574 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5576 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5577 if(wd->expand_item_end < it->old_scrl_y)
5578 dy = wd->expand_item_gap;
5580 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5582 if (wd->expand_item_end < it->old_scrl_y)
5583 dy = wd->expand_item_gap;
5586 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5593 if (!it->old_scrl_y)
5594 it->old_scrl_y = it->scrl_y;
5597 if (it->old_scrl_y + y < oy + oh)
5599 if (!it->realized) _item_realize(it, in, 0);
5601 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5602 it->old_scrl_y = it->scrl_y - y;
5605 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5606 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5608 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5611 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5612 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5613 evas_object_show(it->base.view);
5614 evas_object_raise(it->base.view);
5617 if(wd->select_all_item) evas_object_raise(wd->select_all_item->base.view);
5618 if (it->group_item) evas_object_raise(it->group_item->base.view);
5621 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5623 it2 = elm_genlist_item_prev_get(it);
5626 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5628 if(!it2->effect_done)
5630 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5631 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5632 evas_object_show(it2->base.view);
5633 it2->effect_done = EINA_TRUE;
5637 it2 = elm_genlist_item_prev_get(it2);
5640 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5642 it2 = elm_genlist_item_prev_get(it);
5645 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5647 if(!it2->effect_done)
5649 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5650 it2->effect_done = EINA_TRUE;
5655 it2 = elm_genlist_item_prev_get(it2);
5661 // first = EINA_FALSE;
5665 if (wd->item_moving_effect_timer)
5667 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5668 _item_subitems_clear(wd->expand_item);
5669 EINA_INLIST_FOREACH(wd->blocks, itb)
5671 EINA_LIST_FOREACH(itb->items, l, it)
5673 it->effect_done = EINA_TRUE;
5674 it->list_expanded = 0;
5675 it->old_scrl_y = it->scrl_y;
5679 //evas_render(evas_object_evas_get(wd->obj));
5680 wd->item_moving_effect_timer = NULL;
5681 // first = EINA_TRUE;
5683 _item_auto_scroll(wd);
5684 evas_object_lower(wd->alpha_bg);
5685 evas_object_hide(wd->alpha_bg);
5686 if (wd->calc_job) ecore_job_del(wd->calc_job);
5687 wd->calc_job = ecore_job_add(_calc_job, wd);
5688 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5689 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5691 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5692 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5693 return ECORE_CALLBACK_CANCEL;
5695 return ECORE_CALLBACK_RENEW;
5699 _emit_contract(Elm_Genlist_Item *it)
5701 Elm_Genlist_Item *it2;
5704 // printf("%p is emited contract\n", it);
5705 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5706 it->effect_done = EINA_FALSE;
5708 EINA_LIST_FOREACH(it->items, l, it2)
5710 _emit_contract(it2);
5713 // added for item moving animation.
5715 _item_flip_effect_show(Elm_Genlist_Item *it)
5717 Elm_Genlist_Item *it2;
5719 Widget_Data *wd = it->wd;
5720 Eina_Bool check = EINA_FALSE;
5722 it2 = elm_genlist_item_next_get(it);
5725 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5726 it2 = elm_genlist_item_next_get(it2);
5728 EINA_LIST_FOREACH(it->items, l, it2)
5730 if (it2->parent && it == it2->parent)
5732 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5734 edje_object_signal_emit(it2->base.view, "flip_item", "");
5736 evas_object_move(it2->base.view, -9999, -9999);
5738 evas_object_show(it2->base.view);
5740 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5741 _emit_contract(it2);
5745 return ECORE_CALLBACK_CANCEL;
5750 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5752 printf("!!! NOW FIXING \n");
5757 * Set pinch zoom mode
5759 * @param obj The genlist object
5761 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5766 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5768 printf("!!! NOW FIXING \n");
5772 * Get pinch zoom mode
5774 * @param obj The genlist object
5775 * @return The pinch mode
5776 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5781 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5783 printf("!!! NOW FIXING \n");
5788 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5790 printf("!!! NOW FIXING \n");
5794 ////////////////////////////////////////////////////////////////////////
5796 ////////////////////////////////////////////////////////////////////////
5798 _effect_item_update(Elm_Genlist_Item *it)
5800 if (it->edit_select_check)
5802 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5806 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5811 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5814 if (edit_select_check_state)
5816 it->edit_select_check = EINA_TRUE;
5817 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5821 it->edit_select_check = EINA_FALSE;
5822 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5824 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5825 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5829 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5832 Eina_List *tl = NULL, *l;
5833 Elm_Genlist_Item *it2;
5835 EINA_LIST_FOREACH(it->items, l, it2)
5836 tl = eina_list_append(tl, it2);
5837 EINA_LIST_FREE(tl, it2)
5838 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5842 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5845 Elm_Genlist_Item *tmp_it;
5846 Eina_Bool parent_check = EINA_TRUE;
5848 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5850 if (tmp_it->parent && it->parent)
5851 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5855 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5856 else it->parent->edit_select_check = EINA_FALSE;
5861 _effect_item_update(it->parent);
5862 return _edit_parent_items_checkbox_set(it->parent);
5867 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items)
5869 if (!select_all_it || !select_all_it->wd) return;
5871 Eina_Bool old_check_state;
5872 Elm_Genlist_Item *it;
5873 Widget_Data *wd = select_all_it->wd;
5875 wd->select_all_check = checked;
5876 if (wd->select_all_check)
5877 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_check", "elm");
5879 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_uncheck", "elm");
5883 EINA_INLIST_FOREACH(wd->items, it)
5885 old_check_state = it->edit_select_check;
5886 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5887 else it->edit_select_check = EINA_FALSE;
5889 // TODO : check this
5890 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5891 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5895 if (wd->ed->ec->item_selected)
5896 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
5898 if (wd->calc_job) ecore_job_del(wd->calc_job);
5899 wd->calc_job = ecore_job_add(_calc_job, wd);
5903 _checkbox_item_select_process(Elm_Genlist_Item *it)
5905 Elm_Genlist_Item *tmp_it;
5906 Eina_Bool old_check_state;
5907 int check_cnt = 0, total_cnt = 0;
5910 _edit_item_checkbox_set(it, it->edit_select_check);
5911 _edit_subitems_checkbox_set(it);
5912 _edit_parent_items_checkbox_set(it);
5914 if (it->wd->ed) it->wd->ed->del_item = it;
5916 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5918 if (tmp_it->edit_select_check) check_cnt++;
5922 if (it->wd->select_all_item)
5924 old_check_state = it->wd->select_all_check;
5925 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
5926 else it->wd->select_all_check = EINA_FALSE;
5928 if (check_cnt == total_cnt)
5930 it->wd->select_all_check = EINA_TRUE;
5931 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
5935 it->wd->select_all_check = EINA_FALSE;
5936 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
5942 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5944 Elm_Genlist_Item *it = data;
5946 it->edit_select_check = !it->edit_select_check;
5947 _checkbox_item_select_process(it);
5951 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5953 Elm_Genlist_Item *select_all_it = data;
5954 Widget_Data *wd = select_all_it->wd;
5957 _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE);
5962 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5964 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5966 evas_object_resize(it->edit_obj,it->w, it->h);
5967 evas_object_move(it->edit_obj, itx, ity);
5969 if (it->wd->select_all_check)
5970 it->edit_select_check = EINA_TRUE;
5973 if (it->edit_select_check)
5975 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5979 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5985 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5987 if ((it->effect_item_realized) || (it->delete_me)) return;
5988 int itmode = 0, pad = 0;
5989 const char *pad_str;
5991 it->pad_left = it->pad_right = 0;
5993 if (it->itc->func.editmode_get)
5994 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
5995 itmode &= it->wd->edit_mode;
5997 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5998 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
6000 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6001 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6002 _elm_config->scale);
6003 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6004 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6006 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6007 else strncpy(buf, "item", sizeof(buf));
6008 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6010 strncat(buf, "/", sizeof(buf) - strlen(buf));
6012 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
6014 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
6015 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6019 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6022 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6023 if (pad_str) pad = atoi(pad_str);
6025 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6027 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable_effect", "elm");
6028 else edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6030 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6031 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6032 "elm", _checkbox_item_select_cb);
6034 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,select",
6035 "elm", _checkbox_item_select_cb, it);
6036 it->pad_left += pad * _elm_config->scale;
6040 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6042 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6043 "elm", _checkbox_item_select_cb);
6046 if (effect_on && itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6048 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm");
6049 edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6051 else if (itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6052 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm");
6054 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6056 if (it->itc->func.icon_get)
6061 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6062 EINA_LIST_FOREACH(it->icons, l, key)
6064 Evas_Object *ic = it->itc->func.icon_get
6065 (it->base.data, it->base.widget, l->data);
6069 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6070 edje_object_part_swallow(it->edit_obj, key, ic);
6071 evas_object_show(ic);
6072 elm_widget_sub_object_add(it->base.widget, ic);
6077 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6078 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6079 evas_object_show(it->edit_obj);
6081 it->effect_item_realized = EINA_TRUE;
6082 it->want_unrealize = EINA_FALSE;
6086 _effect_item_unrealize(Elm_Genlist_Item *it)
6090 if (!it->effect_item_realized) return;
6091 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6093 it->pad_left = it->pad_right = 0;
6094 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6095 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6096 edje_object_message_signal_process(it->edit_obj);
6097 edje_object_part_unswallow(it->edit_obj, it->base.view);
6098 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6099 elm_widget_sub_object_add(it->base.widget, it->base.view);
6100 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6101 // _item_cache_add(it);
6102 evas_object_del(it->edit_obj);
6103 it->edit_obj = NULL;
6104 EINA_LIST_FREE(it->edit_icon_objs, icon)
6105 evas_object_del(icon);
6107 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6108 it->effect_item_realized = EINA_FALSE;
6112 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6114 fprintf(stderr, "=================> Caution!!! <========================\n");
6115 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6116 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6117 fprintf(stderr, "=======================================================\n");
6119 elm_genlist_edit_mode_set(obj, emode, edit_class);
6123 * Get Genlist edit mode
6125 * @param obj The genlist object
6126 * @return The edit mode status
6127 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6132 elm_genlist_edit_mode_get(const Evas_Object *obj)
6134 ELM_CHECK_WIDTYPE(obj, widtype);
6135 Widget_Data *wd = elm_widget_data_get(obj);
6136 if (!wd) return EINA_FALSE;
6138 if (wd->edit_mode) return EINA_TRUE;
6139 else return EINA_FALSE;
6143 * Set Genlist edit mode
6145 * This sets Genlist edit mode.
6147 * @param obj The Genlist object
6148 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6149 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6154 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6156 ELM_CHECK_WIDTYPE(obj, widtype);
6159 Eina_Bool done = EINA_FALSE;
6160 static Elm_Genlist_Item_Class itc;
6162 Elm_Genlist_Item *it;
6164 Widget_Data *wd = elm_widget_data_get(obj);
6166 if (wd->edit_mode == emode) return;
6168 wd->edit_mode = emode;
6170 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6171 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6174 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6176 EINA_INLIST_FOREACH(wd->blocks, itb)
6181 EINA_LIST_FOREACH(itb->items, l, it)
6183 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6185 it->pad_left = it->pad_right = 0;
6186 _effect_item_unrealize(it);
6196 EINA_INLIST_FOREACH(wd->items, it)
6198 it->edit_select_check = EINA_FALSE;
6200 if (wd->ed) free (wd->ed);
6202 wd->reorder_mode = EINA_FALSE;
6203 if (wd->select_all_item)
6205 wd->select_all_check = EINA_FALSE;
6206 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down);
6207 elm_widget_item_pre_notify_del(wd->select_all_item);
6208 _item_unrealize(wd->select_all_item);
6209 elm_widget_item_del(wd->select_all_item);
6211 wd->select_all_item = NULL;
6214 Evas_Object *editfield;
6215 EINA_LIST_FREE(wd->edit_field, editfield)
6216 evas_object_del(editfield);
6217 wd->edit_field = NULL;
6219 _item_cache_zero(wd);
6223 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6224 wd->reorder_mode = EINA_TRUE;
6227 wd->ed = calloc(1, sizeof(Edit_Data));
6229 wd->ed->ec = edit_class;
6231 EINA_INLIST_FOREACH(wd->blocks, itb)
6236 EINA_LIST_FOREACH(itb->items, l, it)
6238 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6240 if(it->selected) _item_unselect(it);
6241 _effect_item_realize(it, EINA_TRUE);
6251 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6253 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6254 itc.item_style = edit_class->select_all_item_style;
6256 itc.item_style = "select_all";
6257 itc.func.label_get = NULL;
6258 itc.func.icon_get = NULL;
6259 itc.func.del = NULL;
6260 itc.func.editmode_get = NULL;
6261 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6264 if (!wd->select_all_item) return;
6266 _item_realize(wd->select_all_item, 0, 0);
6267 edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down, wd->select_all_item);
6269 wd->select_all_item->rel = NULL;
6270 wd->select_all_item->block = NULL;
6274 if (wd->calc_job) ecore_job_del(wd->calc_job);
6275 wd->calc_job = ecore_job_add(_calc_job, wd);
6279 * Delete selected items in genlist edit mode.
6281 * @param obj The genlist object
6286 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6288 ELM_CHECK_WIDTYPE(obj, widtype);
6289 Widget_Data *wd = elm_widget_data_get(obj);
6291 if (!wd->blocks) return;
6292 Elm_Genlist_Item *it;
6293 Eina_List *edit_selected_list, *l;
6297 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
6300 if (wd->edit_field) return;
6301 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
6302 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy,&cvw, &cvh);
6303 EINA_INLIST_FOREACH(wd->blocks, itb)
6305 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
6306 itb->y - wd->pan_y + oy,
6308 cvx, cvy, cvw, cvh))
6309 EINA_LIST_FOREACH(itb->items, l, it)
6311 it->old_scrl_y =itb->y + it->y - it->wd->pan_y + oy;
6314 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6315 cnt = eina_list_count(edit_selected_list);
6316 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6318 wd->expand_item_gap = wd->expand_item_end = 0;
6319 EINA_LIST_FOREACH(edit_selected_list, l, it)
6321 if (it->flags != ELM_GENLIST_ITEM_GROUP)
6323 it->wd->expand_item_gap += it->h * -1;
6324 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
6325 cvx, cvy, cvw, cvh));
6326 if (!it->wd->expand_item_end && vis ) it->wd->expand_item_end = it->old_scrl_y;
6327 it->wd->expand_item = elm_genlist_item_prev_get(it);
6328 elm_genlist_item_del(it);
6331 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE;
6332 eina_list_free(edit_selected_list);
6334 evas_render(evas_object_evas_get(wd->obj));
6335 if (wd->calc_job) ecore_job_del(wd->calc_job);
6336 wd->calc_job = ecore_job_add(_calc_job, wd);
6340 elm_genlist_selected_items_del(Evas_Object *obj)
6342 fprintf(stderr, "=================> Caution!!! <========================\n");
6343 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6344 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6345 fprintf(stderr, "=======================================================\n");
6346 elm_genlist_edit_selected_items_del(obj);
6350 * Get a list of selected items in genlist
6352 * This returns a list of the selected items in the genlist. The list
6353 * contains Elm_Genlist_Item pointers. The list must be freed by the
6354 * caller when done with eina_list_free(). The item pointers in the list
6355 * are only vallid so long as those items are not deleted or the genlist is
6358 * @param obj The genlist object
6359 * @return The list of selected items, nor NULL if none are selected.
6364 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6366 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6367 Widget_Data *wd = elm_widget_data_get(obj);
6368 Eina_List *list = NULL;
6369 Elm_Genlist_Item *it;
6370 if (!wd) return NULL;
6372 EINA_INLIST_FOREACH(wd->items, it)
6374 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6380 // TODO : add comment
6382 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6385 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6386 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6388 selected = !!selected;
6389 if (it->edit_select_check == selected) return;
6391 it->edit_select_check = selected;
6392 _checkbox_item_select_process(it);
6395 // TODO : add comment
6396 EAPI const Eina_Bool
6397 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6399 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6400 return it->edit_select_check;
6404 * Set a given item's rename mode
6406 * This renames the item's label from genlist
6408 * @param it The item
6409 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6414 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6416 if (!it) return NULL;
6417 if (it->wd->queue_idler) return NULL;
6419 const Eina_List *l, *list, *l2;
6420 const char *label, *rename_swallow_part;
6422 Eina_Bool done = EINA_FALSE;
6423 int label_cnt = 0 , swallow_part_cnt = 0;
6426 Evas_Object *editfield;
6427 Evas_Object *entry = NULL;
6428 int edit_field_cnt = 0;
6430 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6435 Elm_Genlist_Item *it;
6437 EINA_LIST_FOREACH(itb->items, l, it)
6441 it->renamed = EINA_FALSE;
6442 if (it->selected) _item_unselect(it);
6443 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6445 entry = elm_editfield_entry_get(editfield);
6446 const char *text = elm_entry_entry_get(entry);
6447 if (it->itc->func.label_changed)
6448 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6450 EINA_LIST_FREE(it->wd->edit_field, editfield)
6451 evas_object_del(editfield);
6452 it->wd->edit_field = NULL;
6454 if (it->wd->edit_mode)
6456 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6457 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6458 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6459 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6462 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6475 it->renamed = EINA_TRUE;
6476 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6478 it->wd->edit_mode = 0xF0;
6479 _effect_item_realize(it, EINA_TRUE);
6480 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6483 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6484 EINA_LIST_FOREACH(it->labels, list, label)
6486 if (it->itc->func.label_get)
6488 swallow_part_cnt = 0;
6490 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6491 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6493 if (label_cnt == swallow_part_cnt)
6495 editfield = elm_editfield_add(it->base.widget);
6496 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6498 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6499 elm_editfield_eraser_set(editfield, EINA_TRUE);
6500 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6501 elm_widget_sub_object_add(it->edit_obj, editfield);
6503 evas_object_show(editfield);
6505 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6508 entry = elm_editfield_entry_get(editfield);
6509 elm_entry_entry_set(entry,s);
6510 elm_entry_cursor_end_set(entry);
6514 elm_editfield_guide_text_set(editfield, "Text Input");
6521 elm_widget_focused_object_clear(elm_widget_focused_object_get(it->wd->obj));
6522 elm_widget_focus_set(editfield, EINA_TRUE);
6528 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6530 Elm_Genlist_Item *it = data;
6532 _delete_sweep_objs(it);
6536 _scr_hold_timer_cb(void *data)
6538 Elm_Genlist_Item *it = data;
6539 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6540 it->wd->scr_hold_timer = NULL;
6541 return ECORE_CALLBACK_CANCEL;
6545 _delete_sweep_objs(Elm_Genlist_Item *it)
6549 elm_widget_stringlist_free(it->sweep_labels);
6550 it->sweep_labels = NULL;
6551 elm_widget_stringlist_free(it->sweep_icons);
6552 it->sweep_icons = NULL;
6553 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6554 evas_object_del(ic);
6558 _create_sweep_objs(Elm_Genlist_Item *it)
6564 if (it->itc->func.label_get)
6567 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6569 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6571 char *s = it->itc->func.label_get
6572 ((void *)it->base.data, it->base.widget, l->data);
6576 edje_object_part_text_set(it->base.view, l->data, s);
6581 if (it->itc->func.icon_get)
6584 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6586 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6588 ic = it->itc->func.icon_get
6589 ((void *)it->base.data, it->base.widget, l->data);
6593 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6594 edje_object_part_swallow(it->base.view, key, ic);
6595 evas_object_show(ic);
6596 elm_widget_sub_object_add(it->base.widget, ic);
6603 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6606 Elm_Genlist_Item *it2;
6607 const char *allow_slide;
6609 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6610 if ((!allow_slide) || (atoi(allow_slide) != 1))
6615 if (it->sweeped) return;
6616 if (it->wd->scr_hold_timer)
6618 ecore_timer_del(it->wd->scr_hold_timer);
6619 it->wd->scr_hold_timer = NULL;
6621 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6622 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6624 _delete_sweep_objs(it);
6625 _create_sweep_objs(it);
6626 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6627 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6628 it->wassweeped = EINA_TRUE;
6629 it->sweeped = EINA_TRUE;
6631 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6635 it2->sweeped = EINA_FALSE;
6636 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6637 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6638 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6644 if (!it->sweeped) return;
6645 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6646 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6647 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6648 it->sweeped = EINA_FALSE;
6653 _item_auto_scroll(void *data)
6655 Widget_Data *wd = data;
6658 if ((wd->expand_item) && (!wd->auto_scrolled))
6660 Elm_Genlist_Item *it;
6662 Evas_Coord ox, oy, ow, oh;
6663 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6665 wd->auto_scrolled = EINA_TRUE;
6666 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6668 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6670 elm_genlist_item_bring_in(it);